From e0e7b42efa134bd01fcdddf1b4ffbc6800c3d80e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 May 2026 11:06:16 +0000 Subject: [PATCH] feat: Node.js SDK update for version 24.1.0 --- CHANGELOG.md | 13 +- README.md | 4 +- .../databases/create-big-int-attribute.md | 21 + .../databases/update-big-int-attribute.md | 21 + docs/examples/functions/create-variable.md | 1 + docs/examples/functions/create.md | 2 +- docs/examples/functions/list-variables.md | 4 +- docs/examples/functions/update-variable.md | 2 +- docs/examples/functions/update.md | 2 +- docs/examples/presences/delete.md | 14 + docs/examples/presences/get.md | 14 + docs/examples/presences/list.md | 16 + docs/examples/presences/update-presence.md | 20 + docs/examples/presences/upsert.md | 19 + docs/examples/project/create-ephemeral-key.md | 15 + docs/examples/project/create-key.md | 2 +- docs/examples/project/create-mock-phone.md | 15 + docs/examples/project/create-smtp-test.md | 14 + docs/examples/project/delete-mock-phone.md | 14 + docs/examples/project/delete.md | 12 + docs/examples/project/get-email-template.md | 15 + docs/examples/project/get-mock-phone.md | 14 + .../examples/project/get-o-auth-2-provider.md | 14 + docs/examples/project/get-policy.md | 14 + docs/examples/project/list-email-templates.md | 15 + docs/examples/project/list-mock-phones.md | 15 + .../project/list-o-auth-2-providers.md | 15 + docs/examples/project/list-policies.md | 15 + docs/examples/project/update-auth-method.md | 15 + .../examples/project/update-email-template.md | 21 + docs/examples/project/update-key.md | 2 +- .../update-membership-privacy-policy.md | 18 + docs/examples/project/update-mock-phone.md | 15 + .../project/update-o-auth-2-amazon.md | 16 + .../examples/project/update-o-auth-2-apple.md | 18 + .../project/update-o-auth-2-auth-0.md | 17 + .../project/update-o-auth-2-authentik.md | 17 + .../project/update-o-auth-2-autodesk.md | 16 + .../project/update-o-auth-2-bitbucket.md | 16 + .../examples/project/update-o-auth-2-bitly.md | 16 + docs/examples/project/update-o-auth-2-box.md | 16 + .../project/update-o-auth-2-dailymotion.md | 16 + .../project/update-o-auth-2-discord.md | 16 + .../project/update-o-auth-2-disqus.md | 16 + .../project/update-o-auth-2-dropbox.md | 16 + docs/examples/project/update-o-auth-2-etsy.md | 16 + .../project/update-o-auth-2-facebook.md | 16 + .../examples/project/update-o-auth-2-figma.md | 16 + .../project/update-o-auth-2-fusion-auth.md | 17 + .../project/update-o-auth-2-git-hub.md | 16 + .../project/update-o-auth-2-gitlab.md | 17 + .../project/update-o-auth-2-google.md | 16 + .../project/update-o-auth-2-keycloak.md | 18 + docs/examples/project/update-o-auth-2-kick.md | 16 + .../project/update-o-auth-2-linkedin.md | 16 + .../project/update-o-auth-2-microsoft.md | 17 + .../project/update-o-auth-2-notion.md | 16 + docs/examples/project/update-o-auth-2-oidc.md | 20 + docs/examples/project/update-o-auth-2-okta.md | 18 + .../project/update-o-auth-2-paypal-sandbox.md | 16 + .../project/update-o-auth-2-paypal.md | 16 + .../examples/project/update-o-auth-2-podio.md | 16 + .../project/update-o-auth-2-salesforce.md | 16 + .../examples/project/update-o-auth-2-slack.md | 16 + .../project/update-o-auth-2-spotify.md | 16 + .../project/update-o-auth-2-stripe.md | 16 + .../update-o-auth-2-tradeshift-sandbox.md | 16 + .../project/update-o-auth-2-tradeshift.md | 16 + .../project/update-o-auth-2-twitch.md | 16 + .../project/update-o-auth-2-word-press.md | 16 + .../examples/project/update-o-auth-2-yahoo.md | 16 + .../project/update-o-auth-2-yandex.md | 16 + docs/examples/project/update-o-auth-2-zoho.md | 16 + docs/examples/project/update-o-auth-2-zoom.md | 16 + docs/examples/project/update-o-auth-2x.md | 16 + .../update-password-dictionary-policy.md | 14 + .../project/update-password-history-policy.md | 14 + .../update-password-personal-data-policy.md | 14 + ...-protocol-status.md => update-protocol.md} | 2 +- ...te-service-status.md => update-service.md} | 2 +- .../project/update-session-alert-policy.md | 14 + .../project/update-session-duration-policy.md | 14 + .../update-session-invalidation-policy.md | 14 + .../project/update-session-limit-policy.md | 14 + docs/examples/project/update-smtp.md | 23 + .../project/update-user-limit-policy.md | 14 + docs/examples/proxy/create-api-rule.md | 14 + docs/examples/proxy/create-function-rule.md | 16 + docs/examples/proxy/create-redirect-rule.md | 18 + docs/examples/proxy/create-site-rule.md | 16 + docs/examples/proxy/delete-rule.md | 14 + docs/examples/proxy/get-rule.md | 14 + docs/examples/proxy/list-rules.md | 15 + docs/examples/proxy/update-rule-status.md | 14 + docs/examples/sites/create-variable.md | 1 + docs/examples/sites/list-variables.md | 4 +- docs/examples/sites/update-variable.md | 2 +- .../tablesdb/create-big-int-column.md | 21 + .../tablesdb/update-big-int-column.md | 21 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 87 +- src/enums/build-runtime.ts | 1 + src/enums/email-template-locale.ts | 133 + src/enums/email-template-type.ts | 9 + src/enums/method-id.ts | 9 + src/enums/o-auth-provider.ts | 3 + src/enums/policy-id.ts | 11 + src/enums/provider-id.ts | 49 + src/enums/proxy-resource-type.ts | 4 + .../proxy-rule-deployment-resource-type.ts | 4 + src/enums/proxy-rule-status.ts | 5 + src/enums/runtime.ts | 1 + src/enums/scopes.ts | 77 +- src/enums/secure.ts | 4 + src/enums/status-code.ts | 6 + src/index.ts | 12 + src/inputFile.ts | 149 +- src/models.ts | 1593 ++++- src/services/account.ts | 5 +- src/services/activities.ts | 1 + src/services/avatars.ts | 1 + src/services/backups.ts | 1 + src/services/databases.ts | 223 + src/services/functions.ts | 88 +- src/services/graphql.ts | 1 + src/services/health.ts | 1 + src/services/locale.ts | 1 + src/services/messaging.ts | 1 + src/services/presences.ts | 373 ++ src/services/project.ts | 5564 +++++++++++++++-- src/services/proxy.ts | 541 ++ src/services/sites.ts | 88 +- src/services/storage.ts | 20 +- src/services/tables-db.ts | 221 + src/services/teams.ts | 1 + src/services/tokens.ts | 1 + src/services/users.ts | 1 + src/services/webhooks.ts | 1 + test/services/account.test.js | 106 +- test/services/activities.test.js | 4 +- test/services/backups.test.js | 24 +- test/services/databases.test.js | 194 +- test/services/functions.test.js | 52 +- test/services/graphql.test.js | 4 +- test/services/health.test.js | 48 +- test/services/locale.test.js | 16 +- test/services/messaging.test.js | 112 +- test/services/presences.test.js | 110 + test/services/project.test.js | 2394 ++++++- test/services/proxy.test.js | 215 + test/services/sites.test.js | 50 +- test/services/storage.test.js | 20 +- test/services/tables-d-b.test.js | 194 +- test/services/teams.test.js | 30 +- test/services/tokens.test.js | 10 +- test/services/users.test.js | 98 +- test/services/webhooks.test.js | 12 +- 158 files changed, 13085 insertions(+), 1314 deletions(-) create mode 100644 docs/examples/databases/create-big-int-attribute.md create mode 100644 docs/examples/databases/update-big-int-attribute.md create mode 100644 docs/examples/presences/delete.md create mode 100644 docs/examples/presences/get.md create mode 100644 docs/examples/presences/list.md create mode 100644 docs/examples/presences/update-presence.md create mode 100644 docs/examples/presences/upsert.md create mode 100644 docs/examples/project/create-ephemeral-key.md create mode 100644 docs/examples/project/create-mock-phone.md create mode 100644 docs/examples/project/create-smtp-test.md create mode 100644 docs/examples/project/delete-mock-phone.md create mode 100644 docs/examples/project/delete.md create mode 100644 docs/examples/project/get-email-template.md create mode 100644 docs/examples/project/get-mock-phone.md create mode 100644 docs/examples/project/get-o-auth-2-provider.md create mode 100644 docs/examples/project/get-policy.md create mode 100644 docs/examples/project/list-email-templates.md create mode 100644 docs/examples/project/list-mock-phones.md create mode 100644 docs/examples/project/list-o-auth-2-providers.md create mode 100644 docs/examples/project/list-policies.md create mode 100644 docs/examples/project/update-auth-method.md create mode 100644 docs/examples/project/update-email-template.md create mode 100644 docs/examples/project/update-membership-privacy-policy.md create mode 100644 docs/examples/project/update-mock-phone.md create mode 100644 docs/examples/project/update-o-auth-2-amazon.md create mode 100644 docs/examples/project/update-o-auth-2-apple.md create mode 100644 docs/examples/project/update-o-auth-2-auth-0.md create mode 100644 docs/examples/project/update-o-auth-2-authentik.md create mode 100644 docs/examples/project/update-o-auth-2-autodesk.md create mode 100644 docs/examples/project/update-o-auth-2-bitbucket.md create mode 100644 docs/examples/project/update-o-auth-2-bitly.md create mode 100644 docs/examples/project/update-o-auth-2-box.md create mode 100644 docs/examples/project/update-o-auth-2-dailymotion.md create mode 100644 docs/examples/project/update-o-auth-2-discord.md create mode 100644 docs/examples/project/update-o-auth-2-disqus.md create mode 100644 docs/examples/project/update-o-auth-2-dropbox.md create mode 100644 docs/examples/project/update-o-auth-2-etsy.md create mode 100644 docs/examples/project/update-o-auth-2-facebook.md create mode 100644 docs/examples/project/update-o-auth-2-figma.md create mode 100644 docs/examples/project/update-o-auth-2-fusion-auth.md create mode 100644 docs/examples/project/update-o-auth-2-git-hub.md create mode 100644 docs/examples/project/update-o-auth-2-gitlab.md create mode 100644 docs/examples/project/update-o-auth-2-google.md create mode 100644 docs/examples/project/update-o-auth-2-keycloak.md create mode 100644 docs/examples/project/update-o-auth-2-kick.md create mode 100644 docs/examples/project/update-o-auth-2-linkedin.md create mode 100644 docs/examples/project/update-o-auth-2-microsoft.md create mode 100644 docs/examples/project/update-o-auth-2-notion.md create mode 100644 docs/examples/project/update-o-auth-2-oidc.md create mode 100644 docs/examples/project/update-o-auth-2-okta.md create mode 100644 docs/examples/project/update-o-auth-2-paypal-sandbox.md create mode 100644 docs/examples/project/update-o-auth-2-paypal.md create mode 100644 docs/examples/project/update-o-auth-2-podio.md create mode 100644 docs/examples/project/update-o-auth-2-salesforce.md create mode 100644 docs/examples/project/update-o-auth-2-slack.md create mode 100644 docs/examples/project/update-o-auth-2-spotify.md create mode 100644 docs/examples/project/update-o-auth-2-stripe.md create mode 100644 docs/examples/project/update-o-auth-2-tradeshift-sandbox.md create mode 100644 docs/examples/project/update-o-auth-2-tradeshift.md create mode 100644 docs/examples/project/update-o-auth-2-twitch.md create mode 100644 docs/examples/project/update-o-auth-2-word-press.md create mode 100644 docs/examples/project/update-o-auth-2-yahoo.md create mode 100644 docs/examples/project/update-o-auth-2-yandex.md create mode 100644 docs/examples/project/update-o-auth-2-zoho.md create mode 100644 docs/examples/project/update-o-auth-2-zoom.md create mode 100644 docs/examples/project/update-o-auth-2x.md create mode 100644 docs/examples/project/update-password-dictionary-policy.md create mode 100644 docs/examples/project/update-password-history-policy.md create mode 100644 docs/examples/project/update-password-personal-data-policy.md rename docs/examples/project/{update-protocol-status.md => update-protocol.md} (87%) rename docs/examples/project/{update-service-status.md => update-service.md} (88%) create mode 100644 docs/examples/project/update-session-alert-policy.md create mode 100644 docs/examples/project/update-session-duration-policy.md create mode 100644 docs/examples/project/update-session-invalidation-policy.md create mode 100644 docs/examples/project/update-session-limit-policy.md create mode 100644 docs/examples/project/update-smtp.md create mode 100644 docs/examples/project/update-user-limit-policy.md create mode 100644 docs/examples/proxy/create-api-rule.md create mode 100644 docs/examples/proxy/create-function-rule.md create mode 100644 docs/examples/proxy/create-redirect-rule.md create mode 100644 docs/examples/proxy/create-site-rule.md create mode 100644 docs/examples/proxy/delete-rule.md create mode 100644 docs/examples/proxy/get-rule.md create mode 100644 docs/examples/proxy/list-rules.md create mode 100644 docs/examples/proxy/update-rule-status.md create mode 100644 docs/examples/tablesdb/create-big-int-column.md create mode 100644 docs/examples/tablesdb/update-big-int-column.md create mode 100644 src/enums/email-template-locale.ts create mode 100644 src/enums/email-template-type.ts create mode 100644 src/enums/method-id.ts create mode 100644 src/enums/policy-id.ts create mode 100644 src/enums/provider-id.ts create mode 100644 src/enums/proxy-resource-type.ts create mode 100644 src/enums/proxy-rule-deployment-resource-type.ts create mode 100644 src/enums/proxy-rule-status.ts create mode 100644 src/enums/secure.ts create mode 100644 src/enums/status-code.ts create mode 100644 src/services/presences.ts create mode 100644 src/services/proxy.ts create mode 100644 test/services/presences.test.js create mode 100644 test/services/proxy.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d30e04e1..078bc7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,26 @@ # Change Log +## 24.1.0 + +* Added: Introduced `bigint` create/update APIs for legacy Databases attributes +* Added: Introduced `bigint` create/update APIs for `TablesDB` columns +* Updated: Extended key-list query filters with `key`, `resourceType`, `resourceId`, and `secret` + ## 24.0.0 * [BREAKING] Renamed Webhook model fields: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword`, `signatureKey` → `secret` * [BREAKING] Renamed Webhook service parameters to match: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword` +* [BREAKING] Renamed `Webhooks.updateSignature()` to `Webhooks.updateSecret()` with new optional `secret` parameter +* Added `Client.getHeaders()` method to retrieve request headers * Added `secret` parameter to Webhook create and update methods * Added `x` OAuth provider to `OAuthProvider` enum * Added `userType` field to `Log` model * Added `purge` parameter to `updateCollection` and `updateTable` for cache invalidation * Added Project service: platform CRUD, key CRUD, protocol/service status management -* Added new models: `Key`, `KeyList`, `PlatformAndroid`, `PlatformApple`, `PlatformLinux`, `PlatformList`, and others +* Added new models: `Key`, `KeyList`, `Project`, `DevKey`, `MockNumber`, `AuthProvider`, `PlatformAndroid`, `PlatformApple`, `PlatformLinux`, `PlatformList`, `PlatformWeb`, `PlatformWindows`, `BillingLimits`, `Block` * Added new enums: `PlatformType`, `ProtocolId`, `ServiceId` -* Updated `BuildRuntime`, `Runtime`, `Scopes` enums with new values +* Updated `BuildRuntime`, `Runtime` enums with `dart-3.11` and `flutter-3.41` +* Updated `Scopes` enum with `keysRead`, `keysWrite`, `platformsRead`, `platformsWrite` * Updated `X-Appwrite-Response-Format` header to `1.9.1` * Updated TTL description for list caching in Databases and TablesDB diff --git a/README.md b/README.md index d959a06b..4bed7d85 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md new file mode 100644 index 00000000..4aa7ddff --- /dev/null +++ b/docs/examples/databases/create-big-int-attribute.md @@ -0,0 +1,21 @@ +```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 databases = new sdk.Databases(client); + +const result = await databases.createBigIntAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +}); +``` diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md new file mode 100644 index 00000000..75bbe092 --- /dev/null +++ b/docs/examples/databases/update-big-int-attribute.md @@ -0,0 +1,21 @@ +```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 databases = new sdk.Databases(client); + +const result = await databases.updateBigIntAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); +``` diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 0d8dcfaa..21246bbe 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -10,6 +10,7 @@ const functions = new sdk.Functions(client); const result = await functions.createVariable({ functionId: '', + variableId: '', key: '', value: '', secret: false // optional diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index b0004d85..4e3d5e95 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -20,7 +20,7 @@ const result = await functions.create({ logging: false, // optional entrypoint: '', // optional commands: '', // optional - scopes: [sdk.Scopes.SessionsWrite], // optional + scopes: [sdk.Scopes.ProjectRead], // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index 166effad..d09e5d05 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -9,6 +9,8 @@ const client = new sdk.Client() const functions = new sdk.Functions(client); const result = await functions.listVariables({ - functionId: '' + functionId: '', + queries: [], // optional + total: false // optional }); ``` diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index abd2dad5..e0bdec98 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -11,7 +11,7 @@ const functions = new sdk.Functions(client); const result = await functions.updateVariable({ functionId: '', variableId: '', - key: '', + key: '', // optional value: '', // optional secret: false // optional }); diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 915037ff..fe60cad3 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -20,7 +20,7 @@ const result = await functions.update({ logging: false, // optional entrypoint: '', // optional commands: '', // optional - scopes: [sdk.Scopes.SessionsWrite], // optional + scopes: [sdk.Scopes.ProjectRead], // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional diff --git a/docs/examples/presences/delete.md b/docs/examples/presences/delete.md new file mode 100644 index 00000000..4c1cfc24 --- /dev/null +++ b/docs/examples/presences/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 + .setKey(''); // Your secret API key + +const presences = new sdk.Presences(client); + +const result = await presences.delete({ + presenceId: '' +}); +``` diff --git a/docs/examples/presences/get.md b/docs/examples/presences/get.md new file mode 100644 index 00000000..1e8a332d --- /dev/null +++ b/docs/examples/presences/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 + .setKey(''); // Your secret API key + +const presences = new sdk.Presences(client); + +const result = await presences.get({ + presenceId: '' +}); +``` diff --git a/docs/examples/presences/list.md b/docs/examples/presences/list.md new file mode 100644 index 00000000..fbb18d4d --- /dev/null +++ b/docs/examples/presences/list.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 presences = new sdk.Presences(client); + +const result = await presences.list({ + queries: [], // optional + total: false, // optional + ttl: 0 // optional +}); +``` diff --git a/docs/examples/presences/update-presence.md b/docs/examples/presences/update-presence.md new file mode 100644 index 00000000..ffb1272f --- /dev/null +++ b/docs/examples/presences/update-presence.md @@ -0,0 +1,20 @@ +```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 presences = new sdk.Presences(client); + +const result = await presences.updatePresence({ + presenceId: '', + userId: '', + status: '', // optional + expiresAt: '2020-10-15T06:38:00.000+00:00', // optional + metadata: {}, // optional + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + purge: false // optional +}); +``` diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md new file mode 100644 index 00000000..63b9267f --- /dev/null +++ b/docs/examples/presences/upsert.md @@ -0,0 +1,19 @@ +```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 presences = new sdk.Presences(client); + +const result = await presences.upsert({ + presenceId: '', + userId: '', + status: '', + permissions: [sdk.Permission.read(sdk.Role.any())], // optional + expiresAt: '2020-10-15T06:38:00.000+00:00', // optional + metadata: {} // optional +}); +``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md new file mode 100644 index 00000000..31d21013 --- /dev/null +++ b/docs/examples/project/create-ephemeral-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 + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.createEphemeralKey({ + scopes: [sdk.Scopes.ProjectRead], + duration: 600 +}); +``` diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md index b5274bfc..03ba6271 100644 --- a/docs/examples/project/create-key.md +++ b/docs/examples/project/create-key.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.createKey({ keyId: '', name: '', - scopes: [sdk.Scopes.SessionsWrite], + scopes: [sdk.Scopes.ProjectRead], expire: '2020-10-15T06:38:00.000+00:00' // optional }); ``` diff --git a/docs/examples/project/create-mock-phone.md b/docs/examples/project/create-mock-phone.md new file mode 100644 index 00000000..6bb2962c --- /dev/null +++ b/docs/examples/project/create-mock-phone.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 project = new sdk.Project(client); + +const result = await project.createMockPhone({ + number: '+12065550100', + otp: '' +}); +``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md new file mode 100644 index 00000000..708daf85 --- /dev/null +++ b/docs/examples/project/create-smtp-test.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 project = new sdk.Project(client); + +const result = await project.createSMTPTest({ + emails: [] +}); +``` diff --git a/docs/examples/project/delete-mock-phone.md b/docs/examples/project/delete-mock-phone.md new file mode 100644 index 00000000..94d341a7 --- /dev/null +++ b/docs/examples/project/delete-mock-phone.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 project = new sdk.Project(client); + +const result = await project.deleteMockPhone({ + number: '+12065550100' +}); +``` diff --git a/docs/examples/project/delete.md b/docs/examples/project/delete.md new file mode 100644 index 00000000..150939ed --- /dev/null +++ b/docs/examples/project/delete.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 project = new sdk.Project(client); + +const result = await project.delete(); +``` diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md new file mode 100644 index 00000000..06b062f0 --- /dev/null +++ b/docs/examples/project/get-email-template.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 project = new sdk.Project(client); + +const result = await project.getEmailTemplate({ + templateId: sdk.EmailTemplateType.Verification, + locale: sdk.EmailTemplateLocale.Af // optional +}); +``` diff --git a/docs/examples/project/get-mock-phone.md b/docs/examples/project/get-mock-phone.md new file mode 100644 index 00000000..73082c43 --- /dev/null +++ b/docs/examples/project/get-mock-phone.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 project = new sdk.Project(client); + +const result = await project.getMockPhone({ + number: '+12065550100' +}); +``` diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md new file mode 100644 index 00000000..a6df0d67 --- /dev/null +++ b/docs/examples/project/get-o-auth-2-provider.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 project = new sdk.Project(client); + +const result = await project.getOAuth2Provider({ + providerId: sdk.ProviderId.Amazon +}); +``` diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md new file mode 100644 index 00000000..df5abb54 --- /dev/null +++ b/docs/examples/project/get-policy.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 project = new sdk.Project(client); + +const result = await project.getPolicy({ + policyId: sdk.PolicyId.PasswordDictionary +}); +``` diff --git a/docs/examples/project/list-email-templates.md b/docs/examples/project/list-email-templates.md new file mode 100644 index 00000000..34bc7778 --- /dev/null +++ b/docs/examples/project/list-email-templates.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 project = new sdk.Project(client); + +const result = await project.listEmailTemplates({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/project/list-mock-phones.md b/docs/examples/project/list-mock-phones.md new file mode 100644 index 00000000..0816b18a --- /dev/null +++ b/docs/examples/project/list-mock-phones.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 project = new sdk.Project(client); + +const result = await project.listMockPhones({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/project/list-o-auth-2-providers.md b/docs/examples/project/list-o-auth-2-providers.md new file mode 100644 index 00000000..244767d3 --- /dev/null +++ b/docs/examples/project/list-o-auth-2-providers.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 project = new sdk.Project(client); + +const result = await project.listOAuth2Providers({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/project/list-policies.md b/docs/examples/project/list-policies.md new file mode 100644 index 00000000..f7b6260f --- /dev/null +++ b/docs/examples/project/list-policies.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 project = new sdk.Project(client); + +const result = await project.listPolicies({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md new file mode 100644 index 00000000..d6b2c6ca --- /dev/null +++ b/docs/examples/project/update-auth-method.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 project = new sdk.Project(client); + +const result = await project.updateAuthMethod({ + methodId: sdk.MethodId.EmailPassword, + enabled: false +}); +``` diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md new file mode 100644 index 00000000..67e0fac9 --- /dev/null +++ b/docs/examples/project/update-email-template.md @@ -0,0 +1,21 @@ +```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 project = new sdk.Project(client); + +const result = await project.updateEmailTemplate({ + templateId: sdk.EmailTemplateType.Verification, + locale: sdk.EmailTemplateLocale.Af, // optional + subject: '', // optional + message: '', // optional + senderName: '', // optional + senderEmail: 'email@example.com', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '' // optional +}); +``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index ad191f88..488fae13 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -11,7 +11,7 @@ const project = new sdk.Project(client); const result = await project.updateKey({ keyId: '', name: '', - scopes: [sdk.Scopes.SessionsWrite], + scopes: [sdk.Scopes.ProjectRead], expire: '2020-10-15T06:38:00.000+00:00' // optional }); ``` diff --git a/docs/examples/project/update-membership-privacy-policy.md b/docs/examples/project/update-membership-privacy-policy.md new file mode 100644 index 00000000..66eff9f3 --- /dev/null +++ b/docs/examples/project/update-membership-privacy-policy.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateMembershipPrivacyPolicy({ + userId: false, // optional + userEmail: false, // optional + userPhone: false, // optional + userName: false, // optional + userMFA: false // optional +}); +``` diff --git a/docs/examples/project/update-mock-phone.md b/docs/examples/project/update-mock-phone.md new file mode 100644 index 00000000..a0c70abc --- /dev/null +++ b/docs/examples/project/update-mock-phone.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 project = new sdk.Project(client); + +const result = await project.updateMockPhone({ + number: '+12065550100', + otp: '' +}); +``` diff --git a/docs/examples/project/update-o-auth-2-amazon.md b/docs/examples/project/update-o-auth-2-amazon.md new file mode 100644 index 00000000..12a535ff --- /dev/null +++ b/docs/examples/project/update-o-auth-2-amazon.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Amazon({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md new file mode 100644 index 00000000..ae985a4a --- /dev/null +++ b/docs/examples/project/update-o-auth-2-apple.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Apple({ + serviceId: '', // optional + keyId: '', // optional + teamId: '', // optional + p8File: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md new file mode 100644 index 00000000..37bf4a56 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-auth-0.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Auth0({ + clientId: '', // optional + clientSecret: '', // optional + endpoint: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-authentik.md b/docs/examples/project/update-o-auth-2-authentik.md new file mode 100644 index 00000000..e500466b --- /dev/null +++ b/docs/examples/project/update-o-auth-2-authentik.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Authentik({ + clientId: '', // optional + clientSecret: '', // optional + endpoint: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-autodesk.md b/docs/examples/project/update-o-auth-2-autodesk.md new file mode 100644 index 00000000..0b8aabce --- /dev/null +++ b/docs/examples/project/update-o-auth-2-autodesk.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Autodesk({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-bitbucket.md b/docs/examples/project/update-o-auth-2-bitbucket.md new file mode 100644 index 00000000..d3b5dc7b --- /dev/null +++ b/docs/examples/project/update-o-auth-2-bitbucket.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Bitbucket({ + key: '', // optional + secret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-bitly.md b/docs/examples/project/update-o-auth-2-bitly.md new file mode 100644 index 00000000..feecad27 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-bitly.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Bitly({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-box.md b/docs/examples/project/update-o-auth-2-box.md new file mode 100644 index 00000000..c9724638 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-box.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Box({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-dailymotion.md b/docs/examples/project/update-o-auth-2-dailymotion.md new file mode 100644 index 00000000..8d176339 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-dailymotion.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Dailymotion({ + apiKey: '', // optional + apiSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md new file mode 100644 index 00000000..5469509f --- /dev/null +++ b/docs/examples/project/update-o-auth-2-discord.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Discord({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-disqus.md b/docs/examples/project/update-o-auth-2-disqus.md new file mode 100644 index 00000000..c71bebfe --- /dev/null +++ b/docs/examples/project/update-o-auth-2-disqus.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Disqus({ + publicKey: '', // optional + secretKey: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-dropbox.md b/docs/examples/project/update-o-auth-2-dropbox.md new file mode 100644 index 00000000..9f2654dc --- /dev/null +++ b/docs/examples/project/update-o-auth-2-dropbox.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Dropbox({ + appKey: '', // optional + appSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-etsy.md b/docs/examples/project/update-o-auth-2-etsy.md new file mode 100644 index 00000000..684c4243 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-etsy.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Etsy({ + keyString: '', // optional + sharedSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-facebook.md b/docs/examples/project/update-o-auth-2-facebook.md new file mode 100644 index 00000000..7fca48a6 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-facebook.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Facebook({ + appId: '', // optional + appSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-figma.md b/docs/examples/project/update-o-auth-2-figma.md new file mode 100644 index 00000000..3b805738 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-figma.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Figma({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-fusion-auth.md b/docs/examples/project/update-o-auth-2-fusion-auth.md new file mode 100644 index 00000000..654991c9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-fusion-auth.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2FusionAuth({ + clientId: '', // optional + clientSecret: '', // optional + endpoint: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md new file mode 100644 index 00000000..cc2be084 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-git-hub.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2GitHub({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-gitlab.md b/docs/examples/project/update-o-auth-2-gitlab.md new file mode 100644 index 00000000..40e1943e --- /dev/null +++ b/docs/examples/project/update-o-auth-2-gitlab.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Gitlab({ + applicationId: '', // optional + secret: '', // optional + endpoint: 'https://example.com', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md new file mode 100644 index 00000000..dce02e9c --- /dev/null +++ b/docs/examples/project/update-o-auth-2-google.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Google({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-keycloak.md b/docs/examples/project/update-o-auth-2-keycloak.md new file mode 100644 index 00000000..bce76ee5 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-keycloak.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Keycloak({ + clientId: '', // optional + clientSecret: '', // optional + endpoint: '', // optional + realmName: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-kick.md b/docs/examples/project/update-o-auth-2-kick.md new file mode 100644 index 00000000..1d581052 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kick.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Kick({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-linkedin.md b/docs/examples/project/update-o-auth-2-linkedin.md new file mode 100644 index 00000000..02c68d99 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-linkedin.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Linkedin({ + clientId: '', // optional + primaryClientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md new file mode 100644 index 00000000..cc5a8c27 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-microsoft.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Microsoft({ + applicationId: '', // optional + applicationSecret: '', // optional + tenant: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-notion.md b/docs/examples/project/update-o-auth-2-notion.md new file mode 100644 index 00000000..c3297799 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-notion.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Notion({ + oauthClientId: '', // optional + oauthClientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md new file mode 100644 index 00000000..7f1f6eb7 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -0,0 +1,20 @@ +```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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Oidc({ + clientId: '', // optional + clientSecret: '', // optional + wellKnownURL: 'https://example.com', // optional + authorizationURL: 'https://example.com', // optional + tokenURL: 'https://example.com', // optional + userInfoURL: 'https://example.com', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md new file mode 100644 index 00000000..a85c9809 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-okta.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateOAuth2Okta({ + clientId: '', // optional + clientSecret: '', // optional + domain: '', // optional + authorizationServerId: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-paypal-sandbox.md b/docs/examples/project/update-o-auth-2-paypal-sandbox.md new file mode 100644 index 00000000..e6b8de7f --- /dev/null +++ b/docs/examples/project/update-o-auth-2-paypal-sandbox.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2PaypalSandbox({ + clientId: '', // optional + secretKey: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-paypal.md b/docs/examples/project/update-o-auth-2-paypal.md new file mode 100644 index 00000000..8f7162c7 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-paypal.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Paypal({ + clientId: '', // optional + secretKey: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-podio.md b/docs/examples/project/update-o-auth-2-podio.md new file mode 100644 index 00000000..3d6c2c44 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-podio.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Podio({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md new file mode 100644 index 00000000..a1937639 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-salesforce.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Salesforce({ + customerKey: '', // optional + customerSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-slack.md b/docs/examples/project/update-o-auth-2-slack.md new file mode 100644 index 00000000..6dab9092 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-slack.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Slack({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-spotify.md b/docs/examples/project/update-o-auth-2-spotify.md new file mode 100644 index 00000000..72ffa64d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-spotify.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Spotify({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-stripe.md b/docs/examples/project/update-o-auth-2-stripe.md new file mode 100644 index 00000000..1df015f1 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-stripe.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Stripe({ + clientId: '', // optional + apiSecretKey: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md new file mode 100644 index 00000000..df090e92 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2TradeshiftSandbox({ + oauth2ClientId: '', // optional + oauth2ClientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift.md b/docs/examples/project/update-o-auth-2-tradeshift.md new file mode 100644 index 00000000..afddd8c0 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tradeshift.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Tradeshift({ + oauth2ClientId: '', // optional + oauth2ClientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-twitch.md b/docs/examples/project/update-o-auth-2-twitch.md new file mode 100644 index 00000000..ad096ea9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-twitch.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Twitch({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-word-press.md b/docs/examples/project/update-o-auth-2-word-press.md new file mode 100644 index 00000000..597ccd5b --- /dev/null +++ b/docs/examples/project/update-o-auth-2-word-press.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2WordPress({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-yahoo.md b/docs/examples/project/update-o-auth-2-yahoo.md new file mode 100644 index 00000000..79b3b021 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-yahoo.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Yahoo({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-yandex.md b/docs/examples/project/update-o-auth-2-yandex.md new file mode 100644 index 00000000..2f79c448 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-yandex.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Yandex({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md new file mode 100644 index 00000000..031a2816 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-zoho.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Zoho({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2-zoom.md b/docs/examples/project/update-o-auth-2-zoom.md new file mode 100644 index 00000000..985400b1 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-zoom.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2Zoom({ + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-o-auth-2x.md b/docs/examples/project/update-o-auth-2x.md new file mode 100644 index 00000000..183e2257 --- /dev/null +++ b/docs/examples/project/update-o-auth-2x.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 project = new sdk.Project(client); + +const result = await project.updateOAuth2X({ + customerKey: '', // optional + secretKey: '', // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-password-dictionary-policy.md b/docs/examples/project/update-password-dictionary-policy.md new file mode 100644 index 00000000..8b8bdd02 --- /dev/null +++ b/docs/examples/project/update-password-dictionary-policy.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 project = new sdk.Project(client); + +const result = await project.updatePasswordDictionaryPolicy({ + enabled: false +}); +``` diff --git a/docs/examples/project/update-password-history-policy.md b/docs/examples/project/update-password-history-policy.md new file mode 100644 index 00000000..b8ab9d03 --- /dev/null +++ b/docs/examples/project/update-password-history-policy.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 project = new sdk.Project(client); + +const result = await project.updatePasswordHistoryPolicy({ + total: 1 +}); +``` diff --git a/docs/examples/project/update-password-personal-data-policy.md b/docs/examples/project/update-password-personal-data-policy.md new file mode 100644 index 00000000..df490a4a --- /dev/null +++ b/docs/examples/project/update-password-personal-data-policy.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 project = new sdk.Project(client); + +const result = await project.updatePasswordPersonalDataPolicy({ + enabled: false +}); +``` diff --git a/docs/examples/project/update-protocol-status.md b/docs/examples/project/update-protocol.md similarity index 87% rename from docs/examples/project/update-protocol-status.md rename to docs/examples/project/update-protocol.md index b3da4bf3..06331946 100644 --- a/docs/examples/project/update-protocol-status.md +++ b/docs/examples/project/update-protocol.md @@ -8,7 +8,7 @@ const client = new sdk.Client() const project = new sdk.Project(client); -const result = await project.updateProtocolStatus({ +const result = await project.updateProtocol({ protocolId: sdk.ProtocolId.Rest, enabled: false }); diff --git a/docs/examples/project/update-service-status.md b/docs/examples/project/update-service.md similarity index 88% rename from docs/examples/project/update-service-status.md rename to docs/examples/project/update-service.md index fe9514b4..45cc56d0 100644 --- a/docs/examples/project/update-service-status.md +++ b/docs/examples/project/update-service.md @@ -8,7 +8,7 @@ const client = new sdk.Client() const project = new sdk.Project(client); -const result = await project.updateServiceStatus({ +const result = await project.updateService({ serviceId: sdk.ServiceId.Account, enabled: false }); diff --git a/docs/examples/project/update-session-alert-policy.md b/docs/examples/project/update-session-alert-policy.md new file mode 100644 index 00000000..54546084 --- /dev/null +++ b/docs/examples/project/update-session-alert-policy.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 project = new sdk.Project(client); + +const result = await project.updateSessionAlertPolicy({ + enabled: false +}); +``` diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md new file mode 100644 index 00000000..2a4873be --- /dev/null +++ b/docs/examples/project/update-session-duration-policy.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 project = new sdk.Project(client); + +const result = await project.updateSessionDurationPolicy({ + duration: 5 +}); +``` diff --git a/docs/examples/project/update-session-invalidation-policy.md b/docs/examples/project/update-session-invalidation-policy.md new file mode 100644 index 00000000..a5840bc2 --- /dev/null +++ b/docs/examples/project/update-session-invalidation-policy.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 project = new sdk.Project(client); + +const result = await project.updateSessionInvalidationPolicy({ + enabled: false +}); +``` diff --git a/docs/examples/project/update-session-limit-policy.md b/docs/examples/project/update-session-limit-policy.md new file mode 100644 index 00000000..514d77aa --- /dev/null +++ b/docs/examples/project/update-session-limit-policy.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 project = new sdk.Project(client); + +const result = await project.updateSessionLimitPolicy({ + total: 1 +}); +``` diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md new file mode 100644 index 00000000..ac001956 --- /dev/null +++ b/docs/examples/project/update-smtp.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const project = new sdk.Project(client); + +const result = await project.updateSMTP({ + host: '', // optional + port: null, // optional + username: '', // optional + password: '', // optional + senderEmail: 'email@example.com', // optional + senderName: '', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '', // optional + secure: sdk.Secure.Tls, // optional + enabled: false // optional +}); +``` diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md new file mode 100644 index 00000000..bb372042 --- /dev/null +++ b/docs/examples/project/update-user-limit-policy.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 project = new sdk.Project(client); + +const result = await project.updateUserLimitPolicy({ + total: 1 +}); +``` diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md new file mode 100644 index 00000000..25fcf691 --- /dev/null +++ b/docs/examples/proxy/create-api-rule.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 proxy = new sdk.Proxy(client); + +const result = await proxy.createAPIRule({ + domain: '' +}); +``` diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md new file mode 100644 index 00000000..cf225f67 --- /dev/null +++ b/docs/examples/proxy/create-function-rule.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 proxy = new sdk.Proxy(client); + +const result = await proxy.createFunctionRule({ + domain: '', + functionId: '', + branch: '' // optional +}); +``` diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md new file mode 100644 index 00000000..0f33abd6 --- /dev/null +++ b/docs/examples/proxy/create-redirect-rule.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 + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const proxy = new sdk.Proxy(client); + +const result = await proxy.createRedirectRule({ + domain: '', + url: 'https://example.com', + statusCode: sdk.StatusCode.MovedPermanently301, + resourceId: '', + resourceType: sdk.ProxyResourceType.Site +}); +``` diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md new file mode 100644 index 00000000..bafbee3d --- /dev/null +++ b/docs/examples/proxy/create-site-rule.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 proxy = new sdk.Proxy(client); + +const result = await proxy.createSiteRule({ + domain: '', + siteId: '', + branch: '' // optional +}); +``` diff --git a/docs/examples/proxy/delete-rule.md b/docs/examples/proxy/delete-rule.md new file mode 100644 index 00000000..2d07a110 --- /dev/null +++ b/docs/examples/proxy/delete-rule.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 proxy = new sdk.Proxy(client); + +const result = await proxy.deleteRule({ + ruleId: '' +}); +``` diff --git a/docs/examples/proxy/get-rule.md b/docs/examples/proxy/get-rule.md new file mode 100644 index 00000000..e89612dc --- /dev/null +++ b/docs/examples/proxy/get-rule.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 proxy = new sdk.Proxy(client); + +const result = await proxy.getRule({ + ruleId: '' +}); +``` diff --git a/docs/examples/proxy/list-rules.md b/docs/examples/proxy/list-rules.md new file mode 100644 index 00000000..b161a085 --- /dev/null +++ b/docs/examples/proxy/list-rules.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 proxy = new sdk.Proxy(client); + +const result = await proxy.listRules({ + queries: [], // optional + total: false // optional +}); +``` diff --git a/docs/examples/proxy/update-rule-status.md b/docs/examples/proxy/update-rule-status.md new file mode 100644 index 00000000..9e050fc7 --- /dev/null +++ b/docs/examples/proxy/update-rule-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 proxy = new sdk.Proxy(client); + +const result = await proxy.updateRuleStatus({ + ruleId: '' +}); +``` diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index be07336b..cad7be76 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -10,6 +10,7 @@ const sites = new sdk.Sites(client); const result = await sites.createVariable({ siteId: '', + variableId: '', key: '', value: '', secret: false // optional diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index 0451b1eb..26ae3212 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -9,6 +9,8 @@ const client = new sdk.Client() const sites = new sdk.Sites(client); const result = await sites.listVariables({ - siteId: '' + siteId: '', + queries: [], // optional + total: false // optional }); ``` diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index 40a98106..2853a180 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -11,7 +11,7 @@ const sites = new sdk.Sites(client); const result = await sites.updateVariable({ siteId: '', variableId: '', - key: '', + key: '', // optional value: '', // optional secret: false // optional }); diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md new file mode 100644 index 00000000..9c1c01f4 --- /dev/null +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -0,0 +1,21 @@ +```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.createBigIntColumn({ + databaseId: '', + tableId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +}); +``` diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md new file mode 100644 index 00000000..87c20e4b --- /dev/null +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -0,0 +1,21 @@ +```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.updateBigIntColumn({ + databaseId: '', + tableId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); +``` diff --git a/package-lock.json b/package-lock.json index 848f3d9c..69c1e71e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "24.0.0", + "version": "24.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "24.0.0", + "version": "24.1.0", "dependencies": { "json-bigint": "1.0.0", "node-fetch-native-with-agent": "1.7.2" diff --git a/package.json b/package.json index bcf42393..24e2e0ca 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": "24.0.0", + "version": "24.1.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index d413d82b..84774c0a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import { fetch, FormData, File } from 'node-fetch-native-with-agent'; import { createAgent } from 'node-fetch-native-with-agent/agent'; import { Models } from './models'; +import { InputFile } from './inputFile'; import JSONbigModule from 'json-bigint'; const JSONbigParser = JSONbigModule({ storeAsString: false }); const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true }); @@ -73,7 +74,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/24.0.0'; + let ua = 'AppwriteNodeJSSDK/24.1.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -117,6 +118,8 @@ class Client { locale: '', session: '', forwardeduseragent: '', + devkey: '', + cookie: '', impersonateuserid: '', impersonateuseremail: '', impersonateuserphone: '', @@ -125,9 +128,9 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '24.0.0', + 'x-sdk-version': '24.1.0', 'user-agent' : getUserAgent(), - 'X-Appwrite-Response-Format': '1.9.1', + 'X-Appwrite-Response-Format': '1.9.4', }; /** @@ -278,6 +281,34 @@ class Client { this.config.forwardeduseragent = value; return this; } + /** + * Set DevKey + * + * Your secret dev API key + * + * @param value string + * + * @return {this} + */ + setDevKey(value: string): this { + this.headers['X-Appwrite-Dev-Key'] = value; + this.config.devkey = value; + return this; + } + /** + * Set Cookie + * + * The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. + * + * @param value string + * + * @return {this} + */ + setCookie(value: string): this { + this.headers['Cookie'] = value; + this.config.cookie = value; + return this; + } /** * Set ImpersonateUserId * @@ -367,12 +398,60 @@ class Client { } async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { - const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? []; + const [fileParam, file] = Object.entries(originalPayload).find( + ([_, value]) => value instanceof File || value instanceof InputFile + ) ?? []; if (!file || !fileParam) { throw new Error('File not found in payload'); } + if (file instanceof InputFile) { + const size = await file.size(); + + if (size <= Client.CHUNK_SIZE) { + const payload = { ...originalPayload }; + payload[fileParam] = await file.toFile(); + return await this.call(method, url, headers, payload); + } + + let start = 0; + let response = null; + + while (start < size) { + let end = start + Client.CHUNK_SIZE; + if (end >= size) { + end = size; + } + + headers['content-range'] = `bytes ${start}-${end - 1}/${size}`; + const chunk = await file.slice(start, end); + + const payload = { ...originalPayload }; + payload[fileParam] = new File([chunk], file.filename); + + response = await this.call(method, url, headers, payload); + + if (onProgress && typeof onProgress === 'function') { + onProgress({ + $id: response.$id, + progress: Math.round((end / size) * 100), + sizeUploaded: end, + chunksTotal: Math.ceil(size / Client.CHUNK_SIZE), + chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE) + }); + } + + if (response && response.$id) { + headers['x-appwrite-id'] = response.$id; + } + + start = end; + } + + return response; + } + if (file.size <= Client.CHUNK_SIZE) { return await this.call(method, url, headers, originalPayload); } diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 6aea9aa5..1466d635 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -79,6 +79,7 @@ export enum BuildRuntime { Go124 = 'go-1.24', Go125 = 'go-1.25', Go126 = 'go-1.26', + Rust183 = 'rust-1.83', Static1 = 'static-1', Flutter324 = 'flutter-3.24', Flutter327 = 'flutter-3.27', diff --git a/src/enums/email-template-locale.ts b/src/enums/email-template-locale.ts new file mode 100644 index 00000000..82656b89 --- /dev/null +++ b/src/enums/email-template-locale.ts @@ -0,0 +1,133 @@ +export enum EmailTemplateLocale { + Af = 'af', + Arae = 'ar-ae', + Arbh = 'ar-bh', + Ardz = 'ar-dz', + Areg = 'ar-eg', + Ariq = 'ar-iq', + Arjo = 'ar-jo', + Arkw = 'ar-kw', + Arlb = 'ar-lb', + Arly = 'ar-ly', + Arma = 'ar-ma', + Arom = 'ar-om', + Arqa = 'ar-qa', + Arsa = 'ar-sa', + Arsy = 'ar-sy', + Artn = 'ar-tn', + Arye = 'ar-ye', + As = 'as', + Az = 'az', + Be = 'be', + Bg = 'bg', + Bh = 'bh', + Bn = 'bn', + Bs = 'bs', + Ca = 'ca', + Cs = 'cs', + Cy = 'cy', + Da = 'da', + De = 'de', + Deat = 'de-at', + Dech = 'de-ch', + Deli = 'de-li', + Delu = 'de-lu', + El = 'el', + En = 'en', + Enau = 'en-au', + Enbz = 'en-bz', + Enca = 'en-ca', + Engb = 'en-gb', + Enie = 'en-ie', + Enjm = 'en-jm', + Ennz = 'en-nz', + Entt = 'en-tt', + Enus = 'en-us', + Enza = 'en-za', + Eo = 'eo', + Es = 'es', + Esar = 'es-ar', + Esbo = 'es-bo', + Escl = 'es-cl', + Esco = 'es-co', + Escr = 'es-cr', + Esdo = 'es-do', + Esec = 'es-ec', + Esgt = 'es-gt', + Eshn = 'es-hn', + Esmx = 'es-mx', + Esni = 'es-ni', + Espa = 'es-pa', + Espe = 'es-pe', + Espr = 'es-pr', + Espy = 'es-py', + Essv = 'es-sv', + Esuy = 'es-uy', + Esve = 'es-ve', + Et = 'et', + Eu = 'eu', + Fa = 'fa', + Fi = 'fi', + Fo = 'fo', + Fr = 'fr', + Frbe = 'fr-be', + Frca = 'fr-ca', + Frch = 'fr-ch', + Frlu = 'fr-lu', + Ga = 'ga', + Gd = 'gd', + He = 'he', + Hi = 'hi', + Hr = 'hr', + Hu = 'hu', + Id = 'id', + Is = 'is', + It = 'it', + Itch = 'it-ch', + Ja = 'ja', + Ji = 'ji', + Ko = 'ko', + Ku = 'ku', + Lt = 'lt', + Lv = 'lv', + Mk = 'mk', + Ml = 'ml', + Ms = 'ms', + Mt = 'mt', + Nb = 'nb', + Ne = 'ne', + Nl = 'nl', + Nlbe = 'nl-be', + Nn = 'nn', + No = 'no', + Pa = 'pa', + Pl = 'pl', + Pt = 'pt', + Ptbr = 'pt-br', + Rm = 'rm', + Ro = 'ro', + Romd = 'ro-md', + Ru = 'ru', + Rumd = 'ru-md', + Sb = 'sb', + Sk = 'sk', + Sl = 'sl', + Sq = 'sq', + Sr = 'sr', + Sv = 'sv', + Svfi = 'sv-fi', + Th = 'th', + Tn = 'tn', + Tr = 'tr', + Ts = 'ts', + Ua = 'ua', + Ur = 'ur', + Ve = 've', + Vi = 'vi', + Xh = 'xh', + Zhcn = 'zh-cn', + Zhhk = 'zh-hk', + Zhsg = 'zh-sg', + Zhtw = 'zh-tw', + Zu = 'zu', +} \ No newline at end of file diff --git a/src/enums/email-template-type.ts b/src/enums/email-template-type.ts new file mode 100644 index 00000000..2a561bf0 --- /dev/null +++ b/src/enums/email-template-type.ts @@ -0,0 +1,9 @@ +export enum EmailTemplateType { + Verification = 'verification', + MagicSession = 'magicSession', + Recovery = 'recovery', + Invitation = 'invitation', + MfaChallenge = 'mfaChallenge', + SessionAlert = 'sessionAlert', + OtpSession = 'otpSession', +} \ No newline at end of file diff --git a/src/enums/method-id.ts b/src/enums/method-id.ts new file mode 100644 index 00000000..062d0d0e --- /dev/null +++ b/src/enums/method-id.ts @@ -0,0 +1,9 @@ +export enum MethodId { + Emailpassword = 'email-password', + Magicurl = 'magic-url', + Emailotp = 'email-otp', + Anonymous = 'anonymous', + Invites = 'invites', + Jwt = 'jwt', + Phone = 'phone', +} \ No newline at end of file diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index efc44844..cc9e340b 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -14,9 +14,12 @@ export enum OAuthProvider { Etsy = 'etsy', Facebook = 'facebook', Figma = 'figma', + Fusionauth = 'fusionauth', Github = 'github', Gitlab = 'gitlab', Google = 'google', + Keycloak = 'keycloak', + Kick = 'kick', Linkedin = 'linkedin', Microsoft = 'microsoft', Notion = 'notion', diff --git a/src/enums/policy-id.ts b/src/enums/policy-id.ts new file mode 100644 index 00000000..ab1c4cd2 --- /dev/null +++ b/src/enums/policy-id.ts @@ -0,0 +1,11 @@ +export enum PolicyId { + Passworddictionary = 'password-dictionary', + Passwordhistory = 'password-history', + Passwordpersonaldata = 'password-personal-data', + Sessionalert = 'session-alert', + Sessionduration = 'session-duration', + Sessioninvalidation = 'session-invalidation', + Sessionlimit = 'session-limit', + Userlimit = 'user-limit', + Membershipprivacy = 'membership-privacy', +} \ No newline at end of file diff --git a/src/enums/provider-id.ts b/src/enums/provider-id.ts new file mode 100644 index 00000000..943d7334 --- /dev/null +++ b/src/enums/provider-id.ts @@ -0,0 +1,49 @@ +export enum ProviderId { + Amazon = 'amazon', + Apple = 'apple', + Auth0 = 'auth0', + Authentik = 'authentik', + Autodesk = 'autodesk', + Bitbucket = 'bitbucket', + Bitly = 'bitly', + Box = 'box', + Dailymotion = 'dailymotion', + Discord = 'discord', + Disqus = 'disqus', + Dropbox = 'dropbox', + Etsy = 'etsy', + Facebook = 'facebook', + Figma = 'figma', + Fusionauth = 'fusionauth', + Github = 'github', + Gitlab = 'gitlab', + Google = 'google', + Keycloak = 'keycloak', + Kick = 'kick', + Linkedin = 'linkedin', + Microsoft = 'microsoft', + Notion = 'notion', + Oidc = 'oidc', + Okta = 'okta', + Paypal = 'paypal', + PaypalSandbox = 'paypalSandbox', + Podio = 'podio', + Salesforce = 'salesforce', + Slack = 'slack', + Spotify = 'spotify', + Stripe = 'stripe', + Tradeshift = 'tradeshift', + TradeshiftBox = 'tradeshiftBox', + Twitch = 'twitch', + Wordpress = 'wordpress', + X = 'x', + Yahoo = 'yahoo', + Yammer = 'yammer', + Yandex = 'yandex', + Zoho = 'zoho', + Zoom = 'zoom', + Mock = 'mock', + Mockunverified = 'mock-unverified', + GithubImagine = 'githubImagine', + GoogleImagine = 'googleImagine', +} \ No newline at end of file diff --git a/src/enums/proxy-resource-type.ts b/src/enums/proxy-resource-type.ts new file mode 100644 index 00000000..e04c8046 --- /dev/null +++ b/src/enums/proxy-resource-type.ts @@ -0,0 +1,4 @@ +export enum ProxyResourceType { + Site = 'site', + Function = 'function', +} \ No newline at end of file diff --git a/src/enums/proxy-rule-deployment-resource-type.ts b/src/enums/proxy-rule-deployment-resource-type.ts new file mode 100644 index 00000000..89236c74 --- /dev/null +++ b/src/enums/proxy-rule-deployment-resource-type.ts @@ -0,0 +1,4 @@ +export enum ProxyRuleDeploymentResourceType { + Function = 'function', + Site = 'site', +} \ No newline at end of file diff --git a/src/enums/proxy-rule-status.ts b/src/enums/proxy-rule-status.ts new file mode 100644 index 00000000..67b8e4cb --- /dev/null +++ b/src/enums/proxy-rule-status.ts @@ -0,0 +1,5 @@ +export enum ProxyRuleStatus { + Unverified = 'unverified', + Verifying = 'verifying', + Verified = 'verified', +} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index 3a57958b..f4d20688 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -79,6 +79,7 @@ export enum Runtime { Go124 = 'go-1.24', Go125 = 'go-1.25', Go126 = 'go-1.26', + Rust183 = 'rust-1.83', Static1 = 'static-1', Flutter324 = 'flutter-3.24', Flutter327 = 'flutter-3.27', diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts index d98f20ab..bab24a98 100644 --- a/src/enums/scopes.ts +++ b/src/enums/scopes.ts @@ -1,71 +1,86 @@ export enum Scopes { - SessionsWrite = 'sessions.write', + ProjectRead = 'project.read', + ProjectWrite = 'project.write', + KeysRead = 'keys.read', + KeysWrite = 'keys.write', + PlatformsRead = 'platforms.read', + PlatformsWrite = 'platforms.write', + MocksRead = 'mocks.read', + MocksWrite = 'mocks.write', + PoliciesRead = 'policies.read', + PoliciesWrite = 'policies.write', + ProjectPoliciesRead = 'project.policies.read', + ProjectPoliciesWrite = 'project.policies.write', + TemplatesRead = 'templates.read', + TemplatesWrite = 'templates.write', + Oauth2Read = 'oauth2.read', + Oauth2Write = 'oauth2.write', UsersRead = 'users.read', UsersWrite = 'users.write', + SessionsRead = 'sessions.read', + SessionsWrite = 'sessions.write', TeamsRead = 'teams.read', TeamsWrite = 'teams.write', DatabasesRead = 'databases.read', DatabasesWrite = 'databases.write', - CollectionsRead = 'collections.read', - CollectionsWrite = 'collections.write', TablesRead = 'tables.read', TablesWrite = 'tables.write', - AttributesRead = 'attributes.read', - AttributesWrite = 'attributes.write', ColumnsRead = 'columns.read', ColumnsWrite = 'columns.write', IndexesRead = 'indexes.read', IndexesWrite = 'indexes.write', - DocumentsRead = 'documents.read', - DocumentsWrite = 'documents.write', RowsRead = 'rows.read', RowsWrite = 'rows.write', - FilesRead = 'files.read', - FilesWrite = 'files.write', + CollectionsRead = 'collections.read', + CollectionsWrite = 'collections.write', + AttributesRead = 'attributes.read', + AttributesWrite = 'attributes.write', + DocumentsRead = 'documents.read', + DocumentsWrite = 'documents.write', BucketsRead = 'buckets.read', BucketsWrite = 'buckets.write', + FilesRead = 'files.read', + FilesWrite = 'files.write', + TokensRead = 'tokens.read', + TokensWrite = 'tokens.write', FunctionsRead = 'functions.read', FunctionsWrite = 'functions.write', + ExecutionsRead = 'executions.read', + ExecutionsWrite = 'executions.write', + ExecutionRead = 'execution.read', + ExecutionWrite = 'execution.write', SitesRead = 'sites.read', SitesWrite = 'sites.write', LogRead = 'log.read', LogWrite = 'log.write', - ExecutionRead = 'execution.read', - ExecutionWrite = 'execution.write', - LocaleRead = 'locale.read', - AvatarsRead = 'avatars.read', - HealthRead = 'health.read', ProvidersRead = 'providers.read', ProvidersWrite = 'providers.write', - MessagesRead = 'messages.read', - MessagesWrite = 'messages.write', TopicsRead = 'topics.read', TopicsWrite = 'topics.write', SubscribersRead = 'subscribers.read', SubscribersWrite = 'subscribers.write', TargetsRead = 'targets.read', TargetsWrite = 'targets.write', + MessagesRead = 'messages.read', + MessagesWrite = 'messages.write', RulesRead = 'rules.read', RulesWrite = 'rules.write', - SchedulesRead = 'schedules.read', - SchedulesWrite = 'schedules.write', + WebhooksRead = 'webhooks.read', + WebhooksWrite = 'webhooks.write', + LocaleRead = 'locale.read', + AvatarsRead = 'avatars.read', + HealthRead = 'health.read', + AssistantRead = 'assistant.read', MigrationsRead = 'migrations.read', MigrationsWrite = 'migrations.write', + SchedulesRead = 'schedules.read', + SchedulesWrite = 'schedules.write', VcsRead = 'vcs.read', VcsWrite = 'vcs.write', - AssistantRead = 'assistant.read', - TokensRead = 'tokens.read', - TokensWrite = 'tokens.write', - WebhooksRead = 'webhooks.read', - WebhooksWrite = 'webhooks.write', - ProjectRead = 'project.read', - ProjectWrite = 'project.write', - KeysRead = 'keys.read', - KeysWrite = 'keys.write', - PlatformsRead = 'platforms.read', - PlatformsWrite = 'platforms.write', - PoliciesWrite = 'policies.write', - PoliciesRead = 'policies.read', + PresencesRead = 'presences.read', + PresencesWrite = 'presences.write', + BackupsPoliciesRead = 'backups.policies.read', + BackupsPoliciesWrite = 'backups.policies.write', ArchivesRead = 'archives.read', ArchivesWrite = 'archives.write', RestorationsRead = 'restorations.read', diff --git a/src/enums/secure.ts b/src/enums/secure.ts new file mode 100644 index 00000000..0ab54cf8 --- /dev/null +++ b/src/enums/secure.ts @@ -0,0 +1,4 @@ +export enum Secure { + Tls = 'tls', + Ssl = 'ssl', +} \ No newline at end of file diff --git a/src/enums/status-code.ts b/src/enums/status-code.ts new file mode 100644 index 00000000..1f3adf8b --- /dev/null +++ b/src/enums/status-code.ts @@ -0,0 +1,6 @@ +export enum StatusCode { + MovedPermanently301 = '301', + Found302 = '302', + TemporaryRedirect307 = '307', + PermanentRedirect308 = '308', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 743e850e..d598e963 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,9 @@ export { Graphql } from './services/graphql'; export { Health } from './services/health'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; +export { Presences } from './services/presences'; export { Project } from './services/project'; +export { Proxy } from './services/proxy'; export { Sites } from './services/sites'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; @@ -47,8 +49,16 @@ export { ExecutionMethod } from './enums/execution-method'; export { Name } from './enums/name'; export { MessagePriority } from './enums/message-priority'; export { SmtpEncryption } from './enums/smtp-encryption'; +export { MethodId } from './enums/method-id'; +export { ProviderId } from './enums/provider-id'; +export { PolicyId } from './enums/policy-id'; export { ProtocolId } from './enums/protocol-id'; export { ServiceId } from './enums/service-id'; +export { Secure } from './enums/secure'; +export { EmailTemplateType } from './enums/email-template-type'; +export { EmailTemplateLocale } from './enums/email-template-locale'; +export { StatusCode } from './enums/status-code'; +export { ProxyResourceType } from './enums/proxy-resource-type'; export { Framework } from './enums/framework'; export { BuildRuntime } from './enums/build-runtime'; export { Adapter } from './enums/adapter'; @@ -67,4 +77,6 @@ export { ExecutionStatus } from './enums/execution-status'; export { PlatformType } from './enums/platform-type'; export { HealthAntivirusStatus } from './enums/health-antivirus-status'; export { HealthCheckStatus } from './enums/health-check-status'; +export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; +export { ProxyRuleStatus } from './enums/proxy-rule-status'; export { MessageStatus } from './enums/message-status'; diff --git a/src/inputFile.ts b/src/inputFile.ts index a30ea55d..94afbe23 100644 --- a/src/inputFile.ts +++ b/src/inputFile.ts @@ -1,23 +1,144 @@ import { File } from "node-fetch-native-with-agent"; -import { realpathSync, readFileSync } from "fs"; -import type { BinaryLike } from "crypto"; + +type FsPromises = { + stat: (path: string) => Promise<{ size: number }>; + open: (path: string, flags: string) => Promise<{ + read: (buffer: Uint8Array, offset: number, length: number, position: number) => Promise<{ bytesRead: number }>; + close: () => Promise; + }>; + readFile: (path: string) => Promise; +}; + +function isEdgeRuntime(): boolean { + return typeof globalThis !== 'undefined' && typeof (globalThis as { EdgeRuntime?: unknown }).EdgeRuntime !== 'undefined'; +} + +function assertFileSystemAvailable(): void { + if (isEdgeRuntime()) { + throw new Error('File system operations are not supported in edge runtimes. Please use InputFile.fromBuffer instead.'); + } +} + +async function getFs(): Promise { + assertFileSystemAvailable(); + + try { + const fs = await import('fs'); + return fs.promises; + } catch { + throw new Error('File system operations are not available in this runtime. Please use InputFile.fromBuffer instead.'); + } +} + +function getFilename(path: string): string { + const segments = path.replace(/\\/g, '/').split('/').filter(Boolean); + return segments.pop() ?? 'file'; +} + +type BlobLike = { + size: number; + slice: (start: number, end: number) => BlobLike; + arrayBuffer: () => Promise; +}; + +type InputFileSource = + | { type: 'path'; path: string } + | { type: 'buffer'; data: Uint8Array } + | { type: 'blob'; data: BlobLike }; export class InputFile { - static fromBuffer( - parts: Blob | BinaryLike, - name: string - ): File { - return new File([parts], name); + private source: InputFileSource; + filename: string; + + private constructor(source: InputFileSource, filename: string) { + this.source = source; + this.filename = filename; + } + + static fromBuffer(parts: BlobLike | Uint8Array | ArrayBuffer | string, name: string): InputFile { + if (parts && !ArrayBuffer.isView(parts) && typeof (parts as BlobLike).arrayBuffer === 'function') { + return new InputFile({ type: 'blob', data: parts as BlobLike }, name); + } + + if (typeof parts === 'string') { + return new InputFile({ type: 'buffer', data: new TextEncoder().encode(parts) }, name); + } + + if (parts instanceof ArrayBuffer) { + return new InputFile({ type: 'buffer', data: new Uint8Array(parts) }, name); + } + + if (ArrayBuffer.isView(parts)) { + return new InputFile({ + type: 'buffer', + data: new Uint8Array(parts.buffer, parts.byteOffset, parts.byteLength), + }, name); + } + + throw new Error('Unsupported input type for InputFile.fromBuffer'); + } + + static fromPath(path: string, name?: string): InputFile { + assertFileSystemAvailable(); + return new InputFile({ type: 'path', path }, name ?? getFilename(path)); + } + + static fromPlainText(content: string, name: string): InputFile { + return new InputFile({ type: 'buffer', data: new TextEncoder().encode(content) }, name); + } + + async size(): Promise { + switch (this.source.type) { + case 'path': { + const fs = await getFs(); + return (await fs.stat(this.source.path)).size; + } + case 'buffer': + return this.source.data.length; + case 'blob': + return this.source.data.size; + } + } + + async slice(start: number, end: number): Promise { + const length = end - start; + + switch (this.source.type) { + case 'path': { + const fs = await getFs(); + const handle = await fs.open(this.source.path, 'r'); + try { + const buffer = new Uint8Array(length); + const result = await handle.read(buffer, 0, length, start); + return result.bytesRead === buffer.length ? buffer : buffer.subarray(0, result.bytesRead); + } finally { + await handle.close(); + } + } + case 'buffer': + return this.source.data.subarray(start, end); + case 'blob': { + const arrayBuffer = await this.source.data.slice(start, end).arrayBuffer(); + return new Uint8Array(arrayBuffer); + } + } } - static fromPath(path: string, name: string): File { - const realPath = realpathSync(path); - const contents = readFileSync(realPath); - return this.fromBuffer(contents, name); + async toFile(): Promise { + const data = await this.toUint8Array(); + return new File([data], this.filename); } - static fromPlainText(content: string, name: string): File { - const arrayBytes = new TextEncoder().encode(content); - return this.fromBuffer(arrayBytes, name); + private async toUint8Array(): Promise { + switch (this.source.type) { + case 'path': { + const fs = await getFs(); + return await fs.readFile(this.source.path); + } + case 'buffer': + return this.source.data; + case 'blob': + return new Uint8Array(await this.source.data.arrayBuffer()); + } } } diff --git a/src/models.ts b/src/models.ts index 0f9546a3..06951df0 100644 --- a/src/models.ts +++ b/src/models.ts @@ -8,6 +8,8 @@ import { ExecutionStatus } from "./enums/execution-status" import { PlatformType } from "./enums/platform-type" import { HealthAntivirusStatus } from "./enums/health-antivirus-status" import { HealthCheckStatus } from "./enums/health-check-status" +import { ProxyRuleDeploymentResourceType } from "./enums/proxy-rule-deployment-resource-type" +import { ProxyRuleStatus } from "./enums/proxy-rule-status" import { MessageStatus } from "./enums/message-status" /** @@ -45,6 +47,20 @@ export namespace Models { documents: Document[]; } + /** + * Presences List + */ + export type PresenceList = { + /** + * Total number of presences that matched your query. + */ + total: number; + /** + * List of presences. + */ + presences: Presence[]; + } + /** * Tables List */ @@ -437,6 +453,48 @@ export namespace Models { variables: Variable[]; } + /** + * Mock Numbers List + */ + export type MockNumberList = { + /** + * Total number of mockNumbers that matched your query. + */ + total: number; + /** + * List of mockNumbers. + */ + mockNumbers: MockNumber[]; + } + + /** + * Policies List + */ + export type PolicyList = { + /** + * Total number of policies in the given project. + */ + total: number; + /** + * List of policies. + */ + policies: (Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy)[]; + } + + /** + * Email Templates List + */ + export type EmailTemplateList = { + /** + * Total number of templates that matched your query. + */ + total: number; + /** + * List of templates. + */ + templates: EmailTemplate[]; + } + /** * Status List */ @@ -451,6 +509,20 @@ export namespace Models { statuses: HealthStatus[]; } + /** + * Rule List + */ + export type ProxyRuleList = { + /** + * Total number of rules that matched your query. + */ + total: number; + /** + * List of rules. + */ + rules: ProxyRule[]; + } + /** * Locale codes list */ @@ -640,7 +712,7 @@ export namespace Models { /** * Collection attributes. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; /** * Collection indexes. */ @@ -666,7 +738,7 @@ export namespace Models { /** * List of attributes. */ - attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; } /** @@ -769,6 +841,56 @@ export namespace Models { default?: number; } + /** + * AttributeBigInt + */ + export type AttributeBigint = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number | bigint; + /** + * Maximum value to enforce for new documents. + */ + max?: number | bigint; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: number | bigint; + } + /** * AttributeFloat */ @@ -1510,7 +1632,7 @@ export namespace Models { /** * Table columns. */ - columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; /** * Table indexes. */ @@ -1536,7 +1658,7 @@ export namespace Models { /** * List of columns. */ - columns: (Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; } /** @@ -1639,6 +1761,56 @@ export namespace Models { default?: number; } + /** + * ColumnBigInt + */ + export type ColumnBigint = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number | bigint; + /** + * Maximum value to enforce for new documents. + */ + max?: number | bigint; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: number | bigint; + } + /** * ColumnFloat */ @@ -2511,6 +2683,57 @@ export namespace Models { [__default]: true; }; + /** + * Presence + */ + export type Presence = { + /** + * Presence ID. + */ + $id: string; + /** + * Presence sequence ID. + */ + $sequence: string; + /** + * Presence creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Presence update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * User internal ID. + */ + userInternalId: string; + /** + * User ID. + */ + userId: string; + /** + * Presence status. + */ + status?: string; + /** + * Presence source. + */ + source: string; + /** + * Presence expiry date in ISO 8601 format. + */ + expiresAt?: string; + } + + export type DefaultPresence = Presence & { + [key: string]: any; + [__default]: true; + }; + /** * Log */ @@ -3284,6 +3507,10 @@ export namespace Models { * User email address. Hide this attribute by toggling membership privacy in the Console. */ userEmail: string; + /** + * User phone number. Hide this attribute by toggling membership privacy in the Console. + */ + userPhone: string; /** * Team ID. */ @@ -3972,6 +4199,14 @@ export namespace Models { * Whether or not to show user MFA status in the teams membership response. */ authMembershipsMfa: boolean; + /** + * Whether or not to show user IDs in the teams membership response. + */ + authMembershipsUserId: boolean; + /** + * Whether or not to show user phone numbers in the teams membership response. + */ + authMembershipsUserPhone: boolean; /** * Whether or not all existing sessions should be invalidated on password change */ @@ -4008,10 +4243,14 @@ export namespace Models { * SMTP sender email */ smtpSenderEmail: string; + /** + * SMTP reply to name + */ + smtpReplyToName: string; /** * SMTP reply to email */ - smtpReplyTo: string; + smtpReplyToEmail: string; /** * SMTP server host name */ @@ -4025,7 +4264,7 @@ export namespace Models { */ smtpUsername: string; /** - * SMTP server password + * SMTP server password. This property is write-only and always returned empty. */ smtpPassword: string; /** @@ -4275,9 +4514,9 @@ export namespace Models { } /** - * DevKey + * Ephemeral Key */ - export type DevKey = { + export type EphemeralKey = { /** * Key ID. */ @@ -4298,6 +4537,10 @@ export namespace Models { * Key expiration date in ISO 8601 format. */ expire: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; /** * Secret key. */ @@ -4313,77 +4556,1219 @@ export namespace Models { } /** - * Mock Number + * DevKey */ - export type MockNumber = { + export type DevKey = { /** - * Mock phone number for testing phone authentication. Useful for testing phone authentication without sending an SMS. + * Key ID. */ - phone: string; + $id: string; /** - * Mock OTP for the number. + * Key creation date in ISO 8601 format. */ - otp: string; - } - - /** - * AuthProvider - */ - export type AuthProvider = { + $createdAt: string; /** - * Auth Provider. + * Key update date in ISO 8601 format. */ - key: string; + $updatedAt: string; /** - * Auth Provider name. + * Key name. */ name: string; /** - * OAuth 2.0 application ID. + * Key expiration date in ISO 8601 format. */ - appId: string; + expire: string; /** - * OAuth 2.0 application secret. Might be JSON string if provider requires extra configuration. + * Secret key. */ secret: string; /** - * Auth Provider is active and can be used to create session. + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ - enabled: boolean; + accessedAt: string; + /** + * List of SDK user agents that used this key. + */ + sdks: string[]; } /** - * Platform Web + * Mock Number */ - export type PlatformWeb = { + export type MockNumber = { /** - * Platform ID. + * Mock phone number for testing phone authentication. Useful for testing phone authentication without sending an SMS. */ - $id: string; + number: string; /** - * Platform creation date in ISO 8601 format. + * Mock OTP for the number. + */ + otp: string; + /** + * Attribute creation date in ISO 8601 format. */ $createdAt: string; /** - * Platform update date in ISO 8601 format. + * Attribute update date in ISO 8601 format. */ $updatedAt: string; + } + + /** + * OAuth2GitHub + */ + export type OAuth2Github = { /** - * Platform name. + * OAuth2 provider ID. */ - name: string; + $id: string; /** - * Platform type. Possible values are: windows, apple, android, linux, web. + * OAuth2 provider is active and can be used to create sessions. */ - type: PlatformType; + enabled: boolean; /** - * Web app hostname. Empty string for other platforms. + * GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App ID and client ID are available. */ - hostname: string; + clientId: string; + /** + * GitHub OAuth2 client secret. + */ + clientSecret: string; } /** - * Platform Apple + * OAuth2Discord + */ + export type OAuth2Discord = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Discord OAuth2 client ID. + */ + clientId: string; + /** + * Discord OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Figma + */ + export type OAuth2Figma = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Figma OAuth2 client ID. + */ + clientId: string; + /** + * Figma OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Dropbox + */ + export type OAuth2Dropbox = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Dropbox OAuth2 app key. + */ + appKey: string; + /** + * Dropbox OAuth2 app secret. + */ + appSecret: string; + } + + /** + * OAuth2Dailymotion + */ + export type OAuth2Dailymotion = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Dailymotion OAuth2 API key. + */ + apiKey: string; + /** + * Dailymotion OAuth2 API secret. + */ + apiSecret: string; + } + + /** + * OAuth2Bitbucket + */ + export type OAuth2Bitbucket = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Bitbucket OAuth2 key. + */ + key: string; + /** + * Bitbucket OAuth2 secret. + */ + secret: string; + } + + /** + * OAuth2Bitly + */ + export type OAuth2Bitly = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Bitly OAuth2 client ID. + */ + clientId: string; + /** + * Bitly OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Box + */ + export type OAuth2Box = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Box OAuth2 client ID. + */ + clientId: string; + /** + * Box OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Autodesk + */ + export type OAuth2Autodesk = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Autodesk OAuth2 client ID. + */ + clientId: string; + /** + * Autodesk OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Google + */ + export type OAuth2Google = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Google OAuth2 client ID. + */ + clientId: string; + /** + * Google OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Zoom + */ + export type OAuth2Zoom = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Zoom OAuth2 client ID. + */ + clientId: string; + /** + * Zoom OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Zoho + */ + export type OAuth2Zoho = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Zoho OAuth2 client ID. + */ + clientId: string; + /** + * Zoho OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Yandex + */ + export type OAuth2Yandex = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Yandex OAuth2 client ID. + */ + clientId: string; + /** + * Yandex OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2X + */ + export type OAuth2X = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * X OAuth2 customer key. + */ + customerKey: string; + /** + * X OAuth2 secret key. + */ + secretKey: string; + } + + /** + * OAuth2WordPress + */ + export type OAuth2WordPress = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * WordPress OAuth2 client ID. + */ + clientId: string; + /** + * WordPress OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Twitch + */ + export type OAuth2Twitch = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Twitch OAuth2 client ID. + */ + clientId: string; + /** + * Twitch OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Stripe + */ + export type OAuth2Stripe = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Stripe OAuth2 client ID. + */ + clientId: string; + /** + * Stripe OAuth2 API secret key. + */ + apiSecretKey: string; + } + + /** + * OAuth2Spotify + */ + export type OAuth2Spotify = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Spotify OAuth2 client ID. + */ + clientId: string; + /** + * Spotify OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Slack + */ + export type OAuth2Slack = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Slack OAuth2 client ID. + */ + clientId: string; + /** + * Slack OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Podio + */ + export type OAuth2Podio = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Podio OAuth2 client ID. + */ + clientId: string; + /** + * Podio OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Notion + */ + export type OAuth2Notion = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Notion OAuth2 client ID. + */ + oauthClientId: string; + /** + * Notion OAuth2 client secret. + */ + oauthClientSecret: string; + } + + /** + * OAuth2Salesforce + */ + export type OAuth2Salesforce = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Salesforce OAuth2 consumer key. + */ + customerKey: string; + /** + * Salesforce OAuth2 consumer secret. + */ + customerSecret: string; + } + + /** + * OAuth2Yahoo + */ + export type OAuth2Yahoo = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Yahoo OAuth2 client ID. + */ + clientId: string; + /** + * Yahoo OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Linkedin + */ + export type OAuth2Linkedin = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * LinkedIn OAuth2 client ID. + */ + clientId: string; + /** + * LinkedIn OAuth2 primary client secret. + */ + primaryClientSecret: string; + } + + /** + * OAuth2Disqus + */ + export type OAuth2Disqus = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Disqus OAuth2 public key. + */ + publicKey: string; + /** + * Disqus OAuth2 secret key. + */ + secretKey: string; + } + + /** + * OAuth2Amazon + */ + export type OAuth2Amazon = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Amazon OAuth2 client ID. + */ + clientId: string; + /** + * Amazon OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Etsy + */ + export type OAuth2Etsy = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Etsy OAuth2 keystring. + */ + keyString: string; + /** + * Etsy OAuth2 shared secret. + */ + sharedSecret: string; + } + + /** + * OAuth2Facebook + */ + export type OAuth2Facebook = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Facebook OAuth2 app ID. + */ + appId: string; + /** + * Facebook OAuth2 app secret. + */ + appSecret: string; + } + + /** + * OAuth2Tradeshift + */ + export type OAuth2Tradeshift = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Tradeshift OAuth2 client ID. + */ + oauth2ClientId: string; + /** + * Tradeshift OAuth2 client secret. + */ + oauth2ClientSecret: string; + } + + /** + * OAuth2Paypal + */ + export type OAuth2Paypal = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * PayPal OAuth2 client ID. + */ + clientId: string; + /** + * PayPal OAuth2 secret key. + */ + secretKey: string; + } + + /** + * OAuth2Gitlab + */ + export type OAuth2Gitlab = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * GitLab OAuth2 application ID. + */ + applicationId: string; + /** + * GitLab OAuth2 secret. + */ + secret: string; + /** + * GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted instances. + */ + endpoint: string; + } + + /** + * OAuth2Authentik + */ + export type OAuth2Authentik = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Authentik OAuth2 client ID. + */ + clientId: string; + /** + * Authentik OAuth2 client secret. + */ + clientSecret: string; + /** + * Authentik OAuth2 endpoint domain. + */ + endpoint: string; + } + + /** + * OAuth2Auth0 + */ + export type OAuth2Auth0 = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Auth0 OAuth2 client ID. + */ + clientId: string; + /** + * Auth0 OAuth2 client secret. + */ + clientSecret: string; + /** + * Auth0 OAuth2 endpoint domain. + */ + endpoint: string; + } + + /** + * OAuth2FusionAuth + */ + export type OAuth2FusionAuth = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * FusionAuth OAuth2 client ID. + */ + clientId: string; + /** + * FusionAuth OAuth2 client secret. + */ + clientSecret: string; + /** + * FusionAuth OAuth2 endpoint domain. + */ + endpoint: string; + } + + /** + * OAuth2Keycloak + */ + export type OAuth2Keycloak = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Keycloak OAuth2 client ID. + */ + clientId: string; + /** + * Keycloak OAuth2 client secret. + */ + clientSecret: string; + /** + * Keycloak OAuth2 endpoint domain. + */ + endpoint: string; + /** + * Keycloak OAuth2 realm name. + */ + realmName: string; + } + + /** + * OAuth2Oidc + */ + export type OAuth2Oidc = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * OpenID Connect OAuth2 client ID. + */ + clientId: string; + /** + * OpenID Connect OAuth2 client secret. + */ + clientSecret: string; + /** + * OpenID Connect well-known configuration URL. When set, authorization, token, and user info endpoints can be discovered automatically. + */ + wellKnownURL: string; + /** + * OpenID Connect authorization endpoint URL. + */ + authorizationURL: string; + /** + * OpenID Connect token endpoint URL. + */ + tokenURL: string; + /** + * OpenID Connect user info endpoint URL. + */ + userInfoURL: string; + } + + /** + * OAuth2Okta + */ + export type OAuth2Okta = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Okta OAuth2 client ID. + */ + clientId: string; + /** + * Okta OAuth2 client secret. + */ + clientSecret: string; + /** + * Okta OAuth2 domain. + */ + domain: string; + /** + * Okta OAuth2 authorization server ID. + */ + authorizationServerId: string; + } + + /** + * OAuth2Kick + */ + export type OAuth2Kick = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Kick OAuth2 client ID. + */ + clientId: string; + /** + * Kick OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Apple + */ + export type OAuth2Apple = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Apple OAuth2 service ID. + */ + serviceId: string; + /** + * Apple OAuth2 key ID. + */ + keyId: string; + /** + * Apple OAuth2 team ID. + */ + teamId: string; + /** + * Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. + */ + p8File: string; + } + + /** + * OAuth2Microsoft + */ + export type OAuth2Microsoft = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Microsoft OAuth2 application ID. + */ + applicationId: string; + /** + * Microsoft OAuth2 application secret. + */ + applicationSecret: string; + /** + * Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. + */ + tenant: string; + } + + /** + * OAuth2 Providers List + */ + export type OAuth2ProviderList = { + /** + * Total number of OAuth2 providers in the given project. + */ + total: number; + /** + * List of OAuth2 providers. + */ + providers: (Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft)[]; + } + + /** + * Policy Password Dictionary + */ + export type PolicyPasswordDictionary = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether password dictionary policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Password History + */ + export type PolicyPasswordHistory = { + /** + * Policy ID. + */ + $id: string; + /** + * Password history length. A value of 0 means the policy is disabled. + */ + total: number; + } + + /** + * Policy Password Personal Data + */ + export type PolicyPasswordPersonalData = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether password personal data policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Session Alert + */ + export type PolicySessionAlert = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether session alert policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Session Duration + */ + export type PolicySessionDuration = { + /** + * Policy ID. + */ + $id: string; + /** + * Session duration in seconds. + */ + duration: number; + } + + /** + * Policy Session Invalidation + */ + export type PolicySessionInvalidation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether session invalidation policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Session Limit + */ + export type PolicySessionLimit = { + /** + * Policy ID. + */ + $id: string; + /** + * Maximum number of sessions allowed per user. A value of 0 means the policy is disabled. + */ + total: number; + } + + /** + * Policy User Limit + */ + export type PolicyUserLimit = { + /** + * Policy ID. + */ + $id: string; + /** + * Maximum number of users allowed in the project. A value of 0 means the policy is disabled. + */ + total: number; + } + + /** + * Policy Membership Privacy + */ + export type PolicyMembershipPrivacy = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether user ID is visible in memberships. + */ + userId: boolean; + /** + * Whether user email is visible in memberships. + */ + userEmail: boolean; + /** + * Whether user phone is visible in memberships. + */ + userPhone: boolean; + /** + * Whether user name is visible in memberships. + */ + userName: boolean; + /** + * Whether user MFA status is visible in memberships. + */ + userMFA: boolean; + } + + /** + * AuthProvider + */ + export type AuthProvider = { + /** + * Auth Provider. + */ + key: string; + /** + * Auth Provider name. + */ + name: string; + /** + * OAuth 2.0 application ID. + */ + appId: string; + /** + * OAuth 2.0 application secret. Might be JSON string if provider requires extra configuration. This property is write-only and always returned empty. + */ + secret: string; + /** + * Auth Provider is active and can be used to create session. + */ + enabled: boolean; + } + + /** + * Platform Web + */ + export type PlatformWeb = { + /** + * Platform ID. + */ + $id: string; + /** + * Platform creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Platform update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Platform name. + */ + name: string; + /** + * Platform type. Possible values are: windows, apple, android, linux, web. + */ + type: PlatformType; + /** + * Web app hostname. Empty string for other platforms. + */ + hostname: string; + } + + /** + * Platform Apple */ export type PlatformApple = { /** @@ -4778,6 +6163,110 @@ export namespace Models { slug: string; } + /** + * Rule + */ + export type ProxyRule = { + /** + * Rule ID. + */ + $id: string; + /** + * Rule creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Rule update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Domain name. + */ + domain: string; + /** + * Action definition for the rule. Possible values are "api", "deployment", or "redirect" + */ + type: string; + /** + * Defines how the rule was created. Possible values are "manual" or "deployment" + */ + trigger: string; + /** + * URL to redirect to. Used if type is "redirect" + */ + redirectUrl: string; + /** + * Status code to apply during redirect. Used if type is "redirect" + */ + redirectStatusCode: number; + /** + * ID of deployment. Used if type is "deployment" + */ + deploymentId: string; + /** + * Type of deployment. Possible values are "function", "site". Used if rule's type is "deployment". + */ + deploymentResourceType?: ProxyRuleDeploymentResourceType; + /** + * ID of deployment's resource (site or function ID). Used if type is "deployment" + */ + deploymentResourceId: string; + /** + * Name of Git branch that updates rule. Used if type is "deployment" + */ + deploymentVcsProviderBranch: string; + /** + * Domain verification status. Possible values are "unverified", "verifying", "verified" + */ + status: ProxyRuleStatus; + /** + * Logs from rule verification or certificate generation. Certificate generation logs are prioritized if both are available. + */ + logs: string; + /** + * Certificate auto-renewal date in ISO 8601 format. + */ + renewAt: string; + } + + /** + * EmailTemplate + */ + export type EmailTemplate = { + /** + * Template type + */ + templateId: string; + /** + * Template locale + */ + locale: string; + /** + * Template message + */ + message: string; + /** + * Name of the sender + */ + senderName: string; + /** + * Email of the sender + */ + senderEmail: string; + /** + * Reply to email address + */ + replyToEmail: string; + /** + * Reply to name + */ + replyToName: string; + /** + * Email subject + */ + subject: string; + } + /** * MFA Challenge */ @@ -5257,7 +6746,7 @@ export namespace Models { */ size: number; /** - * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. + * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ status: string; /** @@ -5348,6 +6837,26 @@ export namespace Models { * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ expiredAt?: string; + /** + * Name of the project this block applies to. + */ + projectName: string; + /** + * Region of the project this block applies to. + */ + region: string; + /** + * Name of the organization that owns the project. + */ + organizationName: string; + /** + * ID of the organization that owns the project. + */ + organizationId: string; + /** + * Billing plan of the organization that owns the project. + */ + billingPlan: string; } /** diff --git a/src/services/account.ts b/src/services/account.ts index 07b94599..c98e454b 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; @@ -2338,7 +2339,7 @@ export class Account { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} params.provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -2353,7 +2354,7 @@ export class Account { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + * @param {OAuthProvider} provider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. diff --git a/src/services/activities.ts b/src/services/activities.ts index 23071821..64e79410 100644 --- a/src/services/activities.ts +++ b/src/services/activities.ts @@ -2,6 +2,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; + export class Activities { client: Client; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 5090ba03..37ed3bd3 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; import { Flag } from '../enums/flag'; diff --git a/src/services/backups.ts b/src/services/backups.ts index 32774270..ef8dbc03 100644 --- a/src/services/backups.ts +++ b/src/services/backups.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { BackupServices } from '../enums/backup-services'; export class Backups { diff --git a/src/services/databases.ts b/src/services/databases.ts index 54fb8bdc..9a2e744c 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { DatabasesIndexType } from '../enums/databases-index-type'; @@ -1136,6 +1137,228 @@ export class Databases { ); } + /** + * Create a bigint attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBigIntColumn` instead. + */ + createBigIntAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + /** + * Create a bigint attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBigIntAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; + createBigIntAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + ): Promise { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a bigint attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. + */ + updateBigIntAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + /** + * Update a bigint attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBigIntAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; + updateBigIntAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + ): Promise { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + /** * Create a boolean attribute. * diff --git a/src/services/functions.ts b/src/services/functions.ts index 743acc04..75835a0b 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,6 +1,8 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { InputFile } from '../inputFile'; + import { Runtime } from '../enums/runtime'; import { Scopes } from '../enums/scopes'; import { TemplateReferenceType } from '../enums/template-reference-type'; @@ -758,14 +760,14 @@ export class Functions { * Use the "command" param to set the entrypoint used to execute your code. * * @param {string} params.functionId - Function ID. - * @param {File} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {File | InputFile} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. * @param {string} params.entrypoint - Entrypoint File. * @param {string} params.commands - Build Commands. * @throws {AppwriteException} * @returns {Promise} */ - createDeployment(params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void }): Promise; + createDeployment(params: { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void }): Promise; /** * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. * @@ -774,7 +776,7 @@ export class Functions { * Use the "command" param to set the entrypoint used to execute your code. * * @param {string} functionId - Function ID. - * @param {File} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {File | InputFile} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. * @param {boolean} activate - Automatically activate the deployment when it is finished building. * @param {string} entrypoint - Entrypoint File. * @param {string} commands - Build Commands. @@ -782,21 +784,21 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise; + createDeployment(functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise; createDeployment( - paramsOrFirst: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(File)?, (boolean)?, (string)?, (string)?,((progress: UploadProgress) => void)?] + paramsOrFirst: { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(File | InputFile)?, (boolean)?, (string)?, (string)?,((progress: UploadProgress) => void)?] ): Promise { - let params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; + let params: { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string }; let onProgress: ((progress: UploadProgress) => void); if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; + params = (paramsOrFirst || {}) as { functionId: string, code: File | InputFile, activate: boolean, entrypoint?: string, commands?: string }; onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); } else { params = { functionId: paramsOrFirst as string, - code: rest[0] as File, + code: rest[0] as File | InputFile, activate: rest[1] as boolean, entrypoint: rest[2] as string, commands: rest[3] as string @@ -1647,33 +1649,42 @@ export class Functions { * Get a list of all variables of a specific function. * * @param {string} params.functionId - Function unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params: { functionId: string }): Promise; + listVariables(params: { functionId: string, queries?: string[], total?: boolean }): Promise; /** * Get a list of all variables of a specific function. * * @param {string} functionId - Function unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @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. */ - listVariables(functionId: string): Promise; + listVariables(functionId: string, queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst: { functionId: string } | string + paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] ): Promise { - let params: { functionId: string }; + let params: { functionId: string, queries?: string[], total?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string }; + params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], total?: boolean }; } else { params = { - functionId: paramsOrFirst as string + functionId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean }; } const functionId = params.functionId; + const queries = params.queries; + const total = params.total; if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); @@ -1681,6 +1692,12 @@ export class Functions { const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); 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 } = { @@ -1698,17 +1715,19 @@ export class Functions { * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable 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.key - Variable key. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { functionId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise; /** * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable 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} key - Variable key. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. @@ -1716,25 +1735,27 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(functionId: string, key: string, value: string, secret?: boolean): Promise; + createVariable(functionId: string, variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { functionId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + paramsOrFirst: { functionId: string, variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] ): Promise { - let params: { functionId: string, key: string, value: string, secret?: boolean }; + let params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, key: string, value: string, secret?: boolean }; + params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; } else { params = { functionId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean }; } const functionId = params.functionId; + const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; @@ -1742,6 +1763,9 @@ export class Functions { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } @@ -1751,6 +1775,9 @@ export class Functions { const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; + } if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1844,7 +1871,7 @@ export class Functions { * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { functionId: string, variableId: string, key: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise; /** * Update variable by its unique ID. * @@ -1857,15 +1884,15 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(functionId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise; + updateVariable(functionId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { functionId: string, variableId: string, key: string, value?: string, secret?: boolean } | string, + paramsOrFirst: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, ...rest: [(string)?, (string)?, (string)?, (boolean)?] ): Promise { - let params: { functionId: string, variableId: string, key: string, value?: string, secret?: boolean }; + let params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key: string, value?: string, secret?: boolean }; + params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; } else { params = { functionId: paramsOrFirst as string, @@ -1888,9 +1915,6 @@ export class Functions { if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); const payload: Payload = {}; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index b5f9ffcf..fc553978 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -2,6 +2,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; + export class Graphql { client: Client; diff --git a/src/services/health.ts b/src/services/health.ts index 713f33ba..1bd2cf03 100644 --- a/src/services/health.ts +++ b/src/services/health.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { Name } from '../enums/name'; export class Health { diff --git a/src/services/locale.ts b/src/services/locale.ts index e6b40879..865a085f 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -2,6 +2,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; + export class Locale { client: Client; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 16dd8998..1b8ac968 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { MessagePriority } from '../enums/message-priority'; import { SmtpEncryption } from '../enums/smtp-encryption'; diff --git a/src/services/presences.ts b/src/services/presences.ts new file mode 100644 index 00000000..36a98567 --- /dev/null +++ b/src/services/presences.ts @@ -0,0 +1,373 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + + +export class Presences { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List presence logs. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + */ + list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise>; + /** + * List presence logs. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], total?: boolean, ttl?: number): Promise>; + list( + paramsOrFirst?: { queries?: string[], total?: boolean, ttl?: number } | string[], + ...rest: [(boolean)?, (number)?] + ): Promise> { + let params: { queries?: string[], total?: boolean, ttl?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean, ttl?: number }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean, + ttl: rest[1] as number + }; + } + + const queries = params.queries; + const total = params.total; + const ttl = params.ttl; + + + const apiPath = '/presences'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a presence log by its unique ID. + * + * @param {string} params.presenceId - Presence unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { presenceId: string }): Promise; + /** + * Get a presence log by its unique ID. + * + * @param {string} presenceId - Presence unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(presenceId: string): Promise; + get( + paramsOrFirst: { presenceId: string } | string + ): Promise { + let params: { presenceId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { presenceId: string }; + } else { + params = { + presenceId: paramsOrFirst as string + }; + } + + const presenceId = params.presenceId; + + if (typeof presenceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + + const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create or update a presence log by its unique ID. + * + * @param {string} params.presenceId - Presence unique ID. + * @param {string} params.userId - User ID. + * @param {string} params.status - Presence status. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.expiresAt - Presence expiry datetime. + * @param {object} params.metadata - Presence metadata object. + * @throws {AppwriteException} + * @returns {Promise} + */ + upsert(params: { presenceId: string, userId?: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; + /** + * Create or update a presence log by its unique ID. + * + * @param {string} presenceId - Presence unique ID. + * @param {string} userId - User ID. + * @param {string} status - Presence status. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} expiresAt - Presence expiry datetime. + * @param {object} metadata - Presence metadata object. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsert(presenceId: string, userId?: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise; + upsert( + paramsOrFirst: { presenceId: string, userId?: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, + ...rest: [(string)?, (string)?, (string[])?, (string)?, (object)?] + ): Promise { + let params: { presenceId: string, userId?: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { presenceId: string, userId?: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + } else { + params = { + presenceId: paramsOrFirst as string, + userId: rest[0] as string, + status: rest[1] as string, + permissions: rest[2] as string[], + expiresAt: rest[3] as string, + metadata: rest[4] as object + }; + } + + const presenceId = params.presenceId; + const userId = params.userId; + const status = params.status; + const permissions = params.permissions; + const expiresAt = params.expiresAt; + const metadata = params.metadata; + + if (typeof presenceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof status === 'undefined') { + throw new AppwriteException('Missing required parameter: "status"'); + } + + const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof expiresAt !== 'undefined') { + payload['expiresAt'] = expiresAt; + } + if (typeof metadata !== 'undefined') { + payload['metadata'] = metadata; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a presence log by its unique ID. + * + * @param {string} params.presenceId - Presence unique ID. + * @param {string} params.userId - User ID. + * @param {string} params.status - Presence status. + * @param {string} params.expiresAt - Presence expiry datetime. + * @param {object} params.metadata - Presence metadata object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.purge - When true, purge cached responses used by list presences endpoint. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePresence(params: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; + /** + * Update a presence log by its unique ID. + * + * @param {string} presenceId - Presence unique ID. + * @param {string} userId - User ID. + * @param {string} status - Presence status. + * @param {string} expiresAt - Presence expiry datetime. + * @param {object} metadata - Presence metadata object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} purge - When true, purge cached responses used by list presences endpoint. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePresence(presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise; + updatePresence( + paramsOrFirst: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (object)?, (string[])?, (boolean)?] + ): Promise { + let params: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + } else { + params = { + presenceId: paramsOrFirst as string, + userId: rest[0] as string, + status: rest[1] as string, + expiresAt: rest[2] as string, + metadata: rest[3] as object, + permissions: rest[4] as string[], + purge: rest[5] as boolean + }; + } + + const presenceId = params.presenceId; + const userId = params.userId; + const status = params.status; + const expiresAt = params.expiresAt; + const metadata = params.metadata; + const permissions = params.permissions; + const purge = params.purge; + + if (typeof presenceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof expiresAt !== 'undefined') { + payload['expiresAt'] = expiresAt; + } + if (typeof metadata !== 'undefined') { + payload['metadata'] = metadata; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof purge !== 'undefined') { + payload['purge'] = purge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a presence log by its unique ID. + * + * @param {string} params.presenceId - Presence unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { presenceId: string }): Promise<{}>; + /** + * Delete a presence log by its unique ID. + * + * @param {string} presenceId - Presence unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(presenceId: string): Promise<{}>; + delete( + paramsOrFirst: { presenceId: string } | string + ): Promise<{}> { + let params: { presenceId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { presenceId: string }; + } else { + params = { + presenceId: paramsOrFirst as string + }; + } + + const presenceId = params.presenceId; + + if (typeof presenceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + + const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/project.ts b/src/services/project.ts index f2829b93..187567dc 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -1,9 +1,16 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + +import { MethodId } from '../enums/method-id'; import { Scopes } from '../enums/scopes'; +import { ProviderId } from '../enums/provider-id'; +import { PolicyId } from '../enums/policy-id'; import { ProtocolId } from '../enums/protocol-id'; import { ServiceId } from '../enums/service-id'; +import { Secure } from '../enums/secure'; +import { EmailTemplateType } from '../enums/email-template-type'; +import { EmailTemplateLocale } from '../enums/email-template-locale'; export class Project { client: Client; @@ -12,6 +19,93 @@ export class Project { this.client = client; } + /** + * Delete a project. + * + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(): Promise<{}> { + + const apiPath = '/project'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * + * @param {MethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + * @param {boolean} params.enabled - Auth method status. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAuthMethod(params: { methodId: MethodId, enabled: boolean }): Promise; + /** + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * + * @param {MethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + * @param {boolean} enabled - Auth method status. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAuthMethod(methodId: MethodId, enabled: boolean): Promise; + updateAuthMethod( + paramsOrFirst: { methodId: MethodId, enabled: boolean } | MethodId, + ...rest: [(boolean)?] + ): Promise { + let params: { methodId: MethodId, enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { methodId: MethodId, enabled: boolean }; + } else { + params = { + methodId: paramsOrFirst as MethodId, + enabled: rest[0] as boolean + }; + } + + const methodId = params.methodId; + const enabled = params.enabled; + + if (typeof methodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "methodId"'); + } + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/auth-methods/{methodId}'.replace('{methodId}', methodId); + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + /** * Get a list of all API keys from the current project. * @@ -73,6 +167,8 @@ export class Project { /** * Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create an ephemeral API key if you need a short-lived key instead. * * @param {string} params.keyId - Key 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 - Key name. Max length: 128 chars. @@ -84,6 +180,8 @@ export class Project { createKey(params: { keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; /** * Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create an ephemeral API key if you need a short-lived key instead. * * @param {string} keyId - Key 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 - Key name. Max length: 128 chars. @@ -154,6 +252,76 @@ export class Project { ); } + /** + * Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {number} params.duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + createEphemeralKey(params: { scopes: Scopes[], duration: number }): Promise; + /** + * Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {number} duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEphemeralKey(scopes: Scopes[], duration: number): Promise; + createEphemeralKey( + paramsOrFirst: { scopes: Scopes[], duration: number } | Scopes[], + ...rest: [(number)?] + ): Promise { + let params: { scopes: Scopes[], duration: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { scopes: Scopes[], duration: number }; + } else { + params = { + scopes: paramsOrFirst as Scopes[], + duration: rest[0] as number + }; + } + + const scopes = params.scopes; + const duration = params.duration; + + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + if (typeof duration === 'undefined') { + throw new AppwriteException('Missing required parameter: "duration"'); + } + + const apiPath = '/project/keys/ephemeral'; + const payload: Payload = {}; + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + /** * Get a key by its unique ID. * @@ -393,28 +561,28 @@ export class Project { } /** - * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + * Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - listPlatforms(params?: { queries?: string[], total?: boolean }): Promise; + listMockPhones(params?: { queries?: string[], total?: boolean }): Promise; /** - * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + * Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listPlatforms(queries?: string[], total?: boolean): Promise; - listPlatforms( + listMockPhones(queries?: string[], total?: boolean): Promise; + listMockPhones( paramsOrFirst?: { queries?: string[], total?: boolean } | string[], ...rest: [(boolean)?] - ): Promise { + ): Promise { let params: { queries?: string[], total?: boolean }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -430,7 +598,7 @@ export class Project { const total = params.total; - const apiPath = '/project/platforms'; + const apiPath = '/project/mock-phones'; const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -452,66 +620,56 @@ export class Project { } /** - * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + * Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. * - * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string} params.number - Phone number to associate with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} params.otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - createAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + createMockPhone(params: { number: string, otp: string }): Promise; /** - * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + * Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. * - * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string} number - Phone number to associate with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; - createAndroidPlatform( - paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, applicationId: string }; + createMockPhone(number: string, otp: string): Promise; + createMockPhone( + paramsOrFirst: { number: string, otp: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { number: string, otp: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + params = (paramsOrFirst || {}) as { number: string, otp: string }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - applicationId: rest[1] as string + number: paramsOrFirst as string, + otp: rest[0] as string }; } - const platformId = params.platformId; - const name = params.name; - const applicationId = params.applicationId; + const number = params.number; + const otp = params.otp; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); } - if (typeof applicationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "applicationId"'); + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/project/platforms/android'; + const apiPath = '/project/mock-phones'; const payload: Payload = {}; - if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; + if (typeof number !== 'undefined') { + payload['number'] = number; } - if (typeof applicationId !== 'undefined') { - payload['applicationId'] = applicationId; + if (typeof otp !== 'undefined') { + payload['otp'] = otp; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -528,72 +686,50 @@ export class Project { } /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Get a mock phone by its unique number. This endpoint returns the mock phone's OTP. * - * @param {string} params.platformId - Platform ID. - * @param {string} params.name - Platform name. Max length: 128 chars. - * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @param {string} params.number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + getMockPhone(params: { number: string }): Promise; /** - * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * Get a mock phone by its unique number. This endpoint returns the mock phone's OTP. * - * @param {string} platformId - Platform ID. - * @param {string} name - Platform name. Max length: 128 chars. - * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @param {string} number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; - updateAndroidPlatform( - paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, applicationId: string }; + getMockPhone(number: string): Promise; + getMockPhone( + paramsOrFirst: { number: string } | string + ): Promise { + let params: { number: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + params = (paramsOrFirst || {}) as { number: string }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - applicationId: rest[1] as string + number: paramsOrFirst as string }; } - const platformId = params.platformId; - const name = params.name; - const applicationId = params.applicationId; + const number = params.number; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof applicationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "applicationId"'); + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); } - const apiPath = '/project/platforms/android/{platformId}'.replace('{platformId}', platformId); + const apiPath = '/project/mock-phones/{number}'.replace('{number}', number); const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof applicationId !== 'undefined') { - payload['applicationId'] = applicationId; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'put', + 'get', uri, apiHeaders, payload, @@ -601,66 +737,53 @@ export class Project { } /** - * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + * Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. * - * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} params.bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @param {string} params.number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} params.otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - createApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + updateMockPhone(params: { number: string, otp: string }): Promise; /** - * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + * Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. * - * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @param {string} number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; - createApplePlatform( - paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, bundleIdentifier: string }; + updateMockPhone(number: string, otp: string): Promise; + updateMockPhone( + paramsOrFirst: { number: string, otp: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { number: string, otp: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + params = (paramsOrFirst || {}) as { number: string, otp: string }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - bundleIdentifier: rest[1] as string + number: paramsOrFirst as string, + otp: rest[0] as string }; } - const platformId = params.platformId; - const name = params.name; - const bundleIdentifier = params.bundleIdentifier; + const number = params.number; + const otp = params.otp; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof bundleIdentifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); } - const apiPath = '/project/platforms/apple'; + const apiPath = '/project/mock-phones/{number}'.replace('{number}', number); const payload: Payload = {}; - if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof bundleIdentifier !== 'undefined') { - payload['bundleIdentifier'] = bundleIdentifier; + if (typeof otp !== 'undefined') { + payload['otp'] = otp; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -669,7 +792,7 @@ export class Project { } return this.client.call( - 'post', + 'put', uri, apiHeaders, payload, @@ -677,63 +800,4400 @@ export class Project { } /** - * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + * Delete a mock phone by its unique number. This endpoint removes the mock phone and its OTP configuration from the project. * - * @param {string} params.platformId - Platform ID. - * @param {string} params.name - Platform name. Max length: 128 chars. - * @param {string} params.bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @param {string} params.number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise<{}>} */ - updateApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + deleteMockPhone(params: { number: string }): Promise<{}>; /** - * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + * Delete a mock phone by its unique number. This endpoint removes the mock phone and its OTP configuration from the project. * - * @param {string} platformId - Platform ID. - * @param {string} name - Platform name. Max length: 128 chars. - * @param {string} bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @param {string} number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMockPhone(number: string): Promise<{}>; + deleteMockPhone( + paramsOrFirst: { number: string } | string + ): Promise<{}> { + let params: { number: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { number: string }; + } else { + params = { + number: paramsOrFirst as string + }; + } + + const number = params.number; + + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); + } + + const apiPath = '/project/mock-phones/{number}'.replace('{number}', number); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listOAuth2Providers(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @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. + */ + listOAuth2Providers(queries?: string[], total?: boolean): Promise; + listOAuth2Providers( + 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 = '/project/oauth2'; + 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 } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. + * + * @param {ProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. + * @throws {AppwriteException} + * @returns {Promise} + */ + getOAuth2Provider(params: { providerId: ProviderId }): Promise; + /** + * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. + * + * @param {ProviderId} providerId - OAuth2 provider key. For example: github, google, apple. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getOAuth2Provider(providerId: ProviderId): Promise; + getOAuth2Provider( + paramsOrFirst: { providerId: ProviderId } | ProviderId + ): Promise { + let params: { providerId: ProviderId }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('providerId' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: ProviderId }; + } else { + params = { + providerId: paramsOrFirst as ProviderId + }; + } + + const providerId = params.providerId; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/project/oauth2/:provider'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Amazon configuration. + * + * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Amazon(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Amazon configuration. + * + * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Amazon(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Amazon( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/amazon'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Apple configuration. + * + * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Apple(params?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Apple configuration. + * + * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Apple(serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean): Promise; + updateOAuth2Apple( + paramsOrFirst?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise { + let params: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; + } else { + params = { + serviceId: paramsOrFirst as string, + keyId: rest[0] as string, + teamId: rest[1] as string, + p8File: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const serviceId = params.serviceId; + const keyId = params.keyId; + const teamId = params.teamId; + const p8File = params.p8File; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/apple'; + const payload: Payload = {}; + if (typeof serviceId !== 'undefined') { + payload['serviceId'] = serviceId; + } + if (typeof keyId !== 'undefined') { + payload['keyId'] = keyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof p8File !== 'undefined') { + payload['p8File'] = p8File; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Auth0 configuration. + * + * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Auth0(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Auth0 configuration. + * + * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Auth0(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; + updateOAuth2Auth0( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/auth0'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Authentik configuration. + * + * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Authentik(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Authentik configuration. + * + * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Authentik(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; + updateOAuth2Authentik( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/authentik'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Autodesk configuration. + * + * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Autodesk(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Autodesk configuration. + * + * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Autodesk(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Autodesk( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/autodesk'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Bitbucket configuration. + * + * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Bitbucket(params?: { key?: string, secret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Bitbucket configuration. + * + * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Bitbucket(key?: string, secret?: string, enabled?: boolean): Promise; + updateOAuth2Bitbucket( + paramsOrFirst?: { key?: string, secret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { key?: string, secret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { key?: string, secret?: string, enabled?: boolean }; + } else { + params = { + key: paramsOrFirst as string, + secret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const key = params.key; + const secret = params.secret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/bitbucket'; + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Bitly configuration. + * + * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Bitly(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Bitly configuration. + * + * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Bitly(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Bitly( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/bitly'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Box configuration. + * + * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Box(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Box configuration. + * + * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Box(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Box( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/box'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Dailymotion configuration. + * + * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Dailymotion(params?: { apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Dailymotion configuration. + * + * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Dailymotion(apiKey?: string, apiSecret?: string, enabled?: boolean): Promise; + updateOAuth2Dailymotion( + paramsOrFirst?: { apiKey?: string, apiSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { apiKey?: string, apiSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { apiKey?: string, apiSecret?: string, enabled?: boolean }; + } else { + params = { + apiKey: paramsOrFirst as string, + apiSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const apiKey = params.apiKey; + const apiSecret = params.apiSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/dailymotion'; + const payload: Payload = {}; + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof apiSecret !== 'undefined') { + payload['apiSecret'] = apiSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Discord configuration. + * + * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Discord(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Discord configuration. + * + * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Discord(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Discord( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/discord'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Disqus configuration. + * + * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Disqus(params?: { publicKey?: string, secretKey?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Disqus configuration. + * + * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Disqus(publicKey?: string, secretKey?: string, enabled?: boolean): Promise; + updateOAuth2Disqus( + paramsOrFirst?: { publicKey?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { publicKey?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { publicKey?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + publicKey: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const publicKey = params.publicKey; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/disqus'; + const payload: Payload = {}; + if (typeof publicKey !== 'undefined') { + payload['publicKey'] = publicKey; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Dropbox configuration. + * + * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Dropbox(params?: { appKey?: string, appSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Dropbox configuration. + * + * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Dropbox(appKey?: string, appSecret?: string, enabled?: boolean): Promise; + updateOAuth2Dropbox( + paramsOrFirst?: { appKey?: string, appSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { appKey?: string, appSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appKey?: string, appSecret?: string, enabled?: boolean }; + } else { + params = { + appKey: paramsOrFirst as string, + appSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const appKey = params.appKey; + const appSecret = params.appSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/dropbox'; + const payload: Payload = {}; + if (typeof appKey !== 'undefined') { + payload['appKey'] = appKey; + } + if (typeof appSecret !== 'undefined') { + payload['appSecret'] = appSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Etsy configuration. + * + * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Etsy(params?: { keyString?: string, sharedSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Etsy configuration. + * + * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Etsy(keyString?: string, sharedSecret?: string, enabled?: boolean): Promise; + updateOAuth2Etsy( + paramsOrFirst?: { keyString?: string, sharedSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { keyString?: string, sharedSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyString?: string, sharedSecret?: string, enabled?: boolean }; + } else { + params = { + keyString: paramsOrFirst as string, + sharedSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const keyString = params.keyString; + const sharedSecret = params.sharedSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/etsy'; + const payload: Payload = {}; + if (typeof keyString !== 'undefined') { + payload['keyString'] = keyString; + } + if (typeof sharedSecret !== 'undefined') { + payload['sharedSecret'] = sharedSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Facebook configuration. + * + * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Facebook(params?: { appId?: string, appSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Facebook configuration. + * + * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Facebook(appId?: string, appSecret?: string, enabled?: boolean): Promise; + updateOAuth2Facebook( + paramsOrFirst?: { appId?: string, appSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { appId?: string, appSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId?: string, appSecret?: string, enabled?: boolean }; + } else { + params = { + appId: paramsOrFirst as string, + appSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const appId = params.appId; + const appSecret = params.appSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/facebook'; + const payload: Payload = {}; + if (typeof appId !== 'undefined') { + payload['appId'] = appId; + } + if (typeof appSecret !== 'undefined') { + payload['appSecret'] = appSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Figma configuration. + * + * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Figma(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Figma configuration. + * + * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Figma(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Figma( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/figma'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 FusionAuth configuration. + * + * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2FusionAuth(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 FusionAuth configuration. + * + * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2FusionAuth(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise; + updateOAuth2FusionAuth( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/fusionauth'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 GitHub configuration. + * + * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2GitHub(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 GitHub configuration. + * + * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2GitHub(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2GitHub( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/github'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Gitlab configuration. + * + * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Gitlab(params?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Gitlab configuration. + * + * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Gitlab(applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean): Promise; + updateOAuth2Gitlab( + paramsOrFirst?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + applicationId: paramsOrFirst as string, + secret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const applicationId = params.applicationId; + const secret = params.secret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/gitlab'; + const payload: Payload = {}; + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Google configuration. + * + * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: your-google-client-id.apps.googleusercontent.com + * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: your-google-client-secret + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Google(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Google configuration. + * + * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: your-google-client-id.apps.googleusercontent.com + * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: your-google-client-secret + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Google(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Google( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/google'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Keycloak configuration. + * + * @param {string} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Keycloak(params?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Keycloak configuration. + * + * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Keycloak(clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean): Promise; + updateOAuth2Keycloak( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + realmName: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const realmName = params.realmName; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/keycloak'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof realmName !== 'undefined') { + payload['realmName'] = realmName; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Kick configuration. + * + * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Kick(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Kick configuration. + * + * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Kick(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Kick( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/kick'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Linkedin configuration. + * + * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: your-linkedin-client-secret + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Linkedin(params?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Linkedin configuration. + * + * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: your-linkedin-client-secret + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Linkedin(clientId?: string, primaryClientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Linkedin( + paramsOrFirst?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + primaryClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const primaryClientSecret = params.primaryClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/linkedin'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof primaryClientSecret !== 'undefined') { + payload['primaryClientSecret'] = primaryClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Microsoft configuration. + * + * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Microsoft(params?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Microsoft configuration. + * + * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Microsoft(applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean): Promise; + updateOAuth2Microsoft( + paramsOrFirst?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise { + let params: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; + } else { + params = { + applicationId: paramsOrFirst as string, + applicationSecret: rest[0] as string, + tenant: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const applicationId = params.applicationId; + const applicationSecret = params.applicationSecret; + const tenant = params.tenant; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/microsoft'; + const payload: Payload = {}; + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + if (typeof applicationSecret !== 'undefined') { + payload['applicationSecret'] = applicationSecret; + } + if (typeof tenant !== 'undefined') { + payload['tenant'] = tenant; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Notion configuration. + * + * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Notion(params?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Notion configuration. + * + * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Notion(oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Notion( + paramsOrFirst?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; + } else { + params = { + oauthClientId: paramsOrFirst as string, + oauthClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const oauthClientId = params.oauthClientId; + const oauthClientSecret = params.oauthClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/notion'; + const payload: Payload = {}; + if (typeof oauthClientId !== 'undefined') { + payload['oauthClientId'] = oauthClientId; + } + if (typeof oauthClientSecret !== 'undefined') { + payload['oauthClientSecret'] = oauthClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Oidc configuration. + * + * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Oidc(params?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Oidc configuration. + * + * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Oidc(clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean): Promise; + updateOAuth2Oidc( + paramsOrFirst?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + wellKnownURL: rest[1] as string, + authorizationURL: rest[2] as string, + tokenURL: rest[3] as string, + userInfoURL: rest[4] as string, + enabled: rest[5] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const wellKnownURL = params.wellKnownURL; + const authorizationURL = params.authorizationURL; + const tokenURL = params.tokenURL; + const userInfoURL = params.userInfoURL; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/oidc'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof wellKnownURL !== 'undefined') { + payload['wellKnownURL'] = wellKnownURL; + } + if (typeof authorizationURL !== 'undefined') { + payload['authorizationURL'] = authorizationURL; + } + if (typeof tokenURL !== 'undefined') { + payload['tokenURL'] = tokenURL; + } + if (typeof userInfoURL !== 'undefined') { + payload['userInfoURL'] = userInfoURL; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Okta configuration. + * + * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Okta(params?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Okta configuration. + * + * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Okta(clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean): Promise; + updateOAuth2Okta( + paramsOrFirst?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + domain: rest[1] as string, + authorizationServerId: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const domain = params.domain; + const authorizationServerId = params.authorizationServerId; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/okta'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof authorizationServerId !== 'undefined') { + payload['authorizationServerId'] = authorizationServerId; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Paypal configuration. + * + * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Paypal(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Paypal configuration. + * + * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Paypal(clientId?: string, secretKey?: string, enabled?: boolean): Promise; + updateOAuth2Paypal( + paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/paypal'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 PaypalSandbox configuration. + * + * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2PaypalSandbox(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 PaypalSandbox configuration. + * + * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2PaypalSandbox(clientId?: string, secretKey?: string, enabled?: boolean): Promise; + updateOAuth2PaypalSandbox( + paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/paypalSandbox'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Podio configuration. + * + * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Podio(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Podio configuration. + * + * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Podio(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Podio( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/podio'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Salesforce configuration. + * + * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Salesforce(params?: { customerKey?: string, customerSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Salesforce configuration. + * + * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Salesforce(customerKey?: string, customerSecret?: string, enabled?: boolean): Promise; + updateOAuth2Salesforce( + paramsOrFirst?: { customerKey?: string, customerSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { customerKey?: string, customerSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { customerKey?: string, customerSecret?: string, enabled?: boolean }; + } else { + params = { + customerKey: paramsOrFirst as string, + customerSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const customerKey = params.customerKey; + const customerSecret = params.customerSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/salesforce'; + const payload: Payload = {}; + if (typeof customerKey !== 'undefined') { + payload['customerKey'] = customerKey; + } + if (typeof customerSecret !== 'undefined') { + payload['customerSecret'] = customerSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Slack configuration. + * + * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Slack(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Slack configuration. + * + * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Slack(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Slack( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/slack'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Spotify configuration. + * + * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Spotify(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Spotify configuration. + * + * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Spotify(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Spotify( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/spotify'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Stripe configuration. + * + * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Stripe(params?: { clientId?: string, apiSecretKey?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Stripe configuration. + * + * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Stripe(clientId?: string, apiSecretKey?: string, enabled?: boolean): Promise; + updateOAuth2Stripe( + paramsOrFirst?: { clientId?: string, apiSecretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, apiSecretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, apiSecretKey?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + apiSecretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const apiSecretKey = params.apiSecretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/stripe'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof apiSecretKey !== 'undefined') { + payload['apiSecretKey'] = apiSecretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Tradeshift configuration. + * + * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Tradeshift(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Tradeshift configuration. + * + * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Tradeshift(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Tradeshift( + paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + } else { + params = { + oauth2ClientId: paramsOrFirst as string, + oauth2ClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const oauth2ClientId = params.oauth2ClientId; + const oauth2ClientSecret = params.oauth2ClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/tradeshift'; + const payload: Payload = {}; + if (typeof oauth2ClientId !== 'undefined') { + payload['oauth2ClientId'] = oauth2ClientId; + } + if (typeof oauth2ClientSecret !== 'undefined') { + payload['oauth2ClientSecret'] = oauth2ClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Tradeshift Sandbox configuration. + * + * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2TradeshiftSandbox(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Tradeshift Sandbox configuration. + * + * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2TradeshiftSandbox(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise; + updateOAuth2TradeshiftSandbox( + paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + } else { + params = { + oauth2ClientId: paramsOrFirst as string, + oauth2ClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const oauth2ClientId = params.oauth2ClientId; + const oauth2ClientSecret = params.oauth2ClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/tradeshiftBox'; + const payload: Payload = {}; + if (typeof oauth2ClientId !== 'undefined') { + payload['oauth2ClientId'] = oauth2ClientId; + } + if (typeof oauth2ClientSecret !== 'undefined') { + payload['oauth2ClientSecret'] = oauth2ClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Twitch configuration. + * + * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Twitch(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Twitch configuration. + * + * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Twitch(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Twitch( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/twitch'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 WordPress configuration. + * + * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2WordPress(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 WordPress configuration. + * + * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2WordPress(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2WordPress( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/wordpress'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 X configuration. + * + * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2X(params?: { customerKey?: string, secretKey?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 X configuration. + * + * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2X(customerKey?: string, secretKey?: string, enabled?: boolean): Promise; + updateOAuth2X( + paramsOrFirst?: { customerKey?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { customerKey?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { customerKey?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + customerKey: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const customerKey = params.customerKey; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/x'; + const payload: Payload = {}; + if (typeof customerKey !== 'undefined') { + payload['customerKey'] = customerKey; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Yahoo configuration. + * + * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Yahoo(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Yahoo configuration. + * + * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Yahoo(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Yahoo( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/yahoo'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Yandex configuration. + * + * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Yandex(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Yandex configuration. + * + * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Yandex(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Yandex( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/yandex'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Zoho configuration. + * + * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Zoho(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Zoho configuration. + * + * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Zoho(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Zoho( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/zoho'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update the project OAuth2 Zoom configuration. + * + * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2Zoom(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise; + /** + * Update the project OAuth2 Zoom configuration. + * + * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Zoom(clientId?: string, clientSecret?: string, enabled?: boolean): Promise; + updateOAuth2Zoom( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/zoom'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPlatforms(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + * @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. + */ + listPlatforms(queries?: string[], total?: boolean): Promise; + listPlatforms( + 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 = '/project/platforms'; + 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 } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + /** + * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; + createAndroidPlatform( + paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, applicationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + applicationId: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const applicationId = params.applicationId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof applicationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "applicationId"'); + } + + const apiPath = '/project/platforms/android'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise; + /** + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAndroidPlatform(platformId: string, name: string, applicationId: string): Promise; + updateAndroidPlatform( + paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, applicationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + applicationId: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const applicationId = params.applicationId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof applicationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "applicationId"'); + } + + const apiPath = '/project/platforms/android/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} params.bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + /** + * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; + createApplePlatform( + paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, bundleIdentifier: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + bundleIdentifier: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const bundleIdentifier = params.bundleIdentifier; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof bundleIdentifier === 'undefined') { + throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + } + + const apiPath = '/project/platforms/apple'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof bundleIdentifier !== 'undefined') { + payload['bundleIdentifier'] = bundleIdentifier; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise; + /** + * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; + updateApplePlatform( + paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, bundleIdentifier: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + bundleIdentifier: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const bundleIdentifier = params.bundleIdentifier; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof bundleIdentifier === 'undefined') { + throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + } + + const apiPath = '/project/platforms/apple/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof bundleIdentifier !== 'undefined') { + payload['bundleIdentifier'] = bundleIdentifier; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} params.packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + /** + * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLinuxPlatform(platformId: string, name: string, packageName: string): Promise; + createLinuxPlatform( + paramsOrFirst: { platformId: string, name: string, packageName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, packageName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageName = params.packageName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageName"'); + } + + const apiPath = '/project/platforms/linux'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageName !== 'undefined') { + payload['packageName'] = packageName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + /** + * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLinuxPlatform(platformId: string, name: string, packageName: string): Promise; + updateLinuxPlatform( + paramsOrFirst: { platformId: string, name: string, packageName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, packageName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageName = params.packageName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageName"'); + } + + const apiPath = '/project/platforms/linux/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageName !== 'undefined') { + payload['packageName'] = packageName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} params.hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + /** + * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createWebPlatform(platformId: string, name: string, hostname: string): Promise; + createWebPlatform( + paramsOrFirst: { platformId: string, name: string, hostname: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, hostname: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + hostname: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const hostname = params.hostname; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof hostname === 'undefined') { + throw new AppwriteException('Missing required parameter: "hostname"'); + } + + const apiPath = '/project/platforms/web'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof hostname !== 'undefined') { + payload['hostname'] = hostname; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + /** + * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateWebPlatform(platformId: string, name: string, hostname: string): Promise; + updateWebPlatform( + paramsOrFirst: { platformId: string, name: string, hostname: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, hostname: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + hostname: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const hostname = params.hostname; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof hostname === 'undefined') { + throw new AppwriteException('Missing required parameter: "hostname"'); + } + + const apiPath = '/project/platforms/web/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof hostname !== 'undefined') { + payload['hostname'] = hostname; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} params.packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + /** + * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. + * @param {string} packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; + createWindowsPlatform( + paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, packageIdentifierName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageIdentifierName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageIdentifierName = params.packageIdentifierName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageIdentifierName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + } + + const apiPath = '/project/platforms/windows'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageIdentifierName !== 'undefined') { + payload['packageIdentifierName'] = packageIdentifierName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + /** + * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; + updateWindowsPlatform( + paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { platformId: string, name: string, packageIdentifierName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageIdentifierName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageIdentifierName = params.packageIdentifierName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageIdentifierName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + } + + const apiPath = '/project/platforms/windows/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageIdentifierName !== 'undefined') { + payload['packageIdentifierName'] = packageIdentifierName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + * + * @param {string} params.platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPlatform(params: { platformId: string }): Promise; + /** + * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + * + * @param {string} platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPlatform(platformId: string): Promise; + getPlatform( + paramsOrFirst: { platformId: string } | string + ): Promise { + let params: { platformId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string }; + } else { + params = { + platformId: paramsOrFirst as string + }; + } + + const platformId = params.platformId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + + const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + * + * @param {string} params.platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePlatform(params: { platformId: string }): Promise<{}>; + /** + * Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + * + * @param {string} platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePlatform(platformId: string): Promise<{}>; + deletePlatform( + paramsOrFirst: { platformId: string } | string + ): Promise<{}> { + let params: { platformId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string }; + } else { + params = { + platformId: paramsOrFirst as string + }; + } + + const platformId = params.platformId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + + const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a list of all project policies and their current configuration. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPolicies(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all project policies and their current configuration. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @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. + */ + listPolicies(queries?: string[], total?: boolean): Promise; + listPolicies( + 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 = '/project/policies'; + 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 } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. + * + * @param {boolean} params.userId - Set to true if you want make user ID visible to all team members, or false to hide it. + * @param {boolean} params.userEmail - Set to true if you want make user email visible to all team members, or false to hide it. + * @param {boolean} params.userPhone - Set to true if you want make user phone number visible to all team members, or false to hide it. + * @param {boolean} params.userName - Set to true if you want make user name visible to all team members, or false to hide it. + * @param {boolean} params.userMFA - Set to true if you want make user MFA status visible to all team members, or false to hide it. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMembershipPrivacyPolicy(params?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean }): Promise; + /** + * Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. + * + * @param {boolean} userId - Set to true if you want make user ID visible to all team members, or false to hide it. + * @param {boolean} userEmail - Set to true if you want make user email visible to all team members, or false to hide it. + * @param {boolean} userPhone - Set to true if you want make user phone number visible to all team members, or false to hide it. + * @param {boolean} userName - Set to true if you want make user name visible to all team members, or false to hide it. + * @param {boolean} userMFA - Set to true if you want make user MFA status visible to all team members, or false to hide it. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMembershipPrivacyPolicy(userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean): Promise; + updateMembershipPrivacyPolicy( + paramsOrFirst?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean } | boolean, + ...rest: [(boolean)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise { + let params: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean }; + } else { + params = { + userId: paramsOrFirst as boolean, + userEmail: rest[0] as boolean, + userPhone: rest[1] as boolean, + userName: rest[2] as boolean, + userMFA: rest[3] as boolean + }; + } + + const userId = params.userId; + const userEmail = params.userEmail; + const userPhone = params.userPhone; + const userName = params.userName; + const userMFA = params.userMFA; + + + const apiPath = '/project/policies/membership-privacy'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof userEmail !== 'undefined') { + payload['userEmail'] = userEmail; + } + if (typeof userPhone !== 'undefined') { + payload['userPhone'] = userPhone; + } + if (typeof userName !== 'undefined') { + payload['userName'] = userName; + } + if (typeof userMFA !== 'undefined') { + payload['userMFA'] = userMFA; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. + * + * @param {boolean} params.enabled - Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordDictionaryPolicy(params: { enabled: boolean }): Promise; + /** + * Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. + * + * @param {boolean} enabled - Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordDictionaryPolicy(enabled: boolean): Promise; + updatePasswordDictionaryPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/password-dictionary'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. + * + * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. + * + * @param {number} params.total - Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordHistoryPolicy(params: { total?: number }): Promise; + /** + * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. + * + * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. + * + * @param {number} total - Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordHistoryPolicy(total?: number): Promise; + updatePasswordHistoryPolicy( + paramsOrFirst?: { total?: number } | number + ): Promise { + let params: { total?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { total?: number }; + } else { + params = { + total: paramsOrFirst as number + }; + } + + const total = params.total; + + if (typeof total === 'undefined') { + throw new AppwriteException('Missing required parameter: "total"'); + } + + const apiPath = '/project/policies/password-history'; + const payload: Payload = {}; + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. + * + * @param {boolean} params.enabled - Toggle password personal data policy. Set to true if you want to block passwords including user's personal data, or false to allow it. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePasswordPersonalDataPolicy(params: { enabled: boolean }): Promise; + /** + * Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. + * + * @param {boolean} enabled - Toggle password personal data policy. Set to true if you want to block passwords including user's personal data, or false to allow it. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordPersonalDataPolicy(enabled: boolean): Promise; + updatePasswordPersonalDataPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/password-personal-data'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. + * + * @param {boolean} params.enabled - Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateSessionAlertPolicy(params: { enabled: boolean }): Promise; + /** + * Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. + * + * @param {boolean} enabled - Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSessionAlertPolicy(enabled: boolean): Promise; + updateSessionAlertPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/session-alert'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update maximum duration how long sessions created within a project should stay active for. + * + * @param {number} params.duration - Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateSessionDurationPolicy(params: { duration: number }): Promise; + /** + * Update maximum duration how long sessions created within a project should stay active for. + * + * @param {number} duration - Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise; - updateApplePlatform( - paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, bundleIdentifier: string }; + updateSessionDurationPolicy(duration: number): Promise; + updateSessionDurationPolicy( + paramsOrFirst: { duration: number } | number + ): Promise { + let params: { duration: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + params = (paramsOrFirst || {}) as { duration: number }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - bundleIdentifier: rest[1] as string + duration: paramsOrFirst as number }; } - const platformId = params.platformId; - const name = params.name; - const bundleIdentifier = params.bundleIdentifier; + const duration = params.duration; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof bundleIdentifier === 'undefined') { - throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + if (typeof duration === 'undefined') { + throw new AppwriteException('Missing required parameter: "duration"'); } - const apiPath = '/project/platforms/apple/{platformId}'.replace('{platformId}', platformId); + const apiPath = '/project/policies/session-duration'; const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof bundleIdentifier !== 'undefined') { - payload['bundleIdentifier'] = bundleIdentifier; + if (typeof duration !== 'undefined') { + payload['duration'] = duration; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -742,7 +5202,7 @@ export class Project { } return this.client.call( - 'put', + 'patch', uri, apiHeaders, payload, @@ -750,66 +5210,45 @@ export class Project { } /** - * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + * Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. * - * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} params.packageName - Linux package name. Max length: 256 chars. + * @param {boolean} params.enabled - Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - createLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + updateSessionInvalidationPolicy(params: { enabled: boolean }): Promise; /** - * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + * Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. * - * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} packageName - Linux package name. Max length: 256 chars. + * @param {boolean} enabled - Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createLinuxPlatform(platformId: string, name: string, packageName: string): Promise; - createLinuxPlatform( - paramsOrFirst: { platformId: string, name: string, packageName: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, packageName: string }; + updateSessionInvalidationPolicy(enabled: boolean): Promise; + updateSessionInvalidationPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise { + let params: { enabled: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + params = (paramsOrFirst || {}) as { enabled: boolean }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - packageName: rest[1] as string + enabled: paramsOrFirst as boolean }; } - const platformId = params.platformId; - const name = params.name; - const packageName = params.packageName; + const enabled = params.enabled; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof packageName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageName"'); + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); } - const apiPath = '/project/platforms/linux'; + const apiPath = '/project/policies/session-invalidation'; const payload: Payload = {}; - if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof packageName !== 'undefined') { - payload['packageName'] = packageName; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -818,7 +5257,7 @@ export class Project { } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload, @@ -826,63 +5265,45 @@ export class Project { } /** - * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. * - * @param {string} params.platformId - Platform ID. - * @param {string} params.name - Platform name. Max length: 128 chars. - * @param {string} params.packageName - Linux package name. Max length: 256 chars. + * @param {number} params.total - Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise; + updateSessionLimitPolicy(params: { total?: number }): Promise; /** - * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. * - * @param {string} platformId - Platform ID. - * @param {string} name - Platform name. Max length: 128 chars. - * @param {string} packageName - Linux package name. Max length: 256 chars. + * @param {number} total - Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateLinuxPlatform(platformId: string, name: string, packageName: string): Promise; - updateLinuxPlatform( - paramsOrFirst: { platformId: string, name: string, packageName: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, packageName: string }; + updateSessionLimitPolicy(total?: number): Promise; + updateSessionLimitPolicy( + paramsOrFirst?: { total?: number } | number + ): Promise { + let params: { total?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + params = (paramsOrFirst || {}) as { total?: number }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - packageName: rest[1] as string + total: paramsOrFirst as number }; } - const platformId = params.platformId; - const name = params.name; - const packageName = params.packageName; + const total = params.total; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof packageName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageName"'); + if (typeof total === 'undefined') { + throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/platforms/linux/{platformId}'.replace('{platformId}', platformId); + const apiPath = '/project/policies/session-limit'; const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof packageName !== 'undefined') { - payload['packageName'] = packageName; + if (typeof total !== 'undefined') { + payload['total'] = total; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -891,7 +5312,7 @@ export class Project { } return this.client.call( - 'put', + 'patch', uri, apiHeaders, payload, @@ -899,66 +5320,45 @@ export class Project { } /** - * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} params.hostname - Platform web hostname. Max length: 256 chars. + * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - createWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + updateUserLimitPolicy(params: { total?: number }): Promise; /** - * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. * - * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} hostname - Platform web hostname. Max length: 256 chars. + * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createWebPlatform(platformId: string, name: string, hostname: string): Promise; - createWebPlatform( - paramsOrFirst: { platformId: string, name: string, hostname: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, hostname: string }; + updateUserLimitPolicy(total?: number): Promise; + updateUserLimitPolicy( + paramsOrFirst?: { total?: number } | number + ): Promise { + let params: { total?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + params = (paramsOrFirst || {}) as { total?: number }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - hostname: rest[1] as string + total: paramsOrFirst as number }; } - const platformId = params.platformId; - const name = params.name; - const hostname = params.hostname; + const total = params.total; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof hostname === 'undefined') { - throw new AppwriteException('Missing required parameter: "hostname"'); + if (typeof total === 'undefined') { + throw new AppwriteException('Missing required parameter: "total"'); } - const apiPath = '/project/platforms/web'; + const apiPath = '/project/policies/user-limit'; const payload: Payload = {}; - if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof hostname !== 'undefined') { - payload['hostname'] = hostname; + if (typeof total !== 'undefined') { + payload['total'] = total; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -967,7 +5367,7 @@ export class Project { } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload, @@ -975,63 +5375,104 @@ export class Project { } /** - * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {string} params.platformId - Platform ID. - * @param {string} params.name - Platform name. Max length: 128 chars. - * @param {string} params.hostname - Platform web hostname. Max length: 256 chars. + * @param {PolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise; + getPolicy(params: { policyId: PolicyId }): Promise; /** - * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {string} platformId - Platform ID. - * @param {string} name - Platform name. Max length: 128 chars. - * @param {string} hostname - Platform web hostname. Max length: 256 chars. + * @param {PolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateWebPlatform(platformId: string, name: string, hostname: string): Promise; - updateWebPlatform( - paramsOrFirst: { platformId: string, name: string, hostname: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, hostname: string }; + getPolicy(policyId: PolicyId): Promise; + getPolicy( + paramsOrFirst: { policyId: PolicyId } | PolicyId + ): Promise { + let params: { policyId: PolicyId }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('policyId' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: PolicyId }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - hostname: rest[1] as string + policyId: paramsOrFirst as PolicyId }; } - const platformId = params.platformId; - const name = params.name; - const hostname = params.hostname; + const policyId = params.policyId; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); + + const apiPath = '/project/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * + * @param {ProtocolId} params.protocolId - Protocol name. Can be one of: rest, graphql, websocket + * @param {boolean} params.enabled - Protocol status. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateProtocol(params: { protocolId: ProtocolId, enabled: boolean }): Promise; + /** + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * + * @param {ProtocolId} protocolId - Protocol name. Can be one of: rest, graphql, websocket + * @param {boolean} enabled - Protocol status. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateProtocol(protocolId: ProtocolId, enabled: boolean): Promise; + updateProtocol( + paramsOrFirst: { protocolId: ProtocolId, enabled: boolean } | ProtocolId, + ...rest: [(boolean)?] + ): Promise { + let params: { protocolId: ProtocolId, enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { protocolId: ProtocolId, enabled: boolean }; + } else { + params = { + protocolId: paramsOrFirst as ProtocolId, + enabled: rest[0] as boolean + }; + } + + const protocolId = params.protocolId; + const enabled = params.enabled; + + if (typeof protocolId === 'undefined') { + throw new AppwriteException('Missing required parameter: "protocolId"'); } - if (typeof hostname === 'undefined') { - throw new AppwriteException('Missing required parameter: "hostname"'); + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); } - const apiPath = '/project/platforms/web/{platformId}'.replace('{platformId}', platformId); + const apiPath = '/project/protocols/{protocolId}'.replace('{protocolId}', protocolId); const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof hostname !== 'undefined') { - payload['hostname'] = hostname; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -1040,7 +5481,7 @@ export class Project { } return this.client.call( - 'put', + 'patch', uri, apiHeaders, payload, @@ -1048,66 +5489,53 @@ export class Project { } /** - * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * - * @param {string} params.platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} params.packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @param {ServiceId} params.serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging + * @param {boolean} params.enabled - Service status. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - createWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + updateService(params: { serviceId: ServiceId, enabled: boolean }): Promise; /** - * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * - * @param {string} platformId - Platform 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 - Platform name. Max length: 128 chars. - * @param {string} packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @param {ServiceId} serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging + * @param {boolean} enabled - Service status. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; - createWindowsPlatform( - paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, packageIdentifierName: string }; + updateService(serviceId: ServiceId, enabled: boolean): Promise; + updateService( + paramsOrFirst: { serviceId: ServiceId, enabled: boolean } | ServiceId, + ...rest: [(boolean)?] + ): Promise { + let params: { serviceId: ServiceId, enabled: boolean }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { serviceId: ServiceId, enabled: boolean }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - packageIdentifierName: rest[1] as string + serviceId: paramsOrFirst as ServiceId, + enabled: rest[0] as boolean }; } - const platformId = params.platformId; - const name = params.name; - const packageIdentifierName = params.packageIdentifierName; + const serviceId = params.serviceId; + const enabled = params.enabled; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); + if (typeof serviceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "serviceId"'); } - if (typeof packageIdentifierName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); } - const apiPath = '/project/platforms/windows'; + const apiPath = '/project/services/{serviceId}'.replace('{serviceId}', serviceId); const payload: Payload = {}; - if (typeof platformId !== 'undefined') { - payload['platformId'] = platformId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof packageIdentifierName !== 'undefined') { - payload['packageIdentifierName'] = packageIdentifierName; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -1116,7 +5544,7 @@ export class Project { } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload, @@ -1124,63 +5552,106 @@ export class Project { } /** - * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + * Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. * - * @param {string} params.platformId - Platform ID. - * @param {string} params.name - Platform name. Max length: 128 chars. - * @param {string} params.packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @param {string} params.host - SMTP server hostname (domain) + * @param {number} params.port - SMTP server port + * @param {string} params.username - SMTP server username. Leave empty for no authorization. + * @param {string} params.password - SMTP server password. Leave empty for no authorization. This property is stored securely and cannot be read in future (write-only). + * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. + * @param {string} params.senderName - Name shown in inbox as the sender of the email. + * @param {string} params.replyToEmail - Email used when user replies to the email. + * @param {string} params.replyToName - Name used when user replies to the email. + * @param {Secure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise; + updateSMTP(params?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean }): Promise; /** - * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + * Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. * - * @param {string} platformId - Platform ID. - * @param {string} name - Platform name. Max length: 128 chars. - * @param {string} packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @param {string} host - SMTP server hostname (domain) + * @param {number} port - SMTP server port + * @param {string} username - SMTP server username. Leave empty for no authorization. + * @param {string} password - SMTP server password. Leave empty for no authorization. This property is stored securely and cannot be read in future (write-only). + * @param {string} senderEmail - Email address shown in inbox as the sender of the email. + * @param {string} senderName - Name shown in inbox as the sender of the email. + * @param {string} replyToEmail - Email used when user replies to the email. + * @param {string} replyToName - Name used when user replies to the email. + * @param {Secure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise; - updateWindowsPlatform( - paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, - ...rest: [(string)?, (string)?] - ): Promise { - let params: { platformId: string, name: string, packageIdentifierName: string }; + updateSMTP(host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean): Promise; + updateSMTP( + paramsOrFirst?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean } | string, + ...rest: [(number)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (Secure)?, (boolean)?] + ): Promise { + let params: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean }; } else { params = { - platformId: paramsOrFirst as string, - name: rest[0] as string, - packageIdentifierName: rest[1] as string + host: paramsOrFirst as string, + port: rest[0] as number, + username: rest[1] as string, + password: rest[2] as string, + senderEmail: rest[3] as string, + senderName: rest[4] as string, + replyToEmail: rest[5] as string, + replyToName: rest[6] as string, + secure: rest[7] as Secure, + enabled: rest[8] as boolean }; } - const platformId = params.platformId; - const name = params.name; - const packageIdentifierName = params.packageIdentifierName; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const senderEmail = params.senderEmail; + const senderName = params.senderName; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; + const secure = params.secure; + const enabled = params.enabled; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + + const apiPath = '/project/smtp'; + const payload: Payload = {}; + if (typeof host !== 'undefined') { + payload['host'] = host; } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); + if (typeof port !== 'undefined') { + payload['port'] = port; } - if (typeof packageIdentifierName === 'undefined') { - throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + if (typeof username !== 'undefined') { + payload['username'] = username; } - - const apiPath = '/project/platforms/windows/{platformId}'.replace('{platformId}', platformId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; + if (typeof password !== 'undefined') { + payload['password'] = password; } - if (typeof packageIdentifierName !== 'undefined') { - payload['packageIdentifierName'] = packageIdentifierName; + if (typeof senderEmail !== 'undefined') { + payload['senderEmail'] = senderEmail; + } + if (typeof senderName !== 'undefined') { + payload['senderName'] = senderName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof secure !== 'undefined') { + payload['secure'] = secure; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -1189,7 +5660,7 @@ export class Project { } return this.client.call( - 'put', + 'patch', uri, apiHeaders, payload, @@ -1197,50 +5668,54 @@ export class Project { } /** - * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + * Send a test email to verify SMTP configuration. * - * @param {string} params.platformId - Platform ID. + * @param {string[]} params.emails - Array of emails to send test email to. Maximum of 10 emails are allowed. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise<{}>} */ - getPlatform(params: { platformId: string }): Promise; + createSMTPTest(params: { emails: string[] }): Promise<{}>; /** - * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + * Send a test email to verify SMTP configuration. * - * @param {string} platformId - Platform ID. + * @param {string[]} emails - Array of emails to send test email to. Maximum of 10 emails are allowed. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - getPlatform(platformId: string): Promise; - getPlatform( - paramsOrFirst: { platformId: string } | string - ): Promise { - let params: { platformId: string }; + createSMTPTest(emails: string[]): Promise<{}>; + createSMTPTest( + paramsOrFirst: { emails: string[] } | string[] + ): Promise<{}> { + let params: { emails: string[] }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string }; + params = (paramsOrFirst || {}) as { emails: string[] }; } else { params = { - platformId: paramsOrFirst as string + emails: paramsOrFirst as string[] }; } - const platformId = params.platformId; + const emails = params.emails; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); + if (typeof emails === 'undefined') { + throw new AppwriteException('Missing required parameter: "emails"'); } - const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', platformId); + const apiPath = '/project/smtp/tests'; const payload: Payload = {}; + if (typeof emails !== 'undefined') { + payload['emails'] = emails; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', } return this.client.call( - 'get', + 'post', uri, apiHeaders, payload, @@ -1248,51 +5723,58 @@ export class Project { } /** - * Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + * Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. * - * @param {string} params.platformId - Platform ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise} */ - deletePlatform(params: { platformId: string }): Promise<{}>; + listEmailTemplates(params?: { queries?: string[], total?: boolean }): Promise; /** - * Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + * Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. * - * @param {string} platformId - Platform ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deletePlatform(platformId: string): Promise<{}>; - deletePlatform( - paramsOrFirst: { platformId: string } | string - ): Promise<{}> { - let params: { platformId: string }; + listEmailTemplates(queries?: string[], total?: boolean): Promise; + listEmailTemplates( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { platformId: string }; + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; } else { params = { - platformId: paramsOrFirst as string + queries: paramsOrFirst as string[], + total: rest[0] as boolean }; } - const platformId = params.platformId; + const queries = params.queries; + const total = params.total; - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', platformId); + const apiPath = '/project/templates/email'; 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 } = { - 'content-type': 'application/json', } return this.client.call( - 'delete', + 'get', uri, apiHeaders, payload, @@ -1300,53 +5782,95 @@ export class Project { } /** - * Update the status of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @param {ProtocolId} params.protocolId - Protocol name. Can be one of: rest, graphql, websocket - * @param {boolean} params.enabled - Protocol status. + * @param {EmailTemplateType} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {EmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. + * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string} params.senderName - Name of the email sender. + * @param {string} params.senderEmail - Email of the sender. + * @param {string} params.replyToEmail - Reply to email. + * @param {string} params.replyToName - Reply to name. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateProtocolStatus(params: { protocolId: ProtocolId, enabled: boolean }): Promise; + updateEmailTemplate(params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }): Promise; /** - * Update the status of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @param {ProtocolId} protocolId - Protocol name. Can be one of: rest, graphql, websocket - * @param {boolean} enabled - Protocol status. + * @param {EmailTemplateType} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {EmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. + * @param {string} subject - Subject of the email template. Can be up to 255 characters. + * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string} senderName - Name of the email sender. + * @param {string} senderEmail - Email of the sender. + * @param {string} replyToEmail - Reply to email. + * @param {string} replyToName - Reply to name. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateProtocolStatus(protocolId: ProtocolId, enabled: boolean): Promise; - updateProtocolStatus( - paramsOrFirst: { protocolId: ProtocolId, enabled: boolean } | ProtocolId, - ...rest: [(boolean)?] - ): Promise { - let params: { protocolId: ProtocolId, enabled: boolean }; + updateEmailTemplate(templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string): Promise; + updateEmailTemplate( + paramsOrFirst: { templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string } | EmailTemplateType, + ...rest: [(EmailTemplateLocale)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise { + let params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { protocolId: ProtocolId, enabled: boolean }; + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst || 'subject' in paramsOrFirst || 'message' in paramsOrFirst || 'senderName' in paramsOrFirst || 'senderEmail' in paramsOrFirst || 'replyToEmail' in paramsOrFirst || 'replyToName' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; } else { params = { - protocolId: paramsOrFirst as ProtocolId, - enabled: rest[0] as boolean + templateId: paramsOrFirst as EmailTemplateType, + locale: rest[0] as EmailTemplateLocale, + subject: rest[1] as string, + message: rest[2] as string, + senderName: rest[3] as string, + senderEmail: rest[4] as string, + replyToEmail: rest[5] as string, + replyToName: rest[6] as string }; } - const protocolId = params.protocolId; - const enabled = params.enabled; + const templateId = params.templateId; + const locale = params.locale; + const subject = params.subject; + const message = params.message; + const senderName = params.senderName; + const senderEmail = params.senderEmail; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; - if (typeof protocolId === 'undefined') { - throw new AppwriteException('Missing required parameter: "protocolId"'); - } - if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + if (typeof templateId === 'undefined') { + throw new AppwriteException('Missing required parameter: "templateId"'); } - const apiPath = '/project/protocols/{protocolId}/status'.replace('{protocolId}', protocolId); + const apiPath = '/project/templates/email'; const payload: Payload = {}; - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + if (typeof templateId !== 'undefined') { + payload['templateId'] = templateId; + } + if (typeof locale !== 'undefined') { + payload['locale'] = locale; + } + if (typeof subject !== 'undefined') { + payload['subject'] = subject; + } + if (typeof message !== 'undefined') { + payload['message'] = message; + } + if (typeof senderName !== 'undefined') { + payload['senderName'] = senderName; + } + if (typeof senderEmail !== 'undefined') { + payload['senderEmail'] = senderEmail; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -1363,62 +5887,58 @@ export class Project { } /** - * Update the status of a specific service. Use this endpoint to enable or disable a service in your project. + * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @param {ServiceId} params.serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging - * @param {boolean} params.enabled - Service status. + * @param {EmailTemplateType} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {EmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - updateServiceStatus(params: { serviceId: ServiceId, enabled: boolean }): Promise; + getEmailTemplate(params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale }): Promise; /** - * Update the status of a specific service. Use this endpoint to enable or disable a service in your project. + * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @param {ServiceId} serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging - * @param {boolean} enabled - Service status. + * @param {EmailTemplateType} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {EmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateServiceStatus(serviceId: ServiceId, enabled: boolean): Promise; - updateServiceStatus( - paramsOrFirst: { serviceId: ServiceId, enabled: boolean } | ServiceId, - ...rest: [(boolean)?] - ): Promise { - let params: { serviceId: ServiceId, enabled: boolean }; + getEmailTemplate(templateId: EmailTemplateType, locale?: EmailTemplateLocale): Promise; + getEmailTemplate( + paramsOrFirst: { templateId: EmailTemplateType, locale?: EmailTemplateLocale } | EmailTemplateType, + ...rest: [(EmailTemplateLocale)?] + ): Promise { + let params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale }; - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { serviceId: ServiceId, enabled: boolean }; + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { templateId: EmailTemplateType, locale?: EmailTemplateLocale }; } else { params = { - serviceId: paramsOrFirst as ServiceId, - enabled: rest[0] as boolean + templateId: paramsOrFirst as EmailTemplateType, + locale: rest[0] as EmailTemplateLocale }; } - const serviceId = params.serviceId; - const enabled = params.enabled; + const templateId = params.templateId; + const locale = params.locale; - if (typeof serviceId === 'undefined') { - throw new AppwriteException('Missing required parameter: "serviceId"'); - } - if (typeof enabled === 'undefined') { - throw new AppwriteException('Missing required parameter: "enabled"'); + if (typeof templateId === 'undefined') { + throw new AppwriteException('Missing required parameter: "templateId"'); } - const apiPath = '/project/services/{serviceId}/status'.replace('{serviceId}', serviceId); + const apiPath = '/project/templates/email/{templateId}'.replace('{templateId}', templateId); const payload: Payload = {}; - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + if (typeof locale !== 'undefined') { + payload['locale'] = locale; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'patch', + 'get', uri, apiHeaders, payload, @@ -1487,7 +6007,7 @@ export class Project { /** * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * - * @param {string} params.variableId - Variable 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.variableId - Variable 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.key - Variable key. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. @@ -1498,7 +6018,7 @@ export class Project { /** * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. * - * @param {string} variableId - Variable 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} variableId - Variable 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} key - Variable key. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. @@ -1570,7 +6090,7 @@ export class Project { /** * Get a variable by its unique ID. * - * @param {string} params.variableId - Variable ID. + * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise} */ @@ -1578,7 +6098,7 @@ export class Project { /** * Get a variable by its unique ID. * - * @param {string} variableId - Variable ID. + * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -1621,7 +6141,7 @@ export class Project { /** * Update variable by its unique ID. * - * @param {string} params.variableId - Variable ID. + * @param {string} params.variableId - Variable unique ID. * @param {string} params.key - Variable key. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. @@ -1632,7 +6152,7 @@ export class Project { /** * Update variable by its unique ID. * - * @param {string} variableId - Variable ID. + * @param {string} variableId - Variable unique ID. * @param {string} key - Variable key. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. @@ -1695,7 +6215,7 @@ export class Project { /** * Delete a variable by its unique ID. * - * @param {string} params.variableId - Variable ID. + * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise<{}>} */ @@ -1703,7 +6223,7 @@ export class Project { /** * Delete a variable by its unique ID. * - * @param {string} variableId - Variable ID. + * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. diff --git a/src/services/proxy.ts b/src/services/proxy.ts new file mode 100644 index 00000000..83e4ecc8 --- /dev/null +++ b/src/services/proxy.ts @@ -0,0 +1,541 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +import { StatusCode } from '../enums/status-code'; +import { ProxyResourceType } from '../enums/proxy-resource-type'; + +export class Proxy { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all the proxy rules. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRules(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all the proxy rules. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @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. + */ + listRules(queries?: string[], total?: boolean): Promise; + listRules( + 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 = '/proxy/rules'; + 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 } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new proxy rule for serving Appwrite's API on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @throws {AppwriteException} + * @returns {Promise} + */ + createAPIRule(params: { domain: string }): Promise; + /** + * Create a new proxy rule for serving Appwrite's API on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createAPIRule(domain: string): Promise; + createAPIRule( + paramsOrFirst: { domain: string } | string + ): Promise { + let params: { domain: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string }; + } else { + params = { + domain: paramsOrFirst as string + }; + } + + const domain = params.domain; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + + const apiPath = '/proxy/rules/api'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new proxy rule for executing Appwrite Function on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @param {string} params.functionId - ID of function to be executed. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise} + */ + createFunctionRule(params: { domain: string, functionId: string, branch?: string }): Promise; + /** + * Create a new proxy rule for executing Appwrite Function on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @param {string} functionId - ID of function to be executed. + * @param {string} branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFunctionRule(domain: string, functionId: string, branch?: string): Promise; + createFunctionRule( + paramsOrFirst: { domain: string, functionId: string, branch?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { domain: string, functionId: string, branch?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, functionId: string, branch?: string }; + } else { + params = { + domain: paramsOrFirst as string, + functionId: rest[0] as string, + branch: rest[1] as string + }; + } + + const domain = params.domain; + const functionId = params.functionId; + const branch = params.branch; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/proxy/rules/function'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof functionId !== 'undefined') { + payload['functionId'] = functionId; + } + if (typeof branch !== 'undefined') { + payload['branch'] = branch; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new proxy rule for to redirect from custom domain to another domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @param {string} params.url - Target URL of redirection + * @param {StatusCode} params.statusCode - Status code of redirection + * @param {string} params.resourceId - ID of parent resource. + * @param {ProxyResourceType} params.resourceType - Type of parent resource. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRedirectRule(params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }): Promise; + /** + * Create a new proxy rule for to redirect from custom domain to another domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @param {string} url - Target URL of redirection + * @param {StatusCode} statusCode - Status code of redirection + * @param {string} resourceId - ID of parent resource. + * @param {ProxyResourceType} resourceType - Type of parent resource. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule(domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType): Promise; + createRedirectRule( + paramsOrFirst: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType } | string, + ...rest: [(string)?, (StatusCode)?, (string)?, (ProxyResourceType)?] + ): Promise { + let params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + } else { + params = { + domain: paramsOrFirst as string, + url: rest[0] as string, + statusCode: rest[1] as StatusCode, + resourceId: rest[2] as string, + resourceType: rest[3] as ProxyResourceType + }; + } + + const domain = params.domain; + const url = params.url; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const resourceType = params.resourceType; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException('Missing required parameter: "statusCode"'); + } + if (typeof resourceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "resourceId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException('Missing required parameter: "resourceType"'); + } + + const apiPath = '/proxy/rules/redirect'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof statusCode !== 'undefined') { + payload['statusCode'] = statusCode; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + if (typeof resourceType !== 'undefined') { + payload['resourceType'] = resourceType; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new proxy rule for serving Appwrite Site on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @param {string} params.siteId - ID of site to be executed. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise} + */ + createSiteRule(params: { domain: string, siteId: string, branch?: string }): Promise; + /** + * Create a new proxy rule for serving Appwrite Site on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @param {string} siteId - ID of site to be executed. + * @param {string} branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSiteRule(domain: string, siteId: string, branch?: string): Promise; + createSiteRule( + paramsOrFirst: { domain: string, siteId: string, branch?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise { + let params: { domain: string, siteId: string, branch?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, siteId: string, branch?: string }; + } else { + params = { + domain: paramsOrFirst as string, + siteId: rest[0] as string, + branch: rest[1] as string + }; + } + + const domain = params.domain; + const siteId = params.siteId; + const branch = params.branch; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/proxy/rules/site'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof siteId !== 'undefined') { + payload['siteId'] = siteId; + } + if (typeof branch !== 'undefined') { + payload['branch'] = branch; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a proxy rule by its unique ID. + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRule(params: { ruleId: string }): Promise; + /** + * Get a proxy rule by its unique ID. + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule(ruleId: string): Promise; + getRule( + paramsOrFirst: { ruleId: string } | string + ): Promise { + let params: { ruleId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string + }; + } + + const ruleId = params.ruleId; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a proxy rule by its unique ID. + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a proxy rule by its unique ID. + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule( + paramsOrFirst: { ruleId: string } | string + ): Promise<{}> { + let params: { ruleId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string + }; + } + + const ruleId = params.ruleId; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRuleStatus(params: { ruleId: string }): Promise; + /** + * If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRuleStatus(ruleId: string): Promise; + updateRuleStatus( + paramsOrFirst: { ruleId: string } | string + ): Promise { + let params: { ruleId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string + }; + } + + const ruleId = params.ruleId; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/proxy/rules/{ruleId}/status'.replace('{ruleId}', ruleId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/sites.ts b/src/services/sites.ts index 4ae79aaf..a45f6478 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -1,6 +1,8 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { InputFile } from '../inputFile'; + import { Framework } from '../enums/framework'; import { BuildRuntime } from '../enums/build-runtime'; import { Adapter } from '../enums/adapter'; @@ -774,7 +776,7 @@ export class Sites { * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. * * @param {string} params.siteId - Site ID. - * @param {File} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {File | InputFile} params.code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. * @param {string} params.installCommand - Install Commands. * @param {string} params.buildCommand - Build Commands. * @param {string} params.outputDirectory - Output Directory. @@ -782,12 +784,12 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - createDeployment(params: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void }): Promise; + createDeployment(params: { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void }): Promise; /** * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. * * @param {string} siteId - Site ID. - * @param {File} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + * @param {File | InputFile} code - Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. * @param {string} installCommand - Install Commands. * @param {string} buildCommand - Build Commands. * @param {string} outputDirectory - Output Directory. @@ -796,21 +798,21 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createDeployment(siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void): Promise; + createDeployment(siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void): Promise; createDeployment( - paramsOrFirst: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(File)?, (string)?, (string)?, (string)?, (boolean)?,((progress: UploadProgress) => void)?] + paramsOrFirst: { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(File | InputFile)?, (string)?, (string)?, (string)?, (boolean)?,((progress: UploadProgress) => void)?] ): Promise { - let params: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; + let params: { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; let onProgress: ((progress: UploadProgress) => void); if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; + params = (paramsOrFirst || {}) as { siteId: string, code: File | InputFile, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); } else { params = { siteId: paramsOrFirst as string, - code: rest[0] as File, + code: rest[0] as File | InputFile, installCommand: rest[1] as string, buildCommand: rest[2] as string, outputDirectory: rest[3] as string, @@ -1561,33 +1563,42 @@ export class Sites { * Get a list of all variables of a specific site. * * @param {string} params.siteId - Site unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listVariables(params: { siteId: string }): Promise; + listVariables(params: { siteId: string, queries?: string[], total?: boolean }): Promise; /** * Get a list of all variables of a specific site. * * @param {string} siteId - Site unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @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. */ - listVariables(siteId: string): Promise; + listVariables(siteId: string, queries?: string[], total?: boolean): Promise; listVariables( - paramsOrFirst: { siteId: string } | string + paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] ): Promise { - let params: { siteId: string }; + let params: { siteId: string, queries?: string[], total?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string }; + params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; } else { params = { - siteId: paramsOrFirst as string + siteId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean }; } const siteId = params.siteId; + const queries = params.queries; + const total = params.total; if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); @@ -1595,6 +1606,12 @@ export class Sites { const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', siteId); 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 } = { @@ -1612,17 +1629,19 @@ export class Sites { * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. * * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable 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.key - Variable key. Max length: 255 chars. * @param {string} params.value - Variable value. Max length: 8192 chars. * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. * @throws {AppwriteException} * @returns {Promise} */ - createVariable(params: { siteId: string, key: string, value: string, secret?: boolean }): Promise; + createVariable(params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise; /** * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. * * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable 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} key - Variable key. Max length: 255 chars. * @param {string} value - Variable value. Max length: 8192 chars. * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. @@ -1630,25 +1649,27 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createVariable(siteId: string, key: string, value: string, secret?: boolean): Promise; + createVariable(siteId: string, variableId: string, key: string, value: string, secret?: boolean): Promise; createVariable( - paramsOrFirst: { siteId: string, key: string, value: string, secret?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?] + paramsOrFirst: { siteId: string, variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] ): Promise { - let params: { siteId: string, key: string, value: string, secret?: boolean }; + let params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, key: string, value: string, secret?: boolean }; + params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; } else { params = { siteId: paramsOrFirst as string, - key: rest[0] as string, - value: rest[1] as string, - secret: rest[2] as boolean + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean }; } const siteId = params.siteId; + const variableId = params.variableId; const key = params.key; const value = params.value; const secret = params.secret; @@ -1656,6 +1677,9 @@ export class Sites { if (typeof siteId === 'undefined') { throw new AppwriteException('Missing required parameter: "siteId"'); } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } if (typeof key === 'undefined') { throw new AppwriteException('Missing required parameter: "key"'); } @@ -1665,6 +1689,9 @@ export class Sites { const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', siteId); const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; + } if (typeof key !== 'undefined') { payload['key'] = key; } @@ -1758,7 +1785,7 @@ export class Sites { * @throws {AppwriteException} * @returns {Promise} */ - updateVariable(params: { siteId: string, variableId: string, key: string, value?: string, secret?: boolean }): Promise; + updateVariable(params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise; /** * Update variable by its unique ID. * @@ -1771,15 +1798,15 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateVariable(siteId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise; + updateVariable(siteId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise; updateVariable( - paramsOrFirst: { siteId: string, variableId: string, key: string, value?: string, secret?: boolean } | string, + paramsOrFirst: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, ...rest: [(string)?, (string)?, (string)?, (boolean)?] ): Promise { - let params: { siteId: string, variableId: string, key: string, value?: string, secret?: boolean }; + let params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key: string, value?: string, secret?: boolean }; + params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; } else { params = { siteId: paramsOrFirst as string, @@ -1802,9 +1829,6 @@ export class Sites { if (typeof variableId === 'undefined') { throw new AppwriteException('Missing required parameter: "variableId"'); } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); const payload: Payload = {}; diff --git a/src/services/storage.ts b/src/services/storage.ts index 794ac76d..f38792b7 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,6 +1,8 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { InputFile } from '../inputFile'; + import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; import { ImageFormat } from '../enums/image-format'; @@ -521,12 +523,12 @@ export class Storage { * * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} params.fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {File} params.file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). + * @param {File | InputFile} params.file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). * @param {string[]} params.permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise} */ - createFile(params: { bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void }): Promise; + createFile(params: { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], onProgress?: (progress: UploadProgress) => void }): Promise; /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. * @@ -539,28 +541,28 @@ export class Storage { * * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param {string} fileId - File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {File} file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). + * @param {File | InputFile} file - Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). * @param {string[]} permissions - An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void): Promise; + createFile(bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], onProgress?: (progress: UploadProgress) => void): Promise; createFile( - paramsOrFirst: { bucketId: string, fileId: string, file: File, permissions?: string[], onProgress?: (progress: UploadProgress) => void } | string, - ...rest: [(string)?, (File)?, (string[])?,((progress: UploadProgress) => void)?] + paramsOrFirst: { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[], onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(string)?, (File | InputFile)?, (string[])?,((progress: UploadProgress) => void)?] ): Promise { - let params: { bucketId: string, fileId: string, file: File, permissions?: string[] }; + let params: { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[] }; let onProgress: ((progress: UploadProgress) => void); if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File, permissions?: string[] }; + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, file: File | InputFile, permissions?: string[] }; onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, - file: rest[1] as File, + file: rest[1] as File | InputFile, permissions: rest[2] as string[] }; onProgress = rest[3] as ((progress: UploadProgress) => void); diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 6ec5cf43..40766d5e 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { RelationshipType } from '../enums/relationship-type'; import { RelationMutate } from '../enums/relation-mutate'; import { TablesDBIndexType } from '../enums/tables-db-index-type'; @@ -1125,6 +1126,226 @@ export class TablesDB { ); } + /** + * Create a bigint column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise} + */ + createBigIntColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; + /** + * Create a bigint column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBigIntColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; + createBigIntColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + ): Promise { + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update a bigint column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateBigIntColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; + /** + * Update a bigint column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBigIntColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; + updateBigIntColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + ): Promise { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + /** * Create a boolean column. * diff --git a/src/services/teams.ts b/src/services/teams.ts index 0666aec8..21e81152 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -2,6 +2,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; + export class Teams { client: Client; diff --git a/src/services/tokens.ts b/src/services/tokens.ts index e092894f..1e453a72 100644 --- a/src/services/tokens.ts +++ b/src/services/tokens.ts @@ -2,6 +2,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; + export class Tokens { client: Client; diff --git a/src/services/users.ts b/src/services/users.ts index 7bef1693..19faa4d1 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1,6 +1,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; + import { PasswordHash } from '../enums/password-hash'; import { AuthenticatorType } from '../enums/authenticator-type'; import { MessagingProviderType } from '../enums/messaging-provider-type'; diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts index ddad942e..796cc425 100644 --- a/src/services/webhooks.ts +++ b/src/services/webhooks.ts @@ -2,6 +2,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; + export class Webhooks { client: Client; diff --git a/test/services/account.test.js b/test/services/account.test.js index df618357..a9bbd59a 100644 --- a/test/services/account.test.js +++ b/test/services/account.test.js @@ -11,7 +11,7 @@ describe('Account', () => { test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -40,7 +40,7 @@ describe('Account', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -72,7 +72,7 @@ describe('Account', () => { }); test('test method updateEmail()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -103,7 +103,7 @@ describe('Account', () => { }); test('test method listIdentities()', async () => { - const data = { + const data = { 'total': 5, 'identities': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -118,7 +118,7 @@ describe('Account', () => { }); test('test method deleteIdentity()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await account.deleteIdentity( @@ -132,7 +132,7 @@ describe('Account', () => { }); test('test method createJWT()', async () => { - const data = { + const data = { 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -146,7 +146,7 @@ describe('Account', () => { }); test('test method listLogs()', async () => { - const data = { + const data = { 'total': 5, 'logs': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -161,7 +161,7 @@ describe('Account', () => { }); test('test method updateMFA()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -191,7 +191,7 @@ describe('Account', () => { }); test('test method createMfaAuthenticator()', async () => { - const data = { + const data = { 'secret': '[SHARED_SECRET]', 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -207,7 +207,7 @@ describe('Account', () => { }); test('test method createMFAAuthenticator()', async () => { - const data = { + const data = { 'secret': '[SHARED_SECRET]', 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -223,7 +223,7 @@ describe('Account', () => { }); test('test method updateMfaAuthenticator()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -254,7 +254,7 @@ describe('Account', () => { }); test('test method updateMFAAuthenticator()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -285,7 +285,7 @@ describe('Account', () => { }); test('test method deleteMfaAuthenticator()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await account.deleteMfaAuthenticator( @@ -299,7 +299,7 @@ describe('Account', () => { }); test('test method deleteMFAAuthenticator()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await account.deleteMFAAuthenticator( @@ -313,7 +313,7 @@ describe('Account', () => { }); test('test method createMfaChallenge()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -331,7 +331,7 @@ describe('Account', () => { }); test('test method createMFAChallenge()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -349,7 +349,7 @@ describe('Account', () => { }); test('test method updateMfaChallenge()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -393,7 +393,7 @@ describe('Account', () => { }); test('test method updateMFAChallenge()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -437,7 +437,7 @@ describe('Account', () => { }); test('test method listMfaFactors()', async () => { - const data = { + const data = { 'totp': true, 'phone': true, 'email': true, @@ -454,7 +454,7 @@ describe('Account', () => { }); test('test method listMFAFactors()', async () => { - const data = { + const data = { 'totp': true, 'phone': true, 'email': true, @@ -471,7 +471,7 @@ describe('Account', () => { }); test('test method getMfaRecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -485,7 +485,7 @@ describe('Account', () => { }); test('test method getMFARecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -499,7 +499,7 @@ describe('Account', () => { }); test('test method createMfaRecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -513,7 +513,7 @@ describe('Account', () => { }); test('test method createMFARecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -527,7 +527,7 @@ describe('Account', () => { }); test('test method updateMfaRecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -541,7 +541,7 @@ describe('Account', () => { }); test('test method updateMFARecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -555,7 +555,7 @@ describe('Account', () => { }); test('test method updateName()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -585,7 +585,7 @@ describe('Account', () => { }); test('test method updatePassword()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -615,7 +615,7 @@ describe('Account', () => { }); test('test method updatePhone()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -646,7 +646,7 @@ describe('Account', () => { }); test('test method getPrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await account.getPrefs( @@ -659,7 +659,7 @@ describe('Account', () => { }); test('test method updatePrefs()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -689,7 +689,7 @@ describe('Account', () => { }); test('test method createRecovery()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -710,7 +710,7 @@ describe('Account', () => { }); test('test method updateRecovery()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -732,7 +732,7 @@ describe('Account', () => { }); test('test method listSessions()', async () => { - const data = { + const data = { 'total': 5, 'sessions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -747,7 +747,7 @@ describe('Account', () => { }); test('test method deleteSessions()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await account.deleteSessions( @@ -760,7 +760,7 @@ describe('Account', () => { }); test('test method createAnonymousSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -802,7 +802,7 @@ describe('Account', () => { }); test('test method createEmailPasswordSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -846,7 +846,7 @@ describe('Account', () => { }); test('test method updateMagicURLSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -890,7 +890,7 @@ describe('Account', () => { }); test('test method updatePhoneSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -934,7 +934,7 @@ describe('Account', () => { }); test('test method createSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -978,7 +978,7 @@ describe('Account', () => { }); test('test method getSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1021,7 +1021,7 @@ describe('Account', () => { }); test('test method updateSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1064,7 +1064,7 @@ describe('Account', () => { }); test('test method deleteSession()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await account.deleteSession( @@ -1078,7 +1078,7 @@ describe('Account', () => { }); test('test method updateStatus()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1107,7 +1107,7 @@ describe('Account', () => { }); test('test method createEmailToken()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1128,7 +1128,7 @@ describe('Account', () => { }); test('test method createMagicURLToken()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1163,7 +1163,7 @@ describe('Account', () => { }); test('test method createPhoneToken()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1184,7 +1184,7 @@ describe('Account', () => { }); test('test method createEmailVerification()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1204,7 +1204,7 @@ describe('Account', () => { }); test('test method createVerification()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1224,7 +1224,7 @@ describe('Account', () => { }); test('test method updateEmailVerification()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1245,7 +1245,7 @@ describe('Account', () => { }); test('test method updateVerification()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1266,7 +1266,7 @@ describe('Account', () => { }); test('test method createPhoneVerification()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1285,7 +1285,7 @@ describe('Account', () => { }); test('test method updatePhoneVerification()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', diff --git a/test/services/activities.test.js b/test/services/activities.test.js index fcf8e46e..667ecc56 100644 --- a/test/services/activities.test.js +++ b/test/services/activities.test.js @@ -11,7 +11,7 @@ describe('Activities', () => { test('test method listEvents()', async () => { - const data = { + const data = { 'total': 5, 'events': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Activities', () => { }); test('test method getEvent()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'userType': 'user', 'userId': '610fc2f985ee0', diff --git a/test/services/backups.test.js b/test/services/backups.test.js index b87b1c08..c888402e 100644 --- a/test/services/backups.test.js +++ b/test/services/backups.test.js @@ -11,7 +11,7 @@ describe('Backups', () => { test('test method listArchives()', async () => { - const data = { + const data = { 'total': 5, 'archives': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Backups', () => { }); test('test method createArchive()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -50,7 +50,7 @@ describe('Backups', () => { }); test('test method getArchive()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -74,7 +74,7 @@ describe('Backups', () => { }); test('test method deleteArchive()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await backups.deleteArchive( @@ -88,7 +88,7 @@ describe('Backups', () => { }); test('test method listPolicies()', async () => { - const data = { + const data = { 'total': 5, 'policies': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -103,7 +103,7 @@ describe('Backups', () => { }); test('test method createPolicy()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'Hourly backups', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -129,7 +129,7 @@ describe('Backups', () => { }); test('test method getPolicy()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'Hourly backups', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -152,7 +152,7 @@ describe('Backups', () => { }); test('test method updatePolicy()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'Hourly backups', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -175,7 +175,7 @@ describe('Backups', () => { }); test('test method deletePolicy()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await backups.deletePolicy( @@ -189,7 +189,7 @@ describe('Backups', () => { }); test('test method createRestoration()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -215,7 +215,7 @@ describe('Backups', () => { }); test('test method listRestorations()', async () => { - const data = { + const data = { 'total': 5, 'restorations': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -230,7 +230,7 @@ describe('Backups', () => { }); test('test method getRestoration()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/databases.test.js b/test/services/databases.test.js index 6ed0b897..241f44f8 100644 --- a/test/services/databases.test.js +++ b/test/services/databases.test.js @@ -11,7 +11,7 @@ describe('Databases', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'databases': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Databases', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -49,7 +49,7 @@ describe('Databases', () => { }); test('test method listTransactions()', async () => { - const data = { + const data = { 'total': 5, 'transactions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -64,7 +64,7 @@ describe('Databases', () => { }); test('test method createTransaction()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -83,7 +83,7 @@ describe('Databases', () => { }); test('test method getTransaction()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -103,7 +103,7 @@ describe('Databases', () => { }); test('test method updateTransaction()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -123,7 +123,7 @@ describe('Databases', () => { }); test('test method deleteTransaction()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.deleteTransaction( @@ -137,7 +137,7 @@ describe('Databases', () => { }); test('test method createOperations()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -157,7 +157,7 @@ describe('Databases', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -179,7 +179,7 @@ describe('Databases', () => { }); test('test method update()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -201,7 +201,7 @@ describe('Databases', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.delete( @@ -215,7 +215,7 @@ describe('Databases', () => { }); test('test method listCollections()', async () => { - const data = { + const data = { 'total': 5, 'collections': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -231,7 +231,7 @@ describe('Databases', () => { }); test('test method createCollection()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -259,7 +259,7 @@ describe('Databases', () => { }); test('test method getCollection()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -286,7 +286,7 @@ describe('Databases', () => { }); test('test method updateCollection()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -313,7 +313,7 @@ describe('Databases', () => { }); test('test method deleteCollection()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.deleteCollection( @@ -328,7 +328,7 @@ describe('Databases', () => { }); test('test method listAttributes()', async () => { - const data = { + const data = { 'total': 5, 'attributes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -344,8 +344,57 @@ describe('Databases', () => { expect(response).toEqual(data); }); + test('test method createBigIntAttribute()', async () => { + const data = { + 'key': 'count', + 'type': 'bigint', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.createBigIntAttribute( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateBigIntAttribute()', async () => { + const data = { + 'key': 'count', + 'type': 'bigint', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await databases.updateBigIntAttribute( + '', + '', + '', + true, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBooleanAttribute()', async () => { - const data = { + const data = { 'key': 'isEnabled', 'type': 'boolean', 'status': 'available', @@ -369,7 +418,7 @@ describe('Databases', () => { }); test('test method updateBooleanAttribute()', async () => { - const data = { + const data = { 'key': 'isEnabled', 'type': 'boolean', 'status': 'available', @@ -394,7 +443,7 @@ describe('Databases', () => { }); test('test method createDatetimeAttribute()', async () => { - const data = { + const data = { 'key': 'birthDay', 'type': 'datetime', 'status': 'available', @@ -419,7 +468,7 @@ describe('Databases', () => { }); test('test method updateDatetimeAttribute()', async () => { - const data = { + const data = { 'key': 'birthDay', 'type': 'datetime', 'status': 'available', @@ -445,7 +494,7 @@ describe('Databases', () => { }); test('test method createEmailAttribute()', async () => { - const data = { + const data = { 'key': 'userEmail', 'type': 'string', 'status': 'available', @@ -470,7 +519,7 @@ describe('Databases', () => { }); test('test method updateEmailAttribute()', async () => { - const data = { + const data = { 'key': 'userEmail', 'type': 'string', 'status': 'available', @@ -496,7 +545,7 @@ describe('Databases', () => { }); test('test method createEnumAttribute()', async () => { - const data = { + const data = { 'key': 'status', 'type': 'string', 'status': 'available', @@ -523,7 +572,7 @@ describe('Databases', () => { }); test('test method updateEnumAttribute()', async () => { - const data = { + const data = { 'key': 'status', 'type': 'string', 'status': 'available', @@ -551,7 +600,7 @@ describe('Databases', () => { }); test('test method createFloatAttribute()', async () => { - const data = { + const data = { 'key': 'percentageCompleted', 'type': 'double', 'status': 'available', @@ -575,7 +624,7 @@ describe('Databases', () => { }); test('test method updateFloatAttribute()', async () => { - const data = { + const data = { 'key': 'percentageCompleted', 'type': 'double', 'status': 'available', @@ -600,7 +649,7 @@ describe('Databases', () => { }); test('test method createIntegerAttribute()', async () => { - const data = { + const data = { 'key': 'count', 'type': 'integer', 'status': 'available', @@ -624,7 +673,7 @@ describe('Databases', () => { }); test('test method updateIntegerAttribute()', async () => { - const data = { + const data = { 'key': 'count', 'type': 'integer', 'status': 'available', @@ -649,7 +698,7 @@ describe('Databases', () => { }); test('test method createIpAttribute()', async () => { - const data = { + const data = { 'key': 'ipAddress', 'type': 'string', 'status': 'available', @@ -674,7 +723,7 @@ describe('Databases', () => { }); test('test method updateIpAttribute()', async () => { - const data = { + const data = { 'key': 'ipAddress', 'type': 'string', 'status': 'available', @@ -700,7 +749,7 @@ describe('Databases', () => { }); test('test method createLineAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -724,7 +773,7 @@ describe('Databases', () => { }); test('test method updateLineAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -748,7 +797,7 @@ describe('Databases', () => { }); test('test method createLongtextAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -772,7 +821,7 @@ describe('Databases', () => { }); test('test method updateLongtextAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -797,7 +846,7 @@ describe('Databases', () => { }); test('test method createMediumtextAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -821,7 +870,7 @@ describe('Databases', () => { }); test('test method updateMediumtextAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -846,7 +895,7 @@ describe('Databases', () => { }); test('test method createPointAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -870,7 +919,7 @@ describe('Databases', () => { }); test('test method updatePointAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -894,7 +943,7 @@ describe('Databases', () => { }); test('test method createPolygonAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -918,7 +967,7 @@ describe('Databases', () => { }); test('test method updatePolygonAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -942,7 +991,7 @@ describe('Databases', () => { }); test('test method createRelationshipAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -972,7 +1021,7 @@ describe('Databases', () => { }); test('test method updateRelationshipAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1001,7 +1050,7 @@ describe('Databases', () => { }); test('test method createStringAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1027,7 +1076,7 @@ describe('Databases', () => { }); test('test method updateStringAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1053,7 +1102,7 @@ describe('Databases', () => { }); test('test method createTextAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1077,7 +1126,7 @@ describe('Databases', () => { }); test('test method updateTextAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1102,7 +1151,7 @@ describe('Databases', () => { }); test('test method createUrlAttribute()', async () => { - const data = { + const data = { 'key': 'githubUrl', 'type': 'string', 'status': 'available', @@ -1127,7 +1176,7 @@ describe('Databases', () => { }); test('test method updateUrlAttribute()', async () => { - const data = { + const data = { 'key': 'githubUrl', 'type': 'string', 'status': 'available', @@ -1153,7 +1202,7 @@ describe('Databases', () => { }); test('test method createVarcharAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1179,7 +1228,7 @@ describe('Databases', () => { }); test('test method updateVarcharAttribute()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1205,14 +1254,15 @@ describe('Databases', () => { }); test('test method getAttribute()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', + const data = { + 'key': 'fullName', + 'type': 'string', 'status': 'available', 'error': 'string', 'required': true, '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.getAttribute( @@ -1228,7 +1278,7 @@ describe('Databases', () => { }); test('test method deleteAttribute()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.deleteAttribute( @@ -1244,7 +1294,7 @@ describe('Databases', () => { }); test('test method listDocuments()', async () => { - const data = { + const data = { 'total': 5, 'documents': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1261,7 +1311,7 @@ describe('Databases', () => { }); test('test method createDocument()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$collectionId': '5e5ea5c15117e', @@ -1285,7 +1335,7 @@ describe('Databases', () => { }); test('test method createDocuments()', async () => { - const data = { + const data = { 'total': 5, 'documents': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1303,7 +1353,7 @@ describe('Databases', () => { }); test('test method upsertDocuments()', async () => { - const data = { + const data = { 'total': 5, 'documents': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1321,7 +1371,7 @@ describe('Databases', () => { }); test('test method updateDocuments()', async () => { - const data = { + const data = { 'total': 5, 'documents': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1338,7 +1388,7 @@ describe('Databases', () => { }); test('test method deleteDocuments()', async () => { - const data = { + const data = { 'total': 5, 'documents': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1355,7 +1405,7 @@ describe('Databases', () => { }); test('test method getDocument()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$collectionId': '5e5ea5c15117e', @@ -1378,7 +1428,7 @@ describe('Databases', () => { }); test('test method upsertDocument()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$collectionId': '5e5ea5c15117e', @@ -1401,7 +1451,7 @@ describe('Databases', () => { }); test('test method updateDocument()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$collectionId': '5e5ea5c15117e', @@ -1424,7 +1474,7 @@ describe('Databases', () => { }); test('test method deleteDocument()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.deleteDocument( @@ -1440,7 +1490,7 @@ describe('Databases', () => { }); test('test method decrementDocumentAttribute()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$collectionId': '5e5ea5c15117e', @@ -1464,7 +1514,7 @@ describe('Databases', () => { }); test('test method incrementDocumentAttribute()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$collectionId': '5e5ea5c15117e', @@ -1488,7 +1538,7 @@ describe('Databases', () => { }); test('test method listIndexes()', async () => { - const data = { + const data = { 'total': 5, 'indexes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1505,7 +1555,7 @@ describe('Databases', () => { }); test('test method createIndex()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1532,7 +1582,7 @@ describe('Databases', () => { }); test('test method getIndex()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1557,7 +1607,7 @@ describe('Databases', () => { }); test('test method deleteIndex()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await databases.deleteIndex( diff --git a/test/services/functions.test.js b/test/services/functions.test.js index b057cd62..f5e19c8d 100644 --- a/test/services/functions.test.js +++ b/test/services/functions.test.js @@ -11,7 +11,7 @@ describe('Functions', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'functions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Functions', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -72,7 +72,7 @@ describe('Functions', () => { }); test('test method listRuntimes()', async () => { - const data = { + const data = { 'total': 5, 'runtimes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -87,7 +87,7 @@ describe('Functions', () => { }); test('test method listSpecifications()', async () => { - const data = { + const data = { 'total': 5, 'specifications': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -102,7 +102,7 @@ describe('Functions', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -146,7 +146,7 @@ describe('Functions', () => { }); test('test method update()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -191,7 +191,7 @@ describe('Functions', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.delete( @@ -205,7 +205,7 @@ describe('Functions', () => { }); test('test method updateFunctionDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -250,7 +250,7 @@ describe('Functions', () => { }); test('test method listDeployments()', async () => { - const data = { + const data = { 'total': 5, 'deployments': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -266,7 +266,7 @@ describe('Functions', () => { }); test('test method createDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -309,7 +309,7 @@ describe('Functions', () => { }); test('test method createDuplicateDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -351,7 +351,7 @@ describe('Functions', () => { }); test('test method createTemplateDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -397,7 +397,7 @@ describe('Functions', () => { }); test('test method createVcsDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -440,7 +440,7 @@ describe('Functions', () => { }); test('test method getDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -482,7 +482,7 @@ describe('Functions', () => { }); test('test method deleteDeployment()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.deleteDeployment( @@ -512,7 +512,7 @@ describe('Functions', () => { }); test('test method updateDeploymentStatus()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -554,7 +554,7 @@ describe('Functions', () => { }); test('test method listExecutions()', async () => { - const data = { + const data = { 'total': 5, 'executions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -570,7 +570,7 @@ describe('Functions', () => { }); test('test method createExecution()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -601,7 +601,7 @@ describe('Functions', () => { }); test('test method getExecution()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -633,7 +633,7 @@ describe('Functions', () => { }); test('test method deleteExecution()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.deleteExecution( @@ -648,7 +648,7 @@ describe('Functions', () => { }); test('test method listVariables()', async () => { - const data = { + const data = { 'total': 5, 'variables': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -664,7 +664,7 @@ describe('Functions', () => { }); test('test method createVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -677,6 +677,7 @@ describe('Functions', () => { const response = await functions.createVariable( '', + '', '', '', ); @@ -688,7 +689,7 @@ describe('Functions', () => { }); test('test method getVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -711,7 +712,7 @@ describe('Functions', () => { }); test('test method updateVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -725,7 +726,6 @@ describe('Functions', () => { const response = await functions.updateVariable( '', '', - '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -735,7 +735,7 @@ describe('Functions', () => { }); test('test method deleteVariable()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await functions.deleteVariable( diff --git a/test/services/graphql.test.js b/test/services/graphql.test.js index 3ff83bbd..da7e49bf 100644 --- a/test/services/graphql.test.js +++ b/test/services/graphql.test.js @@ -11,7 +11,7 @@ describe('Graphql', () => { test('test method query()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await graphql.query( @@ -25,7 +25,7 @@ describe('Graphql', () => { }); test('test method mutation()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await graphql.mutation( diff --git a/test/services/health.test.js b/test/services/health.test.js index 75178b52..17f087e2 100644 --- a/test/services/health.test.js +++ b/test/services/health.test.js @@ -11,7 +11,7 @@ describe('Health', () => { test('test method get()', async () => { - const data = { + const data = { 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -27,7 +27,7 @@ describe('Health', () => { }); test('test method getAntivirus()', async () => { - const data = { + const data = { 'version': '1.0.0', 'status': 'online',}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -42,7 +42,7 @@ describe('Health', () => { }); test('test method getCache()', async () => { - const data = { + const data = { 'total': 5, 'statuses': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -57,7 +57,7 @@ describe('Health', () => { }); test('test method getCertificate()', async () => { - const data = { + const data = { 'name': '/CN=www.google.com', 'subjectSN': '', 'issuerOrganisation': '', @@ -76,7 +76,7 @@ describe('Health', () => { }); test('test method getConsolePausing()', async () => { - const data = { + const data = { 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -92,7 +92,7 @@ describe('Health', () => { }); test('test method getDB()', async () => { - const data = { + const data = { 'total': 5, 'statuses': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -107,7 +107,7 @@ describe('Health', () => { }); test('test method getPubSub()', async () => { - const data = { + const data = { 'total': 5, 'statuses': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -122,7 +122,7 @@ describe('Health', () => { }); test('test method getQueueAudits()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -136,7 +136,7 @@ describe('Health', () => { }); test('test method getQueueBuilds()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -150,7 +150,7 @@ describe('Health', () => { }); test('test method getQueueCertificates()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -164,7 +164,7 @@ describe('Health', () => { }); test('test method getQueueDatabases()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -178,7 +178,7 @@ describe('Health', () => { }); test('test method getQueueDeletes()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -192,7 +192,7 @@ describe('Health', () => { }); test('test method getFailedJobs()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -207,7 +207,7 @@ describe('Health', () => { }); test('test method getQueueFunctions()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -221,7 +221,7 @@ describe('Health', () => { }); test('test method getQueueLogs()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -235,7 +235,7 @@ describe('Health', () => { }); test('test method getQueueMails()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -249,7 +249,7 @@ describe('Health', () => { }); test('test method getQueueMessaging()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -263,7 +263,7 @@ describe('Health', () => { }); test('test method getQueueMigrations()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -277,7 +277,7 @@ describe('Health', () => { }); test('test method getQueueStatsResources()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -291,7 +291,7 @@ describe('Health', () => { }); test('test method getQueueUsage()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -305,7 +305,7 @@ describe('Health', () => { }); test('test method getQueueWebhooks()', async () => { - const data = { + const data = { 'size': 8,}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -319,7 +319,7 @@ describe('Health', () => { }); test('test method getStorage()', async () => { - const data = { + const data = { 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -335,7 +335,7 @@ describe('Health', () => { }); test('test method getStorageLocal()', async () => { - const data = { + const data = { 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -351,7 +351,7 @@ describe('Health', () => { }); test('test method getTime()', async () => { - const data = { + const data = { 'remoteTime': 1639490751, 'localTime': 1639490844, 'diff': 93,}; diff --git a/test/services/locale.test.js b/test/services/locale.test.js index 4667641d..51ef111e 100644 --- a/test/services/locale.test.js +++ b/test/services/locale.test.js @@ -11,7 +11,7 @@ describe('Locale', () => { test('test method get()', async () => { - const data = { + const data = { 'ip': '127.0.0.1', 'countryCode': 'US', 'country': 'United States', @@ -31,7 +31,7 @@ describe('Locale', () => { }); test('test method listCodes()', async () => { - const data = { + const data = { 'total': 5, 'localeCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -46,7 +46,7 @@ describe('Locale', () => { }); test('test method listContinents()', async () => { - const data = { + const data = { 'total': 5, 'continents': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -61,7 +61,7 @@ describe('Locale', () => { }); test('test method listCountries()', async () => { - const data = { + const data = { 'total': 5, 'countries': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -76,7 +76,7 @@ describe('Locale', () => { }); test('test method listCountriesEU()', async () => { - const data = { + const data = { 'total': 5, 'countries': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -91,7 +91,7 @@ describe('Locale', () => { }); test('test method listCountriesPhones()', async () => { - const data = { + const data = { 'total': 5, 'phones': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -106,7 +106,7 @@ describe('Locale', () => { }); test('test method listCurrencies()', async () => { - const data = { + const data = { 'total': 5, 'currencies': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -121,7 +121,7 @@ describe('Locale', () => { }); test('test method listLanguages()', async () => { - const data = { + const data = { 'total': 5, 'languages': [],}; mockedFetch.mockImplementation(() => Response.json(data)); diff --git a/test/services/messaging.test.js b/test/services/messaging.test.js index 40931583..f327a32d 100644 --- a/test/services/messaging.test.js +++ b/test/services/messaging.test.js @@ -11,7 +11,7 @@ describe('Messaging', () => { test('test method listMessages()', async () => { - const data = { + const data = { 'total': 5, 'messages': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Messaging', () => { }); test('test method createEmail()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -52,7 +52,7 @@ describe('Messaging', () => { }); test('test method updateEmail()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -76,7 +76,7 @@ describe('Messaging', () => { }); test('test method createPush()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -100,7 +100,7 @@ describe('Messaging', () => { }); test('test method updatePush()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -124,7 +124,7 @@ describe('Messaging', () => { }); test('test method createSms()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -149,7 +149,7 @@ describe('Messaging', () => { }); test('test method createSMS()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -174,7 +174,7 @@ describe('Messaging', () => { }); test('test method updateSms()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -198,7 +198,7 @@ describe('Messaging', () => { }); test('test method updateSMS()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -222,7 +222,7 @@ describe('Messaging', () => { }); test('test method getMessage()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -246,7 +246,7 @@ describe('Messaging', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await messaging.delete( @@ -260,7 +260,7 @@ describe('Messaging', () => { }); test('test method listMessageLogs()', async () => { - const data = { + const data = { 'total': 5, 'logs': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -276,7 +276,7 @@ describe('Messaging', () => { }); test('test method listTargets()', async () => { - const data = { + const data = { 'total': 5, 'targets': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -292,7 +292,7 @@ describe('Messaging', () => { }); test('test method listProviders()', async () => { - const data = { + const data = { 'total': 5, 'providers': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -307,7 +307,7 @@ describe('Messaging', () => { }); test('test method createApnsProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -330,7 +330,7 @@ describe('Messaging', () => { }); test('test method createAPNSProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -353,7 +353,7 @@ describe('Messaging', () => { }); test('test method updateApnsProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -375,7 +375,7 @@ describe('Messaging', () => { }); test('test method updateAPNSProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -397,7 +397,7 @@ describe('Messaging', () => { }); test('test method createFcmProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -420,7 +420,7 @@ describe('Messaging', () => { }); test('test method createFCMProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -443,7 +443,7 @@ describe('Messaging', () => { }); test('test method updateFcmProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -465,7 +465,7 @@ describe('Messaging', () => { }); test('test method updateFCMProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -487,7 +487,7 @@ describe('Messaging', () => { }); test('test method createMailgunProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -510,7 +510,7 @@ describe('Messaging', () => { }); test('test method updateMailgunProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -532,7 +532,7 @@ describe('Messaging', () => { }); test('test method createMsg91Provider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -555,7 +555,7 @@ describe('Messaging', () => { }); test('test method updateMsg91Provider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -577,7 +577,7 @@ describe('Messaging', () => { }); test('test method createResendProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -600,7 +600,7 @@ describe('Messaging', () => { }); test('test method updateResendProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -622,7 +622,7 @@ describe('Messaging', () => { }); test('test method createSendgridProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -645,7 +645,7 @@ describe('Messaging', () => { }); test('test method updateSendgridProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -667,7 +667,7 @@ describe('Messaging', () => { }); test('test method createSmtpProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -691,7 +691,7 @@ describe('Messaging', () => { }); test('test method createSMTPProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -715,7 +715,7 @@ describe('Messaging', () => { }); test('test method updateSmtpProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -737,7 +737,7 @@ describe('Messaging', () => { }); test('test method updateSMTPProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -759,7 +759,7 @@ describe('Messaging', () => { }); test('test method createTelesignProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -782,7 +782,7 @@ describe('Messaging', () => { }); test('test method updateTelesignProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -804,7 +804,7 @@ describe('Messaging', () => { }); test('test method createTextmagicProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -827,7 +827,7 @@ describe('Messaging', () => { }); test('test method updateTextmagicProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -849,7 +849,7 @@ describe('Messaging', () => { }); test('test method createTwilioProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -872,7 +872,7 @@ describe('Messaging', () => { }); test('test method updateTwilioProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -894,7 +894,7 @@ describe('Messaging', () => { }); test('test method createVonageProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -917,7 +917,7 @@ describe('Messaging', () => { }); test('test method updateVonageProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -939,7 +939,7 @@ describe('Messaging', () => { }); test('test method getProvider()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -961,7 +961,7 @@ describe('Messaging', () => { }); test('test method deleteProvider()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await messaging.deleteProvider( @@ -975,7 +975,7 @@ describe('Messaging', () => { }); test('test method listProviderLogs()', async () => { - const data = { + const data = { 'total': 5, 'logs': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -991,7 +991,7 @@ describe('Messaging', () => { }); test('test method listSubscriberLogs()', async () => { - const data = { + const data = { 'total': 5, 'logs': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1007,7 +1007,7 @@ describe('Messaging', () => { }); test('test method listTopics()', async () => { - const data = { + const data = { 'total': 5, 'topics': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1022,7 +1022,7 @@ describe('Messaging', () => { }); test('test method createTopic()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1045,7 +1045,7 @@ describe('Messaging', () => { }); test('test method getTopic()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1067,7 +1067,7 @@ describe('Messaging', () => { }); test('test method updateTopic()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1089,7 +1089,7 @@ describe('Messaging', () => { }); test('test method deleteTopic()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await messaging.deleteTopic( @@ -1103,7 +1103,7 @@ describe('Messaging', () => { }); test('test method listTopicLogs()', async () => { - const data = { + const data = { 'total': 5, 'logs': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1119,7 +1119,7 @@ describe('Messaging', () => { }); test('test method listSubscribers()', async () => { - const data = { + const data = { 'total': 5, 'subscribers': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1135,7 +1135,7 @@ describe('Messaging', () => { }); test('test method createSubscriber()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1160,7 +1160,7 @@ describe('Messaging', () => { }); test('test method getSubscriber()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1184,7 +1184,7 @@ describe('Messaging', () => { }); test('test method deleteSubscriber()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await messaging.deleteSubscriber( diff --git a/test/services/presences.test.js b/test/services/presences.test.js new file mode 100644 index 00000000..49e35fc1 --- /dev/null +++ b/test/services/presences.test.js @@ -0,0 +1,110 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Presences } = require("../../dist/services/presences"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Presences', () => { + const client = new Client(); + const presences = new Presences(client); + + + test('test method list()', async () => { + const data = { + 'total': 5, + 'presences': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await presences.list( + ); + + // 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', + '\$sequence': '1', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userInternalId': '1', + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await presences.get( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method upsert()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userInternalId': '1', + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await presences.upsert( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePresence()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userInternalId': '1', + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await presences.updatePresence( + '', + '', + ); + + // 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 presences.delete( + '', + ); + + // 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/project.test.js b/test/services/project.test.js index 6e273b69..06fe2715 100644 --- a/test/services/project.test.js +++ b/test/services/project.test.js @@ -10,8 +10,117 @@ describe('Project', () => { const project = new Project(client); + test('test method delete()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.delete( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateAuthMethod()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateAuthMethod( + 'email-password', + true, + ); + + // 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 = { + const data = { 'total': 5, 'keys': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +135,7 @@ describe('Project', () => { }); test('test method createKey()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -50,8 +159,32 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method createEphemeralKey()', 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 API Key', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'scopes': [], + 'secret': '919c2d18fb5d4...a2ae413da83346ad2', + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + 'sdks': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createEphemeralKey( + [], + 1, + ); + + // 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 = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -74,7 +207,7 @@ describe('Project', () => { }); test('test method updateKey()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -99,7 +232,7 @@ describe('Project', () => { }); test('test method deleteKey()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.deleteKey( @@ -113,7 +246,7 @@ describe('Project', () => { }); test('test method updateLabels()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -142,6 +275,8 @@ describe('Project', () => { 'authMembershipsUserName': true, 'authMembershipsUserEmail': true, 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, 'authInvalidateSessions': true, 'oAuthProviders': [], 'platforms': [], @@ -151,11 +286,12 @@ describe('Project', () => { 'smtpEnabled': true, 'smtpSenderName': 'John Appwrite', 'smtpSenderEmail': 'john@appwrite.io', - 'smtpReplyTo': 'support@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', 'smtpHost': 'mail.appwrite.io', 'smtpPort': 25, 'smtpUsername': 'emailuser', - 'smtpPassword': 'securepassword', + 'smtpPassword': '', 'smtpSecure': 'tls', 'pingCount': 1, 'pingedAt': '2020-10-15T06:38:00.000+00:00', @@ -204,13 +340,13 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method listPlatforms()', async () => { - const data = { + test('test method listMockPhones()', async () => { + const data = { 'total': 5, - 'platforms': [],}; + 'mockNumbers': [],}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.listPlatforms( + const response = await project.listMockPhones( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -219,20 +355,17 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createAndroidPlatform()', async () => { - const data = { - '\$id': '5e5ea5c16897e', + test('test method createMockPhone()', async () => { + const data = { + 'number': '+1612842323', + 'otp': '123456', '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'My Web App', - 'type': 'web', - 'applicationId': 'com.company.appname',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createAndroidPlatform( - '', - '', - '', + const response = await project.createMockPhone( + '+12065550100', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -241,20 +374,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateAndroidPlatform()', async () => { - const data = { - '\$id': '5e5ea5c16897e', + test('test method getMockPhone()', async () => { + const data = { + 'number': '+1612842323', + 'otp': '123456', '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'My Web App', - 'type': 'web', - 'applicationId': 'com.company.appname',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateAndroidPlatform( - '', - '', - '', + const response = await project.getMockPhone( + '+12065550100', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -263,20 +392,17 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createApplePlatform()', async () => { - const data = { - '\$id': '5e5ea5c16897e', + test('test method updateMockPhone()', async () => { + const data = { + 'number': '+1612842323', + 'otp': '123456', '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'My Web App', - 'type': 'web', - 'bundleIdentifier': 'com.company.appname',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createApplePlatform( - '', - '', - '', + const response = await project.updateMockPhone( + '+12065550100', + '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -285,20 +411,12 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateApplePlatform()', 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 Web App', - 'type': 'web', - 'bundleIdentifier': 'com.company.appname',}; + test('test method deleteMockPhone()', async () => { + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateApplePlatform( - '', - '', - '', + const response = await project.deleteMockPhone( + '+12065550100', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -307,20 +425,13 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createLinuxPlatform()', 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 Web App', - 'type': 'web', - 'packageName': 'com.company.appname',}; + test('test method listOAuth2Providers()', async () => { + const data = { + 'total': 5, + 'providers': [],}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createLinuxPlatform( - '', - '', - '', + const response = await project.listOAuth2Providers( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -329,20 +440,17 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateLinuxPlatform()', 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 Web App', - 'type': 'web', - 'packageName': 'com.company.appname',}; + test('test method getOAuth2Provider()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'applicationId': '00001111-aaaa-2222-bbbb-3333cccc4444', + 'applicationSecret': 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', + 'tenant': 'common',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateLinuxPlatform( - '', - '', - '', + const response = await project.getOAuth2Provider( + 'amazon', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -351,20 +459,15 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createWebPlatform()', 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 Web App', - 'type': 'web', - 'hostname': 'app.example.com',}; + test('test method updateOAuth2Amazon()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'amzn1.application-oa2-client.87400c00000000000000000000063d5b2', + 'clientSecret': '79ffe4000000000000000000000000000000000000000000000000000002de55',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createWebPlatform( - '', - '', - 'app.example.com', + const response = await project.updateOAuth2Amazon( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -373,20 +476,17 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateWebPlatform()', 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 Web App', - 'type': 'web', - 'hostname': 'app.example.com',}; + test('test method updateOAuth2Apple()', async () => { + const data = { + '\$id': 'apple', + 'enabled': true, + 'serviceId': 'ip.appwrite.app.web', + 'keyId': 'P4000000N8', + 'teamId': 'D4000000R6', + 'p8File': '-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateWebPlatform( - '', - '', - 'app.example.com', + const response = await project.updateOAuth2Apple( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -395,20 +495,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method createWindowsPlatform()', 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 Web App', - 'type': 'web', - 'packageIdentifierName': 'com.company.appname',}; + test('test method updateOAuth2Auth0()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'OaOkIA000000000000000000005KLSYq', + 'clientSecret': 'zXz0000-00000000000000000000000000000-00000000000000000000PJafnF', + 'endpoint': 'example.us.auth0.com',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.createWindowsPlatform( - '', - '', - '', + const response = await project.updateOAuth2Auth0( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -417,20 +513,16 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateWindowsPlatform()', 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 Web App', - 'type': 'web', - 'packageIdentifierName': 'com.company.appname',}; + test('test method updateOAuth2Authentik()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'dTKOPa0000000000000000000000000000e7G8hv', + 'clientSecret': 'ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK', + 'endpoint': 'example.authentik.com',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateWindowsPlatform( - '', - '', - '', + const response = await project.updateOAuth2Authentik( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -439,18 +531,15 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method getPlatform()', 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 Web App', - 'type': 'web', - 'hostname': 'app.example.com',}; + test('test method updateOAuth2Autodesk()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '5zw90v00000000000000000000kVYXN7', + 'clientSecret': '7I000000000000MW',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.getPlatform( - '', + const response = await project.updateOAuth2Autodesk( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -459,12 +548,15 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method deletePlatform()', async () => { - const data = {message: ""}; + test('test method updateOAuth2Bitbucket()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'key': 'Knt70000000000ByRc', + 'secret': 'NMfLZJ00000000000000000000TLQdDx',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.deletePlatform( - '', + const response = await project.updateOAuth2Bitbucket( ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -473,24 +565,1805 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateProtocolStatus()', async () => { - const data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'New Project', - 'description': 'This is a new project.', - 'teamId': '1592981250', - 'logo': '5f5c451b403cb', - 'url': '5f5c451b403cb', - 'legalName': 'Company LTD.', - 'legalCountry': 'US', - 'legalState': 'New York', - 'legalCity': 'New York City.', - 'legalAddress': '620 Eighth Avenue, New York, NY 10018', - 'legalTaxId': '131102020', - 'authDuration': 60, - 'authLimit': 100, + test('test method updateOAuth2Bitly()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'd95151000000000000000000000000000067af9b', + 'clientSecret': 'a13e250000000000000000000000000000d73095',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Bitly( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Box()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'deglcs00000000000000000000x2og6y', + 'clientSecret': 'OKM1f100000000000000000000eshEif',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Box( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Dailymotion()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'apiKey': '07a9000000000000067f', + 'apiSecret': 'a399a90000000000000000000000000000d90639',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Dailymotion( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Discord()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '950722000000343754', + 'clientSecret': 'YmPXnM000000000000000000002zFg5D',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Discord( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Disqus()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'publicKey': 'cgegH70000000000000000000000000000000000000000000000000000Hr1nYX', + 'secretKey': 'W7Bykj00000000000000000000000000000000000000000000000000003o43w9',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Disqus( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Dropbox()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'appKey': 'jl000000000009t', + 'appSecret': 'g200000000000vw',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Dropbox( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Etsy()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'keyString': 'nsgzxh0000000000008j85a2', + 'sharedSecret': 'tp000000ru',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Etsy( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Facebook()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'appId': '260600000007694', + 'appSecret': '2d0b2800000000000000000000d38af4',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Facebook( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Figma()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'byay5H0000000000VtiI40', + 'clientSecret': 'yEpOYn0000000000000000004iIsU5',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Figma( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2FusionAuth()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'b2222c00-0000-0000-0000-000000862097', + 'clientSecret': 'Jx4s0C0000000000000000000000000000000wGqLsc', + 'endpoint': 'example.fusionauth.io',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2FusionAuth( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2GitHub()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'e4d87900000000540733', + 'clientSecret': '5e07c00000000000000000000000000000198bcc',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2GitHub( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Gitlab()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'applicationId': 'd41ffe0000000000000000000000000000000000000000000000000000d5e252', + 'secret': 'gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38', + 'endpoint': 'https://gitlab.com',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Gitlab( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Google()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'your-google-client-id.apps.googleusercontent.com', + 'clientSecret': 'your-google-client-secret',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Google( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Keycloak()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'appwrite-o0000000st-app', + 'clientSecret': 'jdjrJd00000000000000000000HUsaZO', + 'endpoint': 'keycloak.example.com', + 'realmName': 'appwrite-realm',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Keycloak( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Kick()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '01KQ7C00000000000001MFHS32', + 'clientSecret': '34ac5600000000000000000000000000000000000000000000000000e830c8b',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Kick( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Linkedin()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '770000000000dv', + 'primaryClientSecret': 'your-linkedin-client-secret',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Linkedin( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Microsoft()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'applicationId': '00001111-aaaa-2222-bbbb-3333cccc4444', + 'applicationSecret': 'A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u', + 'tenant': 'common',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Microsoft( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Notion()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'oauthClientId': '341d8700-0000-0000-0000-000000446ee3', + 'oauthClientSecret': 'secret_dLUr4b000000000000000000000000000000lFHAa9',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Notion( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Oidc()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'qibI2x0000000000000000000000000006L2YFoG', + 'clientSecret': 'Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV', + 'wellKnownURL': 'https://myoauth.com/.well-known/openid-configuration', + 'authorizationURL': 'https://myoauth.com/oauth2/authorize', + 'tokenURL': 'https://myoauth.com/oauth2/token', + 'userInfoURL': 'https://myoauth.com/oauth2/userinfo',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Oidc( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Okta()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '0oa00000000000000698', + 'clientSecret': 'Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV', + 'domain': 'trial-6400025.okta.com', + 'authorizationServerId': 'aus000000000000000h7z',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Okta( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Paypal()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', + 'secretKey': 'EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Paypal( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2PaypalSandbox()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB', + 'secretKey': 'EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2PaypalSandbox( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Podio()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'appwrite-oauth-test-app', + 'clientSecret': 'Rn247T0000000000000000000000000000000000000000000000000000W2zWTN',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Podio( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Salesforce()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'customerKey': '3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq', + 'customerSecret': '3w000000000000e2',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Salesforce( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Slack()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '23000000089.15000000000023', + 'clientSecret': '81656000000000000000000000f3d2fd',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Slack( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Spotify()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '6ec271000000000000000000009beace', + 'clientSecret': 'db068a000000000000000000008b5b9f',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Spotify( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Stripe()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'ca_UKibXX0000000000000000000006byvR', + 'apiSecretKey': 'sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Stripe( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Tradeshift()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'oauth2ClientId': 'appwrite-test-org.appwrite-test-app', + 'oauth2ClientSecret': '7cb52700-0000-0000-0000-000000ca5b83',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Tradeshift( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2TradeshiftSandbox()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'oauth2ClientId': 'appwrite-test-org.appwrite-test-app', + 'oauth2ClientSecret': '7cb52700-0000-0000-0000-000000ca5b83',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2TradeshiftSandbox( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Twitch()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'vvi0in000000000000000000ikmt9p', + 'clientSecret': 'pmapue000000000000000000zylw3v',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Twitch( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2WordPress()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '130005', + 'clientSecret': 'PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2WordPress( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2X()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'customerKey': 'slzZV0000000000000NFLaWT', + 'secretKey': 'tkEPkp00000000000000000000000000000000000000FTxbI9',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2X( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Yahoo()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm', + 'clientSecret': 'cf978f0000000000000000000000000000c5e2e9',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Yahoo( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Yandex()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '6a8a6a0000000000000000000091483c', + 'clientSecret': 'bbf98500000000000000000000c75a63',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Yandex( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Zoho()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': '1000.83C178000000000000000000RPNX0B', + 'clientSecret': 'fb5cac000000000000000000000000000000a68f6e',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Zoho( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateOAuth2Zoom()', async () => { + const data = { + '\$id': 'github', + 'enabled': true, + 'clientId': 'QMAC00000000000000w0AQ', + 'clientSecret': 'GAWsG4000000000000000000007U01ON',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateOAuth2Zoom( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listPlatforms()', async () => { + const data = { + 'total': 5, + 'platforms': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.listPlatforms( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createAndroidPlatform()', 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 Web App', + 'type': 'web', + 'applicationId': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createAndroidPlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateAndroidPlatform()', 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 Web App', + 'type': 'web', + 'applicationId': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateAndroidPlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createApplePlatform()', 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 Web App', + 'type': 'web', + 'bundleIdentifier': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createApplePlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateApplePlatform()', 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 Web App', + 'type': 'web', + 'bundleIdentifier': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateApplePlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createLinuxPlatform()', 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 Web App', + 'type': 'web', + 'packageName': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createLinuxPlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateLinuxPlatform()', 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 Web App', + 'type': 'web', + 'packageName': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateLinuxPlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createWebPlatform()', 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 Web App', + 'type': 'web', + 'hostname': 'app.example.com',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createWebPlatform( + '', + '', + 'app.example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateWebPlatform()', 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 Web App', + 'type': 'web', + 'hostname': 'app.example.com',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateWebPlatform( + '', + '', + 'app.example.com', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createWindowsPlatform()', 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 Web App', + 'type': 'web', + 'packageIdentifierName': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createWindowsPlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateWindowsPlatform()', 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 Web App', + 'type': 'web', + 'packageIdentifierName': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateWindowsPlatform( + '', + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPlatform()', 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 Web App', + 'type': 'web', + 'packageName': 'com.company.appname',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.getPlatform( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deletePlatform()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.deletePlatform( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listPolicies()', async () => { + const data = { + 'total': 9, + 'policies': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.listPolicies( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateMembershipPrivacyPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateMembershipPrivacyPolicy( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePasswordDictionaryPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updatePasswordDictionaryPolicy( + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePasswordHistoryPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updatePasswordHistoryPolicy( + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updatePasswordPersonalDataPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updatePasswordPersonalDataPolicy( + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSessionAlertPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateSessionAlertPolicy( + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSessionDurationPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateSessionDurationPolicy( + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSessionInvalidationPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateSessionInvalidationPolicy( + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateSessionLimitPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateSessionLimitPolicy( + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateUserLimitPolicy()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateUserLimitPolicy( + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getPolicy()', async () => { + const data = { + '\$id': 'password-dictionary', + 'userId': true, + 'userEmail': true, + 'userPhone': true, + 'userName': true, + 'userMFA': true,}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.getPolicy( + 'password-dictionary', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateProtocol()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, 'authSessionsLimit': 10, 'authPasswordHistory': 5, 'authPasswordDictionary': true, @@ -503,6 +2376,8 @@ describe('Project', () => { 'authMembershipsUserName': true, 'authMembershipsUserEmail': true, 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, 'authInvalidateSessions': true, 'oAuthProviders': [], 'platforms': [], @@ -512,11 +2387,12 @@ describe('Project', () => { 'smtpEnabled': true, 'smtpSenderName': 'John Appwrite', 'smtpSenderEmail': 'john@appwrite.io', - 'smtpReplyTo': 'support@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', 'smtpHost': 'mail.appwrite.io', 'smtpPort': 25, 'smtpUsername': 'emailuser', - 'smtpPassword': 'securepassword', + 'smtpPassword': '', 'smtpSecure': 'tls', 'pingCount': 1, 'pingedAt': '2020-10-15T06:38:00.000+00:00', @@ -555,7 +2431,7 @@ describe('Project', () => { 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateProtocolStatus( + const response = await project.updateProtocol( 'rest', true, ); @@ -566,8 +2442,8 @@ describe('Project', () => { expect(response).toEqual(data); }); - test('test method updateServiceStatus()', async () => { - const data = { + test('test method updateService()', async () => { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -596,6 +2472,8 @@ describe('Project', () => { 'authMembershipsUserName': true, 'authMembershipsUserEmail': true, 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, 'authInvalidateSessions': true, 'oAuthProviders': [], 'platforms': [], @@ -605,11 +2483,12 @@ describe('Project', () => { 'smtpEnabled': true, 'smtpSenderName': 'John Appwrite', 'smtpSenderEmail': 'john@appwrite.io', - 'smtpReplyTo': 'support@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', 'smtpHost': 'mail.appwrite.io', 'smtpPort': 25, 'smtpUsername': 'emailuser', - 'smtpPassword': 'securepassword', + 'smtpPassword': '', 'smtpSecure': 'tls', 'pingCount': 1, 'pingedAt': '2020-10-15T06:38:00.000+00:00', @@ -648,7 +2527,7 @@ describe('Project', () => { 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; mockedFetch.mockImplementation(() => Response.json(data)); - const response = await project.updateServiceStatus( + const response = await project.updateService( 'account', true, ); @@ -659,8 +2538,175 @@ describe('Project', () => { expect(response).toEqual(data); }); + test('test method updateSMTP()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'New Project', + 'description': 'This is a new project.', + 'teamId': '1592981250', + 'logo': '5f5c451b403cb', + 'url': '5f5c451b403cb', + 'legalName': 'Company LTD.', + 'legalCountry': 'US', + 'legalState': 'New York', + 'legalCity': 'New York City.', + 'legalAddress': '620 Eighth Avenue, New York, NY 10018', + 'legalTaxId': '131102020', + 'authDuration': 60, + 'authLimit': 100, + 'authSessionsLimit': 10, + 'authPasswordHistory': 5, + 'authPasswordDictionary': true, + 'authPersonalDataCheck': true, + 'authDisposableEmails': true, + 'authCanonicalEmails': true, + 'authFreeEmails': true, + 'authMockNumbers': [], + 'authSessionAlerts': true, + 'authMembershipsUserName': true, + 'authMembershipsUserEmail': true, + 'authMembershipsMfa': true, + 'authMembershipsUserId': true, + 'authMembershipsUserPhone': true, + 'authInvalidateSessions': true, + 'oAuthProviders': [], + 'platforms': [], + 'webhooks': [], + 'keys': [], + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': 'John Appwrite', + 'smtpSenderEmail': 'john@appwrite.io', + 'smtpReplyToName': 'Support Team', + 'smtpReplyToEmail': 'support@appwrite.io', + 'smtpHost': 'mail.appwrite.io', + 'smtpPort': 25, + 'smtpUsername': 'emailuser', + 'smtpPassword': '', + 'smtpSecure': 'tls', + 'pingCount': 1, + 'pingedAt': '2020-10-15T06:38:00.000+00:00', + 'labels': [], + 'status': 'active', + 'authEmailPassword': true, + 'authUsersAuthMagicURL': true, + 'authEmailOtp': true, + 'authAnonymous': true, + 'authInvites': true, + 'authJWT': true, + 'authPhone': true, + 'serviceStatusForAccount': true, + 'serviceStatusForAvatars': true, + 'serviceStatusForDatabases': true, + 'serviceStatusForTablesdb': true, + 'serviceStatusForLocale': true, + 'serviceStatusForHealth': true, + 'serviceStatusForProject': true, + 'serviceStatusForStorage': true, + 'serviceStatusForTeams': true, + 'serviceStatusForUsers': true, + 'serviceStatusForVcs': true, + 'serviceStatusForSites': true, + 'serviceStatusForFunctions': true, + 'serviceStatusForProxy': true, + 'serviceStatusForGraphql': true, + 'serviceStatusForMigrations': true, + 'serviceStatusForMessaging': true, + 'protocolStatusForRest': true, + 'protocolStatusForGraphql': true, + 'protocolStatusForWebsocket': true, + 'region': 'fra', + 'billingLimits': {}, + 'blocks': [], + 'consoleAccessedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateSMTP( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSMTPTest()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.createSMTPTest( + [], + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method listEmailTemplates()', async () => { + const data = { + 'total': 5, + 'templates': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.listEmailTemplates( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateEmailTemplate()', async () => { + const data = { + 'templateId': 'verification', + 'locale': 'en_us', + 'message': 'Click on the link to verify your account.', + 'senderName': 'My User', + 'senderEmail': 'mail@appwrite.io', + 'replyToEmail': 'emails@appwrite.io', + 'replyToName': 'Support Team', + 'subject': 'Please verify your email address',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.updateEmailTemplate( + 'verification', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getEmailTemplate()', async () => { + const data = { + 'templateId': 'verification', + 'locale': 'en_us', + 'message': 'Click on the link to verify your account.', + 'senderName': 'My User', + 'senderEmail': 'mail@appwrite.io', + 'replyToEmail': 'emails@appwrite.io', + 'replyToName': 'Support Team', + 'subject': 'Please verify your email address',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await project.getEmailTemplate( + 'verification', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method listVariables()', async () => { - const data = { + const data = { 'total': 5, 'variables': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -675,7 +2721,7 @@ describe('Project', () => { }); test('test method createVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -699,7 +2745,7 @@ describe('Project', () => { }); test('test method getVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -721,7 +2767,7 @@ describe('Project', () => { }); test('test method updateVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -743,7 +2789,7 @@ describe('Project', () => { }); test('test method deleteVariable()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await project.deleteVariable( diff --git a/test/services/proxy.test.js b/test/services/proxy.test.js new file mode 100644 index 00000000..05a556ff --- /dev/null +++ b/test/services/proxy.test.js @@ -0,0 +1,215 @@ +const { Client } = require("../../dist/client"); +const { InputFile } = require("../../dist/inputFile"); +const { Proxy } = require("../../dist/services/proxy"); + +const { fetch: mockedFetch, Response } = require("node-fetch-native-with-agent"); +jest.mock('node-fetch-native-with-agent', () => ({ ...jest.requireActual('node-fetch-native-with-agent'), fetch: jest.fn() })); + +describe('Proxy', () => { + const client = new Client(); + const proxy = new Proxy(client); + + + test('test method listRules()', async () => { + const data = { + 'total': 5, + 'rules': [],}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.listRules( + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createAPIRule()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'domain': 'appwrite.company.com', + 'type': 'deployment', + 'trigger': 'manual', + 'redirectUrl': 'https://appwrite.io/docs', + 'redirectStatusCode': 301, + 'deploymentId': 'n3u9feiwmf', + 'deploymentResourceId': 'n3u9feiwmf', + 'deploymentVcsProviderBranch': 'main', + 'status': 'verified', + 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + 'renewAt': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.createAPIRule( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createFunctionRule()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'domain': 'appwrite.company.com', + 'type': 'deployment', + 'trigger': 'manual', + 'redirectUrl': 'https://appwrite.io/docs', + 'redirectStatusCode': 301, + 'deploymentId': 'n3u9feiwmf', + 'deploymentResourceId': 'n3u9feiwmf', + 'deploymentVcsProviderBranch': 'main', + 'status': 'verified', + 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + 'renewAt': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.createFunctionRule( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createRedirectRule()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'domain': 'appwrite.company.com', + 'type': 'deployment', + 'trigger': 'manual', + 'redirectUrl': 'https://appwrite.io/docs', + 'redirectStatusCode': 301, + 'deploymentId': 'n3u9feiwmf', + 'deploymentResourceId': 'n3u9feiwmf', + 'deploymentVcsProviderBranch': 'main', + 'status': 'verified', + 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + 'renewAt': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.createRedirectRule( + '', + 'https://example.com', + '301', + '', + 'site', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method createSiteRule()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'domain': 'appwrite.company.com', + 'type': 'deployment', + 'trigger': 'manual', + 'redirectUrl': 'https://appwrite.io/docs', + 'redirectStatusCode': 301, + 'deploymentId': 'n3u9feiwmf', + 'deploymentResourceId': 'n3u9feiwmf', + 'deploymentVcsProviderBranch': 'main', + 'status': 'verified', + 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + 'renewAt': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.createSiteRule( + '', + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method getRule()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'domain': 'appwrite.company.com', + 'type': 'deployment', + 'trigger': 'manual', + 'redirectUrl': 'https://appwrite.io/docs', + 'redirectStatusCode': 301, + 'deploymentId': 'n3u9feiwmf', + 'deploymentResourceId': 'n3u9feiwmf', + 'deploymentVcsProviderBranch': 'main', + 'status': 'verified', + 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + 'renewAt': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.getRule( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method deleteRule()', async () => { + const data = {message: ""}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.deleteRule( + '', + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateRuleStatus()', async () => { + const data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'domain': 'appwrite.company.com', + 'type': 'deployment', + 'trigger': 'manual', + 'redirectUrl': 'https://appwrite.io/docs', + 'redirectStatusCode': 301, + 'deploymentId': 'n3u9feiwmf', + 'deploymentResourceId': 'n3u9feiwmf', + 'deploymentVcsProviderBranch': 'main', + 'status': 'verified', + 'logs': 'Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.', + 'renewAt': 'datetime',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await proxy.updateRuleStatus( + '', + ); + + // 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/sites.test.js b/test/services/sites.test.js index 75f88054..11e9f6da 100644 --- a/test/services/sites.test.js +++ b/test/services/sites.test.js @@ -11,7 +11,7 @@ describe('Sites', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'sites': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Sites', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -75,7 +75,7 @@ describe('Sites', () => { }); test('test method listFrameworks()', async () => { - const data = { + const data = { 'total': 5, 'frameworks': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -90,7 +90,7 @@ describe('Sites', () => { }); test('test method listSpecifications()', async () => { - const data = { + const data = { 'total': 5, 'specifications': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -105,7 +105,7 @@ describe('Sites', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -151,7 +151,7 @@ describe('Sites', () => { }); test('test method update()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -199,7 +199,7 @@ describe('Sites', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await sites.delete( @@ -213,7 +213,7 @@ describe('Sites', () => { }); test('test method updateSiteDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -260,7 +260,7 @@ describe('Sites', () => { }); test('test method listDeployments()', async () => { - const data = { + const data = { 'total': 5, 'deployments': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -276,7 +276,7 @@ describe('Sites', () => { }); test('test method createDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -318,7 +318,7 @@ describe('Sites', () => { }); test('test method createDuplicateDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -360,7 +360,7 @@ describe('Sites', () => { }); test('test method createTemplateDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -406,7 +406,7 @@ describe('Sites', () => { }); test('test method createVcsDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -449,7 +449,7 @@ describe('Sites', () => { }); test('test method getDeployment()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -491,7 +491,7 @@ describe('Sites', () => { }); test('test method deleteDeployment()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await sites.deleteDeployment( @@ -521,7 +521,7 @@ describe('Sites', () => { }); test('test method updateDeploymentStatus()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -563,7 +563,7 @@ describe('Sites', () => { }); test('test method listLogs()', async () => { - const data = { + const data = { 'total': 5, 'executions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -579,7 +579,7 @@ describe('Sites', () => { }); test('test method getLog()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -611,7 +611,7 @@ describe('Sites', () => { }); test('test method deleteLog()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await sites.deleteLog( @@ -626,7 +626,7 @@ describe('Sites', () => { }); test('test method listVariables()', async () => { - const data = { + const data = { 'total': 5, 'variables': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -642,7 +642,7 @@ describe('Sites', () => { }); test('test method createVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -655,6 +655,7 @@ describe('Sites', () => { const response = await sites.createVariable( '', + '', '', '', ); @@ -666,7 +667,7 @@ describe('Sites', () => { }); test('test method getVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -689,7 +690,7 @@ describe('Sites', () => { }); test('test method updateVariable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -703,7 +704,6 @@ describe('Sites', () => { const response = await sites.updateVariable( '', '', - '', ); // Remove custom toString method on the objects to allow for clean data comparison. @@ -713,7 +713,7 @@ describe('Sites', () => { }); test('test method deleteVariable()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await sites.deleteVariable( diff --git a/test/services/storage.test.js b/test/services/storage.test.js index 43f5d0c7..22ab1799 100644 --- a/test/services/storage.test.js +++ b/test/services/storage.test.js @@ -11,7 +11,7 @@ describe('Storage', () => { test('test method listBuckets()', async () => { - const data = { + const data = { 'total': 5, 'buckets': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Storage', () => { }); test('test method createBucket()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -55,7 +55,7 @@ describe('Storage', () => { }); test('test method getBucket()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -83,7 +83,7 @@ describe('Storage', () => { }); test('test method updateBucket()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -112,7 +112,7 @@ describe('Storage', () => { }); test('test method deleteBucket()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await storage.deleteBucket( @@ -126,7 +126,7 @@ describe('Storage', () => { }); test('test method listFiles()', async () => { - const data = { + const data = { 'total': 5, 'files': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -142,7 +142,7 @@ describe('Storage', () => { }); test('test method createFile()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'bucketId': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -171,7 +171,7 @@ describe('Storage', () => { }); test('test method getFile()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'bucketId': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -199,7 +199,7 @@ describe('Storage', () => { }); test('test method updateFile()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'bucketId': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -227,7 +227,7 @@ describe('Storage', () => { }); test('test method deleteFile()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await storage.deleteFile( diff --git a/test/services/tables-d-b.test.js b/test/services/tables-d-b.test.js index 02012d43..5c89adc6 100644 --- a/test/services/tables-d-b.test.js +++ b/test/services/tables-d-b.test.js @@ -11,7 +11,7 @@ describe('TablesDB', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'databases': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('TablesDB', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -49,7 +49,7 @@ describe('TablesDB', () => { }); test('test method listTransactions()', async () => { - const data = { + const data = { 'total': 5, 'transactions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -64,7 +64,7 @@ describe('TablesDB', () => { }); test('test method createTransaction()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -83,7 +83,7 @@ describe('TablesDB', () => { }); test('test method getTransaction()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -103,7 +103,7 @@ describe('TablesDB', () => { }); test('test method updateTransaction()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -123,7 +123,7 @@ describe('TablesDB', () => { }); test('test method deleteTransaction()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.deleteTransaction( @@ -137,7 +137,7 @@ describe('TablesDB', () => { }); test('test method createOperations()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -157,7 +157,7 @@ describe('TablesDB', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -179,7 +179,7 @@ describe('TablesDB', () => { }); test('test method update()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -201,7 +201,7 @@ describe('TablesDB', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.delete( @@ -215,7 +215,7 @@ describe('TablesDB', () => { }); test('test method listTables()', async () => { - const data = { + const data = { 'total': 5, 'tables': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -231,7 +231,7 @@ describe('TablesDB', () => { }); test('test method createTable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -259,7 +259,7 @@ describe('TablesDB', () => { }); test('test method getTable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -286,7 +286,7 @@ describe('TablesDB', () => { }); test('test method updateTable()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -313,7 +313,7 @@ describe('TablesDB', () => { }); test('test method deleteTable()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.deleteTable( @@ -328,7 +328,7 @@ describe('TablesDB', () => { }); test('test method listColumns()', async () => { - const data = { + const data = { 'total': 5, 'columns': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -344,8 +344,57 @@ describe('TablesDB', () => { expect(response).toEqual(data); }); + test('test method createBigIntColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'bigint', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.createBigIntColumn( + '', + '', + '', + true, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + + test('test method updateBigIntColumn()', async () => { + const data = { + 'key': 'count', + 'type': 'bigint', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + mockedFetch.mockImplementation(() => Response.json(data)); + + const response = await tablesDB.updateBigIntColumn( + '', + '', + '', + true, + 1, + ); + + // Remove custom toString method on the objects to allow for clean data comparison. + delete response.toString; + + expect(response).toEqual(data); + }); + test('test method createBooleanColumn()', async () => { - const data = { + const data = { 'key': 'isEnabled', 'type': 'boolean', 'status': 'available', @@ -369,7 +418,7 @@ describe('TablesDB', () => { }); test('test method updateBooleanColumn()', async () => { - const data = { + const data = { 'key': 'isEnabled', 'type': 'boolean', 'status': 'available', @@ -394,7 +443,7 @@ describe('TablesDB', () => { }); test('test method createDatetimeColumn()', async () => { - const data = { + const data = { 'key': 'birthDay', 'type': 'datetime', 'status': 'available', @@ -419,7 +468,7 @@ describe('TablesDB', () => { }); test('test method updateDatetimeColumn()', async () => { - const data = { + const data = { 'key': 'birthDay', 'type': 'datetime', 'status': 'available', @@ -445,7 +494,7 @@ describe('TablesDB', () => { }); test('test method createEmailColumn()', async () => { - const data = { + const data = { 'key': 'userEmail', 'type': 'string', 'status': 'available', @@ -470,7 +519,7 @@ describe('TablesDB', () => { }); test('test method updateEmailColumn()', async () => { - const data = { + const data = { 'key': 'userEmail', 'type': 'string', 'status': 'available', @@ -496,7 +545,7 @@ describe('TablesDB', () => { }); test('test method createEnumColumn()', async () => { - const data = { + const data = { 'key': 'status', 'type': 'string', 'status': 'available', @@ -523,7 +572,7 @@ describe('TablesDB', () => { }); test('test method updateEnumColumn()', async () => { - const data = { + const data = { 'key': 'status', 'type': 'string', 'status': 'available', @@ -551,7 +600,7 @@ describe('TablesDB', () => { }); test('test method createFloatColumn()', async () => { - const data = { + const data = { 'key': 'percentageCompleted', 'type': 'double', 'status': 'available', @@ -575,7 +624,7 @@ describe('TablesDB', () => { }); test('test method updateFloatColumn()', async () => { - const data = { + const data = { 'key': 'percentageCompleted', 'type': 'double', 'status': 'available', @@ -600,7 +649,7 @@ describe('TablesDB', () => { }); test('test method createIntegerColumn()', async () => { - const data = { + const data = { 'key': 'count', 'type': 'integer', 'status': 'available', @@ -624,7 +673,7 @@ describe('TablesDB', () => { }); test('test method updateIntegerColumn()', async () => { - const data = { + const data = { 'key': 'count', 'type': 'integer', 'status': 'available', @@ -649,7 +698,7 @@ describe('TablesDB', () => { }); test('test method createIpColumn()', async () => { - const data = { + const data = { 'key': 'ipAddress', 'type': 'string', 'status': 'available', @@ -674,7 +723,7 @@ describe('TablesDB', () => { }); test('test method updateIpColumn()', async () => { - const data = { + const data = { 'key': 'ipAddress', 'type': 'string', 'status': 'available', @@ -700,7 +749,7 @@ describe('TablesDB', () => { }); test('test method createLineColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -724,7 +773,7 @@ describe('TablesDB', () => { }); test('test method updateLineColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -748,7 +797,7 @@ describe('TablesDB', () => { }); test('test method createLongtextColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -772,7 +821,7 @@ describe('TablesDB', () => { }); test('test method updateLongtextColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -797,7 +846,7 @@ describe('TablesDB', () => { }); test('test method createMediumtextColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -821,7 +870,7 @@ describe('TablesDB', () => { }); test('test method updateMediumtextColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -846,7 +895,7 @@ describe('TablesDB', () => { }); test('test method createPointColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -870,7 +919,7 @@ describe('TablesDB', () => { }); test('test method updatePointColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -894,7 +943,7 @@ describe('TablesDB', () => { }); test('test method createPolygonColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -918,7 +967,7 @@ describe('TablesDB', () => { }); test('test method updatePolygonColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -942,7 +991,7 @@ describe('TablesDB', () => { }); test('test method createRelationshipColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -972,7 +1021,7 @@ describe('TablesDB', () => { }); test('test method createStringColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -998,7 +1047,7 @@ describe('TablesDB', () => { }); test('test method updateStringColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1024,7 +1073,7 @@ describe('TablesDB', () => { }); test('test method createTextColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1048,7 +1097,7 @@ describe('TablesDB', () => { }); test('test method updateTextColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1073,7 +1122,7 @@ describe('TablesDB', () => { }); test('test method createUrlColumn()', async () => { - const data = { + const data = { 'key': 'githubUrl', 'type': 'string', 'status': 'available', @@ -1098,7 +1147,7 @@ describe('TablesDB', () => { }); test('test method updateUrlColumn()', async () => { - const data = { + const data = { 'key': 'githubUrl', 'type': 'string', 'status': 'available', @@ -1124,7 +1173,7 @@ describe('TablesDB', () => { }); test('test method createVarcharColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1150,7 +1199,7 @@ describe('TablesDB', () => { }); test('test method updateVarcharColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1176,14 +1225,15 @@ describe('TablesDB', () => { }); test('test method getColumn()', async () => { - const data = { - 'key': 'isEnabled', - 'type': 'boolean', + const data = { + 'key': 'fullName', + 'type': 'string', 'status': 'available', 'error': 'string', 'required': true, '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'size': 128,}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.getColumn( @@ -1199,7 +1249,7 @@ describe('TablesDB', () => { }); test('test method deleteColumn()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.deleteColumn( @@ -1215,7 +1265,7 @@ describe('TablesDB', () => { }); test('test method updateRelationshipColumn()', async () => { - const data = { + const data = { 'key': 'fullName', 'type': 'string', 'status': 'available', @@ -1244,7 +1294,7 @@ describe('TablesDB', () => { }); test('test method listIndexes()', async () => { - const data = { + const data = { 'total': 5, 'indexes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1261,7 +1311,7 @@ describe('TablesDB', () => { }); test('test method createIndex()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1288,7 +1338,7 @@ describe('TablesDB', () => { }); test('test method getIndex()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1313,7 +1363,7 @@ describe('TablesDB', () => { }); test('test method deleteIndex()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.deleteIndex( @@ -1329,7 +1379,7 @@ describe('TablesDB', () => { }); test('test method listRows()', async () => { - const data = { + const data = { 'total': 5, 'rows': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1346,7 +1396,7 @@ describe('TablesDB', () => { }); test('test method createRow()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$tableId': '5e5ea5c15117e', @@ -1370,7 +1420,7 @@ describe('TablesDB', () => { }); test('test method createRows()', async () => { - const data = { + const data = { 'total': 5, 'rows': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1388,7 +1438,7 @@ describe('TablesDB', () => { }); test('test method upsertRows()', async () => { - const data = { + const data = { 'total': 5, 'rows': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1406,7 +1456,7 @@ describe('TablesDB', () => { }); test('test method updateRows()', async () => { - const data = { + const data = { 'total': 5, 'rows': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1423,7 +1473,7 @@ describe('TablesDB', () => { }); test('test method deleteRows()', async () => { - const data = { + const data = { 'total': 5, 'rows': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -1440,7 +1490,7 @@ describe('TablesDB', () => { }); test('test method getRow()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$tableId': '5e5ea5c15117e', @@ -1463,7 +1513,7 @@ describe('TablesDB', () => { }); test('test method upsertRow()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$tableId': '5e5ea5c15117e', @@ -1486,7 +1536,7 @@ describe('TablesDB', () => { }); test('test method updateRow()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$tableId': '5e5ea5c15117e', @@ -1509,7 +1559,7 @@ describe('TablesDB', () => { }); test('test method deleteRow()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tablesDB.deleteRow( @@ -1525,7 +1575,7 @@ describe('TablesDB', () => { }); test('test method decrementRowColumn()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$tableId': '5e5ea5c15117e', @@ -1549,7 +1599,7 @@ describe('TablesDB', () => { }); test('test method incrementRowColumn()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$sequence': '1', '\$tableId': '5e5ea5c15117e', diff --git a/test/services/teams.test.js b/test/services/teams.test.js index df5c9ac1..dcb4055b 100644 --- a/test/services/teams.test.js +++ b/test/services/teams.test.js @@ -11,7 +11,7 @@ describe('Teams', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'teams': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Teams', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -47,7 +47,7 @@ describe('Teams', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -67,7 +67,7 @@ describe('Teams', () => { }); test('test method updateName()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -88,7 +88,7 @@ describe('Teams', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await teams.delete( @@ -102,7 +102,7 @@ describe('Teams', () => { }); test('test method listMemberships()', async () => { - const data = { + const data = { 'total': 5, 'memberships': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -118,13 +118,14 @@ describe('Teams', () => { }); test('test method createMembership()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c16897e', 'userName': 'John Doe', 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', 'teamId': '5e5ea5c16897e', 'teamName': 'VIP', 'invited': '2020-10-15T06:38:00.000+00:00', @@ -146,13 +147,14 @@ describe('Teams', () => { }); test('test method getMembership()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c16897e', 'userName': 'John Doe', 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', 'teamId': '5e5ea5c16897e', 'teamName': 'VIP', 'invited': '2020-10-15T06:38:00.000+00:00', @@ -174,13 +176,14 @@ describe('Teams', () => { }); test('test method updateMembership()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c16897e', 'userName': 'John Doe', 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', 'teamId': '5e5ea5c16897e', 'teamName': 'VIP', 'invited': '2020-10-15T06:38:00.000+00:00', @@ -203,7 +206,7 @@ describe('Teams', () => { }); test('test method deleteMembership()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await teams.deleteMembership( @@ -218,13 +221,14 @@ describe('Teams', () => { }); test('test method updateMembershipStatus()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c16897e', 'userName': 'John Doe', 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', 'teamId': '5e5ea5c16897e', 'teamName': 'VIP', 'invited': '2020-10-15T06:38:00.000+00:00', @@ -248,7 +252,7 @@ describe('Teams', () => { }); test('test method getPrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await teams.getPrefs( @@ -262,7 +266,7 @@ describe('Teams', () => { }); test('test method updatePrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await teams.updatePrefs( diff --git a/test/services/tokens.test.js b/test/services/tokens.test.js index b9c14cb4..000f188e 100644 --- a/test/services/tokens.test.js +++ b/test/services/tokens.test.js @@ -11,7 +11,7 @@ describe('Tokens', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'tokens': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -28,7 +28,7 @@ describe('Tokens', () => { }); test('test method createFileToken()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', @@ -50,7 +50,7 @@ describe('Tokens', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', @@ -71,7 +71,7 @@ describe('Tokens', () => { }); test('test method update()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'resourceId': '5e5ea5c168bb8:5e5ea5c168bb8', @@ -92,7 +92,7 @@ describe('Tokens', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await tokens.delete( diff --git a/test/services/users.test.js b/test/services/users.test.js index c01295da..cb5441a2 100644 --- a/test/services/users.test.js +++ b/test/services/users.test.js @@ -11,7 +11,7 @@ describe('Users', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'users': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Users', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -56,7 +56,7 @@ describe('Users', () => { }); test('test method createArgon2User()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -88,7 +88,7 @@ describe('Users', () => { }); test('test method createBcryptUser()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -120,7 +120,7 @@ describe('Users', () => { }); test('test method listIdentities()', async () => { - const data = { + const data = { 'total': 5, 'identities': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -135,7 +135,7 @@ describe('Users', () => { }); test('test method deleteIdentity()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.deleteIdentity( @@ -149,7 +149,7 @@ describe('Users', () => { }); test('test method createMD5User()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -181,7 +181,7 @@ describe('Users', () => { }); test('test method createPHPassUser()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -213,7 +213,7 @@ describe('Users', () => { }); test('test method createScryptUser()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -250,7 +250,7 @@ describe('Users', () => { }); test('test method createScryptModifiedUser()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -285,7 +285,7 @@ describe('Users', () => { }); test('test method createSHAUser()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -317,7 +317,7 @@ describe('Users', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -347,7 +347,7 @@ describe('Users', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.delete( @@ -361,7 +361,7 @@ describe('Users', () => { }); test('test method updateEmail()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -392,7 +392,7 @@ describe('Users', () => { }); test('test method updateImpersonator()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -423,7 +423,7 @@ describe('Users', () => { }); test('test method createJWT()', async () => { - const data = { + const data = { 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -438,7 +438,7 @@ describe('Users', () => { }); test('test method updateLabels()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -469,7 +469,7 @@ describe('Users', () => { }); test('test method listLogs()', async () => { - const data = { + const data = { 'total': 5, 'logs': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -485,7 +485,7 @@ describe('Users', () => { }); test('test method listMemberships()', async () => { - const data = { + const data = { 'total': 5, 'memberships': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -501,7 +501,7 @@ describe('Users', () => { }); test('test method updateMfa()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -532,7 +532,7 @@ describe('Users', () => { }); test('test method updateMFA()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -563,7 +563,7 @@ describe('Users', () => { }); test('test method deleteMfaAuthenticator()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.deleteMfaAuthenticator( @@ -578,7 +578,7 @@ describe('Users', () => { }); test('test method deleteMFAAuthenticator()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.deleteMFAAuthenticator( @@ -593,7 +593,7 @@ describe('Users', () => { }); test('test method listMfaFactors()', async () => { - const data = { + const data = { 'totp': true, 'phone': true, 'email': true, @@ -611,7 +611,7 @@ describe('Users', () => { }); test('test method listMFAFactors()', async () => { - const data = { + const data = { 'totp': true, 'phone': true, 'email': true, @@ -629,7 +629,7 @@ describe('Users', () => { }); test('test method getMfaRecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -644,7 +644,7 @@ describe('Users', () => { }); test('test method getMFARecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -659,7 +659,7 @@ describe('Users', () => { }); test('test method updateMfaRecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -674,7 +674,7 @@ describe('Users', () => { }); test('test method updateMFARecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -689,7 +689,7 @@ describe('Users', () => { }); test('test method createMfaRecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -704,7 +704,7 @@ describe('Users', () => { }); test('test method createMFARecoveryCodes()', async () => { - const data = { + const data = { 'recoveryCodes': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -719,7 +719,7 @@ describe('Users', () => { }); test('test method updateName()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -750,7 +750,7 @@ describe('Users', () => { }); test('test method updatePassword()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -781,7 +781,7 @@ describe('Users', () => { }); test('test method updatePhone()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -812,7 +812,7 @@ describe('Users', () => { }); test('test method getPrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.getPrefs( @@ -826,7 +826,7 @@ describe('Users', () => { }); test('test method updatePrefs()', async () => { - const data = {}; + const data = {}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.updatePrefs( @@ -841,7 +841,7 @@ describe('Users', () => { }); test('test method listSessions()', async () => { - const data = { + const data = { 'total': 5, 'sessions': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -857,7 +857,7 @@ describe('Users', () => { }); test('test method createSession()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -900,7 +900,7 @@ describe('Users', () => { }); test('test method deleteSessions()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.deleteSessions( @@ -914,7 +914,7 @@ describe('Users', () => { }); test('test method deleteSession()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.deleteSession( @@ -929,7 +929,7 @@ describe('Users', () => { }); test('test method updateStatus()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -960,7 +960,7 @@ describe('Users', () => { }); test('test method listTargets()', async () => { - const data = { + const data = { 'total': 5, 'targets': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -976,7 +976,7 @@ describe('Users', () => { }); test('test method createTarget()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1001,7 +1001,7 @@ describe('Users', () => { }); test('test method getTarget()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1024,7 +1024,7 @@ describe('Users', () => { }); test('test method updateTarget()', async () => { - const data = { + const data = { '\$id': '259125845563242502', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1047,7 +1047,7 @@ describe('Users', () => { }); test('test method deleteTarget()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await users.deleteTarget( @@ -1062,7 +1062,7 @@ describe('Users', () => { }); test('test method createToken()', async () => { - const data = { + const data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', @@ -1082,7 +1082,7 @@ describe('Users', () => { }); test('test method updateEmailVerification()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -1113,7 +1113,7 @@ describe('Users', () => { }); test('test method updatePhoneVerification()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', diff --git a/test/services/webhooks.test.js b/test/services/webhooks.test.js index d254ef7f..01e7abd3 100644 --- a/test/services/webhooks.test.js +++ b/test/services/webhooks.test.js @@ -11,7 +11,7 @@ describe('Webhooks', () => { test('test method list()', async () => { - const data = { + const data = { 'total': 5, 'webhooks': [],}; mockedFetch.mockImplementation(() => Response.json(data)); @@ -26,7 +26,7 @@ describe('Webhooks', () => { }); test('test method create()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -56,7 +56,7 @@ describe('Webhooks', () => { }); test('test method get()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -83,7 +83,7 @@ describe('Webhooks', () => { }); test('test method update()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', @@ -113,7 +113,7 @@ describe('Webhooks', () => { }); test('test method delete()', async () => { - const data = {message: ""}; + const data = {message: ""}; mockedFetch.mockImplementation(() => Response.json(data)); const response = await webhooks.delete( @@ -127,7 +127,7 @@ describe('Webhooks', () => { }); test('test method updateSecret()', async () => { - const data = { + const data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00',