From 7b83a27f8814d341a34b7b3509c5a9a732ce9d2a Mon Sep 17 00:00:00 2001 From: premtsd-code Date: Wed, 20 May 2026 08:03:16 +0000 Subject: [PATCH 1/3] chore: update Console SDK to 13.0.1 --- .github/workflows/publish.yml | 4 +- .npmrc | 1 + CHANGELOG.md | 8 + README.md | 4 +- docs/examples/advisor/delete-report.md | 15 + docs/examples/advisor/get-insight.md | 16 + .../get.md => advisor/get-report.md} | 8 +- docs/examples/advisor/list-insights.md | 17 + docs/examples/advisor/list-reports.md | 16 + docs/examples/console/get-email-template.md | 16 + .../console/list-organization-scopes.md | 13 + docs/examples/presences/delete.md | 15 + docs/examples/presences/get-usage.md | 15 + docs/examples/presences/get.md | 15 + docs/examples/presences/list.md | 17 + docs/examples/presences/update-presence.md | 21 + docs/examples/presences/upsert.md | 20 + docs/examples/project/create-ephemeral-key.md | 4 +- docs/examples/project/create-key.md | 4 +- docs/examples/project/get-email-template.md | 6 +- .../examples/project/get-o-auth-2-provider.md | 4 +- docs/examples/project/get-policy.md | 4 +- docs/examples/project/get.md | 13 + docs/examples/project/update-auth-method.md | 4 +- ...md => update-deny-aliased-email-policy.md} | 2 +- .../examples/project/update-email-template.md | 6 +- docs/examples/project/update-key.md | 4 +- .../project/update-o-auth-2-google.md | 4 +- docs/examples/project/update-protocol.md | 4 +- docs/examples/project/update-service.md | 4 +- docs/examples/project/update-smtp.md | 4 +- docs/examples/projects/create.md | 11 +- docs/examples/usage/list-events.md | 16 + docs/examples/usage/list-gauges.md | 16 + package-lock.json | 4 +- package.json | 2 +- src/channel.ts | 15 +- src/client.ts | 4 +- src/enums/appwrite-migration-resource.ts | 1 + src/enums/build-runtime.ts | 3 + src/enums/o-auth-provider.ts | 2 - ...th-method.ts => project-auth-method-id.ts} | 2 +- ...e-type.ts => project-email-template-id.ts} | 2 +- ...le.ts => project-email-template-locale.ts} | 2 +- src/enums/project-key-scopes.ts | 96 +++ ...t.ts => project-o-auth-2-google-prompt.ts} | 2 +- src/enums/project-o-auth-provider-id.ts | 47 ++ ...project-policy.ts => project-policy-id.ts} | 2 +- ...{protocol-id.ts => project-protocol-id.ts} | 2 +- .../{service-id.ts => project-service-id.ts} | 3 +- .../{secure.ts => project-smtp-secure.ts} | 2 +- src/enums/query-suggestion-resource.ts | 3 + src/enums/runtime.ts | 3 + src/enums/runtimes.ts | 3 + src/enums/scopes.ts | 7 + src/index.ts | 21 +- src/models.ts | 672 +++++++++++------- src/services/advisor.ts | 309 ++++++++ src/services/console.ts | 84 +++ src/services/presences.ts | 437 ++++++++++++ src/services/project.ts | 283 ++++---- src/services/projects.ts | 128 +--- src/services/realtime.ts | 161 ++++- src/services/usage.ts | 130 ++++ 64 files changed, 2173 insertions(+), 590 deletions(-) create mode 100644 .npmrc create mode 100644 docs/examples/advisor/delete-report.md create mode 100644 docs/examples/advisor/get-insight.md rename docs/examples/{projects/get.md => advisor/get-report.md} (56%) create mode 100644 docs/examples/advisor/list-insights.md create mode 100644 docs/examples/advisor/list-reports.md create mode 100644 docs/examples/console/get-email-template.md create mode 100644 docs/examples/console/list-organization-scopes.md create mode 100644 docs/examples/presences/delete.md create mode 100644 docs/examples/presences/get-usage.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/get.md rename docs/examples/project/{update-deny-canonical-email-policy.md => update-deny-aliased-email-policy.md} (83%) create mode 100644 docs/examples/usage/list-events.md create mode 100644 docs/examples/usage/list-gauges.md rename src/enums/{auth-method.ts => project-auth-method-id.ts} (84%) rename src/enums/{email-template-type.ts => project-email-template-id.ts} (86%) rename src/enums/{email-template-locale.ts => project-email-template-locale.ts} (98%) create mode 100644 src/enums/project-key-scopes.ts rename src/enums/{prompt.ts => project-o-auth-2-google-prompt.ts} (67%) create mode 100644 src/enums/project-o-auth-provider-id.ts rename src/enums/{project-policy.ts => project-policy-id.ts} (92%) rename src/enums/{protocol-id.ts => project-protocol-id.ts} (69%) rename src/enums/{service-id.ts => project-service-id.ts} (88%) rename src/enums/{secure.ts => project-smtp-secure.ts} (52%) create mode 100644 src/services/advisor.ts create mode 100644 src/services/presences.ts create mode 100644 src/services/usage.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 47ba2484..ee63d526 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Use Node.js - uses: actions/setup-node@v6 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: '24.14.1' registry-url: 'https://registry.npmjs.org' diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..7253a5ce --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +min-release-age=7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 842e0fb3..99d4ad3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 13.0.1 + +* Fixed: `BillingLimits` inner fields and `Project.billingLimits` are now optional — server emits sparse "limits crossed" map +* Fixed: `Project.consoleAccessedAt` defaults to empty string for never-accessed projects (no longer null) +* Added: `File.sizeActual` field — actual bytes used on disk after compression / encryption +* Updated: `BuildRuntime` and `Runtime` enums with `deno-1.21`, `deno-1.24`, and `deno-1.35` +* Updated: Advisor doc examples corrected to use API key auth instead of session + ## 13.0.0 * Breaking: Renamed `updateCanonicalEmails` to `updateDenyCanonicalEmailPolicy` on `Project` service diff --git a/README.md b/README.md index daed6142..68bff962 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Console SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.5-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) @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/advisor/delete-report.md b/docs/examples/advisor/delete-report.md new file mode 100644 index 00000000..d549dddb --- /dev/null +++ b/docs/examples/advisor/delete-report.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Advisor } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.deleteReport({ + reportId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/advisor/get-insight.md new file mode 100644 index 00000000..bf59a7ed --- /dev/null +++ b/docs/examples/advisor/get-insight.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Advisor } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.getInsight({ + reportId: '', + insightId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/projects/get.md b/docs/examples/advisor/get-report.md similarity index 56% rename from docs/examples/projects/get.md rename to docs/examples/advisor/get-report.md index b8856f8e..cdb46636 100644 --- a/docs/examples/projects/get.md +++ b/docs/examples/advisor/get-report.md @@ -1,14 +1,14 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Advisor } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const advisor = new Advisor(client); -const result = await projects.get({ - projectId: '' +const result = await advisor.getReport({ + reportId: '' }); console.log(result); diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md new file mode 100644 index 00000000..e3d97867 --- /dev/null +++ b/docs/examples/advisor/list-insights.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Advisor } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.listInsights({ + reportId: '', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/advisor/list-reports.md new file mode 100644 index 00000000..5cf736e5 --- /dev/null +++ b/docs/examples/advisor/list-reports.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Advisor } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.listReports({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/console/get-email-template.md b/docs/examples/console/get-email-template.md new file mode 100644 index 00000000..8f16d121 --- /dev/null +++ b/docs/examples/console/get-email-template.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Console, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const xconsole = new Console(client); + +const result = await xconsole.getEmailTemplate({ + templateId: ProjectEmailTemplateId.Verification, + locale: ProjectEmailTemplateLocale.Af // optional +}); + +console.log(result); +``` diff --git a/docs/examples/console/list-organization-scopes.md b/docs/examples/console/list-organization-scopes.md new file mode 100644 index 00000000..0253b965 --- /dev/null +++ b/docs/examples/console/list-organization-scopes.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Console } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const xconsole = new Console(client); + +const result = await xconsole.listOrganizationScopes(); + +console.log(result); +``` diff --git a/docs/examples/presences/delete.md b/docs/examples/presences/delete.md new file mode 100644 index 00000000..7773d3a2 --- /dev/null +++ b/docs/examples/presences/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Presences } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const presences = new Presences(client); + +const result = await presences.delete({ + presenceId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/presences/get-usage.md b/docs/examples/presences/get-usage.md new file mode 100644 index 00000000..5f954980 --- /dev/null +++ b/docs/examples/presences/get-usage.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Presences, UsageRange } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const presences = new Presences(client); + +const result = await presences.getUsage({ + range: UsageRange.24h // optional +}); + +console.log(result); +``` diff --git a/docs/examples/presences/get.md b/docs/examples/presences/get.md new file mode 100644 index 00000000..c2d4ca0d --- /dev/null +++ b/docs/examples/presences/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Presences } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const presences = new Presences(client); + +const result = await presences.get({ + presenceId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/presences/list.md b/docs/examples/presences/list.md new file mode 100644 index 00000000..5cd70b44 --- /dev/null +++ b/docs/examples/presences/list.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Presences } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const presences = new Presences(client); + +const result = await presences.list({ + queries: [], // optional + total: false, // optional + ttl: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/presences/update-presence.md b/docs/examples/presences/update-presence.md new file mode 100644 index 00000000..f735ef39 --- /dev/null +++ b/docs/examples/presences/update-presence.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Presences, Permission, Role } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const presences = new Presences(client); + +const result = await presences.updatePresence({ + presenceId: '', + userId: '', + status: '', // optional + expiresAt: '2020-10-15T06:38:00.000+00:00', // optional + metadata: {}, // optional + permissions: [Permission.read(Role.any())], // optional + purge: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md new file mode 100644 index 00000000..fa7d6cba --- /dev/null +++ b/docs/examples/presences/upsert.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Presences, Permission, Role } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const presences = new Presences(client); + +const result = await presences.upsert({ + presenceId: '', + userId: '', + status: '', + permissions: [Permission.read(Role.any())], // optional + expiresAt: '2020-10-15T06:38:00.000+00:00', // optional + metadata: {} // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index c41bb809..233f3b8e 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, Scopes } from "@appwrite.io/console"; +import { Client, Project, ProjectKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.createEphemeralKey({ - scopes: [Scopes.ProjectRead], + scopes: [ProjectKeyScopes.ProjectRead], duration: 600 }); diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md index 362d4ca0..b0feb14f 100644 --- a/docs/examples/project/create-key.md +++ b/docs/examples/project/create-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, Scopes } from "@appwrite.io/console"; +import { Client, Project, ProjectKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.createKey({ keyId: '', name: '', - scopes: [Scopes.ProjectRead], + scopes: [ProjectKeyScopes.ProjectRead], expire: '2020-10-15T06:38:00.000+00:00' // optional }); diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md index 90eb063c..48e3b230 100644 --- a/docs/examples/project/get-email-template.md +++ b/docs/examples/project/get-email-template.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, EmailTemplateType, EmailTemplateLocale } from "@appwrite.io/console"; +import { Client, Project, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,8 +8,8 @@ const client = new Client() const project = new Project(client); const result = await project.getEmailTemplate({ - templateId: EmailTemplateType.Verification, - locale: EmailTemplateLocale.Af // optional + templateId: ProjectEmailTemplateId.Verification, + locale: ProjectEmailTemplateLocale.Af // optional }); console.log(result); diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md index cb07b451..ed4d8092 100644 --- a/docs/examples/project/get-o-auth-2-provider.md +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, OAuthProvider } from "@appwrite.io/console"; +import { Client, Project, ProjectOAuthProviderId } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getOAuth2Provider({ - providerId: OAuthProvider.Amazon + providerId: ProjectOAuthProviderId.Amazon }); console.log(result); diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md index 45fec071..be06807f 100644 --- a/docs/examples/project/get-policy.md +++ b/docs/examples/project/get-policy.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProjectPolicy } from "@appwrite.io/console"; +import { Client, Project, ProjectPolicyId } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.getPolicy({ - policyId: ProjectPolicy.PasswordDictionary + policyId: ProjectPolicyId.PasswordDictionary }); console.log(result); diff --git a/docs/examples/project/get.md b/docs/examples/project/get.md new file mode 100644 index 00000000..2d4d9f94 --- /dev/null +++ b/docs/examples/project/get.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Project } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const project = new Project(client); + +const result = await project.get(); + +console.log(result); +``` diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md index fc0dfdfd..e92f1245 100644 --- a/docs/examples/project/update-auth-method.md +++ b/docs/examples/project/update-auth-method.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, AuthMethod } from "@appwrite.io/console"; +import { Client, Project, ProjectAuthMethodId } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateAuthMethod({ - methodId: AuthMethod.EmailPassword, + methodId: ProjectAuthMethodId.EmailPassword, enabled: false }); diff --git a/docs/examples/project/update-deny-canonical-email-policy.md b/docs/examples/project/update-deny-aliased-email-policy.md similarity index 83% rename from docs/examples/project/update-deny-canonical-email-policy.md rename to docs/examples/project/update-deny-aliased-email-policy.md index 5b223975..f9a253de 100644 --- a/docs/examples/project/update-deny-canonical-email-policy.md +++ b/docs/examples/project/update-deny-aliased-email-policy.md @@ -7,7 +7,7 @@ const client = new Client() const project = new Project(client); -const result = await project.updateDenyCanonicalEmailPolicy({ +const result = await project.updateDenyAliasedEmailPolicy({ enabled: false }); diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md index 2ede3e88..7b2951f9 100644 --- a/docs/examples/project/update-email-template.md +++ b/docs/examples/project/update-email-template.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, EmailTemplateType, EmailTemplateLocale } from "@appwrite.io/console"; +import { Client, Project, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,8 +8,8 @@ const client = new Client() const project = new Project(client); const result = await project.updateEmailTemplate({ - templateId: EmailTemplateType.Verification, - locale: EmailTemplateLocale.Af, // optional + templateId: ProjectEmailTemplateId.Verification, + locale: ProjectEmailTemplateLocale.Af, // optional subject: '', // optional message: '', // optional senderName: '', // optional diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 3d3282d4..636419e0 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, Scopes } from "@appwrite.io/console"; +import { Client, Project, ProjectKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateKey({ keyId: '', name: '', - scopes: [Scopes.ProjectRead], + scopes: [ProjectKeyScopes.ProjectRead], expire: '2020-10-15T06:38:00.000+00:00' // optional }); diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index b4ecf45f..c84567de 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, Prompt } from "@appwrite.io/console"; +import { Client, Project, ProjectOAuth2GooglePrompt } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const project = new Project(client); const result = await project.updateOAuth2Google({ clientId: '', // optional clientSecret: '', // optional - prompt: [Prompt.None], // optional + prompt: [ProjectOAuth2GooglePrompt.None], // optional enabled: false // optional }); diff --git a/docs/examples/project/update-protocol.md b/docs/examples/project/update-protocol.md index ffdc8e56..e966ad7c 100644 --- a/docs/examples/project/update-protocol.md +++ b/docs/examples/project/update-protocol.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ProtocolId } from "@appwrite.io/console"; +import { Client, Project, ProjectProtocolId } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateProtocol({ - protocolId: ProtocolId.Rest, + protocolId: ProjectProtocolId.Rest, enabled: false }); diff --git a/docs/examples/project/update-service.md b/docs/examples/project/update-service.md index 460a809f..b3b1ffd3 100644 --- a/docs/examples/project/update-service.md +++ b/docs/examples/project/update-service.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, ServiceId } from "@appwrite.io/console"; +import { Client, Project, ProjectServiceId } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const project = new Project(client); const result = await project.updateService({ - serviceId: ServiceId.Account, + serviceId: ProjectServiceId.Account, enabled: false }); diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md index 0fefca64..c2236be5 100644 --- a/docs/examples/project/update-smtp.md +++ b/docs/examples/project/update-smtp.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Project, Secure } from "@appwrite.io/console"; +import { Client, Project, ProjectSMTPSecure } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,7 +16,7 @@ const result = await project.updateSMTP({ senderName: '', // optional replyToEmail: 'email@example.com', // optional replyToName: '', // optional - secure: Secure.Tls, // optional + secure: ProjectSMTPSecure.Tls, // optional enabled: false // optional }); diff --git a/docs/examples/projects/create.md b/docs/examples/projects/create.md index eb8749de..21b9488a 100644 --- a/docs/examples/projects/create.md +++ b/docs/examples/projects/create.md @@ -11,16 +11,7 @@ const result = await projects.create({ projectId: '', name: '', teamId: '', - region: Region.Fra, // optional - description: '', // optional - logo: '', // optional - url: 'https://example.com', // optional - legalName: '', // optional - legalCountry: '', // optional - legalState: '', // optional - legalCity: '', // optional - legalAddress: '', // optional - legalTaxId: '' // optional + region: Region.Fra // optional }); console.log(result); diff --git a/docs/examples/usage/list-events.md b/docs/examples/usage/list-events.md new file mode 100644 index 00000000..c8767f08 --- /dev/null +++ b/docs/examples/usage/list-events.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Usage } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const usage = new Usage(client); + +const result = await usage.listEvents({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/usage/list-gauges.md b/docs/examples/usage/list-gauges.md new file mode 100644 index 00000000..fe14dc55 --- /dev/null +++ b/docs/examples/usage/list-gauges.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Usage } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const usage = new Usage(client); + +const result = await usage.listGauges({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/package-lock.json b/package-lock.json index 685364d8..afc0bebb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "13.0.0", + "version": "13.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "13.0.0", + "version": "13.0.1", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index 93313761..1dec57b6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "13.0.0", + "version": "13.0.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/channel.ts b/src/channel.ts index a5d7ee38..d4618a36 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -11,9 +11,10 @@ interface Func { _fn: any } interface Execution { _exec: any } interface Team { _team: any } interface Membership { _mem: any } +interface Presence { _presence: any } interface Resolved { _res: any } -type Actionable = Document | Row | File | Team | Membership; +type Actionable = Document | Row | File | Team | Membership | Presence; function normalize(id: string): string { if (id === undefined || id === null) { @@ -82,7 +83,7 @@ export class Channel { return this.resolve("create"); } - upsert(this: Channel): Channel { + upsert(this: Channel): Channel { return this.resolve("upsert"); } @@ -123,6 +124,10 @@ export class Channel { return new Channel(["memberships", normalize(id)]); } + static presence(id: string) { + return new Channel(["presences", normalize(id)]); + } + static account(): string { return "account"; } @@ -151,8 +156,12 @@ export class Channel { static memberships(): string { return "memberships"; } + + static presences(): string { + return "presences"; + } } // Export types for backward compatibility with realtime -export type ActionableChannel = Channel | Channel | Channel | Channel | Channel | Channel; +export type ActionableChannel = Channel | Channel | Channel | Channel | Channel | Channel | Channel; export type ResolvedChannel = Channel; diff --git a/src/client.ts b/src/client.ts index 8db723f2..c043b7df 100644 --- a/src/client.ts +++ b/src/client.ts @@ -390,8 +390,8 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '13.0.0', - 'X-Appwrite-Response-Format': '1.9.4', + 'x-sdk-version': '13.0.1', + 'X-Appwrite-Response-Format': '1.9.5', }; /** diff --git a/src/enums/appwrite-migration-resource.ts b/src/enums/appwrite-migration-resource.ts index 71acb705..c8dee275 100644 --- a/src/enums/appwrite-migration-resource.ts +++ b/src/enums/appwrite-migration-resource.ts @@ -24,5 +24,6 @@ export enum AppwriteMigrationResource { Site = 'site', Sitedeployment = 'site-deployment', Sitevariable = 'site-variable', + Platform = 'platform', Backuppolicy = 'backup-policy', } \ No newline at end of file diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 1466d635..dddeeb2b 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -30,6 +30,9 @@ export enum BuildRuntime { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', + Deno121 = 'deno-1.21', + Deno124 = 'deno-1.24', + Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index 06189633..cc9e340b 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -42,6 +42,4 @@ export enum OAuthProvider { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', - GithubImagine = 'githubImagine', - GoogleImagine = 'googleImagine', } \ No newline at end of file diff --git a/src/enums/auth-method.ts b/src/enums/project-auth-method-id.ts similarity index 84% rename from src/enums/auth-method.ts rename to src/enums/project-auth-method-id.ts index d5800ad9..a05c217e 100644 --- a/src/enums/auth-method.ts +++ b/src/enums/project-auth-method-id.ts @@ -1,4 +1,4 @@ -export enum AuthMethod { +export enum ProjectAuthMethodId { Emailpassword = 'email-password', Magicurl = 'magic-url', Emailotp = 'email-otp', diff --git a/src/enums/email-template-type.ts b/src/enums/project-email-template-id.ts similarity index 86% rename from src/enums/email-template-type.ts rename to src/enums/project-email-template-id.ts index 2a561bf0..b5aba1a6 100644 --- a/src/enums/email-template-type.ts +++ b/src/enums/project-email-template-id.ts @@ -1,4 +1,4 @@ -export enum EmailTemplateType { +export enum ProjectEmailTemplateId { Verification = 'verification', MagicSession = 'magicSession', Recovery = 'recovery', diff --git a/src/enums/email-template-locale.ts b/src/enums/project-email-template-locale.ts similarity index 98% rename from src/enums/email-template-locale.ts rename to src/enums/project-email-template-locale.ts index 82656b89..b5bb7cf8 100644 --- a/src/enums/email-template-locale.ts +++ b/src/enums/project-email-template-locale.ts @@ -1,4 +1,4 @@ -export enum EmailTemplateLocale { +export enum ProjectEmailTemplateLocale { Af = 'af', Arae = 'ar-ae', Arbh = 'ar-bh', diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts new file mode 100644 index 00000000..fe019965 --- /dev/null +++ b/src/enums/project-key-scopes.ts @@ -0,0 +1,96 @@ +export enum ProjectKeyScopes { + 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', + TablesRead = 'tables.read', + TablesWrite = 'tables.write', + ColumnsRead = 'columns.read', + ColumnsWrite = 'columns.write', + IndexesRead = 'indexes.read', + IndexesWrite = 'indexes.write', + RowsRead = 'rows.read', + RowsWrite = 'rows.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', + ProvidersRead = 'providers.read', + ProvidersWrite = 'providers.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', + 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', + InsightsRead = 'insights.read', + InsightsWrite = 'insights.write', + ReportsRead = 'reports.read', + ReportsWrite = 'reports.write', + PresencesRead = 'presences.read', + PresencesWrite = 'presences.write', + BackupsPoliciesRead = 'backups.policies.read', + BackupsPoliciesWrite = 'backups.policies.write', + ArchivesRead = 'archives.read', + ArchivesWrite = 'archives.write', + RestorationsRead = 'restorations.read', + RestorationsWrite = 'restorations.write', + DomainsRead = 'domains.read', + DomainsWrite = 'domains.write', + EventsRead = 'events.read', + UsageRead = 'usage.read', +} \ No newline at end of file diff --git a/src/enums/prompt.ts b/src/enums/project-o-auth-2-google-prompt.ts similarity index 67% rename from src/enums/prompt.ts rename to src/enums/project-o-auth-2-google-prompt.ts index 9bb101fa..75db98ec 100644 --- a/src/enums/prompt.ts +++ b/src/enums/project-o-auth-2-google-prompt.ts @@ -1,4 +1,4 @@ -export enum Prompt { +export enum ProjectOAuth2GooglePrompt { None = 'none', Consent = 'consent', SelectAccount = 'select_account', diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts new file mode 100644 index 00000000..e35d6ef0 --- /dev/null +++ b/src/enums/project-o-auth-provider-id.ts @@ -0,0 +1,47 @@ +export enum ProjectOAuthProviderId { + 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', + GithubImagine = 'githubImagine', + GoogleImagine = 'googleImagine', +} \ No newline at end of file diff --git a/src/enums/project-policy.ts b/src/enums/project-policy-id.ts similarity index 92% rename from src/enums/project-policy.ts rename to src/enums/project-policy-id.ts index d52bf99a..2031ce9b 100644 --- a/src/enums/project-policy.ts +++ b/src/enums/project-policy-id.ts @@ -1,4 +1,4 @@ -export enum ProjectPolicy { +export enum ProjectPolicyId { Passworddictionary = 'password-dictionary', Passwordhistory = 'password-history', Passwordpersonaldata = 'password-personal-data', diff --git a/src/enums/protocol-id.ts b/src/enums/project-protocol-id.ts similarity index 69% rename from src/enums/protocol-id.ts rename to src/enums/project-protocol-id.ts index 94d9095f..10a89c21 100644 --- a/src/enums/protocol-id.ts +++ b/src/enums/project-protocol-id.ts @@ -1,4 +1,4 @@ -export enum ProtocolId { +export enum ProjectProtocolId { Rest = 'rest', Graphql = 'graphql', Websocket = 'websocket', diff --git a/src/enums/service-id.ts b/src/enums/project-service-id.ts similarity index 88% rename from src/enums/service-id.ts rename to src/enums/project-service-id.ts index 29281124..01f844a8 100644 --- a/src/enums/service-id.ts +++ b/src/enums/project-service-id.ts @@ -1,4 +1,4 @@ -export enum ServiceId { +export enum ProjectServiceId { Account = 'account', Avatars = 'avatars', Databases = 'databases', @@ -16,4 +16,5 @@ export enum ServiceId { Graphql = 'graphql', Migrations = 'migrations', Messaging = 'messaging', + Advisor = 'advisor', } \ No newline at end of file diff --git a/src/enums/secure.ts b/src/enums/project-smtp-secure.ts similarity index 52% rename from src/enums/secure.ts rename to src/enums/project-smtp-secure.ts index 0ab54cf8..d3d37687 100644 --- a/src/enums/secure.ts +++ b/src/enums/project-smtp-secure.ts @@ -1,4 +1,4 @@ -export enum Secure { +export enum ProjectSMTPSecure { Tls = 'tls', Ssl = 'ssl', } \ No newline at end of file diff --git a/src/enums/query-suggestion-resource.ts b/src/enums/query-suggestion-resource.ts index 5663198a..506c3a65 100644 --- a/src/enums/query-suggestion-resource.ts +++ b/src/enums/query-suggestion-resource.ts @@ -27,6 +27,8 @@ export enum QuerySuggestionResource { Repositories = 'repositories', VcsComments = 'vcscomments', VcsCommentLocks = 'vcscommentlocks', + Reports = 'reports', + Insights = 'insights', Users = 'users', Cache = 'cache', Tokens = 'tokens', @@ -70,5 +72,6 @@ export enum QuerySuggestionResource { ResourceTokens = 'resourcetokens', Transactions = 'transactions', TransactionLogs = 'transactionlogs', + PresenceLogs = 'presencelogs', Stats = 'stats', } \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index f4d20688..a2b22ef0 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -30,6 +30,9 @@ export enum Runtime { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', + Deno121 = 'deno-1.21', + Deno124 = 'deno-1.24', + Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/enums/runtimes.ts b/src/enums/runtimes.ts index 22ed5856..af6abfa2 100644 --- a/src/enums/runtimes.ts +++ b/src/enums/runtimes.ts @@ -30,6 +30,9 @@ export enum Runtimes { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', + Deno121 = 'deno-1.21', + Deno124 = 'deno-1.24', + Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts index 532eb75c..69af4d56 100644 --- a/src/enums/scopes.ts +++ b/src/enums/scopes.ts @@ -78,6 +78,12 @@ export enum Scopes { SchedulesWrite = 'schedules.write', VcsRead = 'vcs.read', VcsWrite = 'vcs.write', + InsightsRead = 'insights.read', + InsightsWrite = 'insights.write', + ReportsRead = 'reports.read', + ReportsWrite = 'reports.write', + PresencesRead = 'presences.read', + PresencesWrite = 'presences.write', BackupsPoliciesRead = 'backups.policies.read', BackupsPoliciesWrite = 'backups.policies.write', ArchivesRead = 'archives.read', @@ -87,6 +93,7 @@ export enum Scopes { DomainsRead = 'domains.read', DomainsWrite = 'domains.write', EventsRead = 'events.read', + UsageRead = 'usage.read', ProjectsRead = 'projects.read', ProjectsWrite = 'projects.write', DevKeysRead = 'devKeys.read', diff --git a/src/index.ts b/src/index.ts index 3acb7d9f..37c577f7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,14 +23,17 @@ export { Manager } from './services/manager'; export { Messaging } from './services/messaging'; export { Migrations } from './services/migrations'; export { Organizations } from './services/organizations'; +export { Presences } from './services/presences'; export { Project } from './services/project'; export { Projects } from './services/projects'; export { Proxy } from './services/proxy'; +export { Advisor } from './services/advisor'; export { Sites } from './services/sites'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; export { Tokens } from './services/tokens'; +export { Usage } from './services/usage'; export { Users } from './services/users'; export { Vcs } from './services/vcs'; export { VectorsDB } from './services/vectors-db'; @@ -59,6 +62,8 @@ export { BackupServices } from './enums/backup-services'; export { Platform } from './enums/platform'; export { ConsoleResourceType } from './enums/console-resource-type'; export { QuerySuggestionResource } from './enums/query-suggestion-resource'; +export { ProjectEmailTemplateId } from './enums/project-email-template-id'; +export { ProjectEmailTemplateLocale } from './enums/project-email-template-locale'; export { UsageRange } from './enums/usage-range'; export { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; @@ -84,14 +89,14 @@ export { FirebaseMigrationResource } from './enums/firebase-migration-resource'; export { NHostMigrationResource } from './enums/n-host-migration-resource'; export { SupabaseMigrationResource } from './enums/supabase-migration-resource'; export { Addon } from './enums/addon'; -export { AuthMethod } from './enums/auth-method'; -export { Prompt } from './enums/prompt'; -export { ProjectPolicy } from './enums/project-policy'; -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 { ProjectAuthMethodId } from './enums/project-auth-method-id'; +export { ProjectKeyScopes } from './enums/project-key-scopes'; +export { ProjectOAuth2GooglePrompt } from './enums/project-o-auth-2-google-prompt'; +export { ProjectOAuthProviderId } from './enums/project-o-auth-provider-id'; +export { ProjectPolicyId } from './enums/project-policy-id'; +export { ProjectProtocolId } from './enums/project-protocol-id'; +export { ProjectServiceId } from './enums/project-service-id'; +export { ProjectSMTPSecure } from './enums/project-smtp-secure'; export { ProjectUsageRange } from './enums/project-usage-range'; export { Region } from './enums/region'; export { Status } from './enums/status'; diff --git a/src/models.ts b/src/models.ts index cef64a94..152b2bdc 100644 --- a/src/models.ts +++ b/src/models.ts @@ -7,6 +7,9 @@ import { DetectionRuntimeType } from "./enums/detection-runtime-type" import { DeploymentStatus } from "./enums/deployment-status" import { ExecutionTrigger } from "./enums/execution-trigger" import { ExecutionStatus } from "./enums/execution-status" +import { ProjectAuthMethodId } from "./enums/project-auth-method-id" +import { ProjectServiceId } from "./enums/project-service-id" +import { ProjectProtocolId } from "./enums/project-protocol-id" import { OAuth2GooglePrompt } from "./enums/o-auth-2-google-prompt" import { PlatformType } from "./enums/platform-type" import { HealthAntivirusStatus } from "./enums/health-antivirus-status" @@ -53,6 +56,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 */ @@ -817,6 +834,34 @@ export namespace Models { embeddings: Embedding[]; } + /** + * Insights List + */ + export type InsightList = { + /** + * Total number of insights that matched your query. + */ + total: number; + /** + * List of insights. + */ + insights: Insight[]; + } + + /** + * Reports List + */ + export type ReportList = { + /** + * Total number of reports that matched your query. + */ + total: number; + /** + * List of reports. + */ + reports: Report[]; + } + /** * Database */ @@ -848,11 +893,11 @@ export namespace Models { /** * Database backup policies. */ - policies: Index[]; + policies: BackupPolicy[]; /** * Database backup archives. */ - archives: Collection[]; + archives: BackupArchive[]; } /** @@ -3183,6 +3228,49 @@ export namespace Models { [__default]: true; }; + /** + * Presence + */ + export type Presence = { + /** + * Presence ID. + */ + $id: 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 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 */ @@ -3784,6 +3872,10 @@ export namespace Models { * File original size in bytes. */ sizeOriginal: number; + /** + * File actual stored size in bytes after compression and/or encryption. + */ + sizeActual: number; /** * Total number of chunks available */ @@ -5056,132 +5148,12 @@ export namespace Models { * Project name. */ name: string; - /** - * Project description. - */ - description: string; /** * Project team ID. */ teamId: string; /** - * Project logo file ID. - */ - logo: string; - /** - * Project website URL. - */ - url: string; - /** - * Company legal name. - */ - legalName: string; - /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format. - */ - legalCountry: string; - /** - * State name. - */ - legalState: string; - /** - * City name. - */ - legalCity: string; - /** - * Company Address. - */ - legalAddress: string; - /** - * Company Tax ID. - */ - legalTaxId: string; - /** - * Session duration in seconds. - */ - authDuration: number; - /** - * Max users allowed. 0 is unlimited. - */ - authLimit: number; - /** - * Max sessions allowed per user. 100 maximum. - */ - authSessionsLimit: number; - /** - * Max allowed passwords in the history list per user. Max passwords limit allowed in history is 20. Use 0 for disabling password history. - */ - authPasswordHistory: number; - /** - * Whether or not to check user's password against most commonly used passwords. - */ - authPasswordDictionary: boolean; - /** - * Whether or not to check the user password for similarity with their personal data. - */ - authPersonalDataCheck: boolean; - /** - * Whether or not to disallow disposable email addresses during signup and email updates. - */ - authDisposableEmails: boolean; - /** - * Whether or not to require canonical email addresses during signup and email updates. - */ - authCanonicalEmails: boolean; - /** - * Whether or not to disallow free email addresses during signup and email updates. - */ - authFreeEmails: boolean; - /** - * An array of mock numbers and their corresponding verification codes (OTPs). - */ - authMockNumbers: MockNumber[]; - /** - * Whether or not to send session alert emails to users. - */ - authSessionAlerts: boolean; - /** - * Whether or not to show user names in the teams membership response. - */ - authMembershipsUserName: boolean; - /** - * Whether or not to show user emails in the teams membership response. - */ - authMembershipsUserEmail: boolean; - /** - * 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 - */ - authInvalidateSessions: boolean; - /** - * List of Auth Providers. - */ - oAuthProviders: AuthProvider[]; - /** - * List of Platforms. - */ - platforms: (Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux)[]; - /** - * List of Webhooks. - */ - webhooks: Webhook[]; - /** - * List of API Keys. - */ - keys: Key[]; - /** - * List of dev keys. + * Deprecated since 1.9.5: List of dev keys. */ devKeys: DevKey[]; /** @@ -5241,129 +5213,75 @@ export namespace Models { */ status: string; /** - * Email/Password auth method status - */ - authEmailPassword: boolean; - /** - * Magic URL auth method status - */ - authUsersAuthMagicURL: boolean; - /** - * Email (OTP) auth method status - */ - authEmailOtp: boolean; - /** - * Anonymous auth method status - */ - authAnonymous: boolean; - /** - * Invites auth method status - */ - authInvites: boolean; - /** - * JWT auth method status - */ - authJWT: boolean; - /** - * Phone auth method status - */ - authPhone: boolean; - /** - * Account service status - */ - serviceStatusForAccount: boolean; - /** - * Avatars service status - */ - serviceStatusForAvatars: boolean; - /** - * Databases (legacy) service status + * List of auth methods. */ - serviceStatusForDatabases: boolean; + authMethods: ProjectAuthMethod[]; /** - * TablesDB service status + * List of services. */ - serviceStatusForTablesdb: boolean; + services: ProjectService[]; /** - * Locale service status + * List of protocols. */ - serviceStatusForLocale: boolean; + protocols: ProjectProtocol[]; /** - * Health service status - */ - serviceStatusForHealth: boolean; - /** - * Project service status - */ - serviceStatusForProject: boolean; - /** - * Storage service status - */ - serviceStatusForStorage: boolean; - /** - * Teams service status - */ - serviceStatusForTeams: boolean; - /** - * Users service status - */ - serviceStatusForUsers: boolean; - /** - * VCS service status - */ - serviceStatusForVcs: boolean; - /** - * Sites service status - */ - serviceStatusForSites: boolean; - /** - * Functions service status - */ - serviceStatusForFunctions: boolean; - /** - * Proxy service status - */ - serviceStatusForProxy: boolean; - /** - * GraphQL service status + * Project region */ - serviceStatusForGraphql: boolean; + region: string; /** - * Migrations service status + * Billing limits reached */ - serviceStatusForMigrations: boolean; + billingLimits?: BillingLimits; /** - * Messaging service status + * Project blocks information */ - serviceStatusForMessaging: boolean; + blocks: Block[]; /** - * REST protocol status + * Last time the project was accessed via console. Used with plan's projectInactivityDays to determine if project is paused. */ - protocolStatusForRest: boolean; + consoleAccessedAt: string; + } + + /** + * ProjectAuthMethod + */ + export type ProjectAuthMethod = { /** - * GraphQL protocol status + * Auth method ID. */ - protocolStatusForGraphql: boolean; + $id: ProjectAuthMethodId; /** - * Websocket protocol status + * Auth method status. */ - protocolStatusForWebsocket: boolean; + enabled: boolean; + } + + /** + * ProjectService + */ + export type ProjectService = { /** - * Project region + * Service ID. */ - region: string; + $id: ProjectServiceId; /** - * Billing limits reached + * Service status. */ - billingLimits: BillingLimits; + enabled: boolean; + } + + /** + * ProjectProtocol + */ + export type ProjectProtocol = { /** - * Project blocks information + * Protocol ID. */ - blocks: Block[]; + $id: ProjectProtocolId; /** - * Last time the project was accessed via console. Used with plan's projectInactivityDays to determine if project is paused. + * Protocol status. */ - consoleAccessedAt: string; + enabled: boolean; } /** @@ -6668,32 +6586,6 @@ export namespace Models { 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 */ @@ -7322,6 +7214,24 @@ export namespace Models { sessions: Metric[]; } + /** + * UsagePresence + */ + export type UsagePresence = { + /** + * Time range of the usage stats. + */ + range: string; + /** + * Current total number of online users. + */ + usersOnlineTotal: number; + /** + * Aggregated number of online users per period. + */ + presences: Metric[]; + } + /** * StorageUsage */ @@ -8964,6 +8874,10 @@ export namespace Models { * Number of functions to be migrated. */ function: number; + /** + * Number of platforms to be migrated. + */ + platform: number; /** * Number of sites to be migrated. */ @@ -8992,6 +8906,160 @@ export namespace Models { * Version of the Appwrite instance to be migrated. */ version: string; + /** + * Number of backup policies to be migrated. + */ + backuppolicy: number; + } + + /** + * Insight + */ + export type Insight = { + /** + * Insight ID. + */ + $id: string; + /** + * Insight creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Insight update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Parent report ID. Insights always belong to a report. + */ + reportId: string; + /** + * Insight type. One of databaseIndex (legacy), tablesDBIndex, documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, siteAccessibility, siteSeo, functionPerformance. The index types are engine-specific so each CTA can pair the right service+method (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or vectorsDB.createIndex). + */ + type: string; + /** + * Insight severity. One of info, warning, critical. + */ + severity: string; + /** + * Insight status. One of active, dismissed. + */ + status: string; + /** + * Type of the resource the insight is about. Plural noun, e.g. databases, sites, functions. + */ + resourceType: string; + /** + * ID of the resource the insight is about. + */ + resourceId: string; + /** + * Plural noun for the parent resource that contains the insight's resource, e.g. an insight about a column index on a table → resourceType=indexes, parentResourceType=tables. Empty when the resource has no parent. + */ + parentResourceType: string; + /** + * ID of the parent resource. Empty when the resource has no parent. + */ + parentResourceId: string; + /** + * Insight title. + */ + title: string; + /** + * Short markdown summary describing the insight. + */ + summary: string; + /** + * List of call-to-action buttons attached to this insight. + */ + ctas: InsightCTA[]; + /** + * Time the insight was analyzed in ISO 8601 format. + */ + analyzedAt?: string; + /** + * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. + */ + dismissedAt?: string; + /** + * User ID that dismissed the insight. Empty when not dismissed. + */ + dismissedBy?: string; + } + + /** + * InsightCTA + */ + export type InsightCTA = { + /** + * Human-readable label for the CTA, used in UI. + */ + label: string; + /** + * Public API service (SDK namespace) the client should invoke. Must match the engine that owns the resource — for index suggestions: databases (legacy), tablesDB, documentsDB, or vectorsDB. + */ + service: string; + /** + * Public API method on the chosen service the client should invoke when this CTA is triggered. + */ + method: string; + /** + * Parameter map the client should pass to the service method when this CTA is triggered. Keys match the target API's parameter names (e.g. databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes for the legacy Databases API). + */ + params: object; + } + + /** + * Report + */ + export type Report = { + /** + * Report ID. + */ + $id: string; + /** + * Report creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Report update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ID of the third-party app that submitted the report. + */ + appId: string; + /** + * Analyzer that produced this report. e.g. lighthouse, audit, databaseAnalyzer. + */ + type: string; + /** + * Short, human-readable title for the report. + */ + title: string; + /** + * Markdown summary describing the report. + */ + summary: string; + /** + * Plural noun describing what the report analyzes, e.g. databases, sites, urls. + */ + targetType: string; + /** + * Free-form target identifier (URL for lighthouse, resource ID for db). + */ + target: string; + /** + * Categories covered by the report, e.g. performance, accessibility. + */ + categories: string[]; + /** + * Insights nested under this report. + */ + insights: Insight[]; + /** + * Time the report was analyzed in ISO 8601 format. + */ + analyzedAt?: string; } /** @@ -9739,35 +9807,35 @@ export namespace Models { /** * Bandwidth limit */ - bandwidth: number; + bandwidth?: number; /** * Storage limit */ - storage: number; + storage?: number; /** * Users limit */ - users: number; + users?: number; /** * Executions limit */ - executions: number; + executions?: number; /** * GBHours limit */ - GBHours: number; + GBHours?: number; /** * Image transformations limit */ - imageTransformations: number; + imageTransformations?: number; /** * Auth phone limit */ - authPhone: number; + authPhone?: number; /** * Budget limit percentage */ - budgetLimit: number; + budgetLimit?: number; } /** @@ -10309,7 +10377,7 @@ export namespace Models { /** * Billing limits reached */ - billingLimits: BillingLimits; + billingLimits?: BillingLimits; /** * Billing plan selected for downgrade. */ @@ -10610,6 +10678,98 @@ export namespace Models { roles: string[]; } + /** + * usageEvent + */ + export type UsageEvent = { + /** + * The metric key. + */ + metric: string; + /** + * The metric value. + */ + value: number; + /** + * The event timestamp. + */ + time: string; + /** + * The API endpoint path. + */ + path: string; + /** + * The HTTP method. + */ + method: string; + /** + * HTTP status code. Stored as string to preserve unset state (empty string = not available). + */ + status: string; + /** + * The resource type. + */ + resourceType: string; + /** + * The resource ID. + */ + resourceId: string; + /** + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format. + */ + countryCode: string; + /** + * The user agent string. + */ + userAgent: string; + } + + /** + * Usage events list + */ + export type UsageEventList = { + /** + * Total number of events that matched your query. + */ + total: number; + /** + * List of events. + */ + events: UsageEvent[]; + } + + /** + * usageGauge + */ + export type UsageGauge = { + /** + * The metric key. + */ + metric: string; + /** + * The current snapshot value. + */ + value: number; + /** + * The snapshot timestamp. + */ + time: string; + } + + /** + * Usage gauges list + */ + export type UsageGaugeList = { + /** + * Total number of gauges that matched your query. + */ + total: number; + /** + * List of gauges. + */ + gauges: UsageGauge[]; + } + /** * UsageOrganization */ diff --git a/src/services/advisor.ts b/src/services/advisor.ts new file mode 100644 index 00000000..ed87a3fa --- /dev/null +++ b/src/services/advisor.ts @@ -0,0 +1,309 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Advisor { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all the project's analyzer reports. You can use the query params to filter your results. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listReports(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all the project's analyzer reports. You can use the query params to filter your results. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt + * @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. + */ + listReports(queries?: string[], total?: boolean): Promise; + listReports( + 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 = '/reports'; + 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 an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. + * + * + * @param {string} params.reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getReport(params: { reportId: string }): Promise; + /** + * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. + * + * + * @param {string} reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReport(reportId: string): Promise; + getReport( + paramsOrFirst: { reportId: string } | string + ): Promise { + let params: { reportId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string }; + } else { + params = { + reportId: paramsOrFirst as string + }; + } + + const reportId = params.reportId; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + const apiPath = '/reports/{reportId}'.replace('{reportId}', reportId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. + * + * + * @param {string} params.reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteReport(params: { reportId: string }): Promise<{}>; + /** + * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. + * + * + * @param {string} reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteReport(reportId: string): Promise<{}>; + deleteReport( + paramsOrFirst: { reportId: string } | string + ): Promise<{}> { + let params: { reportId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string }; + } else { + params = { + reportId: paramsOrFirst as string + }; + } + + const reportId = params.reportId; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + const apiPath = '/reports/{reportId}'.replace('{reportId}', reportId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * List the insights produced under a single analyzer report. You can use the query params to filter your results further. + * + * + * @param {string} params.reportId - Parent report 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listInsights(params: { reportId: string, queries?: string[], total?: boolean }): Promise; + /** + * List the insights produced under a single analyzer report. You can use the query params to filter your results further. + * + * + * @param {string} reportId - Parent report 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy + * @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. + */ + listInsights(reportId: string, queries?: string[], total?: boolean): Promise; + listInsights( + paramsOrFirst: { reportId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise { + let params: { reportId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string, queries?: string[], total?: boolean }; + } else { + params = { + reportId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const reportId = params.reportId; + const queries = params.queries; + const total = params.total; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + const apiPath = '/reports/{reportId}/insights'.replace('{reportId}', reportId); + 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 an insight by its unique ID, scoped to its parent report. + * + * + * @param {string} params.reportId - Parent report ID. + * @param {string} params.insightId - Insight ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getInsight(params: { reportId: string, insightId: string }): Promise; + /** + * Get an insight by its unique ID, scoped to its parent report. + * + * + * @param {string} reportId - Parent report ID. + * @param {string} insightId - Insight ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getInsight(reportId: string, insightId: string): Promise; + getInsight( + paramsOrFirst: { reportId: string, insightId: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { reportId: string, insightId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string, insightId: string }; + } else { + params = { + reportId: paramsOrFirst as string, + insightId: rest[0] as string + }; + } + + const reportId = params.reportId; + const insightId = params.insightId; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + if (typeof insightId === 'undefined') { + throw new AppwriteException('Missing required parameter: "insightId"'); + } + + const apiPath = '/reports/{reportId}/insights/{insightId}'.replace('{reportId}', reportId).replace('{insightId}', insightId); + 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 + ); + } +} diff --git a/src/services/console.ts b/src/services/console.ts index 8e26188b..278fc464 100644 --- a/src/services/console.ts +++ b/src/services/console.ts @@ -5,6 +5,8 @@ import type { Models } from '../models'; import { Platform } from '../enums/platform'; import { ConsoleResourceType } from '../enums/console-resource-type'; import { QuerySuggestionResource } from '../enums/query-suggestion-resource'; +import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; +import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; export class Console { client: Client; @@ -431,6 +433,29 @@ export class Console { ); } + /** + * List all scopes available for organization API keys, along with a description for each scope. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + listOrganizationScopes(): Promise { + + const apiPath = '/console/scopes/organization'; + 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 + ); + } + /** * List all scopes available for project API keys, along with a description for each scope. * @@ -781,6 +806,65 @@ export class Console { ); } + /** + * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. + * + * @param {ProjectEmailTemplateId} params.templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} params.locale - Template locale. If left empty, the fallback locale (en) will be used. + * @throws {AppwriteException} + * @returns {Promise} + */ + getEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }): Promise; + /** + * Get the Appwrite built-in default email template for the specified type and locale. Always returns the unmodified default, ignoring any custom project overrides. + * + * @param {ProjectEmailTemplateId} templateId - Email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} locale - Template locale. If left empty, the fallback locale (en) will be used. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale): Promise; + getEmailTemplate( + paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale } | ProjectEmailTemplateId, + ...rest: [(ProjectEmailTemplateLocale)?] + ): Promise { + let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + } else { + params = { + templateId: paramsOrFirst as ProjectEmailTemplateId, + locale: rest[0] as ProjectEmailTemplateLocale + }; + } + + const templateId = params.templateId; + const locale = params.locale; + + if (typeof templateId === 'undefined') { + throw new AppwriteException('Missing required parameter: "templateId"'); + } + + const apiPath = '/console/templates/email/{templateId}'.replace('{templateId}', templateId); + const payload: Payload = {}; + if (typeof locale !== 'undefined') { + payload['locale'] = locale; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Get all Environment Variables that are relevant for the console. * diff --git a/src/services/presences.ts b/src/services/presences.ts new file mode 100644 index 00000000..373a2530 --- /dev/null +++ b/src/services/presences.ts @@ -0,0 +1,437 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { UsageRange } from '../enums/usage-range'; + +export class Presences { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List presence logs. Expired entries are filtered out automatically. + * + * + * @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. Expired entries are filtered out automatically. + * + * + * @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 presence usage metrics, including the current total of online users and historical online user counts for the selected time range. + * + * + * @param {UsageRange} params.range - Date range. + * @throws {AppwriteException} + * @returns {Promise} + */ + getUsage(params?: { range?: UsageRange }): Promise; + /** + * Get presence usage metrics, including the current total of online users and historical online user counts for the selected time range. + * + * + * @param {UsageRange} range - Date range. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getUsage(range?: UsageRange): Promise; + getUsage( + paramsOrFirst?: { range?: UsageRange } | UsageRange + ): Promise { + let params: { range?: UsageRange }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('range' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { range?: UsageRange }; + } else { + params = { + range: paramsOrFirst as UsageRange + }; + } + + const range = params.range; + + + const apiPath = '/presences/usage'; + const payload: Payload = {}; + if (typeof range !== 'undefined') { + payload['range'] = range; + } + 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. Entries whose `expiresAt` is in the past are treated as not found. + * + * + * @param {string} params.presenceId - Presence unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + get(params: { presenceId: string }): Promise; + /** + * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. + * + * + * @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 user 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 user 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. Using the patch method you can pass only specific fields that will get updated. + * + * + * @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. Using the patch method you can pass only specific fields that will get updated. + * + * + * @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 727f6dd5..ce272371 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -2,16 +2,16 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { AuthMethod } from '../enums/auth-method'; -import { Scopes } from '../enums/scopes'; -import { Prompt } from '../enums/prompt'; -import { OAuthProvider } from '../enums/o-auth-provider'; -import { ProjectPolicy } from '../enums/project-policy'; -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'; +import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; +import { ProjectOAuth2GooglePrompt } from '../enums/project-o-auth-2-google-prompt'; +import { ProjectOAuthProviderId } from '../enums/project-o-auth-provider-id'; +import { ProjectPolicyId } from '../enums/project-policy-id'; +import { ProjectProtocolId } from '../enums/project-protocol-id'; +import { ProjectServiceId } from '../enums/project-service-id'; +import { ProjectSMTPSecure } from '../enums/project-smtp-secure'; +import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; +import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; import { ProjectUsageRange } from '../enums/project-usage-range'; export class Project { @@ -21,6 +21,29 @@ export class Project { this.client = client; } + /** + * Get a project. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + get(): Promise { + + const apiPath = '/project'; + 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 project. * @@ -48,33 +71,33 @@ export class Project { /** * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. * - * @param {AuthMethod} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + * @param {ProjectAuthMethodId} 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: AuthMethod, enabled: boolean }): Promise; + updateAuthMethod(params: { methodId: ProjectAuthMethodId, enabled: boolean }): Promise; /** * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. * - * @param {AuthMethod} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + * @param {ProjectAuthMethodId} 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: AuthMethod, enabled: boolean): Promise; + updateAuthMethod(methodId: ProjectAuthMethodId, enabled: boolean): Promise; updateAuthMethod( - paramsOrFirst: { methodId: AuthMethod, enabled: boolean } | AuthMethod, + paramsOrFirst: { methodId: ProjectAuthMethodId, enabled: boolean } | ProjectAuthMethodId, ...rest: [(boolean)?] ): Promise { - let params: { methodId: AuthMethod, enabled: boolean }; + let params: { methodId: ProjectAuthMethodId, enabled: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { methodId: AuthMethod, enabled: boolean }; + params = (paramsOrFirst || {}) as { methodId: ProjectAuthMethodId, enabled: boolean }; } else { params = { - methodId: paramsOrFirst as AuthMethod, + methodId: paramsOrFirst as ProjectAuthMethodId, enabled: rest[0] as boolean }; } @@ -174,12 +197,12 @@ export class Project { * * @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. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} */ - createKey(params: { keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; + createKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], 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. * @@ -187,26 +210,26 @@ export class Project { * * @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. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createKey(keyId: string, name: string, scopes: Scopes[], expire?: string): Promise; + createKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise; createKey( - paramsOrFirst: { keyId: string, name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(string)?, (Scopes[])?, (string)?] + paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] ): Promise { - let params: { keyId: string, name: string, scopes: Scopes[], expire?: string }; + let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: Scopes[], expire?: string }; + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, - scopes: rest[1] as Scopes[], + scopes: rest[1] as ProjectKeyScopes[], expire: rest[2] as string }; } @@ -259,35 +282,35 @@ export class 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 {ProjectKeyScopes[]} 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; + createEphemeralKey(params: { scopes: ProjectKeyScopes[], 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 {ProjectKeyScopes[]} 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(scopes: ProjectKeyScopes[], duration: number): Promise; createEphemeralKey( - paramsOrFirst: { scopes: Scopes[], duration: number } | Scopes[], + paramsOrFirst: { scopes: ProjectKeyScopes[], duration: number } | ProjectKeyScopes[], ...rest: [(number)?] ): Promise { - let params: { scopes: Scopes[], duration: number }; + let params: { scopes: ProjectKeyScopes[], duration: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { scopes: Scopes[], duration: number }; + params = (paramsOrFirst || {}) as { scopes: ProjectKeyScopes[], duration: number }; } else { params = { - scopes: paramsOrFirst as Scopes[], + scopes: paramsOrFirst as ProjectKeyScopes[], duration: rest[0] as number }; } @@ -380,37 +403,37 @@ export class Project { * * @param {string} params.keyId - Key ID. * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; + updateKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * * @param {string} keyId - Key ID. * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: Scopes[], expire?: string): Promise; + updateKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(string)?, (Scopes[])?, (string)?] + paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] ): Promise { - let params: { keyId: string, name: string, scopes: Scopes[], expire?: string }; + let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: Scopes[], expire?: string }; + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, - scopes: rest[1] as Scopes[], + scopes: rest[1] as ProjectKeyScopes[], expire: rest[2] as string }; } @@ -2164,38 +2187,38 @@ export class Project { * Update the project OAuth2 Google configuration. * * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {Prompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: example-google-client-secret + * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. * @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, prompt?: Prompt[], enabled?: boolean }): Promise; + updateOAuth2Google(params?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }): Promise; /** * Update the project OAuth2 Google configuration. * * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj - * @param {Prompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: example-google-client-secret + * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. * @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, prompt?: Prompt[], enabled?: boolean): Promise; + updateOAuth2Google(clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean): Promise; updateOAuth2Google( - paramsOrFirst?: { clientId?: string, clientSecret?: string, prompt?: Prompt[], enabled?: boolean } | string, - ...rest: [(string)?, (Prompt[])?, (boolean)?] + paramsOrFirst?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean } | string, + ...rest: [(string)?, (ProjectOAuth2GooglePrompt[])?, (boolean)?] ): Promise { - let params: { clientId?: string, clientSecret?: string, prompt?: Prompt[], enabled?: boolean }; + let params: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, prompt?: Prompt[], enabled?: boolean }; + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; } else { params = { clientId: paramsOrFirst as string, clientSecret: rest[0] as string, - prompt: rest[1] as Prompt[], + prompt: rest[1] as ProjectOAuth2GooglePrompt[], enabled: rest[2] as boolean }; } @@ -2386,7 +2409,7 @@ export class Project { * 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: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: example-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} @@ -2396,7 +2419,7 @@ export class Project { * 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: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: example-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} @@ -3841,30 +3864,30 @@ export class Project { /** * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. * - * @param {OAuthProvider} params.providerId - OAuth2 provider key. For example: github, google, apple. + * @param {ProjectOAuthProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. * @throws {AppwriteException} * @returns {Promise} */ - getOAuth2Provider(params: { providerId: OAuthProvider }): Promise; + getOAuth2Provider(params: { providerId: ProjectOAuthProviderId }): Promise; /** * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. * - * @param {OAuthProvider} providerId - OAuth2 provider key. For example: github, google, apple. + * @param {ProjectOAuthProviderId} 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: OAuthProvider): Promise; + getOAuth2Provider(providerId: ProjectOAuthProviderId): Promise; getOAuth2Provider( - paramsOrFirst: { providerId: OAuthProvider } | OAuthProvider + paramsOrFirst: { providerId: ProjectOAuthProviderId } | ProjectOAuthProviderId ): Promise { - let params: { providerId: OAuthProvider }; + let params: { providerId: ProjectOAuthProviderId }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('providerId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: OAuthProvider }; + params = (paramsOrFirst || {}) as { providerId: ProjectOAuthProviderId }; } else { params = { - providerId: paramsOrFirst as OAuthProvider + providerId: paramsOrFirst as ProjectOAuthProviderId }; } @@ -4856,23 +4879,23 @@ export class Project { } /** - * Configures if email aliases such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. + * Configures if aliased emails such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. * - * @param {boolean} params.enabled - Set whether or not to block email aliases during signup and email updates. + * @param {boolean} params.enabled - Set whether or not to block aliased emails during signup and email updates. * @throws {AppwriteException} * @returns {Promise} */ - updateDenyCanonicalEmailPolicy(params: { enabled: boolean }): Promise; + updateDenyAliasedEmailPolicy(params: { enabled: boolean }): Promise; /** - * Configures if email aliases such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. + * Configures if aliased emails such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. * - * @param {boolean} enabled - Set whether or not to block email aliases during signup and email updates. + * @param {boolean} enabled - Set whether or not to block aliased emails during signup and email updates. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateDenyCanonicalEmailPolicy(enabled: boolean): Promise; - updateDenyCanonicalEmailPolicy( + updateDenyAliasedEmailPolicy(enabled: boolean): Promise; + updateDenyAliasedEmailPolicy( paramsOrFirst: { enabled: boolean } | boolean ): Promise { let params: { enabled: boolean }; @@ -4891,7 +4914,7 @@ export class Project { throw new AppwriteException('Missing required parameter: "enabled"'); } - const apiPath = '/project/policies/deny-canonical-email'; + const apiPath = '/project/policies/deny-aliased-email'; const payload: Payload = {}; if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; @@ -5548,30 +5571,30 @@ export class Project { /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicy} 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. + * @param {ProjectPolicyId} 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} */ - getPolicy(params: { policyId: ProjectPolicy }): Promise; + getPolicy(params: { policyId: ProjectPolicyId }): Promise; /** * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. * - * @param {ProjectPolicy} 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. + * @param {ProjectPolicyId} 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} * @deprecated Use the object parameter style method for a better developer experience. */ - getPolicy(policyId: ProjectPolicy): Promise; + getPolicy(policyId: ProjectPolicyId): Promise; getPolicy( - paramsOrFirst: { policyId: ProjectPolicy } | ProjectPolicy + paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId ): Promise { - let params: { policyId: ProjectPolicy }; + let params: { policyId: ProjectPolicyId }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('policyId' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { policyId: ProjectPolicy }; + params = (paramsOrFirst || {}) as { policyId: ProjectPolicyId }; } else { params = { - policyId: paramsOrFirst as ProjectPolicy + policyId: paramsOrFirst as ProjectPolicyId }; } @@ -5599,33 +5622,33 @@ export class Project { /** * 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 {ProjectProtocolId} 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; + updateProtocol(params: { protocolId: ProjectProtocolId, 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 {ProjectProtocolId} 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(protocolId: ProjectProtocolId, enabled: boolean): Promise; updateProtocol( - paramsOrFirst: { protocolId: ProtocolId, enabled: boolean } | ProtocolId, + paramsOrFirst: { protocolId: ProjectProtocolId, enabled: boolean } | ProjectProtocolId, ...rest: [(boolean)?] ): Promise { - let params: { protocolId: ProtocolId, enabled: boolean }; + let params: { protocolId: ProjectProtocolId, enabled: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { protocolId: ProtocolId, enabled: boolean }; + params = (paramsOrFirst || {}) as { protocolId: ProjectProtocolId, enabled: boolean }; } else { params = { - protocolId: paramsOrFirst as ProtocolId, + protocolId: paramsOrFirst as ProjectProtocolId, enabled: rest[0] as boolean }; } @@ -5662,33 +5685,33 @@ export class Project { /** * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * - * @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 {ProjectServiceId} 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, advisor * @param {boolean} params.enabled - Service status. * @throws {AppwriteException} * @returns {Promise} */ - updateService(params: { serviceId: ServiceId, enabled: boolean }): Promise; + updateService(params: { serviceId: ProjectServiceId, enabled: boolean }): Promise; /** * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. * - * @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 {ProjectServiceId} serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor * @param {boolean} enabled - Service status. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateService(serviceId: ServiceId, enabled: boolean): Promise; + updateService(serviceId: ProjectServiceId, enabled: boolean): Promise; updateService( - paramsOrFirst: { serviceId: ServiceId, enabled: boolean } | ServiceId, + paramsOrFirst: { serviceId: ProjectServiceId, enabled: boolean } | ProjectServiceId, ...rest: [(boolean)?] ): Promise { - let params: { serviceId: ServiceId, enabled: boolean }; + let params: { serviceId: ProjectServiceId, enabled: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { serviceId: ServiceId, enabled: boolean }; + params = (paramsOrFirst || {}) as { serviceId: ProjectServiceId, enabled: boolean }; } else { params = { - serviceId: paramsOrFirst as ServiceId, + serviceId: paramsOrFirst as ProjectServiceId, enabled: rest[0] as boolean }; } @@ -5733,12 +5756,12 @@ export class Project { * @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 {ProjectSMTPSecure} 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} */ - updateSMTP(params?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean }): Promise; + updateSMTP(params?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }): Promise; /** * 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. * @@ -5750,21 +5773,21 @@ export class Project { * @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 {ProjectSMTPSecure} 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} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSMTP(host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean): Promise; + updateSMTP(host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, 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)?] + paramsOrFirst?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean } | string, + ...rest: [(number)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (ProjectSMTPSecure)?, (boolean)?] ): Promise { - let params: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: Secure, enabled?: boolean }; + let params: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; 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 }; + params = (paramsOrFirst || {}) as { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; } else { params = { host: paramsOrFirst as string, @@ -5775,7 +5798,7 @@ export class Project { senderName: rest[4] as string, replyToEmail: rest[5] as string, replyToName: rest[6] as string, - secure: rest[7] as Secure, + secure: rest[7] as ProjectSMTPSecure, enabled: rest[8] as boolean }; } @@ -5955,8 +5978,8 @@ export class Project { /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @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 {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} 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. @@ -5966,12 +5989,12 @@ export class Project { * @throws {AppwriteException} * @returns {Promise} */ - updateEmailTemplate(params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }): Promise; + updateEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }): Promise; /** * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. * - * @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 {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} 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. @@ -5982,19 +6005,19 @@ export class Project { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateEmailTemplate(templateId: EmailTemplateType, locale?: EmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string): Promise; + updateEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, 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)?] + paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string } | ProjectEmailTemplateId, + ...rest: [(ProjectEmailTemplateLocale)?, (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 }; + let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; 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 }; + params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; } else { params = { - templateId: paramsOrFirst as EmailTemplateType, - locale: rest[0] as EmailTemplateLocale, + templateId: paramsOrFirst as ProjectEmailTemplateId, + locale: rest[0] as ProjectEmailTemplateLocale, subject: rest[1] as string, message: rest[2] as string, senderName: rest[3] as string, @@ -6060,34 +6083,34 @@ export class Project { /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @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 {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} */ - getEmailTemplate(params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale }): Promise; + getEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }): Promise; /** * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. * - * @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 {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getEmailTemplate(templateId: EmailTemplateType, locale?: EmailTemplateLocale): Promise; + getEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale): Promise; getEmailTemplate( - paramsOrFirst: { templateId: EmailTemplateType, locale?: EmailTemplateLocale } | EmailTemplateType, - ...rest: [(EmailTemplateLocale)?] + paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale } | ProjectEmailTemplateId, + ...rest: [(ProjectEmailTemplateLocale)?] ): Promise { - let params: { templateId: EmailTemplateType, locale?: EmailTemplateLocale }; + let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { templateId: EmailTemplateType, locale?: EmailTemplateLocale }; + params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; } else { params = { - templateId: paramsOrFirst as EmailTemplateType, - locale: rest[0] as EmailTemplateLocale + templateId: paramsOrFirst as ProjectEmailTemplateId, + locale: rest[0] as ProjectEmailTemplateLocale }; } diff --git a/src/services/projects.ts b/src/services/projects.ts index e5721313..22fb0006 100644 --- a/src/services/projects.ts +++ b/src/services/projects.ts @@ -86,19 +86,10 @@ export class Projects { * @param {string} params.name - Project name. Max length: 128 chars. * @param {string} params.teamId - Team unique ID. * @param {Region} params.region - Project Region. - * @param {string} params.description - Project description. Max length: 256 chars. - * @param {string} params.logo - Project logo. - * @param {string} params.url - Project URL. - * @param {string} params.legalName - Project legal Name. Max length: 256 chars. - * @param {string} params.legalCountry - Project legal Country. Max length: 256 chars. - * @param {string} params.legalState - Project legal State. Max length: 256 chars. - * @param {string} params.legalCity - Project legal City. Max length: 256 chars. - * @param {string} params.legalAddress - Project legal Address. Max length: 256 chars. - * @param {string} params.legalTaxId - Project legal Tax ID. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { projectId: string, name: string, teamId: string, region?: Region, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string }): Promise; + create(params: { projectId: string, name: string, teamId: string, region?: Region }): Promise; /** * Create a new project. You can create a maximum of 100 projects per account. * @@ -106,43 +97,25 @@ export class Projects { * @param {string} name - Project name. Max length: 128 chars. * @param {string} teamId - Team unique ID. * @param {Region} region - Project Region. - * @param {string} description - Project description. Max length: 256 chars. - * @param {string} logo - Project logo. - * @param {string} url - Project URL. - * @param {string} legalName - Project legal Name. Max length: 256 chars. - * @param {string} legalCountry - Project legal Country. Max length: 256 chars. - * @param {string} legalState - Project legal State. Max length: 256 chars. - * @param {string} legalCity - Project legal City. Max length: 256 chars. - * @param {string} legalAddress - Project legal Address. Max length: 256 chars. - * @param {string} legalTaxId - Project legal Tax ID. Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(projectId: string, name: string, teamId: string, region?: Region, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string): Promise; + create(projectId: string, name: string, teamId: string, region?: Region): Promise; create( - paramsOrFirst: { projectId: string, name: string, teamId: string, region?: Region, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string } | string, - ...rest: [(string)?, (string)?, (Region)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + paramsOrFirst: { projectId: string, name: string, teamId: string, region?: Region } | string, + ...rest: [(string)?, (string)?, (Region)?] ): Promise { - let params: { projectId: string, name: string, teamId: string, region?: Region, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string }; + let params: { projectId: string, name: string, teamId: string, region?: Region }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string, teamId: string, region?: Region, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string }; + params = (paramsOrFirst || {}) as { projectId: string, name: string, teamId: string, region?: Region }; } else { params = { projectId: paramsOrFirst as string, name: rest[0] as string, teamId: rest[1] as string, - region: rest[2] as Region, - description: rest[3] as string, - logo: rest[4] as string, - url: rest[5] as string, - legalName: rest[6] as string, - legalCountry: rest[7] as string, - legalState: rest[8] as string, - legalCity: rest[9] as string, - legalAddress: rest[10] as string, - legalTaxId: rest[11] as string + region: rest[2] as Region }; } @@ -150,15 +123,6 @@ export class Projects { const name = params.name; const teamId = params.teamId; const region = params.region; - const description = params.description; - const logo = params.logo; - const url = params.url; - const legalName = params.legalName; - const legalCountry = params.legalCountry; - const legalState = params.legalState; - const legalCity = params.legalCity; - const legalAddress = params.legalAddress; - const legalTaxId = params.legalTaxId; if (typeof projectId === 'undefined') { throw new AppwriteException('Missing required parameter: "projectId"'); @@ -184,33 +148,6 @@ export class Projects { if (typeof region !== 'undefined') { payload['region'] = region; } - if (typeof description !== 'undefined') { - payload['description'] = description; - } - if (typeof logo !== 'undefined') { - payload['logo'] = logo; - } - if (typeof url !== 'undefined') { - payload['url'] = url; - } - if (typeof legalName !== 'undefined') { - payload['legalName'] = legalName; - } - if (typeof legalCountry !== 'undefined') { - payload['legalCountry'] = legalCountry; - } - if (typeof legalState !== 'undefined') { - payload['legalState'] = legalState; - } - if (typeof legalCity !== 'undefined') { - payload['legalCity'] = legalCity; - } - if (typeof legalAddress !== 'undefined') { - payload['legalAddress'] = legalAddress; - } - if (typeof legalTaxId !== 'undefined') { - payload['legalTaxId'] = legalTaxId; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -225,57 +162,6 @@ export class Projects { ); } - /** - * Get a project by its unique ID. This endpoint allows you to retrieve the project's details, including its name, description, team, region, and other metadata. - * - * @param {string} params.projectId - Project unique ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - get(params: { projectId: string }): Promise; - /** - * Get a project by its unique ID. This endpoint allows you to retrieve the project's details, including its name, description, team, region, and other metadata. - * - * @param {string} projectId - Project unique ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - get(projectId: string): Promise; - get( - paramsOrFirst: { projectId: string } | string - ): Promise { - let params: { projectId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string }; - } else { - params = { - projectId: paramsOrFirst as string - }; - } - - const projectId = params.projectId; - - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - - const apiPath = '/projects/{projectId}'.replace('{projectId}', projectId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); - } - /** * Update a project by its unique ID. * diff --git a/src/services/realtime.ts b/src/services/realtime.ts index a1368b9e..7aebdaa6 100644 --- a/src/services/realtime.ts +++ b/src/services/realtime.ts @@ -52,10 +52,30 @@ export type RealtimeResponseConnected = { } export type RealtimeRequest = { - type: 'authentication' | 'subscribe' | 'unsubscribe'; + type: 'authentication' | 'subscribe' | 'unsubscribe' | 'presence'; data: any; } +export type RealtimePresence = { + $id: string; + $sequence?: string | number; + $createdAt: string; + $updatedAt: string; + $permissions: string[]; + userInternalId: string; + userId: string; + status?: string; + source: string; + metadata?: Record; +} + +export type RealtimePresenceCreate = { + status: string; + presenceId: string; + permissions?: string[]; + metadata?: Record; +} + type RealtimeRequestSubscribeRow = { subscriptionId?: string; channels: string[]; @@ -73,7 +93,6 @@ export class Realtime { private readonly TYPE_EVENT = 'event'; private readonly TYPE_PONG = 'pong'; private readonly TYPE_CONNECTED = 'connected'; - private readonly TYPE_RESPONSE = 'response'; private readonly DEBOUNCE_MS = 1; private readonly HEARTBEAT_INTERVAL = 20000; // 20 seconds in milliseconds @@ -81,7 +100,13 @@ export class Realtime { private socket?: WebSocket; private activeSubscriptions = new Map>(); private pendingSubscribes = new Map(); + private pendingPresence?: Record; + private appConnected = false; private heartbeatTimer?: number; + // Single-flight lock for createSocket(). When set, concurrent callers join + // this promise instead of issuing a second `new WebSocket(...)`. Cleared + // after the underlying connect resolves or rejects. + private socketCreationPromise?: Promise; private subCallDepth = 0; private reconnectAttempts = 0; @@ -142,8 +167,33 @@ export class Realtime { } } + /** + * Idempotent socket opener. Both `subscribe()` and `upsertPresence()` can + * call this; the single-flight lock (`socketCreationPromise`) guarantees + * only one `new WebSocket(...)` is ever in flight, so concurrent callers + * join the same connection attempt instead of opening duplicates. + * + * Returns early when a healthy socket is already present. + */ private async createSocket(): Promise { - if (this.activeSubscriptions.size === 0) { + // Fast path: a usable socket is already there. No need to open another. + if (this.socket && this.socket.readyState < WebSocket.CLOSING) { + return; + } + // Another caller is already opening one — join it. + if (this.socketCreationPromise) { + return this.socketCreationPromise; + } + this.socketCreationPromise = this.createSocketLocked().finally(() => { + this.socketCreationPromise = undefined; + }); + return this.socketCreationPromise; + } + + private async createSocketLocked(): Promise { + // Nothing to do if there's neither a subscription nor a queued presence + // that needs the wire. (Reconnect cleanup path also flows through here.) + if (this.activeSubscriptions.size === 0 && !this.pendingPresence) { this.reconnect = false; await this.closeSocket(); return; @@ -176,6 +226,15 @@ export class Realtime { } return new Promise((resolve, reject) => { + // Re-check the entry guard synchronously. `disconnect()` may have + // run during the `await this.closeSocket()` above (or any other + // await between the original guard and here), clearing every + // subscription and the pending presence. In that case opening a + // fresh socket would leak a connection with nothing attached. + if (this.activeSubscriptions.size === 0 && !this.pendingPresence) { + resolve(); + return; + } try { const connectionId = ++this.connectionId; const socket = (this.socket = new WebSocket(url)); @@ -206,6 +265,7 @@ export class Realtime { if (connectionId !== this.connectionId || socket !== this.socket) { return; } + this.appConnected = false; this.stopHeartbeat(); this.onCloseCallbacks.forEach(callback => callback()); @@ -326,7 +386,19 @@ export class Realtime { public async disconnect(): Promise { this.activeSubscriptions.clear(); this.pendingSubscribes.clear(); + this.pendingPresence = undefined; + this.appConnected = false; this.reconnect = false; + // Drop the in-flight single-flight slot. Promises can't be cancelled, + // so the underlying createSocketLocked() promise may stay pending + // forever — e.g. when closeSocket() below tears down a CONNECTING + // socket, the `close` event fires but `open`/`error` never do, and + // the inner `new Promise(...)` only resolves on those. Without this + // line, the next subscribe()/upsertPresence() would join the orphan + // promise via the single-flight gate and hang, leaving its pending + // subscription queued with no socket ever opened. Mirrors the Swift + // template's socketCreationTask cancel in disconnect(). + this.socketCreationPromise = undefined; await this.closeSocket(); } @@ -334,6 +406,18 @@ export class Realtime { if (!this.socket || this.socket.readyState !== WebSocket.OPEN) { return; } + // The WebSocket 'open' event fires when the TCP/upgrade handshake + // completes — but the server only accepts `subscribe` frames after + // it has emitted its own application-level `connected` event (which + // flips `appConnected` to true in handleResponseConnected). Sending + // before then triggers a policy-violation close on real Appwrite, + // which reconnects, which sends early again — i.e. a duplicate- + // socket loop. handleResponseConnected re-enqueues every active + // subscription and calls this method again once it's safe, so the + // queued rows are guaranteed to be sent. + if (!this.appConnected) { + return; + } if (this.pendingSubscribes.size < 1) { return; @@ -532,6 +616,66 @@ export class Realtime { return { unsubscribe, update, close }; } + /** + * Fire-and-forget presence upsert. Records the latest payload in state so + * that — if the WebSocket isn't open yet, or later reconnects — only the + * most recent presence is automatically (re)sent on the next `connected` + * event. Repeated calls while the socket is closed collapse to the latest + * payload (older ones are discarded). + * + * Returns a `Promise` for API consistency; the promise resolves as + * soon as the payload has been stored and the opportunistic send attempted. + * + * @param {RealtimePresenceCreate} params - Presence payload (status and presenceId required, permissions/metadata optional) + */ + public async upsertPresence(params: RealtimePresenceCreate): Promise { + const data: Record = { + status: params.status, + presenceId: params.presenceId, + }; + if (params.permissions !== undefined) { + data.permissions = params.permissions; + } + if (params.metadata !== undefined) { + data.metadata = params.metadata; + } + + this.pendingPresence = data; + + // Both subscribe() and upsertPresence() may need to open the socket. + // createSocket() is single-flight (see `socketCreationPromise`), so + // calling it here is a no-op when a connection is already in flight or + // healthy. Fire-and-forget keeps the documented fire-and-forget shape + // of upsertPresence: the returned Promise resolves as soon as the + // payload is stored. + if (!this.socket || this.socket.readyState >= WebSocket.CLOSING) { + this.createSocket().catch((error) => { + console.error('Failed to open realtime socket for presence:', error); + }); + } + + // Opportunistic send for the case where the socket is already past the + // `connected` handshake. The gate inside flushPendingPresence keeps + // this a no-op until appConnected flips to true. + this.flushPendingPresence(); + } + + private flushPendingPresence(): void { + if (!this.pendingPresence) { + return; + } + if (!this.socket || this.socket.readyState !== WebSocket.OPEN) { + return; + } + if (!this.appConnected) { + return; + } + this.socket.send(JSONbig.stringify({ + type: 'presence', + data: this.pendingPresence + })); + } + private handleMessage(message: RealtimeResponse): void { if (!message.type) { return; @@ -550,9 +694,6 @@ export class Realtime { case this.TYPE_PONG: // Handle pong response if needed break; - case this.TYPE_RESPONSE: - this.handleResponseAction(message); - break; } } @@ -585,7 +726,9 @@ export class Realtime { for (const subscriptionId of this.activeSubscriptions.keys()) { this.enqueuePendingSubscribe(subscriptionId); } + this.appConnected = true; this.sendPendingSubscribes(); + this.flushPendingPresence(); } private handleResponseError(message: RealtimeResponse): void { @@ -626,10 +769,4 @@ export class Realtime { }); } } - - private handleResponseAction(_message: RealtimeResponse): void { - // The SDK generates subscriptionIds client-side and sends them on every - // subscribe/unsubscribe, so subscribe/unsubscribe acks carry no state - // the SDK needs to reconcile. - } } diff --git a/src/services/usage.ts b/src/services/usage.ts new file mode 100644 index 00000000..ba131a6d --- /dev/null +++ b/src/services/usage.ts @@ -0,0 +1,130 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Usage { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Query usage event metrics from the usage database. Returns individual event rows with full metadata. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, path, method, status, resource, resourceId, country, userAgent, time (these match the underlying column names — note that the response surfaces `resource` as `resourceType` and `country` as `countryCode`). When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} params.queries - Array of query strings as JSON. Supported: equal("metric", [...]), equal("path", [...]), equal("method", [...]), equal("status", [...]), equal("resource", [...]), equal("resourceId", [...]), equal("country", [...]), equal("userAgent", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listEvents(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Query usage event metrics from the usage database. Returns individual event rows with full metadata. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, path, method, status, resource, resourceId, country, userAgent, time (these match the underlying column names — note that the response surfaces `resource` as `resourceType` and `country` as `countryCode`). When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} queries - Array of query strings as JSON. Supported: equal("metric", [...]), equal("path", [...]), equal("method", [...]), equal("status", [...]), equal("resource", [...]), equal("resourceId", [...]), equal("country", [...]), equal("userAgent", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @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. + */ + listEvents(queries?: string[], total?: boolean): Promise; + listEvents( + 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 = '/usage/events'; + 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 + ); + } + + /** + * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, and timestamp. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} params.queries - Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listGauges(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, and timestamp. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} queries - Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @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. + */ + listGauges(queries?: string[], total?: boolean): Promise; + listGauges( + 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 = '/usage/gauges'; + 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 + ); + } +} From 00c995f2c24e761702f124e21a7c82c1bbec864d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 29 May 2026 07:51:24 +0000 Subject: [PATCH 2/3] chore: update Console SDK to 13.0.0 --- CHANGELOG.md | 8 - README.md | 2 +- docs/examples/account/create-key.md | 4 +- docs/examples/account/update-key.md | 4 +- docs/examples/advisor/list-insights.md | 17 - docs/examples/avatars/get-screenshot.md | 6 +- docs/examples/documentsdb/list.md | 1 - docs/examples/domains/get-price.md | 4 +- docs/examples/domains/list-suggestions.md | 4 +- docs/examples/functions/create.md | 8 +- docs/examples/functions/list-templates.md | 6 +- docs/examples/functions/update.md | 8 +- docs/examples/health/get-failed-jobs.md | 4 +- docs/examples/manager/create-block.md | 4 +- docs/examples/manager/delete-block.md | 4 +- docs/examples/manager/delete-cache.md | 20 + .../migrations/create-appwrite-migration.md | 4 +- docs/examples/migrations/create-csv-import.md | 4 +- .../examples/migrations/create-json-import.md | 4 +- .../create-key.md | 10 +- .../create-project.md} | 7 +- .../delete-key.md} | 8 +- .../delete-project.md} | 9 +- .../get-key.md} | 8 +- docs/examples/organization/get-project.md | 15 + .../list-keys.md} | 6 +- .../list.md => organization/list-projects.md} | 6 +- .../update-key.md | 9 +- docs/examples/organization/update-project.md | 16 + docs/examples/organizations/delete-key.md | 16 - .../examples/organizations/get-addon-price.md | 4 +- docs/examples/organizations/get-key.md | 16 - docs/examples/organizations/list-keys.md | 16 - docs/examples/presences/get-usage.md | 2 +- .../{update-presence.md => update.md} | 3 +- docs/examples/presences/upsert.md | 1 - docs/examples/projects/create-schedule.md | 4 +- docs/examples/projects/update-status.md | 4 +- docs/examples/projects/update.md | 25 - docs/examples/proxy/create-redirect-rule.md | 4 +- docs/examples/sites/create.md | 10 +- docs/examples/sites/list-templates.md | 6 +- docs/examples/sites/update.md | 10 +- docs/examples/users/get-usage.md | 2 +- .../vectorsdb/create-text-embeddings.md | 4 +- docs/examples/vectorsdb/list.md | 1 - package-lock.json | 4 +- package.json | 2 +- src/client.ts | 144 +- src/enums/account-key-scopes.ts | 5 + src/enums/addon.ts | 3 - src/enums/backup-services.ts | 1 + ...esource-type.ts => block-resource-type.ts} | 6 +- src/enums/{theme.ts => browser-theme.ts} | 2 +- src/enums/build-runtime.ts | 94 - src/enums/cache-database.ts | 5 + src/enums/cache-target.ts | 8 + ...on-type.ts => domain-registration-type.ts} | 2 +- ...lter-type.ts => domain-suggestion-type.ts} | 2 +- src/enums/{model.ts => embedding-model.ts} | 2 +- src/enums/frameworks.ts | 17 - src/enums/{runtime.ts => function-runtime.ts} | 7 +- src/enums/function-template-use-case.ts | 9 + src/enums/{name.ts => health-queue-name.ts} | 2 +- ...duplicate.ts => migration-on-duplicate.ts} | 2 +- src/enums/organization-addon.ts | 4 + src/enums/organization-key-scopes.ts | 12 + src/enums/project-o-auth-provider-id.ts | 2 - src/enums/project-status.ts | 3 + src/enums/query-suggestion-resource.ts | 8 +- src/enums/redirect-status-code.ts | 6 + src/enums/schedule-resource-type.ts | 6 + src/enums/scopes.ts | 101 - src/enums/{adapter.ts => site-adapter.ts} | 2 +- .../{runtimes.ts => site-build-runtime.ts} | 7 +- src/enums/{framework.ts => site-framework.ts} | 2 +- ...use-cases.ts => site-template-use-case.ts} | 11 +- src/enums/status-code.ts | 6 - src/enums/status.ts | 3 - src/index.ts | 45 +- src/models.ts | 2201 ++++++++--------- src/services/account.ts | 38 +- src/services/advisor.ts | 309 --- src/services/avatars.ts | 20 +- src/services/documents-db.ts | 21 +- src/services/domains.ts | 452 ++-- src/services/functions.ts | 119 +- src/services/health.ts | 18 +- src/services/manager.ts | 136 +- src/services/migrations.ts | 56 +- src/services/organization.ts | 644 +++++ src/services/organizations.ts | 366 +-- src/services/presences.ts | 102 +- src/services/project.ts | 40 +- src/services/projects.ts | 316 +-- src/services/proxy.ts | 20 +- src/services/sites.ts | 133 +- src/services/usage.ts | 4 +- src/services/vectors-db.ts | 41 +- 99 files changed, 2731 insertions(+), 3178 deletions(-) delete mode 100644 docs/examples/advisor/list-insights.md create mode 100644 docs/examples/manager/delete-cache.md rename docs/examples/{organizations => organization}/create-key.md (53%) rename docs/examples/{projects/create.md => organization/create-project.md} (62%) rename docs/examples/{advisor/get-report.md => organization/delete-key.md} (54%) rename docs/examples/{advisor/get-insight.md => organization/delete-project.md} (52%) rename docs/examples/{advisor/delete-report.md => organization/get-key.md} (54%) create mode 100644 docs/examples/organization/get-project.md rename docs/examples/{advisor/list-reports.md => organization/list-keys.md} (63%) rename docs/examples/{projects/list.md => organization/list-projects.md} (66%) rename docs/examples/{organizations => organization}/update-key.md (56%) create mode 100644 docs/examples/organization/update-project.md delete mode 100644 docs/examples/organizations/delete-key.md delete mode 100644 docs/examples/organizations/get-key.md delete mode 100644 docs/examples/organizations/list-keys.md rename docs/examples/presences/{update-presence.md => update.md} (88%) delete mode 100644 docs/examples/projects/update.md create mode 100644 src/enums/account-key-scopes.ts delete mode 100644 src/enums/addon.ts rename src/enums/{resource-type.ts => block-resource-type.ts} (65%) rename src/enums/{theme.ts => browser-theme.ts} (60%) delete mode 100644 src/enums/build-runtime.ts create mode 100644 src/enums/cache-database.ts create mode 100644 src/enums/cache-target.ts rename src/enums/{registration-type.ts => domain-registration-type.ts} (71%) rename src/enums/{filter-type.ts => domain-suggestion-type.ts} (61%) rename src/enums/{model.ts => embedding-model.ts} (57%) delete mode 100644 src/enums/frameworks.ts rename src/enums/{runtime.ts => function-runtime.ts} (95%) create mode 100644 src/enums/function-template-use-case.ts rename src/enums/{name.ts => health-queue-name.ts} (93%) rename src/enums/{on-duplicate.ts => migration-on-duplicate.ts} (66%) create mode 100644 src/enums/organization-addon.ts create mode 100644 src/enums/organization-key-scopes.ts create mode 100644 src/enums/project-status.ts create mode 100644 src/enums/redirect-status-code.ts create mode 100644 src/enums/schedule-resource-type.ts delete mode 100644 src/enums/scopes.ts rename src/enums/{adapter.ts => site-adapter.ts} (61%) rename src/enums/{runtimes.ts => site-build-runtime.ts} (95%) rename src/enums/{framework.ts => site-framework.ts} (92%) rename src/enums/{use-cases.ts => site-template-use-case.ts} (59%) delete mode 100644 src/enums/status-code.ts delete mode 100644 src/enums/status.ts delete mode 100644 src/services/advisor.ts create mode 100644 src/services/organization.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 99d4ad3e..842e0fb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,5 @@ # Change Log -## 13.0.1 - -* Fixed: `BillingLimits` inner fields and `Project.billingLimits` are now optional — server emits sparse "limits crossed" map -* Fixed: `Project.consoleAccessedAt` defaults to empty string for never-accessed projects (no longer null) -* Added: `File.sizeActual` field — actual bytes used on disk after compression / encryption -* Updated: `BuildRuntime` and `Runtime` enums with `deno-1.21`, `deno-1.24`, and `deno-1.35` -* Updated: Advisor doc examples corrected to use API key auth instead of session - ## 13.0.0 * Breaking: Renamed `updateCanonicalEmails` to `updateDenyCanonicalEmailPolicy` on `Project` service diff --git a/README.md b/README.md index 68bff962..a4922b73 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md index 6371ff17..769228e8 100644 --- a/docs/examples/account/create-key.md +++ b/docs/examples/account/create-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, Scopes } from "@appwrite.io/console"; +import { Client, Account, AccountKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const account = new Account(client); const result = await account.createKey({ name: '', - scopes: [Scopes.Account], + scopes: [AccountKeyScopes.Account], expire: '2020-10-15T06:38:00.000+00:00' // optional }); diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md index 1975baa7..d76022b8 100644 --- a/docs/examples/account/update-key.md +++ b/docs/examples/account/update-key.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Account, Scopes } from "@appwrite.io/console"; +import { Client, Account, AccountKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const account = new Account(client); const result = await account.updateKey({ keyId: '', name: '', - scopes: [Scopes.Account], + scopes: [AccountKeyScopes.Account], expire: '2020-10-15T06:38:00.000+00:00' // optional }); diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md deleted file mode 100644 index e3d97867..00000000 --- a/docs/examples/advisor/list-insights.md +++ /dev/null @@ -1,17 +0,0 @@ -```javascript -import { Client, Advisor } from "@appwrite.io/console"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const advisor = new Advisor(client); - -const result = await advisor.listInsights({ - reportId: '', - queries: [], // optional - total: false // optional -}); - -console.log(result); -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 0f7a9216..45e3517f 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Avatars, Theme, Timezone, BrowserPermission, ImageFormat } from "@appwrite.io/console"; +import { Client, Avatars, BrowserTheme, Timezone, BrowserPermission, ImageFormat } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -16,11 +16,11 @@ const result = avatars.getScreenshot({ viewportWidth: 1920, // optional viewportHeight: 1080, // optional scale: 2, // optional - theme: Theme.Dark, // optional + theme: BrowserTheme.Dark, // optional userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional fullpage: true, // optional locale: 'en-US', // optional - timezone: Timezone.AmericaNewYork, // optional + timezone: Timezone.AfricaAbidjan, // optional latitude: 37.7749, // optional longitude: -122.4194, // optional accuracy: 100, // optional diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md index fa0cd866..1812eebc 100644 --- a/docs/examples/documentsdb/list.md +++ b/docs/examples/documentsdb/list.md @@ -9,7 +9,6 @@ const documentsDB = new DocumentsDB(client); const result = await documentsDB.list({ queries: [], // optional - search: '', // optional total: false // optional }); diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index 78ffc2e0..f3baafb5 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains, RegistrationType } from "@appwrite.io/console"; +import { Client, Domains, DomainRegistrationType } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const domains = new Domains(client); const result = await domains.getPrice({ domain: '', periodYears: null, // optional - registrationType: RegistrationType.New // optional + registrationType: DomainRegistrationType.New // optional }); console.log(result); diff --git a/docs/examples/domains/list-suggestions.md b/docs/examples/domains/list-suggestions.md index 429ad498..28c7b7ae 100644 --- a/docs/examples/domains/list-suggestions.md +++ b/docs/examples/domains/list-suggestions.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Domains, FilterType } from "@appwrite.io/console"; +import { Client, Domains, DomainSuggestionType } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,7 +11,7 @@ const result = await domains.listSuggestions({ query: '', tlds: [], // optional limit: null, // optional - filterType: FilterType.Premium, // optional + filterType: DomainSuggestionType.Premium, // optional priceMax: null, // optional priceMin: null // optional }); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 5cd33258..c7b20209 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions, Runtime, Scopes } from "@appwrite.io/console"; +import { Client, Functions, FunctionRuntime, ProjectKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const functions = new Functions(client); const result = await functions.create({ functionId: '', name: '', - runtime: Runtime.Node145, + runtime: FunctionRuntime.Node145, execute: ["any"], // optional events: [], // optional schedule: '', // optional @@ -19,12 +19,14 @@ const result = await functions.create({ logging: false, // optional entrypoint: '', // optional commands: '', // optional - scopes: [Scopes.ProjectRead], // optional + scopes: [ProjectKeyScopes.ProjectRead], // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional + providerBranches: [], // optional + providerPaths: [], // optional buildSpecification: '', // optional runtimeSpecification: '', // optional deploymentRetention: 0 // optional diff --git a/docs/examples/functions/list-templates.md b/docs/examples/functions/list-templates.md index 41bf6cb3..e28df0b4 100644 --- a/docs/examples/functions/list-templates.md +++ b/docs/examples/functions/list-templates.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions, Runtimes, UseCases } from "@appwrite.io/console"; +import { Client, Functions, FunctionRuntime, FunctionTemplateUseCase } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,8 +8,8 @@ const client = new Client() const functions = new Functions(client); const result = await functions.listTemplates({ - runtimes: [Runtimes.Node145], // optional - useCases: [UseCases.Starter], // optional + runtimes: [FunctionRuntime.Node145], // optional + useCases: [FunctionTemplateUseCase.Starter], // optional limit: 1, // optional offset: 0, // optional total: false // optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index cb77dea1..c84018bb 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Functions, Runtime, Scopes } from "@appwrite.io/console"; +import { Client, Functions, FunctionRuntime, ProjectKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const functions = new Functions(client); const result = await functions.update({ functionId: '', name: '', - runtime: Runtime.Node145, // optional + runtime: FunctionRuntime.Node145, // optional execute: ["any"], // optional events: [], // optional schedule: '', // optional @@ -19,12 +19,14 @@ const result = await functions.update({ logging: false, // optional entrypoint: '', // optional commands: '', // optional - scopes: [Scopes.ProjectRead], // optional + scopes: [ProjectKeyScopes.ProjectRead], // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional + providerBranches: [], // optional + providerPaths: [], // optional buildSpecification: '', // optional runtimeSpecification: '', // optional deploymentRetention: 0 // optional diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md index f87018ff..73017db5 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/health/get-failed-jobs.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Health, Name } from "@appwrite.io/console"; +import { Client, Health, HealthQueueName } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const client = new Client() const health = new Health(client); const result = await health.getFailedJobs({ - name: Name.V1Database, + name: HealthQueueName.V1Database, threshold: null // optional }); diff --git a/docs/examples/manager/create-block.md b/docs/examples/manager/create-block.md index 3515e471..55346824 100644 --- a/docs/examples/manager/create-block.md +++ b/docs/examples/manager/create-block.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Manager, ResourceType } from "@appwrite.io/console"; +import { Client, Manager, BlockResourceType } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const manager = new Manager(client); const result = await manager.createBlock({ projectId: '', - resourceType: ResourceType.Projects, + resourceType: BlockResourceType.Projects, resourceId: '', // optional reason: '', // optional expiredAt: '2020-10-15T06:38:00.000+00:00' // optional diff --git a/docs/examples/manager/delete-block.md b/docs/examples/manager/delete-block.md index 285eee03..b9b0ded7 100644 --- a/docs/examples/manager/delete-block.md +++ b/docs/examples/manager/delete-block.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Manager, ResourceType } from "@appwrite.io/console"; +import { Client, Manager, BlockResourceType } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,7 +8,7 @@ const manager = new Manager(client); const result = await manager.deleteBlock({ projectId: '', - resourceType: ResourceType.Projects, + resourceType: BlockResourceType.Projects, resourceId: '' // optional }); diff --git a/docs/examples/manager/delete-cache.md b/docs/examples/manager/delete-cache.md new file mode 100644 index 00000000..f8ee50c5 --- /dev/null +++ b/docs/examples/manager/delete-cache.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Manager, Region, CacheTarget, CacheDatabase } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + +const manager = new Manager(client); + +const result = await manager.deleteCache({ + region: Region.Fra, // optional + cache: CacheTarget.Cache, // optional + all: false, // optional + database: CacheDatabase.Console, // optional + projectId: '', // optional + collectionId: '', // optional + documentId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/migrations/create-appwrite-migration.md b/docs/examples/migrations/create-appwrite-migration.md index 9729806f..39d13eed 100644 --- a/docs/examples/migrations/create-appwrite-migration.md +++ b/docs/examples/migrations/create-appwrite-migration.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations, AppwriteMigrationResource, OnDuplicate } from "@appwrite.io/console"; +import { Client, Migrations, AppwriteMigrationResource, MigrationOnDuplicate } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await migrations.createAppwriteMigration({ endpoint: 'https://example.com', projectId: '', apiKey: '', - onDuplicate: OnDuplicate.Fail // optional + onDuplicate: MigrationOnDuplicate.Fail // optional }); console.log(result); diff --git a/docs/examples/migrations/create-csv-import.md b/docs/examples/migrations/create-csv-import.md index d24792b6..1a2a97d8 100644 --- a/docs/examples/migrations/create-csv-import.md +++ b/docs/examples/migrations/create-csv-import.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations, OnDuplicate } from "@appwrite.io/console"; +import { Client, Migrations, MigrationOnDuplicate } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await migrations.createCSVImport({ fileId: '', resourceId: '', internalFile: false, // optional - onDuplicate: OnDuplicate.Fail // optional + onDuplicate: MigrationOnDuplicate.Fail // optional }); console.log(result); diff --git a/docs/examples/migrations/create-json-import.md b/docs/examples/migrations/create-json-import.md index f55fc8ff..7af6d23e 100644 --- a/docs/examples/migrations/create-json-import.md +++ b/docs/examples/migrations/create-json-import.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Migrations, OnDuplicate } from "@appwrite.io/console"; +import { Client, Migrations, MigrationOnDuplicate } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +12,7 @@ const result = await migrations.createJSONImport({ fileId: '', resourceId: '', internalFile: false, // optional - onDuplicate: OnDuplicate.Fail // optional + onDuplicate: MigrationOnDuplicate.Fail // optional }); console.log(result); diff --git a/docs/examples/organizations/create-key.md b/docs/examples/organization/create-key.md similarity index 53% rename from docs/examples/organizations/create-key.md rename to docs/examples/organization/create-key.md index a21479a7..3989d829 100644 --- a/docs/examples/organizations/create-key.md +++ b/docs/examples/organization/create-key.md @@ -1,16 +1,16 @@ ```javascript -import { Client, Organizations, Scopes } from "@appwrite.io/console"; +import { Client, Organization, OrganizationKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const organizations = new Organizations(client); +const organization = new Organization(client); -const result = await organizations.createKey({ - organizationId: '', +const result = await organization.createKey({ + keyId: '', name: '', - scopes: [Scopes.ProjectsRead], + scopes: [OrganizationKeyScopes.ProjectsRead], expire: '2020-10-15T06:38:00.000+00:00' // optional }); diff --git a/docs/examples/projects/create.md b/docs/examples/organization/create-project.md similarity index 62% rename from docs/examples/projects/create.md rename to docs/examples/organization/create-project.md index 21b9488a..aba71929 100644 --- a/docs/examples/projects/create.md +++ b/docs/examples/organization/create-project.md @@ -1,16 +1,15 @@ ```javascript -import { Client, Projects, Region } from "@appwrite.io/console"; +import { Client, Organization, Region } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const organization = new Organization(client); -const result = await projects.create({ +const result = await organization.createProject({ projectId: '', name: '', - teamId: '', region: Region.Fra // optional }); diff --git a/docs/examples/advisor/get-report.md b/docs/examples/organization/delete-key.md similarity index 54% rename from docs/examples/advisor/get-report.md rename to docs/examples/organization/delete-key.md index cdb46636..7b167db8 100644 --- a/docs/examples/advisor/get-report.md +++ b/docs/examples/organization/delete-key.md @@ -1,14 +1,14 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Organization } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const advisor = new Advisor(client); +const organization = new Organization(client); -const result = await advisor.getReport({ - reportId: '' +const result = await organization.deleteKey({ + keyId: '' }); console.log(result); diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/organization/delete-project.md similarity index 52% rename from docs/examples/advisor/get-insight.md rename to docs/examples/organization/delete-project.md index bf59a7ed..db62d68c 100644 --- a/docs/examples/advisor/get-insight.md +++ b/docs/examples/organization/delete-project.md @@ -1,15 +1,14 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Organization } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const advisor = new Advisor(client); +const organization = new Organization(client); -const result = await advisor.getInsight({ - reportId: '', - insightId: '' +const result = await organization.deleteProject({ + projectId: '' }); console.log(result); diff --git a/docs/examples/advisor/delete-report.md b/docs/examples/organization/get-key.md similarity index 54% rename from docs/examples/advisor/delete-report.md rename to docs/examples/organization/get-key.md index d549dddb..d962bcae 100644 --- a/docs/examples/advisor/delete-report.md +++ b/docs/examples/organization/get-key.md @@ -1,14 +1,14 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Organization } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const advisor = new Advisor(client); +const organization = new Organization(client); -const result = await advisor.deleteReport({ - reportId: '' +const result = await organization.getKey({ + keyId: '' }); console.log(result); diff --git a/docs/examples/organization/get-project.md b/docs/examples/organization/get-project.md new file mode 100644 index 00000000..a338b024 --- /dev/null +++ b/docs/examples/organization/get-project.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Organization } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organization = new Organization(client); + +const result = await organization.getProject({ + projectId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/organization/list-keys.md similarity index 63% rename from docs/examples/advisor/list-reports.md rename to docs/examples/organization/list-keys.md index 5cf736e5..d52ac31f 100644 --- a/docs/examples/advisor/list-reports.md +++ b/docs/examples/organization/list-keys.md @@ -1,13 +1,13 @@ ```javascript -import { Client, Advisor } from "@appwrite.io/console"; +import { Client, Organization } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const advisor = new Advisor(client); +const organization = new Organization(client); -const result = await advisor.listReports({ +const result = await organization.listKeys({ queries: [], // optional total: false // optional }); diff --git a/docs/examples/projects/list.md b/docs/examples/organization/list-projects.md similarity index 66% rename from docs/examples/projects/list.md rename to docs/examples/organization/list-projects.md index b18c8210..3e4b7588 100644 --- a/docs/examples/projects/list.md +++ b/docs/examples/organization/list-projects.md @@ -1,13 +1,13 @@ ```javascript -import { Client, Projects } from "@appwrite.io/console"; +import { Client, Organization } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const projects = new Projects(client); +const organization = new Organization(client); -const result = await projects.list({ +const result = await organization.listProjects({ queries: [], // optional search: '', // optional total: false // optional diff --git a/docs/examples/organizations/update-key.md b/docs/examples/organization/update-key.md similarity index 56% rename from docs/examples/organizations/update-key.md rename to docs/examples/organization/update-key.md index f8e731cd..bb97a272 100644 --- a/docs/examples/organizations/update-key.md +++ b/docs/examples/organization/update-key.md @@ -1,17 +1,16 @@ ```javascript -import { Client, Organizations, Scopes } from "@appwrite.io/console"; +import { Client, Organization, OrganizationKeyScopes } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const organizations = new Organizations(client); +const organization = new Organization(client); -const result = await organizations.updateKey({ - organizationId: '', +const result = await organization.updateKey({ keyId: '', name: '', - scopes: [Scopes.ProjectsRead], + scopes: [OrganizationKeyScopes.ProjectsRead], expire: '2020-10-15T06:38:00.000+00:00' // optional }); diff --git a/docs/examples/organization/update-project.md b/docs/examples/organization/update-project.md new file mode 100644 index 00000000..ecf77403 --- /dev/null +++ b/docs/examples/organization/update-project.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Organization } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const organization = new Organization(client); + +const result = await organization.updateProject({ + projectId: '', + name: '' +}); + +console.log(result); +``` diff --git a/docs/examples/organizations/delete-key.md b/docs/examples/organizations/delete-key.md deleted file mode 100644 index 961fa689..00000000 --- a/docs/examples/organizations/delete-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -import { Client, Organizations } from "@appwrite.io/console"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.deleteKey({ - organizationId: '', - keyId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/get-addon-price.md b/docs/examples/organizations/get-addon-price.md index 1f96ba39..90043327 100644 --- a/docs/examples/organizations/get-addon-price.md +++ b/docs/examples/organizations/get-addon-price.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Organizations, Addon } from "@appwrite.io/console"; +import { Client, Organizations, OrganizationAddon } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const organizations = new Organizations(client); const result = await organizations.getAddonPrice({ organizationId: '', - addon: Addon.Baa + addon: OrganizationAddon.Baa }); console.log(result); diff --git a/docs/examples/organizations/get-key.md b/docs/examples/organizations/get-key.md deleted file mode 100644 index f4d53628..00000000 --- a/docs/examples/organizations/get-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -import { Client, Organizations } from "@appwrite.io/console"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.getKey({ - organizationId: '', - keyId: '' -}); - -console.log(result); -``` diff --git a/docs/examples/organizations/list-keys.md b/docs/examples/organizations/list-keys.md deleted file mode 100644 index a31f70d5..00000000 --- a/docs/examples/organizations/list-keys.md +++ /dev/null @@ -1,16 +0,0 @@ -```javascript -import { Client, Organizations } from "@appwrite.io/console"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const organizations = new Organizations(client); - -const result = await organizations.listKeys({ - organizationId: '', - total: false // optional -}); - -console.log(result); -``` diff --git a/docs/examples/presences/get-usage.md b/docs/examples/presences/get-usage.md index 5f954980..338e339a 100644 --- a/docs/examples/presences/get-usage.md +++ b/docs/examples/presences/get-usage.md @@ -8,7 +8,7 @@ const client = new Client() const presences = new Presences(client); const result = await presences.getUsage({ - range: UsageRange.24h // optional + range: UsageRange.TwentyFourHours // optional }); console.log(result); diff --git a/docs/examples/presences/update-presence.md b/docs/examples/presences/update.md similarity index 88% rename from docs/examples/presences/update-presence.md rename to docs/examples/presences/update.md index f735ef39..ce1280b0 100644 --- a/docs/examples/presences/update-presence.md +++ b/docs/examples/presences/update.md @@ -7,9 +7,8 @@ const client = new Client() const presences = new Presences(client); -const result = await presences.updatePresence({ +const result = await presences.update({ presenceId: '', - userId: '', status: '', // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {}, // optional diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md index fa7d6cba..8c77a0ce 100644 --- a/docs/examples/presences/upsert.md +++ b/docs/examples/presences/upsert.md @@ -9,7 +9,6 @@ const presences = new Presences(client); const result = await presences.upsert({ presenceId: '', - userId: '', status: '', permissions: [Permission.read(Role.any())], // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional diff --git a/docs/examples/projects/create-schedule.md b/docs/examples/projects/create-schedule.md index a55d7f0f..52c5e7c6 100644 --- a/docs/examples/projects/create-schedule.md +++ b/docs/examples/projects/create-schedule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects, ResourceType } from "@appwrite.io/console"; +import { Client, Projects, ScheduleResourceType } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.createSchedule({ projectId: '', - resourceType: ResourceType.Function, + resourceType: ScheduleResourceType.Function, resourceId: '', schedule: '', active: false, // optional diff --git a/docs/examples/projects/update-status.md b/docs/examples/projects/update-status.md index d795d87e..42345b7c 100644 --- a/docs/examples/projects/update-status.md +++ b/docs/examples/projects/update-status.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Projects, Status } from "@appwrite.io/console"; +import { Client, Projects, ProjectStatus } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const projects = new Projects(client); const result = await projects.updateStatus({ projectId: '', - status: Status.Active + status: ProjectStatus.Active }); console.log(result); diff --git a/docs/examples/projects/update.md b/docs/examples/projects/update.md deleted file mode 100644 index 54004836..00000000 --- a/docs/examples/projects/update.md +++ /dev/null @@ -1,25 +0,0 @@ -```javascript -import { Client, Projects } from "@appwrite.io/console"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const projects = new Projects(client); - -const result = await projects.update({ - projectId: '', - name: '', - description: '', // optional - logo: '', // optional - url: 'https://example.com', // optional - legalName: '', // optional - legalCountry: '', // optional - legalState: '', // optional - legalCity: '', // optional - legalAddress: '', // optional - legalTaxId: '' // optional -}); - -console.log(result); -``` diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md index 1b8d2f39..0e632cc2 100644 --- a/docs/examples/proxy/create-redirect-rule.md +++ b/docs/examples/proxy/create-redirect-rule.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Proxy, StatusCode, ProxyResourceType } from "@appwrite.io/console"; +import { Client, Proxy, RedirectStatusCode, ProxyResourceType } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const proxy = new Proxy(client); const result = await proxy.createRedirectRule({ domain: '', url: 'https://example.com', - statusCode: StatusCode.MovedPermanently301, + statusCode: RedirectStatusCode.MovedPermanently, resourceId: '', resourceType: ProxyResourceType.Site }); diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index a86709e8..8a4f1595 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites, Framework, BuildRuntime, Adapter } from "@appwrite.io/console"; +import { Client, Sites, SiteFramework, SiteBuildRuntime, SiteAdapter } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,8 +10,8 @@ const sites = new Sites(client); const result = await sites.create({ siteId: '', name: '', - framework: Framework.Analog, - buildRuntime: BuildRuntime.Node145, + framework: SiteFramework.Analog, + buildRuntime: SiteBuildRuntime.Node145, enabled: false, // optional logging: false, // optional timeout: 1, // optional @@ -19,13 +19,15 @@ const result = await sites.create({ buildCommand: '', // optional startCommand: '', // optional outputDirectory: '', // optional - adapter: Adapter.Static, // optional + adapter: SiteAdapter.Static, // optional installationId: '', // optional fallbackFile: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional + providerBranches: [], // optional + providerPaths: [], // optional buildSpecification: '', // optional runtimeSpecification: '', // optional deploymentRetention: 0 // optional diff --git a/docs/examples/sites/list-templates.md b/docs/examples/sites/list-templates.md index f427bd25..50b56240 100644 --- a/docs/examples/sites/list-templates.md +++ b/docs/examples/sites/list-templates.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites, Frameworks, UseCases } from "@appwrite.io/console"; +import { Client, Sites, SiteFramework, SiteTemplateUseCase } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -8,8 +8,8 @@ const client = new Client() const sites = new Sites(client); const result = await sites.listTemplates({ - frameworks: [Frameworks.Analog], // optional - useCases: [UseCases.Portfolio], // optional + frameworks: [SiteFramework.Analog], // optional + useCases: [SiteTemplateUseCase.Portfolio], // optional limit: 1, // optional offset: 0 // optional }); diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index 731ae4b9..47f2f7ae 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -1,5 +1,5 @@ ```javascript -import { Client, Sites, Framework, BuildRuntime, Adapter } from "@appwrite.io/console"; +import { Client, Sites, SiteFramework, SiteBuildRuntime, SiteAdapter } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,7 +10,7 @@ const sites = new Sites(client); const result = await sites.update({ siteId: '', name: '', - framework: Framework.Analog, + framework: SiteFramework.Analog, enabled: false, // optional logging: false, // optional timeout: 1, // optional @@ -18,14 +18,16 @@ const result = await sites.update({ buildCommand: '', // optional startCommand: '', // optional outputDirectory: '', // optional - buildRuntime: BuildRuntime.Node145, // optional - adapter: Adapter.Static, // optional + buildRuntime: SiteBuildRuntime.Node145, // optional + adapter: SiteAdapter.Static, // optional fallbackFile: '', // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional providerSilentMode: false, // optional providerRootDirectory: '', // optional + providerBranches: [], // optional + providerPaths: [], // optional buildSpecification: '', // optional runtimeSpecification: '', // optional deploymentRetention: 0 // optional diff --git a/docs/examples/users/get-usage.md b/docs/examples/users/get-usage.md index 53d11dec..b998877b 100644 --- a/docs/examples/users/get-usage.md +++ b/docs/examples/users/get-usage.md @@ -8,7 +8,7 @@ const client = new Client() const users = new Users(client); const result = await users.getUsage({ - range: UsageRange.TwentyFourHours // optional + range: UsageRange.24h // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/create-text-embeddings.md b/docs/examples/vectorsdb/create-text-embeddings.md index e024b563..01654bc4 100644 --- a/docs/examples/vectorsdb/create-text-embeddings.md +++ b/docs/examples/vectorsdb/create-text-embeddings.md @@ -1,5 +1,5 @@ ```javascript -import { Client, VectorsDB, Model } from "@appwrite.io/console"; +import { Client, VectorsDB, EmbeddingModel } from "@appwrite.io/console"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -9,7 +9,7 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.createTextEmbeddings({ texts: [], - model: Model.Embeddinggemma // optional + model: EmbeddingModel.Embeddinggemma // optional }); console.log(result); diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md index e7649d01..d09c6f98 100644 --- a/docs/examples/vectorsdb/list.md +++ b/docs/examples/vectorsdb/list.md @@ -9,7 +9,6 @@ const vectorsDB = new VectorsDB(client); const result = await vectorsDB.list({ queries: [], // optional - search: '', // optional total: false // optional }); diff --git a/package-lock.json b/package-lock.json index afc0bebb..685364d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "13.0.1", + "version": "13.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "13.0.1", + "version": "13.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index 1dec57b6..93313761 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "13.0.1", + "version": "13.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index c043b7df..cad02b2a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -390,7 +390,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '13.0.1', + 'x-sdk-version': '13.0.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -978,44 +978,131 @@ class Client { return await this.call(method, url, headers, originalPayload); } - let start = 0; - let response = null; + const totalChunks = Math.ceil(file.size / Client.CHUNK_SIZE); + + // Upload first chunk alone to get the upload ID + const firstChunkEnd = Math.min(Client.CHUNK_SIZE, file.size); + const firstChunkHeaders = { ...headers, 'content-range': `bytes 0-${firstChunkEnd - 1}/${file.size}` }; + const firstChunk = file.slice(0, firstChunkEnd); + const firstPayload = { ...originalPayload }; + firstPayload[fileParam] = new File([firstChunk], file.name); + + let response = await this.call(method, url, firstChunkHeaders, firstPayload); + const uploadId = response?.$id; + + if (onProgress && typeof onProgress === 'function') { + onProgress({ + $id: uploadId, + progress: Math.round((firstChunkEnd / file.size) * 100), + sizeUploaded: firstChunkEnd, + chunksTotal: totalChunks, + chunksUploaded: 1 + }); + } - while (start < file.size) { - let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk - if (end >= file.size) { - end = file.size; // Adjust for the last chunk to include the last byte - } + if (totalChunks === 1) { + return response; + } - headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`; - const chunk = file.slice(start, end); + // Prepare remaining chunks + const chunks: { start: number; end: number }[] = []; + for (let i = 1; i < totalChunks; i++) { + const start = i * Client.CHUNK_SIZE; + const end = Math.min(start + Client.CHUNK_SIZE, file.size); + chunks.push({ start, end }); + } - let payload = { ...originalPayload }; - payload[fileParam] = new File([chunk], file.name); + // Upload remaining chunks with max concurrency of 8 + const CONCURRENCY = 8; + let completedCount = 1; + let uploadedBytes = firstChunkEnd; + let lastResponse = response; + let finalResponse = null; + let rejected = false; + + const isUploadComplete = (chunkResponse: any) => { + const chunksUploaded = chunkResponse?.chunksUploaded; + const chunksTotal = chunkResponse?.chunksTotal ?? totalChunks; + return typeof chunksUploaded === 'number' && typeof chunksTotal === 'number' && chunksUploaded >= chunksTotal; + }; - response = await this.call(method, url, headers, payload); + const uploadChunk = async (chunk: typeof chunks[0]) => { + const chunkHeaders = { ...headers }; + if (uploadId) { + chunkHeaders['x-appwrite-id'] = uploadId; + } + chunkHeaders['content-range'] = `bytes ${chunk.start}-${chunk.end - 1}/${file.size}`; + + const chunkBlob = file.slice(chunk.start, chunk.end); + const chunkPayload = { ...originalPayload }; + chunkPayload[fileParam] = new File([chunkBlob], file.name); + + const chunkResponse = await this.call(method, url, chunkHeaders, chunkPayload); + + if (rejected) { + return chunkResponse; + } + + completedCount++; + uploadedBytes += (chunk.end - chunk.start); + + lastResponse = chunkResponse; + if (isUploadComplete(chunkResponse)) { + finalResponse = chunkResponse; + } if (onProgress && typeof onProgress === 'function') { onProgress({ - $id: response.$id, - progress: Math.round((end / file.size) * 100), - sizeUploaded: end, - chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE), - chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE) + $id: uploadId, + progress: Math.round((uploadedBytes / file.size) * 100), + sizeUploaded: uploadedBytes, + chunksTotal: totalChunks, + chunksUploaded: completedCount }); } - if (response && response.$id) { - headers['x-appwrite-id'] = response.$id; - } + return chunkResponse; + }; - start = end; - } + await new Promise((resolve, reject) => { + let nextChunk = 0; + let inFlight = 0; + let completed = 0; + + const uploadNext = () => { + if (rejected) { + return; + } + + if (completed === chunks.length) { + resolve(); + return; + } + + while (inFlight < CONCURRENCY && nextChunk < chunks.length) { + const chunk = chunks[nextChunk++]; + inFlight++; + + uploadChunk(chunk) + .then(() => { + inFlight--; + completed++; + uploadNext(); + }) + .catch((error) => { + rejected = true; + reject(error); + }); + } + }; - return response; + uploadNext(); + }); + + return finalResponse ?? lastResponse; } - async ping(): Promise { + async ping(): Promise { return this.call('GET', new URL(this.config.endpoint + '/ping')); } @@ -1069,7 +1156,12 @@ class Client { } if (data && typeof data === 'object') { - data.toString = () => JSONbig.stringify(data); + Object.defineProperty(data, 'toString', { + value: () => JSONbig.stringify(data), + writable: true, + enumerable: false, + configurable: true, + }); } return data; diff --git a/src/enums/account-key-scopes.ts b/src/enums/account-key-scopes.ts new file mode 100644 index 00000000..ef159baf --- /dev/null +++ b/src/enums/account-key-scopes.ts @@ -0,0 +1,5 @@ +export enum AccountKeyScopes { + Account = 'account', + TeamsRead = 'teams.read', + TeamsWrite = 'teams.write', +} \ No newline at end of file diff --git a/src/enums/addon.ts b/src/enums/addon.ts deleted file mode 100644 index 60752f75..00000000 --- a/src/enums/addon.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum Addon { - Baa = 'baa', -} \ No newline at end of file diff --git a/src/enums/backup-services.ts b/src/enums/backup-services.ts index bd0582ce..adef40d2 100644 --- a/src/enums/backup-services.ts +++ b/src/enums/backup-services.ts @@ -3,6 +3,7 @@ export enum BackupServices { Tablesdb = 'tablesdb', Documentsdb = 'documentsdb', Vectorsdb = 'vectorsdb', + DedicatedDatabases = 'dedicatedDatabases', Functions = 'functions', Storage = 'storage', } \ No newline at end of file diff --git a/src/enums/resource-type.ts b/src/enums/block-resource-type.ts similarity index 65% rename from src/enums/resource-type.ts rename to src/enums/block-resource-type.ts index b1f8e6d7..1db8a7cc 100644 --- a/src/enums/resource-type.ts +++ b/src/enums/block-resource-type.ts @@ -1,4 +1,4 @@ -export enum ResourceType { +export enum BlockResourceType { Projects = 'projects', Functions = 'functions', Sites = 'sites', @@ -8,8 +8,4 @@ export enum ResourceType { Topics = 'topics', Subscribers = 'subscribers', Messages = 'messages', - Function = 'function', - Execution = 'execution', - Message = 'message', - Backup = 'backup', } \ No newline at end of file diff --git a/src/enums/theme.ts b/src/enums/browser-theme.ts similarity index 60% rename from src/enums/theme.ts rename to src/enums/browser-theme.ts index 5e823a9b..9f8c382a 100644 --- a/src/enums/theme.ts +++ b/src/enums/browser-theme.ts @@ -1,4 +1,4 @@ -export enum Theme { +export enum BrowserTheme { Light = 'light', Dark = 'dark', } \ No newline at end of file diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts deleted file mode 100644 index dddeeb2b..00000000 --- a/src/enums/build-runtime.ts +++ /dev/null @@ -1,94 +0,0 @@ -export enum BuildRuntime { - Node145 = 'node-14.5', - Node160 = 'node-16.0', - Node180 = 'node-18.0', - Node190 = 'node-19.0', - Node200 = 'node-20.0', - Node210 = 'node-21.0', - Node22 = 'node-22', - Node23 = 'node-23', - Node24 = 'node-24', - Node25 = 'node-25', - Php80 = 'php-8.0', - Php81 = 'php-8.1', - Php82 = 'php-8.2', - Php83 = 'php-8.3', - Php84 = 'php-8.4', - Ruby30 = 'ruby-3.0', - Ruby31 = 'ruby-3.1', - Ruby32 = 'ruby-3.2', - Ruby33 = 'ruby-3.3', - Ruby34 = 'ruby-3.4', - Ruby40 = 'ruby-4.0', - Python38 = 'python-3.8', - Python39 = 'python-3.9', - Python310 = 'python-3.10', - Python311 = 'python-3.11', - Python312 = 'python-3.12', - Python313 = 'python-3.13', - Python314 = 'python-3.14', - Pythonml311 = 'python-ml-3.11', - Pythonml312 = 'python-ml-3.12', - Pythonml313 = 'python-ml-3.13', - Deno121 = 'deno-1.21', - Deno124 = 'deno-1.24', - Deno135 = 'deno-1.35', - Deno140 = 'deno-1.40', - Deno146 = 'deno-1.46', - Deno20 = 'deno-2.0', - Deno25 = 'deno-2.5', - Deno26 = 'deno-2.6', - Dart215 = 'dart-2.15', - Dart216 = 'dart-2.16', - Dart217 = 'dart-2.17', - Dart218 = 'dart-2.18', - Dart219 = 'dart-2.19', - Dart30 = 'dart-3.0', - Dart31 = 'dart-3.1', - Dart33 = 'dart-3.3', - Dart35 = 'dart-3.5', - Dart38 = 'dart-3.8', - Dart39 = 'dart-3.9', - Dart310 = 'dart-3.10', - Dart311 = 'dart-3.11', - Dotnet60 = 'dotnet-6.0', - Dotnet70 = 'dotnet-7.0', - Dotnet80 = 'dotnet-8.0', - Dotnet10 = 'dotnet-10', - Java80 = 'java-8.0', - Java110 = 'java-11.0', - Java170 = 'java-17.0', - Java180 = 'java-18.0', - Java210 = 'java-21.0', - Java22 = 'java-22', - Java25 = 'java-25', - Swift55 = 'swift-5.5', - Swift58 = 'swift-5.8', - Swift59 = 'swift-5.9', - Swift510 = 'swift-5.10', - Swift62 = 'swift-6.2', - Kotlin16 = 'kotlin-1.6', - Kotlin18 = 'kotlin-1.8', - Kotlin19 = 'kotlin-1.9', - Kotlin20 = 'kotlin-2.0', - Kotlin23 = 'kotlin-2.3', - Cpp17 = 'cpp-17', - Cpp20 = 'cpp-20', - Bun10 = 'bun-1.0', - Bun11 = 'bun-1.1', - Bun12 = 'bun-1.2', - Bun13 = 'bun-1.3', - Go123 = 'go-1.23', - 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', - Flutter329 = 'flutter-3.29', - Flutter332 = 'flutter-3.32', - Flutter335 = 'flutter-3.35', - Flutter338 = 'flutter-3.38', - Flutter341 = 'flutter-3.41', -} \ No newline at end of file diff --git a/src/enums/cache-database.ts b/src/enums/cache-database.ts new file mode 100644 index 00000000..47a06a6b --- /dev/null +++ b/src/enums/cache-database.ts @@ -0,0 +1,5 @@ +export enum CacheDatabase { + Console = 'console', + Project = 'project', + Logs = 'logs', +} \ No newline at end of file diff --git a/src/enums/cache-target.ts b/src/enums/cache-target.ts new file mode 100644 index 00000000..b6d74b56 --- /dev/null +++ b/src/enums/cache-target.ts @@ -0,0 +1,8 @@ +export enum CacheTarget { + Cache = 'cache', + Timelimit = 'timelimit', + Locks = 'locks', + Pubsub = 'pubsub', + Queue = 'queue', + All = 'all', +} \ No newline at end of file diff --git a/src/enums/registration-type.ts b/src/enums/domain-registration-type.ts similarity index 71% rename from src/enums/registration-type.ts rename to src/enums/domain-registration-type.ts index a4020695..9e0e10b0 100644 --- a/src/enums/registration-type.ts +++ b/src/enums/domain-registration-type.ts @@ -1,4 +1,4 @@ -export enum RegistrationType { +export enum DomainRegistrationType { New = 'new', Transfer = 'transfer', Renewal = 'renewal', diff --git a/src/enums/filter-type.ts b/src/enums/domain-suggestion-type.ts similarity index 61% rename from src/enums/filter-type.ts rename to src/enums/domain-suggestion-type.ts index b95b6bc0..d2eca6eb 100644 --- a/src/enums/filter-type.ts +++ b/src/enums/domain-suggestion-type.ts @@ -1,4 +1,4 @@ -export enum FilterType { +export enum DomainSuggestionType { Premium = 'premium', Suggestion = 'suggestion', } \ No newline at end of file diff --git a/src/enums/model.ts b/src/enums/embedding-model.ts similarity index 57% rename from src/enums/model.ts rename to src/enums/embedding-model.ts index 78e605e3..cfdbeef1 100644 --- a/src/enums/model.ts +++ b/src/enums/embedding-model.ts @@ -1,3 +1,3 @@ -export enum Model { +export enum EmbeddingModel { Embeddinggemma = 'embeddinggemma', } \ No newline at end of file diff --git a/src/enums/frameworks.ts b/src/enums/frameworks.ts deleted file mode 100644 index 6be80af0..00000000 --- a/src/enums/frameworks.ts +++ /dev/null @@ -1,17 +0,0 @@ -export enum Frameworks { - Analog = 'analog', - Angular = 'angular', - Nextjs = 'nextjs', - React = 'react', - Nuxt = 'nuxt', - Vue = 'vue', - Sveltekit = 'sveltekit', - Astro = 'astro', - Tanstackstart = 'tanstack-start', - Remix = 'remix', - Lynx = 'lynx', - Flutter = 'flutter', - Reactnative = 'react-native', - Vite = 'vite', - Other = 'other', -} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/function-runtime.ts similarity index 95% rename from src/enums/runtime.ts rename to src/enums/function-runtime.ts index a2b22ef0..b80690d8 100644 --- a/src/enums/runtime.ts +++ b/src/enums/function-runtime.ts @@ -1,4 +1,4 @@ -export enum Runtime { +export enum FunctionRuntime { Node145 = 'node-14.5', Node160 = 'node-16.0', Node180 = 'node-18.0', @@ -30,9 +30,6 @@ export enum Runtime { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', - Deno121 = 'deno-1.21', - Deno124 = 'deno-1.24', - Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', @@ -51,6 +48,7 @@ export enum Runtime { Dart39 = 'dart-3.9', Dart310 = 'dart-3.10', Dart311 = 'dart-3.11', + Dart312 = 'dart-3.12', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -91,4 +89,5 @@ export enum Runtime { Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', + Flutter344 = 'flutter-3.44', } \ No newline at end of file diff --git a/src/enums/function-template-use-case.ts b/src/enums/function-template-use-case.ts new file mode 100644 index 00000000..e1c25508 --- /dev/null +++ b/src/enums/function-template-use-case.ts @@ -0,0 +1,9 @@ +export enum FunctionTemplateUseCase { + Starter = 'starter', + Databases = 'databases', + Ai = 'ai', + Messaging = 'messaging', + Utilities = 'utilities', + Devtools = 'dev-tools', + Auth = 'auth', +} \ No newline at end of file diff --git a/src/enums/name.ts b/src/enums/health-queue-name.ts similarity index 93% rename from src/enums/name.ts rename to src/enums/health-queue-name.ts index 8cd297bc..81320f8d 100644 --- a/src/enums/name.ts +++ b/src/enums/health-queue-name.ts @@ -1,4 +1,4 @@ -export enum Name { +export enum HealthQueueName { V1database = 'v1-database', V1deletes = 'v1-deletes', V1audits = 'v1-audits', diff --git a/src/enums/on-duplicate.ts b/src/enums/migration-on-duplicate.ts similarity index 66% rename from src/enums/on-duplicate.ts rename to src/enums/migration-on-duplicate.ts index 9ab3dc85..8b5b9b89 100644 --- a/src/enums/on-duplicate.ts +++ b/src/enums/migration-on-duplicate.ts @@ -1,4 +1,4 @@ -export enum OnDuplicate { +export enum MigrationOnDuplicate { Fail = 'fail', Skip = 'skip', Overwrite = 'overwrite', diff --git a/src/enums/organization-addon.ts b/src/enums/organization-addon.ts new file mode 100644 index 00000000..ff5b7aab --- /dev/null +++ b/src/enums/organization-addon.ts @@ -0,0 +1,4 @@ +export enum OrganizationAddon { + Baa = 'baa', + BackupRecovery = 'backup_recovery', +} \ No newline at end of file diff --git a/src/enums/organization-key-scopes.ts b/src/enums/organization-key-scopes.ts new file mode 100644 index 00000000..05c96d22 --- /dev/null +++ b/src/enums/organization-key-scopes.ts @@ -0,0 +1,12 @@ +export enum OrganizationKeyScopes { + ProjectsRead = 'projects.read', + ProjectsWrite = 'projects.write', + DevKeysRead = 'devKeys.read', + DevKeysWrite = 'devKeys.write', + OrganizationKeysRead = 'organization.keys.read', + OrganizationKeysWrite = 'organization.keys.write', + DomainsRead = 'domains.read', + DomainsWrite = 'domains.write', + KeysRead = 'keys.read', + KeysWrite = 'keys.write', +} \ No newline at end of file diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts index e35d6ef0..e1ed1b85 100644 --- a/src/enums/project-o-auth-provider-id.ts +++ b/src/enums/project-o-auth-provider-id.ts @@ -42,6 +42,4 @@ export enum ProjectOAuthProviderId { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', - GithubImagine = 'githubImagine', - GoogleImagine = 'googleImagine', } \ No newline at end of file diff --git a/src/enums/project-status.ts b/src/enums/project-status.ts new file mode 100644 index 00000000..65720b43 --- /dev/null +++ b/src/enums/project-status.ts @@ -0,0 +1,3 @@ +export enum ProjectStatus { + Active = 'active', +} \ No newline at end of file diff --git a/src/enums/query-suggestion-resource.ts b/src/enums/query-suggestion-resource.ts index 506c3a65..a17f2788 100644 --- a/src/enums/query-suggestion-resource.ts +++ b/src/enums/query-suggestion-resource.ts @@ -43,6 +43,7 @@ export enum QuerySuggestionResource { Topics = 'topics', Subscribers = 'subscribers', Targets = 'targets', + PresenceLogs = 'presencelogs', Companies = 'companies', BillingAddresses = 'billingaddresses', BillingAggregations = 'billingaggregations', @@ -72,6 +73,11 @@ export enum QuerySuggestionResource { ResourceTokens = 'resourcetokens', Transactions = 'transactions', TransactionLogs = 'transactionlogs', - PresenceLogs = 'presencelogs', Stats = 'stats', + DedicatedDatabases = 'dedicateddatabases', + DedicatedDatabaseConfigs = 'dedicateddatabaseconfigs', + DedicatedDatabaseRuntimes = 'dedicateddatabaseruntimes', + DedicatedDatabaseOperations = 'dedicateddatabaseoperations', + DedicatedDatabaseBackups = 'dedicateddatabasebackups', + DedicatedDatabaseRestorations = 'dedicateddatabaserestorations', } \ No newline at end of file diff --git a/src/enums/redirect-status-code.ts b/src/enums/redirect-status-code.ts new file mode 100644 index 00000000..63580669 --- /dev/null +++ b/src/enums/redirect-status-code.ts @@ -0,0 +1,6 @@ +export enum RedirectStatusCode { + MovedPermanently = '301', + Found = '302', + TemporaryRedirect = '307', + PermanentRedirect = '308', +} \ No newline at end of file diff --git a/src/enums/schedule-resource-type.ts b/src/enums/schedule-resource-type.ts new file mode 100644 index 00000000..25ffc458 --- /dev/null +++ b/src/enums/schedule-resource-type.ts @@ -0,0 +1,6 @@ +export enum ScheduleResourceType { + Function = 'function', + Execution = 'execution', + Message = 'message', + Backup = 'backup', +} \ No newline at end of file diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts deleted file mode 100644 index 69af4d56..00000000 --- a/src/enums/scopes.ts +++ /dev/null @@ -1,101 +0,0 @@ -export enum Scopes { - Account = 'account', - TeamsRead = 'teams.read', - TeamsWrite = 'teams.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', - DatabasesRead = 'databases.read', - DatabasesWrite = 'databases.write', - TablesRead = 'tables.read', - TablesWrite = 'tables.write', - ColumnsRead = 'columns.read', - ColumnsWrite = 'columns.write', - IndexesRead = 'indexes.read', - IndexesWrite = 'indexes.write', - RowsRead = 'rows.read', - RowsWrite = 'rows.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', - ProvidersRead = 'providers.read', - ProvidersWrite = 'providers.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', - 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', - InsightsRead = 'insights.read', - InsightsWrite = 'insights.write', - ReportsRead = 'reports.read', - ReportsWrite = 'reports.write', - PresencesRead = 'presences.read', - PresencesWrite = 'presences.write', - BackupsPoliciesRead = 'backups.policies.read', - BackupsPoliciesWrite = 'backups.policies.write', - ArchivesRead = 'archives.read', - ArchivesWrite = 'archives.write', - RestorationsRead = 'restorations.read', - RestorationsWrite = 'restorations.write', - DomainsRead = 'domains.read', - DomainsWrite = 'domains.write', - EventsRead = 'events.read', - UsageRead = 'usage.read', - ProjectsRead = 'projects.read', - ProjectsWrite = 'projects.write', - DevKeysRead = 'devKeys.read', - DevKeysWrite = 'devKeys.write', -} \ No newline at end of file diff --git a/src/enums/adapter.ts b/src/enums/site-adapter.ts similarity index 61% rename from src/enums/adapter.ts rename to src/enums/site-adapter.ts index a3b1ae0c..8d593a5d 100644 --- a/src/enums/adapter.ts +++ b/src/enums/site-adapter.ts @@ -1,4 +1,4 @@ -export enum Adapter { +export enum SiteAdapter { Static = 'static', Ssr = 'ssr', } \ No newline at end of file diff --git a/src/enums/runtimes.ts b/src/enums/site-build-runtime.ts similarity index 95% rename from src/enums/runtimes.ts rename to src/enums/site-build-runtime.ts index af6abfa2..440ce2b0 100644 --- a/src/enums/runtimes.ts +++ b/src/enums/site-build-runtime.ts @@ -1,4 +1,4 @@ -export enum Runtimes { +export enum SiteBuildRuntime { Node145 = 'node-14.5', Node160 = 'node-16.0', Node180 = 'node-18.0', @@ -30,9 +30,6 @@ export enum Runtimes { Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', Pythonml313 = 'python-ml-3.13', - Deno121 = 'deno-1.21', - Deno124 = 'deno-1.24', - Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', @@ -51,6 +48,7 @@ export enum Runtimes { Dart39 = 'dart-3.9', Dart310 = 'dart-3.10', Dart311 = 'dart-3.11', + Dart312 = 'dart-3.12', Dotnet60 = 'dotnet-6.0', Dotnet70 = 'dotnet-7.0', Dotnet80 = 'dotnet-8.0', @@ -91,4 +89,5 @@ export enum Runtimes { Flutter335 = 'flutter-3.35', Flutter338 = 'flutter-3.38', Flutter341 = 'flutter-3.41', + Flutter344 = 'flutter-3.44', } \ No newline at end of file diff --git a/src/enums/framework.ts b/src/enums/site-framework.ts similarity index 92% rename from src/enums/framework.ts rename to src/enums/site-framework.ts index 7093da33..ec4eaf51 100644 --- a/src/enums/framework.ts +++ b/src/enums/site-framework.ts @@ -1,4 +1,4 @@ -export enum Framework { +export enum SiteFramework { Analog = 'analog', Angular = 'angular', Nextjs = 'nextjs', diff --git a/src/enums/use-cases.ts b/src/enums/site-template-use-case.ts similarity index 59% rename from src/enums/use-cases.ts rename to src/enums/site-template-use-case.ts index d8e7306c..7e29c016 100644 --- a/src/enums/use-cases.ts +++ b/src/enums/site-template-use-case.ts @@ -1,16 +1,11 @@ -export enum UseCases { - Starter = 'starter', - Databases = 'databases', - Ai = 'ai', - Messaging = 'messaging', - Utilities = 'utilities', - Devtools = 'dev-tools', - Auth = 'auth', +export enum SiteTemplateUseCase { Portfolio = 'portfolio', + Starter = 'starter', Events = 'events', Ecommerce = 'ecommerce', Documentation = 'documentation', Blog = 'blog', + Ai = 'ai', Forms = 'forms', Dashboard = 'dashboard', } \ No newline at end of file diff --git a/src/enums/status-code.ts b/src/enums/status-code.ts deleted file mode 100644 index 1f3adf8b..00000000 --- a/src/enums/status-code.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum StatusCode { - MovedPermanently301 = '301', - Found302 = '302', - TemporaryRedirect307 = '307', - PermanentRedirect308 = '308', -} \ No newline at end of file diff --git a/src/enums/status.ts b/src/enums/status.ts deleted file mode 100644 index abaf754f..00000000 --- a/src/enums/status.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum Status { - Active = 'active', -} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 37c577f7..c26bc0d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,12 +22,12 @@ export { Locale } from './services/locale'; export { Manager } from './services/manager'; export { Messaging } from './services/messaging'; export { Migrations } from './services/migrations'; +export { Organization } from './services/organization'; export { Organizations } from './services/organizations'; export { Presences } from './services/presences'; export { Project } from './services/project'; export { Projects } from './services/projects'; export { Proxy } from './services/proxy'; -export { Advisor } from './services/advisor'; export { Sites } from './services/sites'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; @@ -47,14 +47,14 @@ export { Role } from './role'; export { ID } from './id'; export { Channel } from './channel'; export { Operator, Condition } from './operator'; -export { Scopes } from './enums/scopes'; +export { AccountKeyScopes } from './enums/account-key-scopes'; export { AuthenticatorType } from './enums/authenticator-type'; export { AuthenticationFactor } from './enums/authentication-factor'; export { OAuthProvider } from './enums/o-auth-provider'; export { Browser } from './enums/browser'; export { CreditCard } from './enums/credit-card'; export { Flag } from './enums/flag'; -export { Theme } from './enums/theme'; +export { BrowserTheme } from './enums/browser-theme'; export { Timezone } from './enums/timezone'; export { BrowserPermission } from './enums/browser-permission'; export { ImageFormat } from './enums/image-format'; @@ -70,27 +70,30 @@ export { RelationMutate } from './enums/relation-mutate'; export { DatabasesIndexType } from './enums/databases-index-type'; export { OrderBy } from './enums/order-by'; export { DocumentsDBIndexType } from './enums/documents-db-index-type'; -export { RegistrationType } from './enums/registration-type'; -export { FilterType } from './enums/filter-type'; -export { Runtime } from './enums/runtime'; -export { Runtimes } from './enums/runtimes'; -export { UseCases } from './enums/use-cases'; +export { DomainRegistrationType } from './enums/domain-registration-type'; +export { DomainSuggestionType } from './enums/domain-suggestion-type'; +export { FunctionRuntime } from './enums/function-runtime'; +export { ProjectKeyScopes } from './enums/project-key-scopes'; +export { FunctionTemplateUseCase } from './enums/function-template-use-case'; export { TemplateReferenceType } from './enums/template-reference-type'; export { VCSReferenceType } from './enums/vcs-reference-type'; export { DeploymentDownloadType } from './enums/deployment-download-type'; export { ExecutionMethod } from './enums/execution-method'; -export { Name } from './enums/name'; -export { ResourceType } from './enums/resource-type'; +export { HealthQueueName } from './enums/health-queue-name'; +export { BlockResourceType } from './enums/block-resource-type'; +export { Region } from './enums/region'; +export { CacheTarget } from './enums/cache-target'; +export { CacheDatabase } from './enums/cache-database'; export { MessagePriority } from './enums/message-priority'; export { SmtpEncryption } from './enums/smtp-encryption'; export { AppwriteMigrationResource } from './enums/appwrite-migration-resource'; -export { OnDuplicate } from './enums/on-duplicate'; +export { MigrationOnDuplicate } from './enums/migration-on-duplicate'; export { FirebaseMigrationResource } from './enums/firebase-migration-resource'; export { NHostMigrationResource } from './enums/n-host-migration-resource'; export { SupabaseMigrationResource } from './enums/supabase-migration-resource'; -export { Addon } from './enums/addon'; +export { OrganizationKeyScopes } from './enums/organization-key-scopes'; +export { OrganizationAddon } from './enums/organization-addon'; export { ProjectAuthMethodId } from './enums/project-auth-method-id'; -export { ProjectKeyScopes } from './enums/project-key-scopes'; export { ProjectOAuth2GooglePrompt } from './enums/project-o-auth-2-google-prompt'; export { ProjectOAuthProviderId } from './enums/project-o-auth-provider-id'; export { ProjectPolicyId } from './enums/project-policy-id'; @@ -98,21 +101,21 @@ export { ProjectProtocolId } from './enums/project-protocol-id'; export { ProjectServiceId } from './enums/project-service-id'; export { ProjectSMTPSecure } from './enums/project-smtp-secure'; export { ProjectUsageRange } from './enums/project-usage-range'; -export { Region } from './enums/region'; -export { Status } from './enums/status'; -export { StatusCode } from './enums/status-code'; +export { ScheduleResourceType } from './enums/schedule-resource-type'; +export { ProjectStatus } from './enums/project-status'; +export { RedirectStatusCode } from './enums/redirect-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'; -export { Frameworks } from './enums/frameworks'; +export { SiteFramework } from './enums/site-framework'; +export { SiteBuildRuntime } from './enums/site-build-runtime'; +export { SiteAdapter } from './enums/site-adapter'; +export { SiteTemplateUseCase } from './enums/site-template-use-case'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; export { TablesDBIndexType } from './enums/tables-db-index-type'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; export { VCSDetectionType } from './enums/vcs-detection-type'; -export { Model } from './enums/model'; +export { EmbeddingModel } from './enums/embedding-model'; export { VectorsDBIndexType } from './enums/vectors-db-index-type'; export { DatabaseType } from './enums/database-type'; export { AttributeStatus } from './enums/attribute-status'; diff --git a/src/models.ts b/src/models.ts index 152b2bdc..2d8e3619 100644 --- a/src/models.ts +++ b/src/models.ts @@ -59,7 +59,7 @@ export namespace Models { /** * Presences List */ - export type PresenceList = { + export type PresenceList = { /** * Total number of presences that matched your query. */ @@ -834,34 +834,6 @@ export namespace Models { embeddings: Embedding[]; } - /** - * Insights List - */ - export type InsightList = { - /** - * Total number of insights that matched your query. - */ - total: number; - /** - * List of insights. - */ - insights: Insight[]; - } - - /** - * Reports List - */ - export type ReportList = { - /** - * Total number of reports that matched your query. - */ - total: number; - /** - * List of reports. - */ - reports: Report[]; - } - /** * Database */ @@ -3264,13 +3236,12 @@ export namespace Models { * Presence expiry date in ISO 8601 format. */ expiresAt?: string; + /** + * Presence metadata. + */ + metadata?: object; } - export type DefaultPresence = Presence & { - [key: string]: any; - [__default]: true; - }; - /** * Log */ @@ -4194,6 +4165,14 @@ export namespace Models { * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests */ providerSilentMode: boolean; + /** + * List of branch name patterns that trigger automatic deployments. Supports glob wildcards. Empty list deploys on all branches. + */ + providerBranches: string[]; + /** + * List of file path patterns that trigger automatic deployments. Supports glob wildcards. Empty list deploys on all file changes. + */ + providerPaths: string[]; /** * Machine specification for deployment builds. */ @@ -4432,6 +4411,14 @@ export namespace Models { * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests */ providerSilentMode: boolean; + /** + * List of branch name patterns that trigger automatic deployments. Supports glob wildcards. Empty list deploys on all branches. + */ + providerBranches: string[]; + /** + * List of file path patterns that trigger automatic deployments. Supports glob wildcards. Empty list deploys on all file changes. + */ + providerPaths: string[]; /** * Machine specification for deployment builds. */ @@ -7765,7 +7752,7 @@ export namespace Models { } /** - * UsageProject + * Project */ export type UsageProject = { /** @@ -8912,156 +8899,6 @@ export namespace Models { backuppolicy: number; } - /** - * Insight - */ - export type Insight = { - /** - * Insight ID. - */ - $id: string; - /** - * Insight creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Insight update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Parent report ID. Insights always belong to a report. - */ - reportId: string; - /** - * Insight type. One of databaseIndex (legacy), tablesDBIndex, documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, siteAccessibility, siteSeo, functionPerformance. The index types are engine-specific so each CTA can pair the right service+method (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or vectorsDB.createIndex). - */ - type: string; - /** - * Insight severity. One of info, warning, critical. - */ - severity: string; - /** - * Insight status. One of active, dismissed. - */ - status: string; - /** - * Type of the resource the insight is about. Plural noun, e.g. databases, sites, functions. - */ - resourceType: string; - /** - * ID of the resource the insight is about. - */ - resourceId: string; - /** - * Plural noun for the parent resource that contains the insight's resource, e.g. an insight about a column index on a table → resourceType=indexes, parentResourceType=tables. Empty when the resource has no parent. - */ - parentResourceType: string; - /** - * ID of the parent resource. Empty when the resource has no parent. - */ - parentResourceId: string; - /** - * Insight title. - */ - title: string; - /** - * Short markdown summary describing the insight. - */ - summary: string; - /** - * List of call-to-action buttons attached to this insight. - */ - ctas: InsightCTA[]; - /** - * Time the insight was analyzed in ISO 8601 format. - */ - analyzedAt?: string; - /** - * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. - */ - dismissedAt?: string; - /** - * User ID that dismissed the insight. Empty when not dismissed. - */ - dismissedBy?: string; - } - - /** - * InsightCTA - */ - export type InsightCTA = { - /** - * Human-readable label for the CTA, used in UI. - */ - label: string; - /** - * Public API service (SDK namespace) the client should invoke. Must match the engine that owns the resource — for index suggestions: databases (legacy), tablesDB, documentsDB, or vectorsDB. - */ - service: string; - /** - * Public API method on the chosen service the client should invoke when this CTA is triggered. - */ - method: string; - /** - * Parameter map the client should pass to the service method when this CTA is triggered. Keys match the target API's parameter names (e.g. databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes for the legacy Databases API). - */ - params: object; - } - - /** - * Report - */ - export type Report = { - /** - * Report ID. - */ - $id: string; - /** - * Report creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Report update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * ID of the third-party app that submitted the report. - */ - appId: string; - /** - * Analyzer that produced this report. e.g. lighthouse, audit, databaseAnalyzer. - */ - type: string; - /** - * Short, human-readable title for the report. - */ - title: string; - /** - * Markdown summary describing the report. - */ - summary: string; - /** - * Plural noun describing what the report analyzes, e.g. databases, sites, urls. - */ - targetType: string; - /** - * Free-form target identifier (URL for lighthouse, resource ID for db). - */ - target: string; - /** - * Categories covered by the report, e.g. performance, accessibility. - */ - categories: string[]; - /** - * Insights nested under this report. - */ - insights: Insight[]; - /** - * Time the report was analyzed in ISO 8601 format. - */ - analyzedAt?: string; - } - /** * ActivityEvent */ @@ -9071,21 +8908,21 @@ export namespace Models { */ $id: string; /** - * User type. + * Actor type. */ - userType: string; + actorType: string; /** - * User ID. + * Actor ID. */ - userId: string; + actorId: string; /** - * User Email. + * Actor Email. */ - userEmail: string; + actorEmail: string; /** - * User Name. + * Actor Name. */ - userName: string; + actorName: string; /** * Resource parent. */ @@ -9227,7 +9064,117 @@ export namespace Models { } /** - * AggregationTeam + * Addon + */ + export type Addon = { + /** + * Addon ID. + */ + $id: string; + /** + * Addon creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Addon update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Addon permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Addon key + */ + key: string; + /** + * Resource type (organization or project) + */ + resourceType: string; + /** + * Resource ID + */ + resourceId: string; + /** + * Payment status. Possible values: pending (awaiting payment confirmation e.g. 3DS), active (payment confirmed and addon is running). + */ + status: string; + /** + * Current value for this billing cycle. For toggle addons: 1 (on) or 0 (off). For numeric addons: the active quantity. + */ + currentValue: number; + /** + * Value to apply at the start of the next billing cycle. Null means no change is scheduled. For toggle addons, 0 means the addon will be removed at the next cycle. + */ + nextValue?: number; + } + + /** + * AddonPrice + */ + export type AddonPrice = { + /** + * Addon key. + */ + addonKey: string; + /** + * Addon display name. + */ + name: string; + /** + * Full monthly price of the addon. + */ + monthlyPrice: number; + /** + * Calculated prorated amount for the current billing cycle. + */ + proratedAmount: number; + /** + * Days remaining in the current billing cycle. + */ + remainingDays: number; + /** + * Total days in the billing cycle. + */ + totalCycleDays: number; + /** + * Currency code. + */ + currency: string; + /** + * When the current billing cycle ends. + */ + billingCycleEnd: string; + } + + /** + * Breakdown + */ + export type AggregationBreakdown = { + /** + * Aggregation ID. + */ + $id: string; + /** + * Project name + */ + name: string; + /** + * Project region + */ + region: string; + /** + * Aggregated amount + */ + amount: number; + /** + * + */ + resources: UsageResources[]; + } + + /** + * Team */ export type AggregationTeam = { /** @@ -9349,47 +9296,21 @@ export namespace Models { } /** - * AggregationBreakdown + * Archive */ - export type AggregationBreakdown = { + export type BackupArchive = { /** - * Aggregation ID. + * Archive ID. */ $id: string; /** - * Project name + * Archive creation time in ISO 8601 format. */ - name: string; + $createdAt: string; /** - * Project region + * Archive update date in ISO 8601 format. */ - region: string; - /** - * Aggregated amount - */ - amount: number; - /** - * - */ - resources: UsageResources[]; - } - - /** - * Archive - */ - export type BackupArchive = { - /** - * Archive ID. - */ - $id: string; - /** - * Archive creation time in ISO 8601 format. - */ - $createdAt: string; - /** - * Archive update date in ISO 8601 format. - */ - $updatedAt: string; + $updatedAt: string; /** * Archive policy ID. */ @@ -9429,7 +9350,7 @@ export namespace Models { } /** - * BillingAddress + * Address */ export type BillingAddress = { /** @@ -9466,6 +9387,44 @@ export namespace Models { postalCode: string; } + /** + * Limits + */ + export type BillingLimits = { + /** + * Bandwidth limit + */ + bandwidth?: number; + /** + * Storage limit + */ + storage?: number; + /** + * Users limit + */ + users?: number; + /** + * Executions limit + */ + executions?: number; + /** + * GBHours limit + */ + GBHours?: number; + /** + * Image transformations limit + */ + imageTransformations?: number; + /** + * Auth phone limit + */ + authPhone?: number; + /** + * Budget limit percentage + */ + budgetLimit?: number; + } + /** * billingPlan */ @@ -9725,7 +9684,7 @@ export namespace Models { } /** - * BillingPlanAddon + * Addon */ export type BillingPlanAddon = { /** @@ -9739,7 +9698,7 @@ export namespace Models { } /** - * BillingPlanAddonDetails + * Details */ export type BillingPlanAddonDetails = { /** @@ -9777,7 +9736,7 @@ export namespace Models { } /** - * BillingPlanLimits + * PlanLimits */ export type BillingPlanLimits = { /** @@ -9800,44 +9759,6 @@ export namespace Models { baa: boolean; } - /** - * BillingLimits - */ - export type BillingLimits = { - /** - * Bandwidth limit - */ - bandwidth?: number; - /** - * Storage limit - */ - storage?: number; - /** - * Users limit - */ - users?: number; - /** - * Executions limit - */ - executions?: number; - /** - * GBHours limit - */ - GBHours?: number; - /** - * Image transformations limit - */ - imageTransformations?: number; - /** - * Auth phone limit - */ - authPhone?: number; - /** - * Budget limit percentage - */ - budgetLimit?: number; - } - /** * Block */ @@ -9952,48 +9873,6 @@ export namespace Models { footer?: boolean; } - /** - * Program - */ - export type Program = { - /** - * Program ID - */ - $id: string; - /** - * Program title - */ - title: string; - /** - * Program description - */ - description: string; - /** - * Program tag for highlighting on console - */ - tag: string; - /** - * Program icon for highlighting on console - */ - icon: string; - /** - * URL for more information on this program - */ - url: string; - /** - * Whether this program is active - */ - active: boolean; - /** - * Whether this program is external - */ - external: boolean; - /** - * Billing plan ID that this is program is associated with. - */ - billingPlanId: string; - } - /** * Coupon */ @@ -10111,1075 +9990,1105 @@ export namespace Models { } /** - * Downgrade Feedback + * DNSRecord */ - export type DowngradeFeedback = { + export type DnsRecord = { /** - * Feedback ID. + * DNS Record ID. */ $id: string; /** - * Feedback creation date in ISO 8601 format. + * DNS Record creation time in ISO 8601 format. */ $createdAt: string; /** - * Feedback update date in ISO 8601 format. + * DNS Record update date in ISO 8601 format. */ $updatedAt: string; /** - * Feedback reason + * DNS record type (e.g. A, CNAME, MX). */ - title: string; + type: string; /** - * Feedback message + * Record name or subdomain. */ - message: string; + name: string; /** - * Plan ID downgrading from + * Value of the record (IP address, domain, etc.). */ - fromPlanId: string; + value: string; /** - * Plan ID downgrading to + * Time to live (in seconds). */ - toPlanId: string; + ttl: number; /** - * Organization ID + * Record priority (commonly used for MX). */ - teamId: string; + priority: number; /** - * User ID who submitted feedback + * Whether this record is locked (read-only). */ - userId: string; + lock: boolean; /** - * Console version + * Record weight (used for SRV records). */ - version: string; + weight: number; + /** + * Target port (used for SRV records). + */ + port: number; + /** + * Comment for the DNS record. + */ + comment: string; } /** - * Invoice + * Domain */ - export type Invoice = { + export type Domain = { /** - * Invoice ID. + * Domain ID. */ $id: string; /** - * Invoice creation time in ISO 8601 format. + * Domain creation time in ISO 8601 format. */ $createdAt: string; /** - * Invoice update date in ISO 8601 format. + * Domain update date in ISO 8601 format. */ $updatedAt: string; /** - * Invoice permissions. [Learn more about permissions](/docs/permissions). + * Domain name. */ - $permissions: string[]; + domain: string; /** - * Project ID + * Domain registrar (e.g. "appwrite" or "third_party"). */ - teamId: string; + registrar: string; /** - * Aggregation ID + * Nameservers setting. "Appwrite" or empty string. */ - aggregationId: string; + nameservers: string; /** - * Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. + * Domain expiry date in ISO 8601 format. */ - plan: string; + expire: string; /** - * Usage breakdown per resource + * Domain renewal date in ISO 8601 format. */ - usage: UsageResources[]; + renewal: string; /** - * Invoice Amount + * If set to true, the domain will automatically renew. */ - amount: number; + autoRenewal: boolean; /** - * Tax percentage + * Renewal price (in cents). */ - tax: number; + renewalPrice: number; /** - * Tax amount + * Transfer status for domains being transferred in. */ - taxAmount: number; + transferStatus: DomainTransferStatusEnum; /** - * VAT percentage + * Team ID. */ - vat: number; + teamId: string; /** - * VAT amount + * Dns records */ - vatAmount: number; + dnsRecords: DnsRecord[]; + } + + /** + * DomainPrice + */ + export type DomainPrice = { /** - * Gross amount after vat, tax, and discounts applied. + * Domain name. */ - grossAmount: number; + domain: string; /** - * Credits used. + * Top-level domain for the requested domain. */ - creditsUsed: number; + tld: string; /** - * Currency the invoice is in + * Whether the domain is currently available for registration. */ - currency: string; + available: boolean; /** - * Client secret for processing failed payments in front-end + * Domain registration price. */ - clientSecret: string; + price: number; /** - * Invoice status + * Price period in years. */ - status: string; + periodYears: number; /** - * Invoice type. Can be one of `subscription`, `domain_purchase`, `domain_renewal`, `domain_transfer`, or `addon_*`. + * Whether the domain is a premium domain. */ - type: string; + premium: boolean; + } + + /** + * DomainPurchase + */ + export type DomainPurchase = { /** - * Last payment error associated with the invoice + * Purchase/invoice ID. */ - lastError: string; + $id: string; /** - * Invoice due date. + * Purchase creation time in ISO 8601 format. */ - dueAt: string; + $createdAt: string; /** - * Beginning date of the invoice + * Purchase update date in ISO 8601 format. */ - from: string; + $updatedAt: string; /** - * End date of the invoice + * Domain document ID. */ - to: string; - } - - /** - * Organization - */ - export type Organization = { + domainId: string; /** - * Team ID. + * Domain name. */ - $id: string; + domain: string; /** - * Team creation date in ISO 8601 format. + * Team ID that owns the domain. */ - $createdAt: string; + organizationId: string; /** - * Team update date in ISO 8601 format. + * Domain purchase status. */ - $updatedAt: string; + status: DomainPurchaseStatus; /** - * Team name. + * Stripe client secret for 3DS; empty when not applicable. */ - name: string; + clientSecret: string; /** - * Total number of team members. + * Purchase amount. */ - total: number; + amount: number; /** - * Team preferences as a key-value object + * Currency code. */ - prefs: Preferences; + currency: string; + } + + /** + * DomainSuggestion + */ + export type DomainSuggestion = { /** - * Project budget limit + * Domain suggestion. */ - billingBudget: number; + domain: string; /** - * Project budget limit + * Is the domain premium? */ - budgetAlerts: number[]; + premium: boolean; /** - * Organization's billing plan ID. + * Domain price. */ - billingPlan: string; + price?: number; /** - * Organization's billing plan ID. + * Is the domain available? */ - billingPlanId: string; + available: boolean; + } + + /** + * domainTransferOut + */ + export type DomainTransferOut = { /** - * Organization's billing plan. + * Domain transfer authorization code. */ - billingPlanDetails: BillingPlan; + authCode: string; + } + + /** + * domainTransferStatus + */ + export type DomainTransferStatus = { /** - * Billing email set for the organization. + * Transfer status. */ - billingEmail: string; + status: DomainTransferStatusEnum; /** - * Billing cycle start date. + * Additional transfer status information. */ - billingStartDate: string; + reason: string; /** - * Current invoice cycle start date. + * Transfer status timestamp in ISO 8601 format. */ - billingCurrentInvoiceDate: string; + timestamp: string; + } + + /** + * Downgrade Feedback + */ + export type DowngradeFeedback = { /** - * Next invoice cycle start date. + * Feedback ID. */ - billingNextInvoiceDate: string; + $id: string; /** - * Start date of trial. + * Feedback creation date in ISO 8601 format. */ - billingTrialStartDate: string; + $createdAt: string; /** - * Number of trial days. + * Feedback update date in ISO 8601 format. */ - billingTrialDays: number; + $updatedAt: string; /** - * Current active aggregation id. + * Feedback reason */ - billingAggregationId: string; + title: string; /** - * Current active aggregation id. + * Feedback message */ - billingInvoiceId: string; + message: string; /** - * Default payment method. + * Plan ID downgrading from */ - paymentMethodId: string; + fromPlanId: string; /** - * Default payment method. + * Plan ID downgrading to */ - billingAddressId: string; + toPlanId: string; /** - * Backup payment method. + * Organization ID */ - backupPaymentMethodId: string; + teamId: string; /** - * Team status. + * User ID who submitted feedback */ - status: string; + userId: string; /** - * Remarks on team status. + * Console version */ - remarks: string; + version: string; + } + + /** + * Estimation + */ + export type Estimation = { /** - * Organization agreements + * Total amount */ - agreementBAA: string; + amount: number; /** - * Program manager's name. + * Gross payable amount */ - programManagerName: string; + grossAmount: number; /** - * Program manager's calendar link. + * Discount amount */ - programManagerCalendar: string; + discount: number; /** - * Program's discord channel name. + * Credits amount */ - programDiscordChannelName: string; + credits: number; /** - * Program's discord channel URL. + * Estimation items */ - programDiscordChannelUrl: string; + items: EstimationItem[]; /** - * Billing limits reached + * Estimation discount items */ - billingLimits?: BillingLimits; + discounts: EstimationItem[]; /** - * Billing plan selected for downgrade. + * Trial days */ - billingPlanDowngrade: string; + trialDays: number; /** - * Tax Id + * Trial end date */ - billingTaxId: string; + trialEndDate?: string; + } + + /** + * DeleteOrganization + */ + export type EstimationDeleteOrganization = { /** - * Marked for deletion + * List of unpaid invoices */ - markedForDeletion: boolean; + unpaidInvoices: Invoice[]; + } + + /** + * Item + */ + export type EstimationItem = { /** - * Product with which the organization is associated (appwrite or imagine) + * Label */ - platform: string; + label: string; /** - * Selected projects + * Gross payable amount */ - projects: string[]; + value: number; } /** - * PaymentAuthentication + * EstimationPlanChange */ - export type PaymentAuthentication = { + export type EstimationPlanChange = { /** - * Message for the end user to show on Console. + * Current billing plan ID */ - message: string; + currentBillingPlanId: string; /** - * Stripe client secret to use for validation. + * Target billing plan ID */ - clientSecret: string; + targetBillingPlanId: string; /** - * Organization ID for which the payment authentication is needed. + * Direction of plan change: upgrade, downgrade, or same */ - organizationId: string; + direction: string; /** - * Invoice ID against which the payment needs to be validated. + * Cost estimation details */ - invoiceId: string; + estimation: PlanChangeEstimationDetails; /** - * Addon ID to use when calling the addon validate endpoint. Empty when authentication is not for an addon. + * Plan limits and compliance information */ - addonId: string; + limits: PlanChangeLimits; } /** - * paymentMethod + * UpdatePlan */ - export type PaymentMethod = { + export type EstimationUpdatePlan = { /** - * Payment Method ID. + * Total amount */ - $id: string; + amount: number; /** - * Payment method creation time in ISO 8601 format. + * Gross payable amount */ - $createdAt: string; + grossAmount: number; /** - * Payment method update date in ISO 8601 format. + * Discount amount */ - $updatedAt: string; + discount: number; /** - * Payment method permissions. [Learn more about permissions](/docs/permissions). + * Credits amount */ - $permissions: string[]; + credits: number; /** - * Payment method ID from the payment provider + * Estimation items */ - providerMethodId: string; + items: EstimationItem[]; /** - * Client secret hash for payment setup + * Estimation discount items */ - clientSecret: string; + discounts: EstimationItem[]; /** - * User ID from the payment provider. + * Trial days */ - providerUserId: string; + trialDays: number; /** - * ID of the Team. + * Trial end date */ - userId: string; + trialEndDate?: string; /** - * Expiry month of the payment method. + * Organization's existing credits */ - expiryMonth: number; + organizationCredits: number; + } + + /** + * Invoice + */ + export type Invoice = { /** - * Expiry year of the payment method. + * Invoice ID. + */ + $id: string; + /** + * Invoice creation time in ISO 8601 format. */ - expiryYear: number; + $createdAt: string; /** - * Last 4 digit of the payment method + * Invoice update date in ISO 8601 format. */ - last4: string; + $updatedAt: string; /** - * Payment method brand + * Invoice permissions. [Learn more about permissions](/docs/permissions). */ - brand: string; + $permissions: string[]; /** - * Name of the owner + * Project ID */ - name: string; + teamId: string; /** - * Mandate ID of the payment method + * Aggregation ID */ - mandateId: string; + aggregationId: string; /** - * Country of the payment method + * Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. */ - country: string; + plan: string; /** - * State of the payment method + * Usage breakdown per resource */ - state: string; + usage: UsageResources[]; /** - * Last payment error associated with the payment method. + * Invoice Amount */ - lastError: string; + amount: number; /** - * True when it's the default payment method. + * Tax percentage */ - default: boolean; + tax: number; /** - * True when payment method has expired. + * Tax amount */ - expired: boolean; + taxAmount: number; /** - * True when payment method has failed to process multiple times. + * VAT percentage */ - failed: boolean; - } - - /** - * backup - */ - export type BackupPolicy = { + vat: number; /** - * Backup policy ID. + * VAT amount */ - $id: string; + vatAmount: number; /** - * Backup policy name. + * Gross amount after vat, tax, and discounts applied. */ - name: string; + grossAmount: number; /** - * Policy creation date in ISO 8601 format. + * Credits used. */ - $createdAt: string; + creditsUsed: number; /** - * Policy update date in ISO 8601 format. + * Currency the invoice is in */ - $updatedAt: string; + currency: string; /** - * The services that are backed up by this policy. + * Client secret for processing failed payments in front-end */ - services: string[]; + clientSecret: string; /** - * The resources that are backed up by this policy. + * Invoice status */ - resources: string[]; + status: string; /** - * The resource ID to backup. Set only if this policy should backup a single resource. + * Invoice type. Can be one of `subscription`, `domain_purchase`, `domain_renewal`, `domain_transfer`, or `addon_*`. */ - resourceId?: string; + type: string; /** - * The resource type to backup. Set only if this policy should backup a single resource. + * Last payment error associated with the invoice */ - resourceType?: string; + lastError: string; /** - * How many days to keep the backup before it will be automatically deleted. + * Invoice due date. */ - retention: number; + dueAt: string; /** - * Policy backup schedule in CRON format. + * Beginning date of the invoice */ - schedule: string; + from: string; /** - * Is this policy enabled. + * End date of the invoice */ - enabled: boolean; + to: string; } /** - * Region + * Organization */ - export type ConsoleRegion = { + export type Organization = { /** - * Region ID + * Team ID. */ $id: string; /** - * Region name + * Team creation date in ISO 8601 format. */ - name: string; + $createdAt: string; /** - * Does the organization have access to this region. + * Team update date in ISO 8601 format. */ - available: boolean; + $updatedAt: string; /** - * Does the backend support this region. + * Team name. */ - disabled: boolean; + name: string; /** - * Is this the region default. + * Total number of team members. */ - default: boolean; + total: number; /** - * Region flag code. + * Team preferences as a key-value object */ - flag: string; - } - - /** - * Restoration - */ - export type BackupRestoration = { + prefs: Preferences; /** - * Restoration ID. + * Project budget limit */ - $id: string; + billingBudget: number; /** - * Restoration creation time in ISO 8601 format. + * Project budget limit */ - $createdAt: string; + budgetAlerts: number[]; /** - * Restoration update date in ISO 8601 format. + * Organization's billing plan ID. */ - $updatedAt: string; + billingPlan: string; /** - * Backup archive ID. + * Organization's billing plan ID. */ - archiveId: string; + billingPlanId: string; /** - * Backup policy ID. + * Organization's billing plan. */ - policyId: string; + billingPlanDetails: BillingPlan; /** - * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. + * Billing email set for the organization. */ - status: string; + billingEmail: string; /** - * The backup start time. + * Billing cycle start date. */ - startedAt: string; + billingStartDate: string; /** - * Migration ID. + * Current invoice cycle start date. */ - migrationId: string; + billingCurrentInvoiceDate: string; /** - * The services that are backed up by this policy. + * Next invoice cycle start date. */ - services: string[]; + billingNextInvoiceDate: string; /** - * The resources that are backed up by this policy. + * Start date of trial. */ - resources: string[]; + billingTrialStartDate: string; /** - * Optional data in key-value object. + * Number of trial days. */ - options: string; - } - - /** - * Review - */ - export type Review = { + billingTrialDays: number; /** - * Name of user + * Current active aggregation id. */ - name: string; + billingAggregationId: string; /** - * Reviewer image + * Current active aggregation id. */ - image: string; + billingInvoiceId: string; /** - * Reviewer description + * Default payment method. */ - description: string; + paymentMethodId: string; /** - * Review + * Default payment method. */ - review: string; - } - - /** - * Roles - */ - export type Roles = { + billingAddressId: string; /** - * Array of scopes accessible to current user. + * Backup payment method. */ - scopes: string[]; + backupPaymentMethodId: string; /** - * Array of roles assigned to current user. + * Team status. */ - roles: string[]; - } - - /** - * usageEvent - */ - export type UsageEvent = { + status: string; /** - * The metric key. + * Remarks on team status. */ - metric: string; + remarks: string; /** - * The metric value. + * Organization agreements */ - value: number; + agreementBAA: string; /** - * The event timestamp. + * Program manager's name. */ - time: string; + programManagerName: string; /** - * The API endpoint path. + * Program manager's calendar link. */ - path: string; + programManagerCalendar: string; /** - * The HTTP method. + * Program's discord channel name. */ - method: string; + programDiscordChannelName: string; /** - * HTTP status code. Stored as string to preserve unset state (empty string = not available). + * Program's discord channel URL. */ - status: string; + programDiscordChannelUrl: string; /** - * The resource type. + * Billing limits reached */ - resourceType: string; + billingLimits?: BillingLimits; /** - * The resource ID. + * Billing plan selected for downgrade. */ - resourceId: string; + billingPlanDowngrade: string; /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format. + * Tax Id */ - countryCode: string; + billingTaxId: string; /** - * The user agent string. + * Marked for deletion */ - userAgent: string; - } - - /** - * Usage events list - */ - export type UsageEventList = { + markedForDeletion: boolean; /** - * Total number of events that matched your query. + * Product with which the organization is associated (appwrite or imagine) */ - total: number; + platform: string; /** - * List of events. + * Selected projects */ - events: UsageEvent[]; + projects: string[]; } /** - * usageGauge + * PaymentAuthentication */ - export type UsageGauge = { + export type PaymentAuthentication = { /** - * The metric key. + * Message for the end user to show on Console. */ - metric: string; + message: string; /** - * The current snapshot value. + * Stripe client secret to use for validation. */ - value: number; + clientSecret: string; /** - * The snapshot timestamp. + * Organization ID for which the payment authentication is needed. */ - time: string; - } - - /** - * Usage gauges list - */ - export type UsageGaugeList = { + organizationId: string; /** - * Total number of gauges that matched your query. + * Invoice ID against which the payment needs to be validated. */ - total: number; + invoiceId: string; /** - * List of gauges. + * Addon ID to use when calling the addon validate endpoint. Empty when authentication is not for an addon. */ - gauges: UsageGauge[]; + addonId: string; } /** - * UsageOrganization + * paymentMethod */ - export type UsageOrganization = { - /** - * Aggregated stats for number of requests. - */ - bandwidth: Metric[]; - /** - * Aggregated stats for consumed bandwidth. - */ - users: Metric[]; - /** - * Aggregated stats for function executions. - */ - executions: Metric[]; + export type PaymentMethod = { /** - * Aggregated stats for database reads. + * Payment Method ID. */ - databasesReads: Metric[]; + $id: string; /** - * Aggregated stats for database writes. + * Payment method creation time in ISO 8601 format. */ - databasesWrites: Metric[]; + $createdAt: string; /** - * Aggregated stats for file transformations. + * Payment method update date in ISO 8601 format. */ - imageTransformations: Metric[]; + $updatedAt: string; /** - * Aggregated stats for total file transformations. + * Payment method permissions. [Learn more about permissions](/docs/permissions). */ - imageTransformationsTotal: number; + $permissions: string[]; /** - * Aggregated stats for file transformations. + * Payment method ID from the payment provider */ - screenshotsGenerated: Metric[]; + providerMethodId: string; /** - * Aggregated stats for total file transformations. + * Client secret hash for payment setup */ - screenshotsGeneratedTotal: number; + clientSecret: string; /** - * Aggregated stats for imagine credits. + * User ID from the payment provider. */ - imagineCredits: Metric[]; + providerUserId: string; /** - * Aggregated stats for total imagine credits. + * ID of the Team. */ - imagineCreditsTotal: number; + userId: string; /** - * Aggregated stats for total users. + * Expiry month of the payment method. */ - usersTotal: number; + expiryMonth: number; /** - * Aggregated stats for total executions. + * Expiry year of the payment method. */ - executionsTotal: number; + expiryYear: number; /** - * Aggregated stats for function executions in mb seconds. + * Last 4 digit of the payment method */ - executionsMBSecondsTotal: number; + last4: string; /** - * Aggregated stats for function builds in mb seconds. + * Payment method brand */ - buildsMBSecondsTotal: number; + brand: string; /** - * Aggregated stats for total file storage. + * Name of the owner */ - filesStorageTotal: number; + name: string; /** - * Aggregated stats for total builds storage. + * Mandate ID of the payment method */ - buildsStorageTotal: number; + mandateId: string; /** - * Aggregated stats for total deployments storage. + * Country of the payment method */ - deploymentsStorageTotal: number; + country: string; /** - * Aggregated stats for total databases storage. + * State of the payment method */ - databasesStorageTotal: number; + state: string; /** - * Aggregated stats for total databases reads. + * Last payment error associated with the payment method. */ - databasesReadsTotal: number; + lastError: string; /** - * Aggregated stats for total databases writes. + * True when it's the default payment method. */ - databasesWritesTotal: number; + default: boolean; /** - * Aggregated stats for total backups storage. + * True when payment method has expired. */ - backupsStorageTotal: number; + expired: boolean; /** - * Aggregated stats for total storage. + * True when payment method has failed to process multiple times. */ - storageTotal: number; + failed: boolean; + } + + /** + * PlanChangeEstimationDetails + */ + export type PlanChangeEstimationDetails = { /** - * Aggregated stats for total auth phone. + * Currency code */ - authPhoneTotal: number; + currency: string; /** - * Aggregated stats for total auth phone estimation. + * Gross amount after all discounts and credits */ - authPhoneEstimate: number; + grossAmount: number; /** - * Aggregated stats for each projects. + * Credits applied from coupon */ - projects: UsageOrganizationProject[]; + credits: number; /** - * Aggregated stats for realtime connections. + * Organization's existing credits applied */ - realtimeConnections: Metric[]; + organizationCredits: number; /** - * Aggregated stats for total realtime connections. + * Discount amount from prorated invoices */ - realtimeConnectionsTotal: number; + discount: number; /** - * Aggregated stats for realtime messages. + * Total amount before discounts and credits */ - realtimeMessages: Metric[]; + amount: number; /** - * Aggregated stats for total realtime messages. + * Next invoice date */ - realtimeMessagesTotal: number; + nextInvoiceDate: string; /** - * Aggregated stats for realtime bandwidth. + * Line items breakdown */ - realtimeBandwidth: Metric[]; + items: object; /** - * Aggregated stats for total realtime bandwidth. + * Applied discounts breakdown */ - realtimeBandwidthTotal: number; + discounts: object; } /** - * UsageOrganizationProject + * PlanChangeLimits */ - export type UsageOrganizationProject = { - /** - * projectId - */ - projectId: string; - /** - * Aggregated stats for number of requests. - */ - bandwidth: Metric[]; - /** - * Aggregated stats for consumed bandwidth. - */ - users: Metric[]; - /** - * Aggregated stats for function executions. - */ - executions: number; - /** - * Aggregated stats for database reads. - */ - databasesReads: Metric[]; + export type PlanChangeLimits = { /** - * Aggregated stats for database writes. + * Total number of projects in the organization */ - databasesWrites: Metric[]; + totalProjects: number; /** - * Aggregated stats for function executions in mb seconds. + * Number of projects exceeding target plan limits */ - executionsMBSeconds: number; + nonCompliantProjects: number; /** - * Aggregated stats for function builds in mb seconds. + * Whether the plan change is allowed */ - buildsMBSeconds: number; + canChangePlan: boolean; /** - * Aggregated stats for number of documents. + * Project compliance details */ - storage: number; + projects: PlanChangeProjectCompliance[]; /** - * Aggregated stats for phone authentication. + * Active addon keys that the target plan does not support. When non-empty, `canChangePlan` is false. */ - authPhoneTotal: number; + unsupportedAddons: string[]; + } + + /** + * PlanChangeProjectCompliance + */ + export type PlanChangeProjectCompliance = { /** - * Aggregated stats for phone authentication estimated cost. + * Project ID */ - authPhoneEstimate: number; + $id: string; /** - * Aggregated stats for total databases reads. + * Project name */ - databasesReadsTotal: number; + name: string; /** - * Aggregated stats for total databases writes. + * Whether the project complies with target plan limits */ - databasesWritesTotal: number; + isCompliant: boolean; /** - * Aggregated stats for file transformations. + * Resource compliance details */ - imageTransformations: Metric[]; + resources: PlanChangeResourceCompliance[]; /** - * Aggregated stats for total file transformations. + * Failure reason when compliance could not be evaluated. Present only when the project DB or Regions API was unreachable; in that case `isCompliant` is false (fail closed) and `resources` is empty. */ - imageTransformationsTotal: number; + error?: string; + } + + /** + * PlanChangeResourceCompliance + */ + export type PlanChangeResourceCompliance = { /** - * Aggregated stats for file transformations. + * Resource type */ - screenshotsGenerated: Metric[]; + type: string; /** - * Aggregated stats for total file transformations. + * Current usage count */ - screenshotsGeneratedTotal: number; + currentUsage: number; /** - * Aggregated stats for imagine credits. + * Allowed limit in target plan */ - imagineCredits: number; + limit: number; /** - * Aggregated stats for realtime connections. + * Compliance status */ - realtimeConnections: number; + status: string; /** - * Aggregated stats for realtime messages. + * Number of resources exceeding the limit */ - realtimeMessages: number; + excess: number; /** - * Aggregated stats for realtime bandwidth. + * Suggestion for resolving the compliance issue */ - realtimeBandwidth: number; + resolutionHint: string; } /** - * Domain + * backup */ - export type Domain = { + export type BackupPolicy = { /** - * Domain ID. + * Backup policy ID. */ $id: string; /** - * Domain creation time in ISO 8601 format. + * Backup policy name. + */ + name: string; + /** + * Policy creation date in ISO 8601 format. */ $createdAt: string; /** - * Domain update date in ISO 8601 format. + * Policy update date in ISO 8601 format. */ $updatedAt: string; /** - * Domain name. + * The services that are backed up by this policy. */ - domain: string; + services: string[]; /** - * Domain registrar (e.g. "appwrite" or "third_party"). + * The resources that are backed up by this policy. */ - registrar: string; + resources: string[]; /** - * Nameservers setting. "Appwrite" or empty string. + * The resource ID to backup. Set only if this policy should backup a single resource. */ - nameservers: string; + resourceId?: string; /** - * Domain expiry date in ISO 8601 format. + * The resource type to backup. Set only if this policy should backup a single resource. */ - expire: string; + resourceType?: string; /** - * Domain renewal date in ISO 8601 format. + * How many days to keep the backup before it will be automatically deleted. */ - renewal: string; + retention: number; /** - * If set to true, the domain will automatically renew. + * Policy backup schedule in CRON format. */ - autoRenewal: boolean; + schedule: string; /** - * Renewal price (in cents). + * Is this policy enabled. */ - renewalPrice: number; + enabled: boolean; + } + + /** + * Program + */ + export type Program = { /** - * Transfer status for domains being transferred in. + * Program ID */ - transferStatus: DomainTransferStatusEnum; + $id: string; /** - * Team ID. + * Program title */ - teamId: string; + title: string; /** - * Dns records + * Program description */ - dnsRecords: DnsRecord[]; - } - - /** - * DomainPurchase - */ - export type DomainPurchase = { + description: string; /** - * Purchase/invoice ID. + * Program tag for highlighting on console */ - $id: string; + tag: string; /** - * Purchase creation time in ISO 8601 format. + * Program icon for highlighting on console */ - $createdAt: string; + icon: string; /** - * Purchase update date in ISO 8601 format. + * URL for more information on this program */ - $updatedAt: string; + url: string; /** - * Domain document ID. + * Whether this program is active */ - domainId: string; + active: boolean; /** - * Domain name. + * Whether this program is external */ - domain: string; + external: boolean; /** - * Team ID that owns the domain. + * Billing plan ID that this is program is associated with. */ - organizationId: string; + billingPlanId: string; + } + + /** + * Region + */ + export type ConsoleRegion = { /** - * Domain purchase status. + * Region ID */ - status: DomainPurchaseStatus; + $id: string; /** - * Stripe client secret for 3DS; empty when not applicable. + * Region name */ - clientSecret: string; + name: string; /** - * Purchase amount. + * Does the organization have access to this region. */ - amount: number; + available: boolean; /** - * Currency code. + * Does the backend support this region. */ - currency: string; + disabled: boolean; + /** + * Is this the region default. + */ + default: boolean; + /** + * Region flag code. + */ + flag: string; } /** - * DNSRecord + * Restoration */ - export type DnsRecord = { + export type BackupRestoration = { /** - * DNS Record ID. + * Restoration ID. */ $id: string; /** - * DNS Record creation time in ISO 8601 format. + * Restoration creation time in ISO 8601 format. */ $createdAt: string; /** - * DNS Record update date in ISO 8601 format. + * Restoration update date in ISO 8601 format. */ $updatedAt: string; /** - * DNS record type (e.g. A, CNAME, MX). - */ - type: string; - /** - * Record name or subdomain. + * Backup archive ID. */ - name: string; + archiveId: string; /** - * Value of the record (IP address, domain, etc.). + * Backup policy ID. */ - value: string; + policyId: string; /** - * Time to live (in seconds). + * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. */ - ttl: number; + status: string; /** - * Record priority (commonly used for MX). + * The backup start time. */ - priority: number; + startedAt: string; /** - * Whether this record is locked (read-only). + * Migration ID. */ - lock: boolean; + migrationId: string; /** - * Record weight (used for SRV records). + * The services that are backed up by this policy. */ - weight: number; + services: string[]; /** - * Target port (used for SRV records). + * The resources that are backed up by this policy. */ - port: number; + resources: string[]; /** - * Comment for the DNS record. + * Optional data in key-value object. */ - comment: string; + options: string; } /** - * UsageResource + * Review */ - export type UsageResources = { + export type Review = { /** - * Invoice name + * Name of user */ name: string; /** - * Invoice value + * Reviewer image */ - value: number; + image: string; /** - * Invoice amount + * Reviewer description */ - amount: number; + description: string; /** - * Invoice rate + * Review */ - rate: number; + review: string; + } + + /** + * Roles + */ + export type Roles = { /** - * Invoice description + * Array of scopes accessible to current user. */ - desc: string; + scopes: string[]; /** - * Resource ID + * Array of roles assigned to current user. */ - resourceId: string; + roles: string[]; } /** @@ -11233,421 +11142,343 @@ export namespace Models { } /** - * Estimation + * usageEvent */ - export type Estimation = { - /** - * Total amount - */ - amount: number; - /** - * Gross payable amount - */ - grossAmount: number; - /** - * Discount amount - */ - discount: number; - /** - * Credits amount - */ - credits: number; - /** - * Estimation items - */ - items: EstimationItem[]; - /** - * Estimation discount items - */ - discounts: EstimationItem[]; - /** - * Trial days - */ - trialDays: number; + export type UsageEvent = { /** - * Trial end date - */ - trialEndDate?: string; - } - - /** - * EstimationUpdatePlan - */ - export type EstimationUpdatePlan = { + * The metric key. + */ + metric: string; /** - * Total amount + * The metric value. */ - amount: number; + value: number; /** - * Gross payable amount + * The event timestamp. */ - grossAmount: number; + time: string; /** - * Discount amount + * The API endpoint path. */ - discount: number; + path: string; /** - * Credits amount + * The HTTP method. */ - credits: number; + method: string; /** - * Estimation items + * HTTP status code. Stored as string to preserve unset state (empty string = not available). */ - items: EstimationItem[]; + status: string; /** - * Estimation discount items + * The resource type. */ - discounts: EstimationItem[]; + resourceType: string; /** - * Trial days + * The resource ID. */ - trialDays: number; + resourceId: string; /** - * Trial end date + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format. */ - trialEndDate?: string; + countryCode: string; /** - * Organization's existing credits + * The user agent string. */ - organizationCredits: number; + userAgent: string; } /** - * EstimationPlanChange + * usageGauge */ - export type EstimationPlanChange = { + export type UsageGauge = { /** - * Current billing plan ID + * The metric key. */ - currentBillingPlanId: string; + metric: string; /** - * Target billing plan ID + * The current snapshot value. */ - targetBillingPlanId: string; + value: number; /** - * Direction of plan change: upgrade, downgrade, or same + * The snapshot timestamp. */ - direction: string; + time: string; /** - * Cost estimation details + * The resource type. */ - estimation: PlanChangeEstimationDetails; + resourceType: string; /** - * Plan limits and compliance information + * The resource ID. */ - limits: PlanChangeLimits; + resourceId: string; } /** - * PlanChangeEstimationDetails + * Organization */ - export type PlanChangeEstimationDetails = { + export type UsageOrganization = { /** - * Currency code + * Aggregated stats for number of requests. */ - currency: string; + bandwidth: Metric[]; /** - * Gross amount after all discounts and credits + * Aggregated stats for consumed bandwidth. */ - grossAmount: number; + users: Metric[]; /** - * Credits applied from coupon + * Aggregated stats for function executions. */ - credits: number; + executions: Metric[]; /** - * Organization's existing credits applied + * Aggregated stats for database reads. */ - organizationCredits: number; + databasesReads: Metric[]; /** - * Discount amount from prorated invoices + * Aggregated stats for database writes. */ - discount: number; + databasesWrites: Metric[]; /** - * Total amount before discounts and credits + * Aggregated stats for file transformations. */ - amount: number; + imageTransformations: Metric[]; /** - * Next invoice date + * Aggregated stats for total file transformations. */ - nextInvoiceDate: string; + imageTransformationsTotal: number; /** - * Line items breakdown + * Aggregated stats for file transformations. */ - items: object; + screenshotsGenerated: Metric[]; /** - * Applied discounts breakdown + * Aggregated stats for total file transformations. */ - discounts: object; - } - - /** - * PlanChangeLimits - */ - export type PlanChangeLimits = { + screenshotsGeneratedTotal: number; /** - * Total number of projects in the organization + * Aggregated stats for imagine credits. */ - totalProjects: number; + imagineCredits: Metric[]; /** - * Number of projects exceeding target plan limits + * Aggregated stats for total imagine credits. */ - nonCompliantProjects: number; + imagineCreditsTotal: number; /** - * Whether the plan change is allowed + * Aggregated stats for total users. */ - canChangePlan: boolean; + usersTotal: number; /** - * Project compliance details + * Aggregated stats for total executions. */ - projects: PlanChangeProjectCompliance[]; + executionsTotal: number; /** - * Active addon keys that the target plan does not support. When non-empty, `canChangePlan` is false. + * Aggregated stats for function executions in mb seconds. */ - unsupportedAddons: string[]; - } - - /** - * PlanChangeProjectCompliance - */ - export type PlanChangeProjectCompliance = { + executionsMBSecondsTotal: number; /** - * Project ID + * Aggregated stats for function builds in mb seconds. */ - $id: string; + buildsMBSecondsTotal: number; /** - * Project name + * Aggregated stats for total file storage. */ - name: string; + filesStorageTotal: number; /** - * Whether the project complies with target plan limits + * Aggregated stats for total builds storage. */ - isCompliant: boolean; + buildsStorageTotal: number; /** - * Resource compliance details + * Aggregated stats for total deployments storage. */ - resources: PlanChangeResourceCompliance[]; + deploymentsStorageTotal: number; /** - * Failure reason when compliance could not be evaluated. Present only when the project DB or Regions API was unreachable; in that case `isCompliant` is false (fail closed) and `resources` is empty. + * Aggregated stats for total databases storage. */ - error?: string; - } - - /** - * PlanChangeResourceCompliance - */ - export type PlanChangeResourceCompliance = { + databasesStorageTotal: number; /** - * Resource type + * Aggregated stats for total databases reads. */ - type: string; + databasesReadsTotal: number; /** - * Current usage count + * Aggregated stats for total databases writes. */ - currentUsage: number; + databasesWritesTotal: number; /** - * Allowed limit in target plan + * Aggregated stats for total backups storage. */ - limit: number; + backupsStorageTotal: number; /** - * Compliance status + * Aggregated stats for total storage. */ - status: string; + storageTotal: number; /** - * Number of resources exceeding the limit + * Aggregated stats for total auth phone. */ - excess: number; + authPhoneTotal: number; /** - * Suggestion for resolving the compliance issue + * Aggregated stats for total auth phone estimation. */ - resolutionHint: string; - } - - /** - * EstimationDeleteOrganization - */ - export type EstimationDeleteOrganization = { + authPhoneEstimate: number; /** - * List of unpaid invoices + * Aggregated stats for each projects. */ - unpaidInvoices: Invoice[]; - } - - /** - * EstimationItem - */ - export type EstimationItem = { + projects: UsageOrganizationProject[]; /** - * Label + * Aggregated stats for realtime connections. */ - label: string; + realtimeConnections: Metric[]; /** - * Gross payable amount + * Aggregated stats for total realtime connections. */ - value: number; + realtimeConnectionsTotal: number; + /** + * Aggregated stats for realtime messages. + */ + realtimeMessages: Metric[]; + /** + * Aggregated stats for total realtime messages. + */ + realtimeMessagesTotal: number; + /** + * Aggregated stats for realtime bandwidth. + */ + realtimeBandwidth: Metric[]; + /** + * Aggregated stats for total realtime bandwidth. + */ + realtimeBandwidthTotal: number; } /** - * DomainPrice + * OrganizationProject */ - export type DomainPrice = { + export type UsageOrganizationProject = { /** - * Domain name. + * projectId */ - domain: string; + projectId: string; /** - * Top-level domain for the requested domain. + * Aggregated stats for number of requests. */ - tld: string; + bandwidth: Metric[]; /** - * Whether the domain is currently available for registration. + * Aggregated stats for consumed bandwidth. */ - available: boolean; + users: Metric[]; /** - * Domain registration price. + * Aggregated stats for function executions. */ - price: number; + executions: number; /** - * Price period in years. + * Aggregated stats for database reads. */ - periodYears: number; + databasesReads: Metric[]; /** - * Whether the domain is a premium domain. + * Aggregated stats for database writes. */ - premium: boolean; - } - - /** - * DomainSuggestion - */ - export type DomainSuggestion = { + databasesWrites: Metric[]; + /** + * Aggregated stats for function executions in mb seconds. + */ + executionsMBSeconds: number; /** - * Domain suggestion. + * Aggregated stats for function builds in mb seconds. */ - domain: string; + buildsMBSeconds: number; /** - * Is the domain premium? + * Aggregated stats for number of documents. */ - premium: boolean; + storage: number; /** - * Domain price. + * Aggregated stats for phone authentication. */ - price?: number; + authPhoneTotal: number; /** - * Is the domain available? + * Aggregated stats for phone authentication estimated cost. */ - available: boolean; - } - - /** - * Addon - */ - export type Addon = { + authPhoneEstimate: number; /** - * Addon ID. + * Aggregated stats for total databases reads. */ - $id: string; + databasesReadsTotal: number; /** - * Addon creation time in ISO 8601 format. + * Aggregated stats for total databases writes. */ - $createdAt: string; + databasesWritesTotal: number; /** - * Addon update date in ISO 8601 format. + * Aggregated stats for file transformations. */ - $updatedAt: string; + imageTransformations: Metric[]; /** - * Addon permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * Aggregated stats for total file transformations. */ - $permissions: string[]; + imageTransformationsTotal: number; /** - * Addon key + * Aggregated stats for file transformations. */ - key: string; + screenshotsGenerated: Metric[]; /** - * Resource type (organization or project) + * Aggregated stats for total file transformations. */ - resourceType: string; + screenshotsGeneratedTotal: number; /** - * Resource ID + * Aggregated stats for imagine credits. */ - resourceId: string; + imagineCredits: number; /** - * Payment status. Possible values: pending (awaiting payment confirmation e.g. 3DS), active (payment confirmed and addon is running). + * Aggregated stats for realtime connections. */ - status: string; + realtimeConnections: number; /** - * Current value for this billing cycle. For toggle addons: 1 (on) or 0 (off). For numeric addons: the active quantity. + * Aggregated stats for realtime messages. */ - currentValue: number; + realtimeMessages: number; /** - * Value to apply at the start of the next billing cycle. Null means no change is scheduled. For toggle addons, 0 means the addon will be removed at the next cycle. + * Aggregated stats for realtime bandwidth. */ - nextValue?: number; + realtimeBandwidth: number; } /** - * AddonPrice + * Resource */ - export type AddonPrice = { - /** - * Addon key. - */ - addonKey: string; + export type UsageResources = { /** - * Addon display name. + * Invoice name */ name: string; /** - * Full monthly price of the addon. - */ - monthlyPrice: number; - /** - * Calculated prorated amount for the current billing cycle. - */ - proratedAmount: number; - /** - * Days remaining in the current billing cycle. + * Invoice value */ - remainingDays: number; + value: number; /** - * Total days in the billing cycle. + * Invoice amount */ - totalCycleDays: number; + amount: number; /** - * Currency code. + * Invoice rate */ - currency: string; + rate: number; /** - * When the current billing cycle ends. + * Invoice description */ - billingCycleEnd: string; - } - - /** - * domainTransferOut - */ - export type DomainTransferOut = { + desc: string; /** - * Domain transfer authorization code. + * Resource ID */ - authCode: string; + resourceId: string; } /** - * domainTransferStatus + * Activity event list */ - export type DomainTransferStatus = { - /** - * Transfer status. - */ - status: DomainTransferStatusEnum; + export type ActivityEventList = { /** - * Additional transfer status information. + * Total number of events that matched your query. */ - reason: string; + total: number; /** - * Transfer status timestamp in ISO 8601 format. + * List of events. */ - timestamp: string; + events: ActivityEvent[]; } /** @@ -11664,20 +11495,6 @@ export namespace Models { addons: Addon[]; } - /** - * Activity event list - */ - export type ActivityEventList = { - /** - * Total number of events that matched your query. - */ - total: number; - /** - * List of events. - */ - events: ActivityEvent[]; - } - /** * Aggregation team list */ @@ -11735,31 +11552,31 @@ export namespace Models { } /** - * Billing invoices list + * Billing address list */ - export type InvoiceList = { + export type BillingAddressList = { /** - * Total number of invoices that matched your query. + * Total number of billingAddresses that matched your query. */ total: number; /** - * List of invoices. + * List of billingAddresses. */ - invoices: Invoice[]; + billingAddresses: BillingAddress[]; } /** - * Billing address list + * Billing invoices list */ - export type BillingAddressList = { + export type InvoiceList = { /** - * Total number of billingAddresses that matched your query. + * Total number of invoices that matched your query. */ total: number; /** - * List of billingAddresses. + * List of invoices. */ - billingAddresses: BillingAddress[]; + invoices: Invoice[]; } /** @@ -11777,100 +11594,128 @@ export namespace Models { } /** - * Organizations list + * Blocks list */ - export type OrganizationList = { + export type BlockList = { /** - * Total number of teams that matched your query. + * Total number of blocks that matched your query. */ total: number; /** - * List of teams. + * List of blocks. */ - teams: Organization[]; + blocks: Block[]; } /** - * Payment methods list + * DNS records list */ - export type PaymentMethodList = { + export type DnsRecordsList = { /** - * Total number of paymentMethods that matched your query. + * Total number of dnsRecords that matched your query. */ total: number; /** - * List of paymentMethods. + * List of dnsRecords. */ - paymentMethods: PaymentMethod[]; + dnsRecords: DnsRecord[]; } /** - * Blocks list + * Domain suggestions list */ - export type BlockList = { + export type DomainSuggestionsList = { /** - * Total number of blocks that matched your query. + * Total number of suggestions that matched your query. */ total: number; /** - * List of blocks. + * List of suggestions. */ - blocks: Block[]; + suggestions: DomainSuggestion[]; } /** - * Regions list + * Domains list */ - export type ConsoleRegionList = { + export type DomainsList = { /** - * Total number of regions that matched your query. + * Total number of domains that matched your query. */ total: number; /** - * List of regions. + * List of domains. */ - regions: ConsoleRegion[]; + domains: Domain[]; } /** - * Domains list + * Organizations list */ - export type DomainsList = { + export type OrganizationList = { /** - * Total number of domains that matched your query. + * Total number of teams that matched your query. */ total: number; /** - * List of domains. + * List of teams. */ - domains: Domain[]; + teams: Organization[]; } /** - * DNS records list + * Payment methods list */ - export type DnsRecordsList = { + export type PaymentMethodList = { /** - * Total number of dnsRecords that matched your query. + * Total number of paymentMethods that matched your query. */ total: number; /** - * List of dnsRecords. + * List of paymentMethods. */ - dnsRecords: DnsRecord[]; + paymentMethods: PaymentMethod[]; } /** - * Domain suggestions list + * Regions list */ - export type DomainSuggestionsList = { + export type ConsoleRegionList = { /** - * Total number of suggestions that matched your query. + * Total number of regions that matched your query. */ total: number; /** - * List of suggestions. + * List of regions. */ - suggestions: DomainSuggestion[]; + regions: ConsoleRegion[]; + } + + /** + * Usage events list + */ + export type UsageEventList = { + /** + * Total number of events that matched your query. + */ + total: number; + /** + * List of events. + */ + events: UsageEvent[]; + } + + /** + * Usage gauges list + */ + export type UsageGaugeList = { + /** + * Total number of gauges that matched your query. + */ + total: number; + /** + * List of gauges. + */ + gauges: UsageGauge[]; } } diff --git a/src/services/account.ts b/src/services/account.ts index e9ef3ae9..b76a97c2 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -2,7 +2,7 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { Scopes } from '../enums/scopes'; +import { AccountKeyScopes } from '../enums/account-key-scopes'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; @@ -889,35 +889,35 @@ export class Account { * Create a new account API key. * * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {AccountKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} */ - createKey(params: { name: string, scopes: Scopes[], expire?: string }): Promise; + createKey(params: { name: string, scopes: AccountKeyScopes[], expire?: string }): Promise; /** * Create a new account API key. * * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {AccountKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createKey(name: string, scopes: Scopes[], expire?: string): Promise; + createKey(name: string, scopes: AccountKeyScopes[], expire?: string): Promise; createKey( - paramsOrFirst: { name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(Scopes[])?, (string)?] + paramsOrFirst: { name: string, scopes: AccountKeyScopes[], expire?: string } | string, + ...rest: [(AccountKeyScopes[])?, (string)?] ): Promise { - let params: { name: string, scopes: Scopes[], expire?: string }; + let params: { name: string, scopes: AccountKeyScopes[], expire?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { name: string, scopes: Scopes[], expire?: string }; + params = (paramsOrFirst || {}) as { name: string, scopes: AccountKeyScopes[], expire?: string }; } else { params = { name: paramsOrFirst as string, - scopes: rest[0] as Scopes[], + scopes: rest[0] as AccountKeyScopes[], expire: rest[1] as string }; } @@ -1014,37 +1014,37 @@ export class Account { * * @param {string} params.keyId - Key unique ID. * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {AccountKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} */ - updateKey(params: { keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; + updateKey(params: { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string }): Promise; /** * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. * * @param {string} keyId - Key unique ID. * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {AccountKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateKey(keyId: string, name: string, scopes: Scopes[], expire?: string): Promise; + updateKey(keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string): Promise; updateKey( - paramsOrFirst: { keyId: string, name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(string)?, (Scopes[])?, (string)?] + paramsOrFirst: { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (AccountKeyScopes[])?, (string)?] ): Promise { - let params: { keyId: string, name: string, scopes: Scopes[], expire?: string }; + let params: { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: Scopes[], expire?: string }; + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: AccountKeyScopes[], expire?: string }; } else { params = { keyId: paramsOrFirst as string, name: rest[0] as string, - scopes: rest[1] as Scopes[], + scopes: rest[1] as AccountKeyScopes[], expire: rest[2] as string }; } diff --git a/src/services/advisor.ts b/src/services/advisor.ts deleted file mode 100644 index ed87a3fa..00000000 --- a/src/services/advisor.ts +++ /dev/null @@ -1,309 +0,0 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; -import type { Models } from '../models'; - - -export class Advisor { - client: Client; - - constructor(client: Client) { - this.client = client; - } - - /** - * Get a list of all the project's analyzer reports. You can use the query params to filter your results. - * - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listReports(params?: { queries?: string[], total?: boolean }): Promise; - /** - * Get a list of all the project's analyzer reports. You can use the query params to filter your results. - * - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt - * @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. - */ - listReports(queries?: string[], total?: boolean): Promise; - listReports( - 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 = '/reports'; - 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 an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. - * - * - * @param {string} params.reportId - Report ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getReport(params: { reportId: string }): Promise; - /** - * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. - * - * - * @param {string} reportId - Report ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getReport(reportId: string): Promise; - getReport( - paramsOrFirst: { reportId: string } | string - ): Promise { - let params: { reportId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string }; - } else { - params = { - reportId: paramsOrFirst as string - }; - } - - const reportId = params.reportId; - - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); - } - - const apiPath = '/reports/{reportId}'.replace('{reportId}', reportId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); - } - - /** - * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. - * - * - * @param {string} params.reportId - Report ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteReport(params: { reportId: string }): Promise<{}>; - /** - * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. - * - * - * @param {string} reportId - Report ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteReport(reportId: string): Promise<{}>; - deleteReport( - paramsOrFirst: { reportId: string } | string - ): Promise<{}> { - let params: { reportId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string }; - } else { - params = { - reportId: paramsOrFirst as string - }; - } - - const reportId = params.reportId; - - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); - } - - const apiPath = '/reports/{reportId}'.replace('{reportId}', reportId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); - } - - /** - * List the insights produced under a single analyzer report. You can use the query params to filter your results further. - * - * - * @param {string} params.reportId - Parent report 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listInsights(params: { reportId: string, queries?: string[], total?: boolean }): Promise; - /** - * List the insights produced under a single analyzer report. You can use the query params to filter your results further. - * - * - * @param {string} reportId - Parent report 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy - * @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. - */ - listInsights(reportId: string, queries?: string[], total?: boolean): Promise; - listInsights( - paramsOrFirst: { reportId: string, queries?: string[], total?: boolean } | string, - ...rest: [(string[])?, (boolean)?] - ): Promise { - let params: { reportId: string, queries?: string[], total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string, queries?: string[], total?: boolean }; - } else { - params = { - reportId: paramsOrFirst as string, - queries: rest[0] as string[], - total: rest[1] as boolean - }; - } - - const reportId = params.reportId; - const queries = params.queries; - const total = params.total; - - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); - } - - const apiPath = '/reports/{reportId}/insights'.replace('{reportId}', reportId); - 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 an insight by its unique ID, scoped to its parent report. - * - * - * @param {string} params.reportId - Parent report ID. - * @param {string} params.insightId - Insight ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getInsight(params: { reportId: string, insightId: string }): Promise; - /** - * Get an insight by its unique ID, scoped to its parent report. - * - * - * @param {string} reportId - Parent report ID. - * @param {string} insightId - Insight ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getInsight(reportId: string, insightId: string): Promise; - getInsight( - paramsOrFirst: { reportId: string, insightId: string } | string, - ...rest: [(string)?] - ): Promise { - let params: { reportId: string, insightId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { reportId: string, insightId: string }; - } else { - params = { - reportId: paramsOrFirst as string, - insightId: rest[0] as string - }; - } - - const reportId = params.reportId; - const insightId = params.insightId; - - if (typeof reportId === 'undefined') { - throw new AppwriteException('Missing required parameter: "reportId"'); - } - if (typeof insightId === 'undefined') { - throw new AppwriteException('Missing required parameter: "insightId"'); - } - - const apiPath = '/reports/{reportId}/insights/{insightId}'.replace('{reportId}', reportId).replace('{insightId}', insightId); - 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 - ); - } -} diff --git a/src/services/avatars.ts b/src/services/avatars.ts index eea5a0f8..48d2215b 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -5,7 +5,7 @@ import type { Models } from '../models'; import { Browser } from '../enums/browser'; import { CreditCard } from '../enums/credit-card'; import { Flag } from '../enums/flag'; -import { Theme } from '../enums/theme'; +import { BrowserTheme } from '../enums/browser-theme'; import { Timezone } from '../enums/timezone'; import { BrowserPermission } from '../enums/browser-permission'; import { ImageFormat } from '../enums/image-format'; @@ -567,7 +567,7 @@ export class Avatars { * @param {number} params.viewportWidth - Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. * @param {number} params.viewportHeight - Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. * @param {number} params.scale - Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. - * @param {Theme} params.theme - Browser theme. Pass "light" or "dark". Defaults to "light". + * @param {BrowserTheme} params.theme - Browser theme. Pass "light" or "dark". Defaults to "light". * @param {string} params.userAgent - Custom user agent string. Defaults to browser default. * @param {boolean} params.fullpage - Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. * @param {string} params.locale - Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. @@ -585,7 +585,7 @@ export class Avatars { * @throws {AppwriteException} * @returns {string} */ - getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): string; + getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): string; /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. * @@ -598,7 +598,7 @@ export class Avatars { * @param {number} viewportWidth - Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. * @param {number} viewportHeight - Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. * @param {number} scale - Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. - * @param {Theme} theme - Browser theme. Pass "light" or "dark". Defaults to "light". + * @param {BrowserTheme} theme - Browser theme. Pass "light" or "dark". Defaults to "light". * @param {string} userAgent - Custom user agent string. Defaults to browser default. * @param {boolean} fullpage - Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0. * @param {string} locale - Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default. @@ -617,15 +617,15 @@ export class Avatars { * @returns {string} * @deprecated Use the object parameter style method for a better developer experience. */ - getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): string; + getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): string; getScreenshot( - paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, - ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] + paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, + ...rest: [(object)?, (number)?, (number)?, (number)?, (BrowserTheme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (BrowserPermission[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] ): string { - let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; + let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; + params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: BrowserTheme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: BrowserPermission[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; } else { params = { url: paramsOrFirst as string, @@ -633,7 +633,7 @@ export class Avatars { viewportWidth: rest[1] as number, viewportHeight: rest[2] as number, scale: rest[3] as number, - theme: rest[4] as Theme, + theme: rest[4] as BrowserTheme, userAgent: rest[5] as string, fullpage: rest[6] as boolean, locale: rest[7] as string, diff --git a/src/services/documents-db.ts b/src/services/documents-db.ts index 9f60777a..052f9ee4 100644 --- a/src/services/documents-db.ts +++ b/src/services/documents-db.ts @@ -17,41 +17,37 @@ export class DocumentsDB { * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { queries?: string[], total?: boolean }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; + list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[], total?: boolean }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; } else { params = { queries: paramsOrFirst as string[], - search: rest[0] as string, - total: rest[1] as boolean + total: rest[0] as boolean }; } const queries = params.queries; - const search = params.search; const total = params.total; @@ -60,9 +56,6 @@ export class DocumentsDB { if (typeof queries !== 'undefined') { payload['queries'] = queries; } - if (typeof search !== 'undefined') { - payload['search'] = search; - } if (typeof total !== 'undefined') { payload['total'] = total; } diff --git a/src/services/domains.ts b/src/services/domains.ts index d364ca02..be74c959 100644 --- a/src/services/domains.ts +++ b/src/services/domains.ts @@ -2,8 +2,8 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { RegistrationType } from '../enums/registration-type'; -import { FilterType } from '../enums/filter-type'; +import { DomainRegistrationType } from '../enums/domain-registration-type'; +import { DomainSuggestionType } from '../enums/domain-suggestion-type'; export class Domains { client: Client; @@ -13,7 +13,7 @@ export class Domains { } /** - * List all domains registered for this project. This endpoint supports pagination. + * List all domains registered for this project. This endpoint supports pagination. * * @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 attributes such as domain name, teamInternalId, expiration, etc. * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. @@ -22,7 +22,7 @@ export class Domains { */ list(params?: { queries?: string[], search?: string }): Promise; /** - * List all domains registered for this project. This endpoint supports pagination. + * List all domains registered for this project. This endpoint supports pagination. * * @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 attributes such as domain name, teamInternalId, expiration, etc. * @param {string} search - Search term to filter your list results. Max length: 256 chars. @@ -72,7 +72,7 @@ export class Domains { } /** - * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. + * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. * * @param {string} params.teamId - Team unique ID. * @param {string} params.domain - Domain name (e.g. "example.com"). @@ -81,7 +81,7 @@ export class Domains { */ create(params: { teamId: string, domain: string }): Promise; /** - * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. + * Create a new domain. Before creating a domain, you need to ensure that your DNS provider is properly configured. After creating the domain, you can use the verification endpoint to check if the domain is ready to be used. * * @param {string} teamId - Team unique ID. * @param {string} domain - Domain name (e.g. "example.com"). @@ -138,39 +138,39 @@ export class Domains { } /** - * Get the registration price for a domain name. + * Get the registration price for a domain name. * * @param {string} params.domain - Domain name to get price for. * @param {number} params.periodYears - Number of years to calculate the domain price for. Must be at least 1. - * @param {RegistrationType} params.registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @param {DomainRegistrationType} params.registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. * @throws {AppwriteException} * @returns {Promise} */ - getPrice(params: { domain: string, periodYears?: number, registrationType?: RegistrationType }): Promise; + getPrice(params: { domain: string, periodYears?: number, registrationType?: DomainRegistrationType }): Promise; /** - * Get the registration price for a domain name. + * Get the registration price for a domain name. * * @param {string} domain - Domain name to get price for. * @param {number} periodYears - Number of years to calculate the domain price for. Must be at least 1. - * @param {RegistrationType} registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + * @param {DomainRegistrationType} registrationType - Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getPrice(domain: string, periodYears?: number, registrationType?: RegistrationType): Promise; + getPrice(domain: string, periodYears?: number, registrationType?: DomainRegistrationType): Promise; getPrice( - paramsOrFirst: { domain: string, periodYears?: number, registrationType?: RegistrationType } | string, - ...rest: [(number)?, (RegistrationType)?] + paramsOrFirst: { domain: string, periodYears?: number, registrationType?: DomainRegistrationType } | string, + ...rest: [(number)?, (DomainRegistrationType)?] ): Promise { - let params: { domain: string, periodYears?: number, registrationType?: RegistrationType }; + let params: { domain: string, periodYears?: number, registrationType?: DomainRegistrationType }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { domain: string, periodYears?: number, registrationType?: RegistrationType }; + params = (paramsOrFirst || {}) as { domain: string, periodYears?: number, registrationType?: DomainRegistrationType }; } else { params = { domain: paramsOrFirst as string, periodYears: rest[0] as number, - registrationType: rest[1] as RegistrationType + registrationType: rest[1] as DomainRegistrationType }; } @@ -207,7 +207,7 @@ export class Domains { } /** - * Initiate a domain purchase by providing registrant details and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Purchase endpoint to capture the payment and finalize the purchase. + * Initiate a domain purchase by providing registrant details and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Purchase endpoint to capture the payment and finalize the purchase. * * @param {string} params.domain - Fully qualified domain name to purchase (for example, example.com). * @param {string} params.organizationId - Team ID that will own the domain. @@ -226,7 +226,7 @@ export class Domains { */ createPurchase(params: { domain: string, organizationId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number, autoRenewal?: boolean }): Promise; /** - * Initiate a domain purchase by providing registrant details and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Purchase endpoint to capture the payment and finalize the purchase. + * Initiate a domain purchase by providing registrant details and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Purchase endpoint to capture the payment and finalize the purchase. * * @param {string} domain - Fully qualified domain name to purchase (for example, example.com). * @param {string} organizationId - Team ID that will own the domain. @@ -361,7 +361,7 @@ export class Domains { } /** - * Finalize a domain purchase initiated with Create Purchase. Verifies that any required 3D Secure authentication is complete, registers the domain, captures the payment, and provisions default DNS records. Returns a 402 error if authentication is still pending. + * Finalize a domain purchase initiated with Create Purchase. Verifies that any required 3D Secure authentication is complete, registers the domain, captures the payment, and provisions default DNS records. Returns a 402 error if authentication is still pending. * * @param {string} params.invoiceId - Invoice ID. * @param {string} params.organizationId - Team ID that owns the domain. @@ -370,7 +370,7 @@ export class Domains { */ updatePurchase(params: { invoiceId: string, organizationId: string }): Promise; /** - * Finalize a domain purchase initiated with Create Purchase. Verifies that any required 3D Secure authentication is complete, registers the domain, captures the payment, and provisions default DNS records. Returns a 402 error if authentication is still pending. + * Finalize a domain purchase initiated with Create Purchase. Verifies that any required 3D Secure authentication is complete, registers the domain, captures the payment, and provisions default DNS records. Returns a 402 error if authentication is still pending. * * @param {string} invoiceId - Invoice ID. * @param {string} organizationId - Team ID that owns the domain. @@ -424,46 +424,46 @@ export class Domains { } /** - * List domain suggestions. + * List domain suggestions. * * @param {string} params.query - Query to find available domains and suggestions. Max length: 256 chars. * @param {string[]} params.tlds - TLDs to suggest. * @param {number} params.limit - Maximum number of suggestions to return. - * @param {FilterType} params.filterType - Filter type: premium, suggestion. + * @param {DomainSuggestionType} params.filterType - Filter type: premium, suggestion. * @param {number} params.priceMax - Filter premium domains by maximum price. Only premium domains at or below this price will be returned. Does not affect regular domain suggestions. * @param {number} params.priceMin - Filter premium domains by minimum price. Only premium domains at or above this price will be returned. Does not affect regular domain suggestions. * @throws {AppwriteException} * @returns {Promise} */ - listSuggestions(params: { query: string, tlds?: string[], limit?: number, filterType?: FilterType, priceMax?: number, priceMin?: number }): Promise; + listSuggestions(params: { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number }): Promise; /** - * List domain suggestions. + * List domain suggestions. * * @param {string} query - Query to find available domains and suggestions. Max length: 256 chars. * @param {string[]} tlds - TLDs to suggest. * @param {number} limit - Maximum number of suggestions to return. - * @param {FilterType} filterType - Filter type: premium, suggestion. + * @param {DomainSuggestionType} filterType - Filter type: premium, suggestion. * @param {number} priceMax - Filter premium domains by maximum price. Only premium domains at or below this price will be returned. Does not affect regular domain suggestions. * @param {number} priceMin - Filter premium domains by minimum price. Only premium domains at or above this price will be returned. Does not affect regular domain suggestions. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listSuggestions(query: string, tlds?: string[], limit?: number, filterType?: FilterType, priceMax?: number, priceMin?: number): Promise; + listSuggestions(query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number): Promise; listSuggestions( - paramsOrFirst: { query: string, tlds?: string[], limit?: number, filterType?: FilterType, priceMax?: number, priceMin?: number } | string, - ...rest: [(string[])?, (number)?, (FilterType)?, (number)?, (number)?] + paramsOrFirst: { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number } | string, + ...rest: [(string[])?, (number)?, (DomainSuggestionType)?, (number)?, (number)?] ): Promise { - let params: { query: string, tlds?: string[], limit?: number, filterType?: FilterType, priceMax?: number, priceMin?: number }; + let params: { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { query: string, tlds?: string[], limit?: number, filterType?: FilterType, priceMax?: number, priceMin?: number }; + params = (paramsOrFirst || {}) as { query: string, tlds?: string[], limit?: number, filterType?: DomainSuggestionType, priceMax?: number, priceMin?: number }; } else { params = { query: paramsOrFirst as string, tlds: rest[0] as string[], limit: rest[1] as number, - filterType: rest[2] as FilterType, + filterType: rest[2] as DomainSuggestionType, priceMax: rest[3] as number, priceMin: rest[4] as number }; @@ -514,7 +514,7 @@ export class Domains { } /** - * Initiate a domain transfer-in by providing an authorization code, registrant details, and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Transfer In endpoint to capture the payment and submit the transfer. + * Initiate a domain transfer-in by providing an authorization code, registrant details, and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Transfer In endpoint to capture the payment and submit the transfer. * * @param {string} params.domain - Domain name to transfer in. * @param {string} params.organizationId - Organization ID that this domain will belong to. @@ -526,7 +526,7 @@ export class Domains { */ createTransferIn(params: { domain: string, organizationId: string, authCode: string, paymentMethodId: string, autoRenewal?: boolean }): Promise; /** - * Initiate a domain transfer-in by providing an authorization code, registrant details, and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Transfer In endpoint to capture the payment and submit the transfer. + * Initiate a domain transfer-in by providing an authorization code, registrant details, and a payment method. Authorizes the payment and returns a `clientSecret`. If 3D Secure is required, use the `clientSecret` on the client to complete the authentication challenge. Once authentication is complete (or if none is needed), call the Update Transfer In endpoint to capture the payment and submit the transfer. * * @param {string} domain - Domain name to transfer in. * @param {string} organizationId - Organization ID that this domain will belong to. @@ -607,7 +607,7 @@ export class Domains { } /** - * Finalize a domain transfer-in initiated with Create Transfer In. Verifies that any required 3D Secure authentication is complete, submits the transfer with the authorization code, captures the payment, and sends a confirmation email. Returns a 402 error if authentication is still pending. + * Finalize a domain transfer-in initiated with Create Transfer In. Verifies that any required 3D Secure authentication is complete, submits the transfer with the authorization code, captures the payment, and sends a confirmation email. Returns a 402 error if authentication is still pending. * * @param {string} params.invoiceId - Invoice ID. * @param {string} params.organizationId - Team ID that owns the domain. @@ -616,7 +616,7 @@ export class Domains { */ updateTransferIn(params: { invoiceId: string, organizationId: string }): Promise; /** - * Finalize a domain transfer-in initiated with Create Transfer In. Verifies that any required 3D Secure authentication is complete, submits the transfer with the authorization code, captures the payment, and sends a confirmation email. Returns a 402 error if authentication is still pending. + * Finalize a domain transfer-in initiated with Create Transfer In. Verifies that any required 3D Secure authentication is complete, submits the transfer with the authorization code, captures the payment, and sends a confirmation email. Returns a 402 error if authentication is still pending. * * @param {string} invoiceId - Invoice ID. * @param {string} organizationId - Team ID that owns the domain. @@ -670,7 +670,7 @@ export class Domains { } /** - * Initiate a domain transfer-out by generating an authorization code for the specified domain. The returned `authCode` should be provided to the gaining provider to complete the transfer. If the domain has auto-renewal enabled, it will be automatically disabled as part of this operation. + * Initiate a domain transfer-out by generating an authorization code for the specified domain. The returned `authCode` should be provided to the gaining provider to complete the transfer. If the domain has auto-renewal enabled, it will be automatically disabled as part of this operation. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.organizationId - Organization ID that this domain belongs to. @@ -679,7 +679,7 @@ export class Domains { */ createTransferOut(params: { domainId: string, organizationId: string }): Promise; /** - * Initiate a domain transfer-out by generating an authorization code for the specified domain. The returned `authCode` should be provided to the gaining provider to complete the transfer. If the domain has auto-renewal enabled, it will be automatically disabled as part of this operation. + * Initiate a domain transfer-out by generating an authorization code for the specified domain. The returned `authCode` should be provided to the gaining provider to complete the transfer. If the domain has auto-renewal enabled, it will be automatically disabled as part of this operation. * * @param {string} domainId - Domain unique ID. * @param {string} organizationId - Organization ID that this domain belongs to. @@ -736,7 +736,7 @@ export class Domains { } /** - * Get a domain by its unique ID. + * Get a domain by its unique ID. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -744,7 +744,7 @@ export class Domains { */ get(params: { domainId: string }): Promise; /** - * Get a domain by its unique ID. + * Get a domain by its unique ID. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -841,7 +841,7 @@ export class Domains { } /** - * Enable or disable auto-renewal for a domain. + * Enable or disable auto-renewal for a domain. * * @param {string} params.domainId - Domain unique ID. * @param {boolean} params.autoRenewal - Whether the domain should renew automatically. @@ -850,7 +850,7 @@ export class Domains { */ updateAutoRenewal(params: { domainId: string, autoRenewal: boolean }): Promise; /** - * Enable or disable auto-renewal for a domain. + * Enable or disable auto-renewal for a domain. * * @param {string} domainId - Domain unique ID. * @param {boolean} autoRenewal - Whether the domain should renew automatically. @@ -904,9 +904,9 @@ export class Domains { } /** - * Verify which NS records are used and update the domain accordingly. This will check the domain's - * nameservers and update the domain's status based on whether the nameservers match the expected - * Appwrite nameservers. + * Verify which NS records are used and update the domain accordingly. This will check the domain's + * nameservers and update the domain's status based on whether the nameservers match the expected + * Appwrite nameservers. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -914,9 +914,9 @@ export class Domains { */ updateNameservers(params: { domainId: string }): Promise; /** - * Verify which NS records are used and update the domain accordingly. This will check the domain's - * nameservers and update the domain's status based on whether the nameservers match the expected - * Appwrite nameservers. + * Verify which NS records are used and update the domain accordingly. This will check the domain's + * nameservers and update the domain's status based on whether the nameservers match the expected + * Appwrite nameservers. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -960,7 +960,7 @@ export class Domains { } /** - * List Google Workspace DNS records. + * List Google Workspace DNS records. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -968,7 +968,7 @@ export class Domains { */ getPresetGoogleWorkspace(params: { domainId: string }): Promise; /** - * List Google Workspace DNS records. + * List Google Workspace DNS records. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1011,8 +1011,8 @@ export class Domains { } /** - * Add Google Workspace DNS records to the domain. This will create the required MX records - * for Google Workspace email hosting. + * Add Google Workspace DNS records to the domain. This will create the required MX records + * for Google Workspace email hosting. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1020,8 +1020,8 @@ export class Domains { */ createPresetGoogleWorkspace(params: { domainId: string }): Promise; /** - * Add Google Workspace DNS records to the domain. This will create the required MX records - * for Google Workspace email hosting. + * Add Google Workspace DNS records to the domain. This will create the required MX records + * for Google Workspace email hosting. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1065,7 +1065,7 @@ export class Domains { } /** - * List iCloud DNS records. + * List iCloud DNS records. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1073,7 +1073,7 @@ export class Domains { */ getPresetICloud(params: { domainId: string }): Promise; /** - * List iCloud DNS records. + * List iCloud DNS records. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1116,8 +1116,8 @@ export class Domains { } /** - * Add iCloud DNS records to the domain. This will create the required MX and SPF records - * for using iCloud email services with your domain. + * Add iCloud DNS records to the domain. This will create the required MX and SPF records + * for using iCloud email services with your domain. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1125,8 +1125,8 @@ export class Domains { */ createPresetICloud(params: { domainId: string }): Promise; /** - * Add iCloud DNS records to the domain. This will create the required MX and SPF records - * for using iCloud email services with your domain. + * Add iCloud DNS records to the domain. This will create the required MX and SPF records + * for using iCloud email services with your domain. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1170,7 +1170,7 @@ export class Domains { } /** - * List Mailgun DNS records. + * List Mailgun DNS records. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1178,7 +1178,7 @@ export class Domains { */ getPresetMailgun(params: { domainId: string }): Promise; /** - * List Mailgun DNS records. + * List Mailgun DNS records. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1221,8 +1221,8 @@ export class Domains { } /** - * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records - * for Mailgun in the specified domain. + * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records + * for Mailgun in the specified domain. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1230,8 +1230,8 @@ export class Domains { */ createPresetMailgun(params: { domainId: string }): Promise; /** - * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records - * for Mailgun in the specified domain. + * Add Mailgun DNS records to the domain. This endpoint will create the required DNS records + * for Mailgun in the specified domain. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1275,7 +1275,7 @@ export class Domains { } /** - * List Outlook DNS records. + * List Outlook DNS records. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1283,7 +1283,7 @@ export class Domains { */ getPresetOutlook(params: { domainId: string }): Promise; /** - * List Outlook DNS records. + * List Outlook DNS records. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1326,8 +1326,8 @@ export class Domains { } /** - * Add Outlook DNS records to the domain. This will create the required MX records - * for setting up Outlook email hosting for your domain. + * Add Outlook DNS records to the domain. This will create the required MX records + * for setting up Outlook email hosting for your domain. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1335,8 +1335,8 @@ export class Domains { */ createPresetOutlook(params: { domainId: string }): Promise; /** - * Add Outlook DNS records to the domain. This will create the required MX records - * for setting up Outlook email hosting for your domain. + * Add Outlook DNS records to the domain. This will create the required MX records + * for setting up Outlook email hosting for your domain. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1380,7 +1380,7 @@ export class Domains { } /** - * List ProtonMail DNS records. + * List ProtonMail DNS records. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1388,7 +1388,7 @@ export class Domains { */ getPresetProtonMail(params: { domainId: string }): Promise; /** - * List ProtonMail DNS records. + * List ProtonMail DNS records. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1431,8 +1431,8 @@ export class Domains { } /** - * Add ProtonMail DNS records to the domain. This will create the required MX records - * for using ProtonMail with your custom domain. + * Add ProtonMail DNS records to the domain. This will create the required MX records + * for using ProtonMail with your custom domain. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1440,8 +1440,8 @@ export class Domains { */ createPresetProtonMail(params: { domainId: string }): Promise; /** - * Add ProtonMail DNS records to the domain. This will create the required MX records - * for using ProtonMail with your custom domain. + * Add ProtonMail DNS records to the domain. This will create the required MX records + * for using ProtonMail with your custom domain. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1485,7 +1485,7 @@ export class Domains { } /** - * List Zoho DNS records. + * List Zoho DNS records. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1493,7 +1493,7 @@ export class Domains { */ getPresetZoho(params: { domainId: string }): Promise; /** - * List Zoho DNS records. + * List Zoho DNS records. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1536,8 +1536,8 @@ export class Domains { } /** - * Add Zoho Mail DNS records to the domain. This will create the required MX records - * for setting up Zoho Mail on your domain. + * Add Zoho Mail DNS records to the domain. This will create the required MX records + * for setting up Zoho Mail on your domain. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -1545,8 +1545,8 @@ export class Domains { */ createPresetZoho(params: { domainId: string }): Promise; /** - * Add Zoho Mail DNS records to the domain. This will create the required MX records - * for setting up Zoho Mail on your domain. + * Add Zoho Mail DNS records to the domain. This will create the required MX records + * for setting up Zoho Mail on your domain. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -1590,8 +1590,8 @@ export class Domains { } /** - * List DNS records for a given domain. You can use this endpoint to list all the DNS records - * associated with your domain. + * List DNS records for a given domain. You can use this endpoint to list all the DNS records + * associated with your domain. * * @param {string} params.domainId - Domain unique ID. * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. You may filter on attributes such as type, name, value, etc. Maximum of 100 queries are allowed, each 4096 characters long. @@ -1600,8 +1600,8 @@ export class Domains { */ listRecords(params: { domainId: string, queries?: string[] }): Promise; /** - * List DNS records for a given domain. You can use this endpoint to list all the DNS records - * associated with your domain. + * List DNS records for a given domain. You can use this endpoint to list all the DNS records + * associated with your domain. * * @param {string} domainId - Domain unique ID. * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. You may filter on attributes such as type, name, value, etc. Maximum of 100 queries are allowed, each 4096 characters long. @@ -1743,9 +1743,9 @@ export class Domains { } /** - * Update an existing A record for the given domain. This endpoint allows you to modify - * the properties of an A record including its name (subdomain), IPv4 address, TTL, - * and optional comment. + * Update an existing A record for the given domain. This endpoint allows you to modify + * the properties of an A record including its name (subdomain), IPv4 address, TTL, + * and optional comment. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -1758,9 +1758,9 @@ export class Domains { */ updateRecordA(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing A record for the given domain. This endpoint allows you to modify - * the properties of an A record including its name (subdomain), IPv4 address, TTL, - * and optional comment. + * Update an existing A record for the given domain. This endpoint allows you to modify + * the properties of an A record including its name (subdomain), IPv4 address, TTL, + * and optional comment. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -1844,8 +1844,8 @@ export class Domains { } /** - * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record - * to your domain. The record will be used to point a hostname to an IPv6 address. + * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record + * to your domain. The record will be used to point a hostname to an IPv6 address. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). @@ -1857,8 +1857,8 @@ export class Domains { */ createRecordAAAA(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record - * to your domain. The record will be used to point a hostname to an IPv6 address. + * Create a new AAAA record for the given domain. This endpoint allows you to add a new IPv6 DNS record + * to your domain. The record will be used to point a hostname to an IPv6 address. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). @@ -1936,9 +1936,9 @@ export class Domains { } /** - * Update an existing AAAA record for the given domain. This endpoint allows you to modify - * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, - * TTL, and optional comment. + * Update an existing AAAA record for the given domain. This endpoint allows you to modify + * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, + * TTL, and optional comment. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -1951,9 +1951,9 @@ export class Domains { */ updateRecordAAAA(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing AAAA record for the given domain. This endpoint allows you to modify - * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, - * TTL, and optional comment. + * Update an existing AAAA record for the given domain. This endpoint allows you to modify + * the properties of an existing AAAA record, including its name (subdomain), IPv6 address, + * TTL, and optional comment. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -2037,9 +2037,9 @@ export class Domains { } /** - * Create a new ALIAS record for the given domain. This record type can be used to point your domain - * to another domain name that will serve as an alias. This is particularly useful when you want to - * map your domain to a target domain that may change its IP address. + * Create a new ALIAS record for the given domain. This record type can be used to point your domain + * to another domain name that will serve as an alias. This is particularly useful when you want to + * map your domain to a target domain that may change its IP address. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name. @@ -2051,9 +2051,9 @@ export class Domains { */ createRecordAlias(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Create a new ALIAS record for the given domain. This record type can be used to point your domain - * to another domain name that will serve as an alias. This is particularly useful when you want to - * map your domain to a target domain that may change its IP address. + * Create a new ALIAS record for the given domain. This record type can be used to point your domain + * to another domain name that will serve as an alias. This is particularly useful when you want to + * map your domain to a target domain that may change its IP address. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name. @@ -2131,11 +2131,11 @@ export class Domains { } /** - * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify - * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. + * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify + * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. * - * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). - * It provides a way to map one domain name to another. + * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). + * It provides a way to map one domain name to another. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -2148,11 +2148,11 @@ export class Domains { */ updateRecordAlias(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify - * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. + * Update an existing ALIAS record for the specified domain. This endpoint allows you to modify + * the properties of an existing ALIAS record including its name, target domain, TTL, and comment. * - * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). - * It provides a way to map one domain name to another. + * The ALIAS record type is similar to a CNAME record but can be used at the zone apex (root domain). + * It provides a way to map one domain name to another. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -2328,9 +2328,9 @@ export class Domains { } /** - * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) - * record is used to specify which certificate authorities (CAs) are authorized to issue certificates - * for a domain. + * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) + * record is used to specify which certificate authorities (CAs) are authorized to issue certificates + * for a domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -2343,9 +2343,9 @@ export class Domains { */ updateRecordCAA(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) - * record is used to specify which certificate authorities (CAs) are authorized to issue certificates - * for a domain. + * Update an existing CAA record for the given domain. A CAA (Certification Authority Authorization) + * record is used to specify which certificate authorities (CAs) are authorized to issue certificates + * for a domain. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -2429,11 +2429,11 @@ export class Domains { } /** - * Create a new CNAME record for the given domain. + * Create a new CNAME record for the given domain. * - * A CNAME record maps a subdomain to another domain name, allowing you to create aliases - * for your domain. For example, you can create a CNAME record to point 'blog.example.com' - * to 'example.wordpress.com'. + * A CNAME record maps a subdomain to another domain name, allowing you to create aliases + * for your domain. For example, you can create a CNAME record to point 'blog.example.com' + * to 'example.wordpress.com'. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). @@ -2445,11 +2445,11 @@ export class Domains { */ createRecordCNAME(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Create a new CNAME record for the given domain. + * Create a new CNAME record for the given domain. * - * A CNAME record maps a subdomain to another domain name, allowing you to create aliases - * for your domain. For example, you can create a CNAME record to point 'blog.example.com' - * to 'example.wordpress.com'. + * A CNAME record maps a subdomain to another domain name, allowing you to create aliases + * for your domain. For example, you can create a CNAME record to point 'blog.example.com' + * to 'example.wordpress.com'. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). @@ -2527,7 +2527,7 @@ export class Domains { } /** - * Update an existing CNAME record for the given domain. + * Update an existing CNAME record for the given domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -2540,7 +2540,7 @@ export class Domains { */ updateRecordCNAME(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing CNAME record for the given domain. + * Update an existing CNAME record for the given domain. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -2624,8 +2624,8 @@ export class Domains { } /** - * Create a new HTTPS record for the given domain. This record is used to configure HTTPS - * settings for your domain, enabling secure communication over SSL/TLS. + * Create a new HTTPS record for the given domain. This record is used to configure HTTPS + * settings for your domain, enabling secure communication over SSL/TLS. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). @@ -2637,8 +2637,8 @@ export class Domains { */ createRecordHTTPS(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Create a new HTTPS record for the given domain. This record is used to configure HTTPS - * settings for your domain, enabling secure communication over SSL/TLS. + * Create a new HTTPS record for the given domain. This record is used to configure HTTPS + * settings for your domain, enabling secure communication over SSL/TLS. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). @@ -2817,10 +2817,10 @@ export class Domains { } /** - * Create a new MX record for the given domain. MX records are used to define the mail servers responsible - * for accepting email messages for the domain. Multiple MX records can be created with different priorities. - * The priority parameter determines the order in which mail servers are used, with lower values indicating - * higher priority. + * Create a new MX record for the given domain. MX records are used to define the mail servers responsible + * for accepting email messages for the domain. Multiple MX records can be created with different priorities. + * The priority parameter determines the order in which mail servers are used, with lower values indicating + * higher priority. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). @@ -2833,10 +2833,10 @@ export class Domains { */ createRecordMX(params: { domainId: string, name: string, value: string, ttl: number, priority: number, comment?: string }): Promise; /** - * Create a new MX record for the given domain. MX records are used to define the mail servers responsible - * for accepting email messages for the domain. Multiple MX records can be created with different priorities. - * The priority parameter determines the order in which mail servers are used, with lower values indicating - * higher priority. + * Create a new MX record for the given domain. MX records are used to define the mail servers responsible + * for accepting email messages for the domain. Multiple MX records can be created with different priorities. + * The priority parameter determines the order in which mail servers are used, with lower values indicating + * higher priority. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). @@ -2923,7 +2923,7 @@ export class Domains { } /** - * Update an existing MX record for the given domain. + * Update an existing MX record for the given domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -2937,7 +2937,7 @@ export class Domains { */ updateRecordMX(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, comment?: string }): Promise; /** - * Update an existing MX record for the given domain. + * Update an existing MX record for the given domain. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -3030,8 +3030,8 @@ export class Domains { } /** - * Create a new NS record for the given domain. NS records specify the nameservers that are used - * to resolve the domain name to IP addresses. Each domain can have multiple NS records. + * Create a new NS record for the given domain. NS records specify the nameservers that are used + * to resolve the domain name to IP addresses. Each domain can have multiple NS records. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain). @@ -3043,8 +3043,8 @@ export class Domains { */ createRecordNS(params: { domainId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Create a new NS record for the given domain. NS records specify the nameservers that are used - * to resolve the domain name to IP addresses. Each domain can have multiple NS records. + * Create a new NS record for the given domain. NS records specify the nameservers that are used + * to resolve the domain name to IP addresses. Each domain can have multiple NS records. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain). @@ -3122,10 +3122,10 @@ export class Domains { } /** - * Update an existing NS record for the given domain. This endpoint allows you to modify - * the properties of an NS (nameserver) record associated with your domain. You can update - * the record name (subdomain), target nameserver value, TTL, and add or modify comments - * for better record management. + * Update an existing NS record for the given domain. This endpoint allows you to modify + * the properties of an NS (nameserver) record associated with your domain. You can update + * the record name (subdomain), target nameserver value, TTL, and add or modify comments + * for better record management. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -3138,10 +3138,10 @@ export class Domains { */ updateRecordNS(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing NS record for the given domain. This endpoint allows you to modify - * the properties of an NS (nameserver) record associated with your domain. You can update - * the record name (subdomain), target nameserver value, TTL, and add or modify comments - * for better record management. + * Update an existing NS record for the given domain. This endpoint allows you to modify + * the properties of an NS (nameserver) record associated with your domain. You can update + * the record name (subdomain), target nameserver value, TTL, and add or modify comments + * for better record management. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -3225,9 +3225,9 @@ export class Domains { } /** - * Create a new SRV record for the given domain. SRV records are used to define the location - * of servers for specific services. For example, they can be used to specify which server - * handles a specific service like SIP or XMPP for the domain. + * Create a new SRV record for the given domain. SRV records are used to define the location + * of servers for specific services. For example, they can be used to specify which server + * handles a specific service like SIP or XMPP for the domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (service name). @@ -3242,9 +3242,9 @@ export class Domains { */ createRecordSRV(params: { domainId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }): Promise; /** - * Create a new SRV record for the given domain. SRV records are used to define the location - * of servers for specific services. For example, they can be used to specify which server - * handles a specific service like SIP or XMPP for the domain. + * Create a new SRV record for the given domain. SRV records are used to define the location + * of servers for specific services. For example, they can be used to specify which server + * handles a specific service like SIP or XMPP for the domain. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (service name). @@ -3349,20 +3349,20 @@ export class Domains { } /** - * Update an existing SRV record for the given domain. + * Update an existing SRV record for the given domain. * - * Required parameters: - * - domainId: Domain unique ID - * - recordId: DNS record unique ID - * - name: Record name (service name) - * - value: Target hostname for this SRV record - * - ttl: Time to live, in seconds - * - priority: Record priority - * - weight: Record weight - * - port: Port number for the service + * Required parameters: + * - domainId: Domain unique ID + * - recordId: DNS record unique ID + * - name: Record name (service name) + * - value: Target hostname for this SRV record + * - ttl: Time to live, in seconds + * - priority: Record priority + * - weight: Record weight + * - port: Port number for the service * - * Optional parameters: - * - comment: A comment for this record + * Optional parameters: + * - comment: A comment for this record * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -3378,20 +3378,20 @@ export class Domains { */ updateRecordSRV(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, priority: number, weight: number, port: number, comment?: string }): Promise; /** - * Update an existing SRV record for the given domain. + * Update an existing SRV record for the given domain. * - * Required parameters: - * - domainId: Domain unique ID - * - recordId: DNS record unique ID - * - name: Record name (service name) - * - value: Target hostname for this SRV record - * - ttl: Time to live, in seconds - * - priority: Record priority - * - weight: Record weight - * - port: Port number for the service + * Required parameters: + * - domainId: Domain unique ID + * - recordId: DNS record unique ID + * - name: Record name (service name) + * - value: Target hostname for this SRV record + * - ttl: Time to live, in seconds + * - priority: Record priority + * - weight: Record weight + * - port: Port number for the service * - * Optional parameters: - * - comment: A comment for this record + * Optional parameters: + * - comment: A comment for this record * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -3502,9 +3502,9 @@ export class Domains { } /** - * Create a new TXT record for the given domain. TXT records can be used - * to provide additional information about your domain, such as domain - * verification records, SPF records, or DKIM records. + * Create a new TXT record for the given domain. TXT records can be used + * to provide additional information about your domain, such as domain + * verification records, SPF records, or DKIM records. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.name - Record name (subdomain) for the TXT record. @@ -3516,9 +3516,9 @@ export class Domains { */ createRecordTXT(params: { domainId: string, name: string, ttl: number, value?: string, comment?: string }): Promise; /** - * Create a new TXT record for the given domain. TXT records can be used - * to provide additional information about your domain, such as domain - * verification records, SPF records, or DKIM records. + * Create a new TXT record for the given domain. TXT records can be used + * to provide additional information about your domain, such as domain + * verification records, SPF records, or DKIM records. * * @param {string} domainId - Domain unique ID. * @param {string} name - Record name (subdomain) for the TXT record. @@ -3593,10 +3593,10 @@ export class Domains { } /** - * Update an existing TXT record for the given domain. + * Update an existing TXT record for the given domain. * - * Update the TXT record details for a specific domain by providing the domain ID, - * record ID, and the new record configuration including name, value, TTL, and an optional comment. + * Update the TXT record details for a specific domain by providing the domain ID, + * record ID, and the new record configuration including name, value, TTL, and an optional comment. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -3609,10 +3609,10 @@ export class Domains { */ updateRecordTXT(params: { domainId: string, recordId: string, name: string, value: string, ttl: number, comment?: string }): Promise; /** - * Update an existing TXT record for the given domain. + * Update an existing TXT record for the given domain. * - * Update the TXT record details for a specific domain by providing the domain ID, - * record ID, and the new record configuration including name, value, TTL, and an optional comment. + * Update the TXT record details for a specific domain by providing the domain ID, + * record ID, and the new record configuration including name, value, TTL, and an optional comment. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -3696,11 +3696,11 @@ export class Domains { } /** - * Get a single DNS record for a given domain by record ID. + * Get a single DNS record for a given domain by record ID. * - * This endpoint allows you to retrieve a specific DNS record associated with a domain - * using its unique identifier. The record contains information about the DNS configuration - * such as type, value, and TTL settings. + * This endpoint allows you to retrieve a specific DNS record associated with a domain + * using its unique identifier. The record contains information about the DNS configuration + * such as type, value, and TTL settings. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -3709,11 +3709,11 @@ export class Domains { */ getRecord(params: { domainId: string, recordId: string }): Promise; /** - * Get a single DNS record for a given domain by record ID. + * Get a single DNS record for a given domain by record ID. * - * This endpoint allows you to retrieve a specific DNS record associated with a domain - * using its unique identifier. The record contains information about the DNS configuration - * such as type, value, and TTL settings. + * This endpoint allows you to retrieve a specific DNS record associated with a domain + * using its unique identifier. The record contains information about the DNS configuration + * such as type, value, and TTL settings. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -3763,8 +3763,8 @@ export class Domains { } /** - * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record - * from a specific domain. + * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record + * from a specific domain. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.recordId - DNS record unique ID. @@ -3773,8 +3773,8 @@ export class Domains { */ deleteRecord(params: { domainId: string, recordId: string }): Promise<{}>; /** - * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record - * from a specific domain. + * Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record + * from a specific domain. * * @param {string} domainId - Domain unique ID. * @param {string} recordId - DNS record unique ID. @@ -3825,10 +3825,10 @@ export class Domains { } /** - * Update the team ID for a specific domain. This endpoint requires admin access. + * Update the team ID for a specific domain. This endpoint requires admin access. * - * Updating the team ID will transfer ownership and access control of the domain - * and all its DNS records to the new team. + * Updating the team ID will transfer ownership and access control of the domain + * and all its DNS records to the new team. * * @param {string} params.domainId - Domain unique ID. * @param {string} params.teamId - New team unique ID. @@ -3837,10 +3837,10 @@ export class Domains { */ updateTeam(params: { domainId: string, teamId: string }): Promise; /** - * Update the team ID for a specific domain. This endpoint requires admin access. + * Update the team ID for a specific domain. This endpoint requires admin access. * - * Updating the team ID will transfer ownership and access control of the domain - * and all its DNS records to the new team. + * Updating the team ID will transfer ownership and access control of the domain + * and all its DNS records to the new team. * * @param {string} domainId - Domain unique ID. * @param {string} teamId - New team unique ID. @@ -3894,7 +3894,7 @@ export class Domains { } /** - * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. + * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -3902,7 +3902,7 @@ export class Domains { */ getTransferStatus(params: { domainId: string }): Promise; /** - * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. + * Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} @@ -3945,8 +3945,8 @@ export class Domains { } /** - * Retrieve the DNS zone file for the given domain. This endpoint will return the DNS - * zone file in a standardized format that can be used to configure DNS servers. + * Retrieve the DNS zone file for the given domain. This endpoint will return the DNS + * zone file in a standardized format that can be used to configure DNS servers. * * @param {string} params.domainId - Domain unique ID. * @throws {AppwriteException} @@ -3954,8 +3954,8 @@ export class Domains { */ getZone(params: { domainId: string }): Promise<{}>; /** - * Retrieve the DNS zone file for the given domain. This endpoint will return the DNS - * zone file in a standardized format that can be used to configure DNS servers. + * Retrieve the DNS zone file for the given domain. This endpoint will return the DNS + * zone file in a standardized format that can be used to configure DNS servers. * * @param {string} domainId - Domain unique ID. * @throws {AppwriteException} diff --git a/src/services/functions.ts b/src/services/functions.ts index 6bef57e6..528372d9 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -2,10 +2,9 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { Runtime } from '../enums/runtime'; -import { Scopes } from '../enums/scopes'; -import { Runtimes } from '../enums/runtimes'; -import { UseCases } from '../enums/use-cases'; +import { FunctionRuntime } from '../enums/function-runtime'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; +import { FunctionTemplateUseCase } from '../enums/function-template-use-case'; import { UsageRange } from '../enums/usage-range'; import { TemplateReferenceType } from '../enums/template-reference-type'; import { VCSReferenceType } from '../enums/vcs-reference-type'; @@ -90,7 +89,7 @@ export class Functions { * * @param {string} params.functionId - Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Function name. Max length: 128 chars. - * @param {Runtime} params.runtime - Execution runtime. + * @param {FunctionRuntime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {string} params.schedule - Schedule CRON syntax. @@ -99,25 +98,27 @@ export class Functions { * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. * @param {string} params.entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". * @param {string} params.commands - Build Commands. - * @param {Scopes[]} params.scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function. * @param {string} params.providerBranch - Production branch for the repo linked to the function. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. + * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + create(params: { functionId: string, name: string, runtime: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. * * @param {string} functionId - Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Function name. Max length: 128 chars. - * @param {Runtime} runtime - Execution runtime. + * @param {FunctionRuntime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {string} schedule - Schedule CRON syntax. @@ -126,12 +127,14 @@ export class Functions { * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. * @param {string} entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". * @param {string} commands - Build Commands. - * @param {Scopes[]} scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. * @param {string} providerRepositoryId - Repository ID of the repo linked to the function. * @param {string} providerBranch - Production branch for the repo linked to the function. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. + * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. @@ -139,20 +142,20 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; + create(functionId: string, name: string, runtime: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + paramsOrFirst: { functionId: string, name: string, runtime: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (FunctionRuntime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (ProjectKeyScopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] ): Promise { - let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { functionId: string, name: string, runtime: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { functionId: paramsOrFirst as string, name: rest[0] as string, - runtime: rest[1] as Runtime, + runtime: rest[1] as FunctionRuntime, execute: rest[2] as string[], events: rest[3] as string[], schedule: rest[4] as string, @@ -161,15 +164,17 @@ export class Functions { logging: rest[7] as boolean, entrypoint: rest[8] as string, commands: rest[9] as string, - scopes: rest[10] as Scopes[], + scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, providerRepositoryId: rest[12] as string, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - buildSpecification: rest[16] as string, - runtimeSpecification: rest[17] as string, - deploymentRetention: rest[18] as number + providerBranches: rest[16] as string[], + providerPaths: rest[17] as string[], + buildSpecification: rest[18] as string, + runtimeSpecification: rest[19] as string, + deploymentRetention: rest[20] as number }; } @@ -190,6 +195,8 @@ export class Functions { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; + const providerBranches = params.providerBranches; + const providerPaths = params.providerPaths; const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; @@ -257,6 +264,12 @@ export class Functions { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } + if (typeof providerBranches !== 'undefined') { + payload['providerBranches'] = providerBranches; + } + if (typeof providerPaths !== 'undefined') { + payload['providerPaths'] = providerPaths; + } if (typeof buildSpecification !== 'undefined') { payload['buildSpecification'] = buildSpecification; } @@ -329,20 +342,20 @@ export class Functions { /** * List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. * - * @param {Runtimes[]} params.runtimes - List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed. - * @param {UseCases[]} params.useCases - List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed. + * @param {FunctionRuntime[]} params.runtimes - List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed. + * @param {FunctionTemplateUseCase[]} params.useCases - List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed. * @param {number} params.limit - Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000. * @param {number} params.offset - Offset the list of returned templates. Maximum offset is 5000. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - listTemplates(params?: { runtimes?: Runtimes[], useCases?: UseCases[], limit?: number, offset?: number, total?: boolean }): Promise; + listTemplates(params?: { runtimes?: FunctionRuntime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean }): Promise; /** * List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. * - * @param {Runtimes[]} runtimes - List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed. - * @param {UseCases[]} useCases - List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed. + * @param {FunctionRuntime[]} runtimes - List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed. + * @param {FunctionTemplateUseCase[]} useCases - List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed. * @param {number} limit - Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000. * @param {number} offset - Offset the list of returned templates. Maximum offset is 5000. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. @@ -350,19 +363,19 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTemplates(runtimes?: Runtimes[], useCases?: UseCases[], limit?: number, offset?: number, total?: boolean): Promise; + listTemplates(runtimes?: FunctionRuntime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean): Promise; listTemplates( - paramsOrFirst?: { runtimes?: Runtimes[], useCases?: UseCases[], limit?: number, offset?: number, total?: boolean } | Runtimes[], - ...rest: [(UseCases[])?, (number)?, (number)?, (boolean)?] + paramsOrFirst?: { runtimes?: FunctionRuntime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean } | FunctionRuntime[], + ...rest: [(FunctionTemplateUseCase[])?, (number)?, (number)?, (boolean)?] ): Promise { - let params: { runtimes?: Runtimes[], useCases?: UseCases[], limit?: number, offset?: number, total?: boolean }; + let params: { runtimes?: FunctionRuntime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('runtimes' in paramsOrFirst || 'useCases' in paramsOrFirst || 'limit' in paramsOrFirst || 'offset' in paramsOrFirst || 'total' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { runtimes?: Runtimes[], useCases?: UseCases[], limit?: number, offset?: number, total?: boolean }; + params = (paramsOrFirst || {}) as { runtimes?: FunctionRuntime[], useCases?: FunctionTemplateUseCase[], limit?: number, offset?: number, total?: boolean }; } else { params = { - runtimes: paramsOrFirst as Runtimes[], - useCases: rest[0] as UseCases[], + runtimes: paramsOrFirst as FunctionRuntime[], + useCases: rest[0] as FunctionTemplateUseCase[], limit: rest[1] as number, offset: rest[2] as number, total: rest[3] as boolean @@ -564,7 +577,7 @@ export class Functions { * * @param {string} params.functionId - Function ID. * @param {string} params.name - Function name. Max length: 128 chars. - * @param {Runtime} params.runtime - Execution runtime. + * @param {FunctionRuntime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. * @param {string} params.schedule - Schedule CRON syntax. @@ -573,25 +586,27 @@ export class Functions { * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. * @param {string} params.entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". * @param {string} params.commands - Build Commands. - * @param {Scopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function * @param {string} params.providerBranch - Production branch for the repo linked to the function * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to function code in the linked repo. + * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + update(params: { functionId: string, name: string, runtime?: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Update function by its unique ID. * * @param {string} functionId - Function ID. * @param {string} name - Function name. Max length: 128 chars. - * @param {Runtime} runtime - Execution runtime. + * @param {FunctionRuntime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. * @param {string} schedule - Schedule CRON syntax. @@ -600,12 +615,14 @@ export class Functions { * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. * @param {string} entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". * @param {string} commands - Build Commands. - * @param {Scopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {ProjectKeyScopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. * @param {string} providerRepositoryId - Repository ID of the repo linked to the function * @param {string} providerBranch - Production branch for the repo linked to the function * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to function code in the linked repo. + * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. @@ -613,20 +630,20 @@ export class Functions { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; + update(functionId: string, name: string, runtime?: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + paramsOrFirst: { functionId: string, name: string, runtime?: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (FunctionRuntime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (ProjectKeyScopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] ): Promise { - let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { functionId: string, name: string, runtime?: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: FunctionRuntime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: ProjectKeyScopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { functionId: paramsOrFirst as string, name: rest[0] as string, - runtime: rest[1] as Runtime, + runtime: rest[1] as FunctionRuntime, execute: rest[2] as string[], events: rest[3] as string[], schedule: rest[4] as string, @@ -635,15 +652,17 @@ export class Functions { logging: rest[7] as boolean, entrypoint: rest[8] as string, commands: rest[9] as string, - scopes: rest[10] as Scopes[], + scopes: rest[10] as ProjectKeyScopes[], installationId: rest[11] as string, providerRepositoryId: rest[12] as string, providerBranch: rest[13] as string, providerSilentMode: rest[14] as boolean, providerRootDirectory: rest[15] as string, - buildSpecification: rest[16] as string, - runtimeSpecification: rest[17] as string, - deploymentRetention: rest[18] as number + providerBranches: rest[16] as string[], + providerPaths: rest[17] as string[], + buildSpecification: rest[18] as string, + runtimeSpecification: rest[19] as string, + deploymentRetention: rest[20] as number }; } @@ -664,6 +683,8 @@ export class Functions { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; + const providerBranches = params.providerBranches; + const providerPaths = params.providerPaths; const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; @@ -725,6 +746,12 @@ export class Functions { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } + if (typeof providerBranches !== 'undefined') { + payload['providerBranches'] = providerBranches; + } + if (typeof providerPaths !== 'undefined') { + payload['providerPaths'] = providerPaths; + } if (typeof buildSpecification !== 'undefined') { payload['buildSpecification'] = buildSpecification; } diff --git a/src/services/health.ts b/src/services/health.ts index 3996c9d2..56ea5d3d 100644 --- a/src/services/health.ts +++ b/src/services/health.ts @@ -2,7 +2,7 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { Name } from '../enums/name'; +import { HealthQueueName } from '../enums/health-queue-name'; export class Health { client: Client; @@ -660,34 +660,34 @@ export class Health { * Returns the amount of failed jobs in a given queue. * * - * @param {Name} params.name - The name of the queue + * @param {HealthQueueName} params.name - The name of the queue * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise} */ - getFailedJobs(params: { name: Name, threshold?: number }): Promise; + getFailedJobs(params: { name: HealthQueueName, threshold?: number }): Promise; /** * Returns the amount of failed jobs in a given queue. * * - * @param {Name} name - The name of the queue + * @param {HealthQueueName} name - The name of the queue * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getFailedJobs(name: Name, threshold?: number): Promise; + getFailedJobs(name: HealthQueueName, threshold?: number): Promise; getFailedJobs( - paramsOrFirst: { name: Name, threshold?: number } | Name, + paramsOrFirst: { name: HealthQueueName, threshold?: number } | HealthQueueName, ...rest: [(number)?] ): Promise { - let params: { name: Name, threshold?: number }; + let params: { name: HealthQueueName, threshold?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('name' in paramsOrFirst || 'threshold' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { name: Name, threshold?: number }; + params = (paramsOrFirst || {}) as { name: HealthQueueName, threshold?: number }; } else { params = { - name: paramsOrFirst as Name, + name: paramsOrFirst as HealthQueueName, threshold: rest[0] as number }; } diff --git a/src/services/manager.ts b/src/services/manager.ts index e4892c0c..a099bafb 100644 --- a/src/services/manager.ts +++ b/src/services/manager.ts @@ -2,7 +2,10 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { ResourceType } from '../enums/resource-type'; +import { BlockResourceType } from '../enums/block-resource-type'; +import { Region } from '../enums/region'; +import { CacheTarget } from '../enums/cache-target'; +import { CacheDatabase } from '../enums/cache-database'; export class Manager { client: Client; @@ -15,19 +18,19 @@ export class Manager { * Creates a new resource block. * * @param {string} params.projectId - Project ID - * @param {ResourceType} params.resourceType - Resource type to block (e.g., projects, functions, databases, storage, etc.) + * @param {BlockResourceType} params.resourceType - Resource type to block (e.g., projects, functions, databases, storage, etc.) * @param {string} params.resourceId - Optional resource ID (if omitted, all resources of this type will be blocked) * @param {string} params.reason - Optional reason why the resource is blocked * @param {string} params.expiredAt - Optional expiration date for the block * @throws {AppwriteException} * @returns {Promise} */ - createBlock(params: { projectId: string, resourceType: ResourceType, resourceId?: string, reason?: string, expiredAt?: string }): Promise; + createBlock(params: { projectId: string, resourceType: BlockResourceType, resourceId?: string, reason?: string, expiredAt?: string }): Promise; /** * Creates a new resource block. * * @param {string} projectId - Project ID - * @param {ResourceType} resourceType - Resource type to block (e.g., projects, functions, databases, storage, etc.) + * @param {BlockResourceType} resourceType - Resource type to block (e.g., projects, functions, databases, storage, etc.) * @param {string} resourceId - Optional resource ID (if omitted, all resources of this type will be blocked) * @param {string} reason - Optional reason why the resource is blocked * @param {string} expiredAt - Optional expiration date for the block @@ -35,19 +38,19 @@ export class Manager { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createBlock(projectId: string, resourceType: ResourceType, resourceId?: string, reason?: string, expiredAt?: string): Promise; + createBlock(projectId: string, resourceType: BlockResourceType, resourceId?: string, reason?: string, expiredAt?: string): Promise; createBlock( - paramsOrFirst: { projectId: string, resourceType: ResourceType, resourceId?: string, reason?: string, expiredAt?: string } | string, - ...rest: [(ResourceType)?, (string)?, (string)?, (string)?] + paramsOrFirst: { projectId: string, resourceType: BlockResourceType, resourceId?: string, reason?: string, expiredAt?: string } | string, + ...rest: [(BlockResourceType)?, (string)?, (string)?, (string)?] ): Promise { - let params: { projectId: string, resourceType: ResourceType, resourceId?: string, reason?: string, expiredAt?: string }; + let params: { projectId: string, resourceType: BlockResourceType, resourceId?: string, reason?: string, expiredAt?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, resourceType: ResourceType, resourceId?: string, reason?: string, expiredAt?: string }; + params = (paramsOrFirst || {}) as { projectId: string, resourceType: BlockResourceType, resourceId?: string, reason?: string, expiredAt?: string }; } else { params = { projectId: paramsOrFirst as string, - resourceType: rest[0] as ResourceType, + resourceType: rest[0] as BlockResourceType, resourceId: rest[1] as string, reason: rest[2] as string, expiredAt: rest[3] as string @@ -102,35 +105,35 @@ export class Manager { * Deletes resource blocks for a project. * * @param {string} params.projectId - Project ID - * @param {ResourceType} params.resourceType - Resource type to unblock + * @param {BlockResourceType} params.resourceType - Resource type to unblock * @param {string} params.resourceId - Optional resource ID (if omitted, all blocks of this type will be removed) * @throws {AppwriteException} * @returns {Promise} */ - deleteBlock(params: { projectId: string, resourceType: ResourceType, resourceId?: string }): Promise; + deleteBlock(params: { projectId: string, resourceType: BlockResourceType, resourceId?: string }): Promise; /** * Deletes resource blocks for a project. * * @param {string} projectId - Project ID - * @param {ResourceType} resourceType - Resource type to unblock + * @param {BlockResourceType} resourceType - Resource type to unblock * @param {string} resourceId - Optional resource ID (if omitted, all blocks of this type will be removed) * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - deleteBlock(projectId: string, resourceType: ResourceType, resourceId?: string): Promise; + deleteBlock(projectId: string, resourceType: BlockResourceType, resourceId?: string): Promise; deleteBlock( - paramsOrFirst: { projectId: string, resourceType: ResourceType, resourceId?: string } | string, - ...rest: [(ResourceType)?, (string)?] + paramsOrFirst: { projectId: string, resourceType: BlockResourceType, resourceId?: string } | string, + ...rest: [(BlockResourceType)?, (string)?] ): Promise { - let params: { projectId: string, resourceType: ResourceType, resourceId?: string }; + let params: { projectId: string, resourceType: BlockResourceType, resourceId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, resourceType: ResourceType, resourceId?: string }; + params = (paramsOrFirst || {}) as { projectId: string, resourceType: BlockResourceType, resourceId?: string }; } else { params = { projectId: paramsOrFirst as string, - resourceType: rest[0] as ResourceType, + resourceType: rest[0] as BlockResourceType, resourceId: rest[1] as string }; } @@ -222,6 +225,101 @@ export class Manager { ); } + /** + * Clears internal cache. + * + * @param {Region} params.region - Target region. + * @param {CacheTarget} params.cache - Cache target. + * @param {boolean} params.all - Clear the entire selected cache target. + * @param {CacheDatabase} params.database - Database cache scope. + * @param {string} params.projectId - Project ID for project or logs database cache. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.documentId - Document ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteCache(params?: { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string }): Promise<{}>; + /** + * Clears internal cache. + * + * @param {Region} region - Target region. + * @param {CacheTarget} cache - Cache target. + * @param {boolean} all - Clear the entire selected cache target. + * @param {CacheDatabase} database - Database cache scope. + * @param {string} projectId - Project ID for project or logs database cache. + * @param {string} collectionId - Collection ID. + * @param {string} documentId - Document ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteCache(region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string): Promise<{}>; + deleteCache( + paramsOrFirst?: { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string } | Region, + ...rest: [(CacheTarget)?, (boolean)?, (CacheDatabase)?, (string)?, (string)?, (string)?] + ): Promise<{}> { + let params: { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('region' in paramsOrFirst || 'cache' in paramsOrFirst || 'all' in paramsOrFirst || 'database' in paramsOrFirst || 'projectId' in paramsOrFirst || 'collectionId' in paramsOrFirst || 'documentId' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { region?: Region, cache?: CacheTarget, all?: boolean, database?: CacheDatabase, projectId?: string, collectionId?: string, documentId?: string }; + } else { + params = { + region: paramsOrFirst as Region, + cache: rest[0] as CacheTarget, + all: rest[1] as boolean, + database: rest[2] as CacheDatabase, + projectId: rest[3] as string, + collectionId: rest[4] as string, + documentId: rest[5] as string + }; + } + + const region = params.region; + const cache = params.cache; + const all = params.all; + const database = params.database; + const projectId = params.projectId; + const collectionId = params.collectionId; + const documentId = params.documentId; + + + const apiPath = '/manager/cache'; + const payload: Payload = {}; + if (typeof region !== 'undefined') { + payload['region'] = region; + } + if (typeof cache !== 'undefined') { + payload['cache'] = cache; + } + if (typeof all !== 'undefined') { + payload['all'] = all; + } + if (typeof database !== 'undefined') { + payload['database'] = database; + } + if (typeof projectId !== 'undefined') { + payload['projectId'] = projectId; + } + if (typeof collectionId !== 'undefined') { + payload['collectionId'] = collectionId; + } + if (typeof documentId !== 'undefined') { + payload['documentId'] = documentId; + } + 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 + ); + } + /** * Updates a console user status using a user ID or email address. * diff --git a/src/services/migrations.ts b/src/services/migrations.ts index 1874744f..6d872766 100644 --- a/src/services/migrations.ts +++ b/src/services/migrations.ts @@ -3,7 +3,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; import { AppwriteMigrationResource } from '../enums/appwrite-migration-resource'; -import { OnDuplicate } from '../enums/on-duplicate'; +import { MigrationOnDuplicate } from '../enums/migration-on-duplicate'; import { FirebaseMigrationResource } from '../enums/firebase-migration-resource'; import { NHostMigrationResource } from '../enums/n-host-migration-resource'; import { SupabaseMigrationResource } from '../enums/supabase-migration-resource'; @@ -88,11 +88,11 @@ export class Migrations { * @param {string} params.endpoint - Source Appwrite endpoint * @param {string} params.projectId - Source Project ID * @param {string} params.apiKey - Source API Key - * @param {OnDuplicate} params.onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. + * @param {MigrationOnDuplicate} params.onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. * @throws {AppwriteException} * @returns {Promise} */ - createAppwriteMigration(params: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate }): Promise; + createAppwriteMigration(params: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: MigrationOnDuplicate }): Promise; /** * Migrate data from another Appwrite project to your current project. This endpoint allows you to migrate resources like databases, collections, documents, users, and files from an existing Appwrite project. * @@ -100,27 +100,27 @@ export class Migrations { * @param {string} endpoint - Source Appwrite endpoint * @param {string} projectId - Source Project ID * @param {string} apiKey - Source API Key - * @param {OnDuplicate} onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. + * @param {MigrationOnDuplicate} onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createAppwriteMigration(resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate): Promise; + createAppwriteMigration(resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: MigrationOnDuplicate): Promise; createAppwriteMigration( - paramsOrFirst: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate } | AppwriteMigrationResource[], - ...rest: [(string)?, (string)?, (string)?, (OnDuplicate)?] + paramsOrFirst: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: MigrationOnDuplicate } | AppwriteMigrationResource[], + ...rest: [(string)?, (string)?, (string)?, (MigrationOnDuplicate)?] ): Promise { - let params: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate }; + let params: { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: MigrationOnDuplicate }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('resources' in paramsOrFirst || 'endpoint' in paramsOrFirst || 'projectId' in paramsOrFirst || 'apiKey' in paramsOrFirst || 'onDuplicate' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: OnDuplicate }; + params = (paramsOrFirst || {}) as { resources: AppwriteMigrationResource[], endpoint: string, projectId: string, apiKey: string, onDuplicate?: MigrationOnDuplicate }; } else { params = { resources: paramsOrFirst as AppwriteMigrationResource[], endpoint: rest[0] as string, projectId: rest[1] as string, apiKey: rest[2] as string, - onDuplicate: rest[3] as OnDuplicate + onDuplicate: rest[3] as MigrationOnDuplicate }; } @@ -381,11 +381,11 @@ export class Migrations { * @param {string} params.fileId - File ID. * @param {string} params.resourceId - Composite ID in the format {databaseId:collectionId}, identifying a collection within a database. * @param {boolean} params.internalFile - Is the file stored in an internal bucket? - * @param {OnDuplicate} params.onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. + * @param {MigrationOnDuplicate} params.onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. * @throws {AppwriteException} * @returns {Promise} */ - createCSVImport(params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }): Promise; + createCSVImport(params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate }): Promise; /** * Import documents from a CSV file into your Appwrite database. This endpoint allows you to import documents from a CSV file uploaded to Appwrite Storage bucket. * @@ -393,27 +393,27 @@ export class Migrations { * @param {string} fileId - File ID. * @param {string} resourceId - Composite ID in the format {databaseId:collectionId}, identifying a collection within a database. * @param {boolean} internalFile - Is the file stored in an internal bucket? - * @param {OnDuplicate} onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. + * @param {MigrationOnDuplicate} onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createCSVImport(bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate): Promise; + createCSVImport(bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate): Promise; createCSVImport( - paramsOrFirst: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate } | string, - ...rest: [(string)?, (string)?, (boolean)?, (OnDuplicate)?] + paramsOrFirst: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate } | string, + ...rest: [(string)?, (string)?, (boolean)?, (MigrationOnDuplicate)?] ): Promise { - let params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; + let params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, resourceId: rest[1] as string, internalFile: rest[2] as boolean, - onDuplicate: rest[3] as OnDuplicate + onDuplicate: rest[3] as MigrationOnDuplicate }; } @@ -692,11 +692,11 @@ export class Migrations { * @param {string} params.fileId - File ID. * @param {string} params.resourceId - Composite ID in the format {databaseId:collectionId}, identifying a collection within a database. * @param {boolean} params.internalFile - Is the file stored in an internal bucket? - * @param {OnDuplicate} params.onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. + * @param {MigrationOnDuplicate} params.onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. * @throws {AppwriteException} * @returns {Promise} */ - createJSONImport(params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }): Promise; + createJSONImport(params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate }): Promise; /** * Import documents from a JSON file into your Appwrite database. This endpoint allows you to import documents from a JSON file uploaded to Appwrite Storage bucket. * @@ -705,27 +705,27 @@ export class Migrations { * @param {string} fileId - File ID. * @param {string} resourceId - Composite ID in the format {databaseId:collectionId}, identifying a collection within a database. * @param {boolean} internalFile - Is the file stored in an internal bucket? - * @param {OnDuplicate} onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. + * @param {MigrationOnDuplicate} onDuplicate - Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createJSONImport(bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate): Promise; + createJSONImport(bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate): Promise; createJSONImport( - paramsOrFirst: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate } | string, - ...rest: [(string)?, (string)?, (boolean)?, (OnDuplicate)?] + paramsOrFirst: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate } | string, + ...rest: [(string)?, (string)?, (boolean)?, (MigrationOnDuplicate)?] ): Promise { - let params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; + let params: { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: OnDuplicate }; + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, resourceId: string, internalFile?: boolean, onDuplicate?: MigrationOnDuplicate }; } else { params = { bucketId: paramsOrFirst as string, fileId: rest[0] as string, resourceId: rest[1] as string, internalFile: rest[2] as boolean, - onDuplicate: rest[3] as OnDuplicate + onDuplicate: rest[3] as MigrationOnDuplicate }; } diff --git a/src/services/organization.ts b/src/services/organization.ts new file mode 100644 index 00000000..e3a26e37 --- /dev/null +++ b/src/services/organization.ts @@ -0,0 +1,644 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { OrganizationKeyScopes } from '../enums/organization-key-scopes'; +import { Region } from '../enums/region'; + +export class Organization { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Get a list of all API keys from the current organization. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listKeys(params?: { queries?: string[], total?: boolean }): Promise; + /** + * Get a list of all API keys from the current organization. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listKeys(queries?: string[], total?: boolean): Promise; + listKeys( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/organization/keys'; + 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 organization API key. + * + * @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. + * @param {OrganizationKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + createKey(params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }): Promise; + /** + * Create a new organization API key. + * + * @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. + * @param {OrganizationKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createKey(keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string): Promise; + createKey( + paramsOrFirst: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (OrganizationKeyScopes[])?, (string)?] + ): Promise { + let params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + } else { + params = { + keyId: paramsOrFirst as string, + name: rest[0] as string, + scopes: rest[1] as OrganizationKeyScopes[], + expire: rest[2] as string + }; + } + + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + + const apiPath = '/organization/keys'; + const payload: Payload = {}; + if (typeof keyId !== 'undefined') { + payload['keyId'] = keyId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + 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. This endpoint returns details about a specific API key in your organization including its scopes. + * + * @param {string} params.keyId - Key unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getKey(params: { keyId: string }): Promise; + /** + * Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. + * + * @param {string} keyId - Key unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getKey(keyId: string): Promise; + getKey( + paramsOrFirst: { keyId: string } | string + ): Promise { + let params: { keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string }; + } else { + params = { + keyId: paramsOrFirst as string + }; + } + + const keyId = params.keyId; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} params.keyId - Key unique ID. + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {OrganizationKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateKey(params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }): Promise; + /** + * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} keyId - Key unique ID. + * @param {string} name - Key name. Max length: 128 chars. + * @param {OrganizationKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateKey(keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string): Promise; + updateKey( + paramsOrFirst: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (OrganizationKeyScopes[])?, (string)?] + ): Promise { + let params: { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: OrganizationKeyScopes[], expire?: string }; + } else { + params = { + keyId: paramsOrFirst as string, + name: rest[0] as string, + scopes: rest[1] as OrganizationKeyScopes[], + expire: rest[2] as string + }; + } + + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + + const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} params.keyId - Key unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteKey(params: { keyId: string }): Promise<{}>; + /** + * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} keyId - Key unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteKey(keyId: string): Promise<{}>; + deleteKey( + paramsOrFirst: { keyId: string } | string + ): Promise<{}> { + let params: { keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string }; + } else { + params = { + keyId: paramsOrFirst as string + }; + } + + const keyId = params.keyId; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/organization/keys/{keyId}'.replace('{keyId}', keyId); + 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 projects. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise} + */ + listProjects(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + /** + * Get a list of all projects. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @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. + */ + listProjects(queries?: string[], search?: string, total?: boolean): Promise; + listProjects( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/organization/projects'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + 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 project. + * + * @param {string} params.projectId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Project name. Max length: 128 chars. + * @param {Region} params.region - Project Region. + * @throws {AppwriteException} + * @returns {Promise} + */ + createProject(params: { projectId: string, name: string, region?: Region }): Promise; + /** + * Create a new project. + * + * @param {string} projectId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Project name. Max length: 128 chars. + * @param {Region} region - Project Region. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createProject(projectId: string, name: string, region?: Region): Promise; + createProject( + paramsOrFirst: { projectId: string, name: string, region?: Region } | string, + ...rest: [(string)?, (Region)?] + ): Promise { + let params: { projectId: string, name: string, region?: Region }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { projectId: string, name: string, region?: Region }; + } else { + params = { + projectId: paramsOrFirst as string, + name: rest[0] as string, + region: rest[1] as Region + }; + } + + const projectId = params.projectId; + const name = params.name; + const region = params.region; + + if (typeof projectId === 'undefined') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/organization/projects'; + const payload: Payload = {}; + if (typeof projectId !== 'undefined') { + payload['projectId'] = projectId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof region !== 'undefined') { + payload['region'] = region; + } + 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 project. + * + * @param {string} params.projectId - Project unique ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + getProject(params: { projectId: string }): Promise; + /** + * Get a project. + * + * @param {string} projectId - Project unique ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getProject(projectId: string): Promise; + getProject( + paramsOrFirst: { projectId: string } | string + ): Promise { + let params: { projectId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { projectId: string }; + } else { + params = { + projectId: paramsOrFirst as string + }; + } + + const projectId = params.projectId; + + if (typeof projectId === 'undefined') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + + const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', projectId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a project by its unique ID. + * + * @param {string} params.projectId - Project unique ID. + * @param {string} params.name - Project name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + updateProject(params: { projectId: string, name: string }): Promise; + /** + * Update a project by its unique ID. + * + * @param {string} projectId - Project unique ID. + * @param {string} name - Project name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateProject(projectId: string, name: string): Promise; + updateProject( + paramsOrFirst: { projectId: string, name: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { projectId: string, name: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { projectId: string, name: string }; + } else { + params = { + projectId: paramsOrFirst as string, + name: rest[0] as string + }; + } + + const projectId = params.projectId; + const name = params.name; + + if (typeof projectId === 'undefined') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', projectId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + 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 project by its unique ID. + * + * @param {string} params.projectId - Project unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteProject(params: { projectId: string }): Promise<{}>; + /** + * Delete a project by its unique ID. + * + * @param {string} projectId - Project unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteProject(projectId: string): Promise<{}>; + deleteProject( + paramsOrFirst: { projectId: string } | string + ): Promise<{}> { + let params: { projectId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { projectId: string }; + } else { + params = { + projectId: paramsOrFirst as string + }; + } + + const projectId = params.projectId; + + if (typeof projectId === 'undefined') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + + const apiPath = '/organization/projects/{projectId}'.replace('{projectId}', projectId); + 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/organizations.ts b/src/services/organizations.ts index 9ed1d233..53b56ddb 100644 --- a/src/services/organizations.ts +++ b/src/services/organizations.ts @@ -3,8 +3,7 @@ import { AppwriteException, Client, type Payload, UploadProgress } from '../clie import type { Models } from '../models'; import { Platform } from '../enums/platform'; -import { Addon } from '../enums/addon'; -import { Scopes } from '../enums/scopes'; +import { OrganizationAddon } from '../enums/organization-addon'; export class Organizations { client: Client; @@ -632,34 +631,34 @@ export class Organizations { * * * @param {string} params.organizationId - Organization ID - * @param {Addon} params.addon - Addon key identifier (e.g. baa). + * @param {OrganizationAddon} params.addon - Addon key identifier (e.g. baa). * @throws {AppwriteException} * @returns {Promise} */ - getAddonPrice(params: { organizationId: string, addon: Addon }): Promise; + getAddonPrice(params: { organizationId: string, addon: OrganizationAddon }): Promise; /** * Get the price details for a billing addon for an organization. * * * @param {string} organizationId - Organization ID - * @param {Addon} addon - Addon key identifier (e.g. baa). + * @param {OrganizationAddon} addon - Addon key identifier (e.g. baa). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAddonPrice(organizationId: string, addon: Addon): Promise; + getAddonPrice(organizationId: string, addon: OrganizationAddon): Promise; getAddonPrice( - paramsOrFirst: { organizationId: string, addon: Addon } | string, - ...rest: [(Addon)?] + paramsOrFirst: { organizationId: string, addon: OrganizationAddon } | string, + ...rest: [(OrganizationAddon)?] ): Promise { - let params: { organizationId: string, addon: Addon }; + let params: { organizationId: string, addon: OrganizationAddon }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, addon: Addon }; + params = (paramsOrFirst || {}) as { organizationId: string, addon: OrganizationAddon }; } else { params = { organizationId: paramsOrFirst as string, - addon: rest[0] as Addon + addon: rest[0] as OrganizationAddon }; } @@ -1951,351 +1950,6 @@ export class Organizations { ); } - /** - * Get a list of all API keys from the current organization. - * - * @param {string} params.organizationId - Organization Unique ID - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - listKeys(params: { organizationId: string, total?: boolean }): Promise; - /** - * Get a list of all API keys from the current organization. - * - * @param {string} organizationId - Organization Unique ID - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - listKeys(organizationId: string, total?: boolean): Promise; - listKeys( - paramsOrFirst: { organizationId: string, total?: boolean } | string, - ...rest: [(boolean)?] - ): Promise { - let params: { organizationId: string, total?: boolean }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, total?: boolean }; - } else { - params = { - organizationId: paramsOrFirst as string, - total: rest[0] as boolean - }; - } - - const organizationId = params.organizationId; - const total = params.total; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - - const apiPath = '/organizations/{organizationId}/keys'.replace('{organizationId}', organizationId); - const payload: Payload = {}; - 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 organization API key. - * - * @param {string} params.organizationId - Organization Unique ID - * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - */ - createKey(params: { organizationId: string, name: string, scopes: Scopes[], expire?: string }): Promise; - /** - * Create a new organization API key. - * - * @param {string} organizationId - Organization Unique ID - * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createKey(organizationId: string, name: string, scopes: Scopes[], expire?: string): Promise; - createKey( - paramsOrFirst: { organizationId: string, name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(string)?, (Scopes[])?, (string)?] - ): Promise { - let params: { organizationId: string, name: string, scopes: Scopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, name: string, scopes: Scopes[], expire?: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - name: rest[0] as string, - scopes: rest[1] as Scopes[], - expire: rest[2] as string - }; - } - - const organizationId = params.organizationId; - const name = params.name; - const scopes = params.scopes; - const expire = params.expire; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof scopes === 'undefined') { - throw new AppwriteException('Missing required parameter: "scopes"'); - } - - const apiPath = '/organizations/{organizationId}/keys'.replace('{organizationId}', organizationId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; - } - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - 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. This endpoint returns details about a specific API key in your organization including it's scopes. - * - * @param {string} params.organizationId - Organization Unique ID - * @param {string} params.keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - */ - getKey(params: { organizationId: string, keyId: string }): Promise; - /** - * Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including it's scopes. - * - * @param {string} organizationId - Organization Unique ID - * @param {string} keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - getKey(organizationId: string, keyId: string): Promise; - getKey( - paramsOrFirst: { organizationId: string, keyId: string } | string, - ...rest: [(string)?] - ): Promise { - let params: { organizationId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, keyId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - keyId: rest[0] as string - }; - } - - const organizationId = params.organizationId; - const keyId = params.keyId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - - const apiPath = '/organizations/{organizationId}/keys/{keyId}'.replace('{organizationId}', organizationId).replace('{keyId}', keyId); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); - } - - /** - * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. - * - * @param {string} params.organizationId - Organization Unique ID - * @param {string} params.keyId - Key unique ID. - * @param {string} params.name - Key name. Max length: 128 chars. - * @param {Scopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - */ - updateKey(params: { organizationId: string, keyId: string, name: string, scopes: Scopes[], expire?: string }): Promise; - /** - * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. - * - * @param {string} organizationId - Organization Unique ID - * @param {string} keyId - Key unique ID. - * @param {string} name - Key name. Max length: 128 chars. - * @param {Scopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. - * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateKey(organizationId: string, keyId: string, name: string, scopes: Scopes[], expire?: string): Promise; - updateKey( - paramsOrFirst: { organizationId: string, keyId: string, name: string, scopes: Scopes[], expire?: string } | string, - ...rest: [(string)?, (string)?, (Scopes[])?, (string)?] - ): Promise { - let params: { organizationId: string, keyId: string, name: string, scopes: Scopes[], expire?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, keyId: string, name: string, scopes: Scopes[], expire?: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - keyId: rest[0] as string, - name: rest[1] as string, - scopes: rest[2] as Scopes[], - expire: rest[3] as string - }; - } - - const organizationId = params.organizationId; - const keyId = params.keyId; - const name = params.name; - const scopes = params.scopes; - const expire = params.expire; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof scopes === 'undefined') { - throw new AppwriteException('Missing required parameter: "scopes"'); - } - - const apiPath = '/organizations/{organizationId}/keys/{keyId}'.replace('{organizationId}', organizationId).replace('{keyId}', keyId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof scopes !== 'undefined') { - payload['scopes'] = scopes; - } - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); - } - - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - * - * @param {string} params.organizationId - Organization Unique ID - * @param {string} params.keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteKey(params: { organizationId: string, keyId: string }): Promise<{}>; - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - * - * @param {string} organizationId - Organization Unique ID - * @param {string} keyId - Key unique ID. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteKey(organizationId: string, keyId: string): Promise<{}>; - deleteKey( - paramsOrFirst: { organizationId: string, keyId: string } | string, - ...rest: [(string)?] - ): Promise<{}> { - let params: { organizationId: string, keyId: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { organizationId: string, keyId: string }; - } else { - params = { - organizationId: paramsOrFirst as string, - keyId: rest[0] as string - }; - } - - const organizationId = params.organizationId; - const keyId = params.keyId; - - if (typeof organizationId === 'undefined') { - throw new AppwriteException('Missing required parameter: "organizationId"'); - } - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - - const apiPath = '/organizations/{organizationId}/keys/{keyId}'.replace('{organizationId}', organizationId).replace('{keyId}', keyId); - 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 - ); - } - /** * Set a organization's default payment method. * diff --git a/src/services/presences.ts b/src/services/presences.ts index 373a2530..a04b036f 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -19,9 +19,9 @@ export class Presences { * @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>} + * @returns {Promise} */ - list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise>; + list(params?: { queries?: string[], total?: boolean, ttl?: number }): Promise; /** * List presence logs. Expired entries are filtered out automatically. * @@ -30,14 +30,14 @@ export class Presences { * @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>} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], total?: boolean, ttl?: number): Promise>; - list( + list(queries?: string[], total?: boolean, ttl?: number): Promise; + list( paramsOrFirst?: { queries?: string[], total?: boolean, ttl?: number } | string[], ...rest: [(boolean)?, (number)?] - ): Promise> { + ): Promise { let params: { queries?: string[], total?: boolean, ttl?: number }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -138,22 +138,22 @@ export class Presences { * * @param {string} params.presenceId - Presence unique ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} */ - get(params: { presenceId: string }): Promise; + get(params: { presenceId: string }): Promise; /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. * * * @param {string} presenceId - Presence unique ID. * @throws {AppwriteException} - * @returns {Promise} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - get(presenceId: string): Promise; - get( + get(presenceId: string): Promise; + get( paramsOrFirst: { presenceId: string } | string - ): Promise { + ): Promise { let params: { presenceId: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -190,51 +190,47 @@ export class Presences { * * * @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} + * @returns {Promise} */ - upsert(params: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; + upsert(params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise; /** * Create or update a presence log by its user 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} + * @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 }; + upsert(presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise; + upsert( + paramsOrFirst: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, + ...rest: [(string)?, (string[])?, (string)?, (object)?] + ): Promise { + let params: { presenceId: 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 }; + params = (paramsOrFirst || {}) as { presenceId: 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 + status: rest[0] as string, + permissions: rest[1] as string[], + expiresAt: rest[2] as string, + metadata: rest[3] as object }; } const presenceId = params.presenceId; - const userId = params.userId; const status = params.status; const permissions = params.permissions; const expiresAt = params.expiresAt; @@ -243,18 +239,12 @@ export class Presences { 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; } @@ -286,54 +276,50 @@ export class Presences { * * * @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} + * @returns {Promise} */ - updatePresence(params: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; + update(params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise; /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. * * * @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} + * @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 }; + update(presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise; + update( + paramsOrFirst: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, + ...rest: [(string)?, (string)?, (object)?, (string[])?, (boolean)?] + ): Promise { + let params: { presenceId: 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 }; + params = (paramsOrFirst || {}) as { presenceId: 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 + status: rest[0] as string, + expiresAt: rest[1] as string, + metadata: rest[2] as object, + permissions: rest[3] as string[], + purge: rest[4] as boolean }; } const presenceId = params.presenceId; - const userId = params.userId; const status = params.status; const expiresAt = params.expiresAt; const metadata = params.metadata; @@ -343,15 +329,9 @@ export class Presences { 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; } diff --git a/src/services/project.ts b/src/services/project.ts index ce272371..721ebf99 100644 --- a/src/services/project.ts +++ b/src/services/project.ts @@ -2187,7 +2187,7 @@ export class Project { * Update the project OAuth2 Google configuration. * * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: example-google-client-secret + * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. * @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} @@ -2198,7 +2198,7 @@ export class Project { * Update the project OAuth2 Google configuration. * * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com - * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: example-google-client-secret + * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. * @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} @@ -2409,7 +2409,7 @@ export class Project { * 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: example-linkedin-client-secret + * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== * @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} @@ -2419,7 +2419,7 @@ export class Project { * 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: example-linkedin-client-secret + * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== * @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} @@ -5750,12 +5750,12 @@ export class Project { * * @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 {string} params.username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string} params.password - SMTP server password. Pass an empty string to clear a previously set value. 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. Pass an empty string to clear a previously set value. + * @param {string} params.senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string} params.replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string} params.replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. * @param {ProjectSMTPSecure} 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} @@ -5767,12 +5767,12 @@ export class Project { * * @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 {string} username - SMTP server username. Pass an empty string to clear a previously set value. + * @param {string} password - SMTP server password. Pass an empty string to clear a previously set value. 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. Pass an empty string to clear a previously set value. + * @param {string} senderName - Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value. + * @param {string} replyToEmail - Email used when user replies to the email. Pass an empty string to clear a previously set value. + * @param {string} replyToName - Name used when user replies to the email. Pass an empty string to clear a previously set value. * @param {ProjectSMTPSecure} 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} @@ -5983,8 +5983,8 @@ export class Project { * @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.senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string} params.replyToEmail - Reply to email. Pass an empty string to clear a previously set value. * @param {string} params.replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise} @@ -5998,8 +5998,8 @@ export class Project { * @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} senderEmail - Email of the sender. Pass an empty string to clear a previously set value. + * @param {string} replyToEmail - Reply to email. Pass an empty string to clear a previously set value. * @param {string} replyToName - Reply to name. * @throws {AppwriteException} * @returns {Promise} diff --git a/src/services/projects.ts b/src/services/projects.ts index 22fb0006..3dfff9d9 100644 --- a/src/services/projects.ts +++ b/src/services/projects.ts @@ -2,9 +2,8 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { Region } from '../enums/region'; -import { ResourceType } from '../enums/resource-type'; -import { Status } from '../enums/status'; +import { ScheduleResourceType } from '../enums/schedule-resource-type'; +import { ProjectStatus } from '../enums/project-status'; export class Projects { client: Client; @@ -13,281 +12,6 @@ export class Projects { this.client = client; } - /** - * Get a list of all projects. You can use the query params to filter your results. - * - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; - /** - * Get a list of all projects. You can use the query params to filter your results. - * - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search - * @param {string} search - Search term to filter your list results. Max length: 256 chars. - * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - list(queries?: string[], search?: string, total?: boolean): Promise; - list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] - ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; - - if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; - } else { - params = { - queries: paramsOrFirst as string[], - search: rest[0] as string, - total: rest[1] as boolean - }; - } - - const queries = params.queries; - const search = params.search; - const total = params.total; - - - const apiPath = '/projects'; - const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - 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 project. You can create a maximum of 100 projects per account. - * - * @param {string} params.projectId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. - * @param {string} params.name - Project name. Max length: 128 chars. - * @param {string} params.teamId - Team unique ID. - * @param {Region} params.region - Project Region. - * @throws {AppwriteException} - * @returns {Promise} - */ - create(params: { projectId: string, name: string, teamId: string, region?: Region }): Promise; - /** - * Create a new project. You can create a maximum of 100 projects per account. - * - * @param {string} projectId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. - * @param {string} name - Project name. Max length: 128 chars. - * @param {string} teamId - Team unique ID. - * @param {Region} region - Project Region. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - create(projectId: string, name: string, teamId: string, region?: Region): Promise; - create( - paramsOrFirst: { projectId: string, name: string, teamId: string, region?: Region } | string, - ...rest: [(string)?, (string)?, (Region)?] - ): Promise { - let params: { projectId: string, name: string, teamId: string, region?: Region }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string, teamId: string, region?: Region }; - } else { - params = { - projectId: paramsOrFirst as string, - name: rest[0] as string, - teamId: rest[1] as string, - region: rest[2] as Region - }; - } - - const projectId = params.projectId; - const name = params.name; - const teamId = params.teamId; - const region = params.region; - - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - - const apiPath = '/projects'; - const payload: Payload = {}; - if (typeof projectId !== 'undefined') { - payload['projectId'] = projectId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; - } - if (typeof region !== 'undefined') { - payload['region'] = region; - } - 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 project by its unique ID. - * - * @param {string} params.projectId - Project unique ID. - * @param {string} params.name - Project name. Max length: 128 chars. - * @param {string} params.description - Project description. Max length: 256 chars. - * @param {string} params.logo - Project logo. - * @param {string} params.url - Project URL. - * @param {string} params.legalName - Project legal name. Max length: 256 chars. - * @param {string} params.legalCountry - Project legal country. Max length: 256 chars. - * @param {string} params.legalState - Project legal state. Max length: 256 chars. - * @param {string} params.legalCity - Project legal city. Max length: 256 chars. - * @param {string} params.legalAddress - Project legal address. Max length: 256 chars. - * @param {string} params.legalTaxId - Project legal tax ID. Max length: 256 chars. - * @throws {AppwriteException} - * @returns {Promise} - */ - update(params: { projectId: string, name: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string }): Promise; - /** - * Update a project by its unique ID. - * - * @param {string} projectId - Project unique ID. - * @param {string} name - Project name. Max length: 128 chars. - * @param {string} description - Project description. Max length: 256 chars. - * @param {string} logo - Project logo. - * @param {string} url - Project URL. - * @param {string} legalName - Project legal name. Max length: 256 chars. - * @param {string} legalCountry - Project legal country. Max length: 256 chars. - * @param {string} legalState - Project legal state. Max length: 256 chars. - * @param {string} legalCity - Project legal city. Max length: 256 chars. - * @param {string} legalAddress - Project legal address. Max length: 256 chars. - * @param {string} legalTaxId - Project legal tax ID. Max length: 256 chars. - * @throws {AppwriteException} - * @returns {Promise} - * @deprecated Use the object parameter style method for a better developer experience. - */ - update(projectId: string, name: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string): Promise; - update( - paramsOrFirst: { projectId: string, name: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] - ): Promise { - let params: { projectId: string, name: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, name: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string }; - } else { - params = { - projectId: paramsOrFirst as string, - name: rest[0] as string, - description: rest[1] as string, - logo: rest[2] as string, - url: rest[3] as string, - legalName: rest[4] as string, - legalCountry: rest[5] as string, - legalState: rest[6] as string, - legalCity: rest[7] as string, - legalAddress: rest[8] as string, - legalTaxId: rest[9] as string - }; - } - - const projectId = params.projectId; - const name = params.name; - const description = params.description; - const logo = params.logo; - const url = params.url; - const legalName = params.legalName; - const legalCountry = params.legalCountry; - const legalState = params.legalState; - const legalCity = params.legalCity; - const legalAddress = params.legalAddress; - const legalTaxId = params.legalTaxId; - - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - - const apiPath = '/projects/{projectId}'.replace('{projectId}', projectId); - const payload: Payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof description !== 'undefined') { - payload['description'] = description; - } - if (typeof logo !== 'undefined') { - payload['logo'] = logo; - } - if (typeof url !== 'undefined') { - payload['url'] = url; - } - if (typeof legalName !== 'undefined') { - payload['legalName'] = legalName; - } - if (typeof legalCountry !== 'undefined') { - payload['legalCountry'] = legalCountry; - } - if (typeof legalState !== 'undefined') { - payload['legalState'] = legalState; - } - if (typeof legalCity !== 'undefined') { - payload['legalCity'] = legalCity; - } - if (typeof legalAddress !== 'undefined') { - payload['legalAddress'] = legalAddress; - } - if (typeof legalTaxId !== 'undefined') { - payload['legalTaxId'] = legalTaxId; - } - 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 - ); - } - /** * Record console access to a project. This endpoint updates the last accessed timestamp for the project to track console activity. * @@ -743,7 +467,7 @@ export class Projects { * Create a new schedule for a resource. * * @param {string} params.projectId - Project unique ID. - * @param {ResourceType} params.resourceType - The resource type for the schedule. Possible values: function, execution, message, backup. + * @param {ScheduleResourceType} params.resourceType - The resource type for the schedule. Possible values: function, execution, message, backup. * @param {string} params.resourceId - The resource ID to associate with this schedule. * @param {string} params.schedule - Schedule CRON expression. * @param {boolean} params.active - Whether the schedule is active. @@ -751,12 +475,12 @@ export class Projects { * @throws {AppwriteException} * @returns {Promise} */ - createSchedule(params: { projectId: string, resourceType: ResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }): Promise; + createSchedule(params: { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }): Promise; /** * Create a new schedule for a resource. * * @param {string} projectId - Project unique ID. - * @param {ResourceType} resourceType - The resource type for the schedule. Possible values: function, execution, message, backup. + * @param {ScheduleResourceType} resourceType - The resource type for the schedule. Possible values: function, execution, message, backup. * @param {string} resourceId - The resource ID to associate with this schedule. * @param {string} schedule - Schedule CRON expression. * @param {boolean} active - Whether the schedule is active. @@ -765,19 +489,19 @@ export class Projects { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createSchedule(projectId: string, resourceType: ResourceType, resourceId: string, schedule: string, active?: boolean, data?: object): Promise; + createSchedule(projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object): Promise; createSchedule( - paramsOrFirst: { projectId: string, resourceType: ResourceType, resourceId: string, schedule: string, active?: boolean, data?: object } | string, - ...rest: [(ResourceType)?, (string)?, (string)?, (boolean)?, (object)?] + paramsOrFirst: { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object } | string, + ...rest: [(ScheduleResourceType)?, (string)?, (string)?, (boolean)?, (object)?] ): Promise { - let params: { projectId: string, resourceType: ResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }; + let params: { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, resourceType: ResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }; + params = (paramsOrFirst || {}) as { projectId: string, resourceType: ScheduleResourceType, resourceId: string, schedule: string, active?: boolean, data?: object }; } else { params = { projectId: paramsOrFirst as string, - resourceType: rest[0] as ResourceType, + resourceType: rest[0] as ScheduleResourceType, resourceId: rest[1] as string, schedule: rest[2] as string, active: rest[3] as boolean, @@ -900,34 +624,34 @@ export class Projects { * * * @param {string} params.projectId - Project ID - * @param {Status} params.status - New status for the project + * @param {ProjectStatus} params.status - New status for the project * @throws {AppwriteException} * @returns {Promise<{}>} */ - updateStatus(params: { projectId: string, status: Status }): Promise<{}>; + updateStatus(params: { projectId: string, status: ProjectStatus }): Promise<{}>; /** * Update the status of a project. Can be used to archive/restore projects, and to restore paused projects. When restoring a paused project, the console fingerprint header must be provided and the project must not be blocked for any reason other than inactivity. * * * @param {string} projectId - Project ID - * @param {Status} status - New status for the project + * @param {ProjectStatus} status - New status for the project * @throws {AppwriteException} * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateStatus(projectId: string, status: Status): Promise<{}>; + updateStatus(projectId: string, status: ProjectStatus): Promise<{}>; updateStatus( - paramsOrFirst: { projectId: string, status: Status } | string, - ...rest: [(Status)?] + paramsOrFirst: { projectId: string, status: ProjectStatus } | string, + ...rest: [(ProjectStatus)?] ): Promise<{}> { - let params: { projectId: string, status: Status }; + let params: { projectId: string, status: ProjectStatus }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { projectId: string, status: Status }; + params = (paramsOrFirst || {}) as { projectId: string, status: ProjectStatus }; } else { params = { projectId: paramsOrFirst as string, - status: rest[0] as Status + status: rest[0] as ProjectStatus }; } diff --git a/src/services/proxy.ts b/src/services/proxy.ts index a5a86736..5cfbba5e 100644 --- a/src/services/proxy.ts +++ b/src/services/proxy.ts @@ -2,7 +2,7 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { StatusCode } from '../enums/status-code'; +import { RedirectStatusCode } from '../enums/redirect-status-code'; import { ProxyResourceType } from '../enums/proxy-resource-type'; export class Proxy { @@ -214,13 +214,13 @@ export class Proxy { * * @param {string} params.domain - Domain name. * @param {string} params.url - Target URL of redirection - * @param {StatusCode} params.statusCode - Status code of redirection + * @param {RedirectStatusCode} 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; + createRedirectRule(params: { domain: string, url: string, statusCode: RedirectStatusCode, resourceId: string, resourceType: ProxyResourceType }): Promise; /** * Create a new proxy rule for to redirect from custom domain to another domain. * @@ -228,27 +228,27 @@ export class Proxy { * * @param {string} domain - Domain name. * @param {string} url - Target URL of redirection - * @param {StatusCode} statusCode - Status code of redirection + * @param {RedirectStatusCode} 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(domain: string, url: string, statusCode: RedirectStatusCode, resourceId: string, resourceType: ProxyResourceType): Promise; createRedirectRule( - paramsOrFirst: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType } | string, - ...rest: [(string)?, (StatusCode)?, (string)?, (ProxyResourceType)?] + paramsOrFirst: { domain: string, url: string, statusCode: RedirectStatusCode, resourceId: string, resourceType: ProxyResourceType } | string, + ...rest: [(string)?, (RedirectStatusCode)?, (string)?, (ProxyResourceType)?] ): Promise { - let params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + let params: { domain: string, url: string, statusCode: RedirectStatusCode, 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 }; + params = (paramsOrFirst || {}) as { domain: string, url: string, statusCode: RedirectStatusCode, resourceId: string, resourceType: ProxyResourceType }; } else { params = { domain: paramsOrFirst as string, url: rest[0] as string, - statusCode: rest[1] as StatusCode, + statusCode: rest[1] as RedirectStatusCode, resourceId: rest[2] as string, resourceType: rest[3] as ProxyResourceType }; diff --git a/src/services/sites.ts b/src/services/sites.ts index e56c2d74..fb2853a1 100644 --- a/src/services/sites.ts +++ b/src/services/sites.ts @@ -2,11 +2,10 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { Framework } from '../enums/framework'; -import { BuildRuntime } from '../enums/build-runtime'; -import { Adapter } from '../enums/adapter'; -import { Frameworks } from '../enums/frameworks'; -import { UseCases } from '../enums/use-cases'; +import { SiteFramework } from '../enums/site-framework'; +import { SiteBuildRuntime } from '../enums/site-build-runtime'; +import { SiteAdapter } from '../enums/site-adapter'; +import { SiteTemplateUseCase } from '../enums/site-template-use-case'; import { UsageRange } from '../enums/usage-range'; import { TemplateReferenceType } from '../enums/template-reference-type'; import { VCSReferenceType } from '../enums/vcs-reference-type'; @@ -90,8 +89,8 @@ export class Sites { * * @param {string} params.siteId - Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Site name. Max length: 128 chars. - * @param {Framework} params.framework - Sites framework. - * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. + * @param {SiteFramework} params.framework - Sites framework. + * @param {SiteBuildRuntime} params.buildRuntime - Runtime to use during build step. * @param {boolean} params.enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. * @param {number} params.timeout - Maximum request time in seconds. @@ -99,27 +98,29 @@ export class Sites { * @param {string} params.buildCommand - Build Command. * @param {string} params.startCommand - Custom start command. Leave empty to use default. * @param {string} params.outputDirectory - Output Directory for site. - * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {SiteAdapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. + * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} params.buildSpecification - Build specification for the site deployments. * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + create(params: { siteId: string, name: string, framework: SiteFramework, buildRuntime: SiteBuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: SiteAdapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Create a new site. * * @param {string} siteId - Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Site name. Max length: 128 chars. - * @param {Framework} framework - Sites framework. - * @param {BuildRuntime} buildRuntime - Runtime to use during build step. + * @param {SiteFramework} framework - Sites framework. + * @param {SiteBuildRuntime} buildRuntime - Runtime to use during build step. * @param {boolean} enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. * @param {boolean} logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. * @param {number} timeout - Maximum request time in seconds. @@ -127,13 +128,15 @@ export class Sites { * @param {string} buildCommand - Build Command. * @param {string} startCommand - Custom start command. Leave empty to use default. * @param {string} outputDirectory - Output Directory for site. - * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {SiteAdapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. + * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} buildSpecification - Build specification for the site deployments. * @param {string} runtimeSpecification - Runtime specification for the SSR executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. @@ -141,21 +144,21 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; + create(siteId: string, name: string, framework: SiteFramework, buildRuntime: SiteBuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: SiteAdapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; create( - paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + paramsOrFirst: { siteId: string, name: string, framework: SiteFramework, buildRuntime: SiteBuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: SiteAdapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (SiteFramework)?, (SiteBuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (SiteAdapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] ): Promise { - let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { siteId: string, name: string, framework: SiteFramework, buildRuntime: SiteBuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: SiteAdapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: SiteFramework, buildRuntime: SiteBuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: SiteAdapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { siteId: paramsOrFirst as string, name: rest[0] as string, - framework: rest[1] as Framework, - buildRuntime: rest[2] as BuildRuntime, + framework: rest[1] as SiteFramework, + buildRuntime: rest[2] as SiteBuildRuntime, enabled: rest[3] as boolean, logging: rest[4] as boolean, timeout: rest[5] as number, @@ -163,16 +166,18 @@ export class Sites { buildCommand: rest[7] as string, startCommand: rest[8] as string, outputDirectory: rest[9] as string, - adapter: rest[10] as Adapter, + adapter: rest[10] as SiteAdapter, installationId: rest[11] as string, fallbackFile: rest[12] as string, providerRepositoryId: rest[13] as string, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - buildSpecification: rest[17] as string, - runtimeSpecification: rest[18] as string, - deploymentRetention: rest[19] as number + providerBranches: rest[17] as string[], + providerPaths: rest[18] as string[], + buildSpecification: rest[19] as string, + runtimeSpecification: rest[20] as string, + deploymentRetention: rest[21] as number }; } @@ -194,6 +199,8 @@ export class Sites { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; + const providerBranches = params.providerBranches; + const providerPaths = params.providerPaths; const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; @@ -267,6 +274,12 @@ export class Sites { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } + if (typeof providerBranches !== 'undefined') { + payload['providerBranches'] = providerBranches; + } + if (typeof providerPaths !== 'undefined') { + payload['providerPaths'] = providerPaths; + } if (typeof buildSpecification !== 'undefined') { payload['buildSpecification'] = buildSpecification; } @@ -339,38 +352,38 @@ export class Sites { /** * List available site templates. You can use template details in [createSite](/docs/references/cloud/server-nodejs/sites#create) method. * - * @param {Frameworks[]} params.frameworks - List of frameworks allowed for filtering site templates. Maximum of 100 frameworks are allowed. - * @param {UseCases[]} params.useCases - List of use cases allowed for filtering site templates. Maximum of 100 use cases are allowed. + * @param {SiteFramework[]} params.frameworks - List of frameworks allowed for filtering site templates. Maximum of 100 frameworks are allowed. + * @param {SiteTemplateUseCase[]} params.useCases - List of use cases allowed for filtering site templates. Maximum of 100 use cases are allowed. * @param {number} params.limit - Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000. * @param {number} params.offset - Offset the list of returned templates. Maximum offset is 5000. * @throws {AppwriteException} * @returns {Promise} */ - listTemplates(params?: { frameworks?: Frameworks[], useCases?: UseCases[], limit?: number, offset?: number }): Promise; + listTemplates(params?: { frameworks?: SiteFramework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number }): Promise; /** * List available site templates. You can use template details in [createSite](/docs/references/cloud/server-nodejs/sites#create) method. * - * @param {Frameworks[]} frameworks - List of frameworks allowed for filtering site templates. Maximum of 100 frameworks are allowed. - * @param {UseCases[]} useCases - List of use cases allowed for filtering site templates. Maximum of 100 use cases are allowed. + * @param {SiteFramework[]} frameworks - List of frameworks allowed for filtering site templates. Maximum of 100 frameworks are allowed. + * @param {SiteTemplateUseCase[]} useCases - List of use cases allowed for filtering site templates. Maximum of 100 use cases are allowed. * @param {number} limit - Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000. * @param {number} offset - Offset the list of returned templates. Maximum offset is 5000. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - listTemplates(frameworks?: Frameworks[], useCases?: UseCases[], limit?: number, offset?: number): Promise; + listTemplates(frameworks?: SiteFramework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number): Promise; listTemplates( - paramsOrFirst?: { frameworks?: Frameworks[], useCases?: UseCases[], limit?: number, offset?: number } | Frameworks[], - ...rest: [(UseCases[])?, (number)?, (number)?] + paramsOrFirst?: { frameworks?: SiteFramework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number } | SiteFramework[], + ...rest: [(SiteTemplateUseCase[])?, (number)?, (number)?] ): Promise { - let params: { frameworks?: Frameworks[], useCases?: UseCases[], limit?: number, offset?: number }; + let params: { frameworks?: SiteFramework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('frameworks' in paramsOrFirst || 'useCases' in paramsOrFirst || 'limit' in paramsOrFirst || 'offset' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { frameworks?: Frameworks[], useCases?: UseCases[], limit?: number, offset?: number }; + params = (paramsOrFirst || {}) as { frameworks?: SiteFramework[], useCases?: SiteTemplateUseCase[], limit?: number, offset?: number }; } else { params = { - frameworks: paramsOrFirst as Frameworks[], - useCases: rest[0] as UseCases[], + frameworks: paramsOrFirst as SiteFramework[], + useCases: rest[0] as SiteTemplateUseCase[], limit: rest[1] as number, offset: rest[2] as number }; @@ -567,7 +580,7 @@ export class Sites { * * @param {string} params.siteId - Site ID. * @param {string} params.name - Site name. Max length: 128 chars. - * @param {Framework} params.framework - Sites framework. + * @param {SiteFramework} params.framework - Sites framework. * @param {boolean} params.enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. * @param {number} params.timeout - Maximum request time in seconds. @@ -575,27 +588,29 @@ export class Sites { * @param {string} params.buildCommand - Build Command. * @param {string} params.startCommand - Custom start command. Leave empty to use default. * @param {string} params.outputDirectory - Output Directory for site. - * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. - * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {SiteBuildRuntime} params.buildRuntime - Runtime to use during build step. + * @param {SiteAdapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} params.fallbackFile - Fallback file for single page application sites. * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} params.providerBranch - Production branch for the repo linked to the site. * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} params.providerRootDirectory - Path to site code in the linked repo. + * @param {string[]} params.providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} params.providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} params.buildSpecification - Build specification for the site deployments. * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. * @throws {AppwriteException} * @returns {Promise} */ - update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; + update(params: { siteId: string, name: string, framework: SiteFramework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: SiteBuildRuntime, adapter?: SiteAdapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise; /** * Update site by its unique ID. * * @param {string} siteId - Site ID. * @param {string} name - Site name. Max length: 128 chars. - * @param {Framework} framework - Sites framework. + * @param {SiteFramework} framework - Sites framework. * @param {boolean} enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. * @param {boolean} logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. * @param {number} timeout - Maximum request time in seconds. @@ -603,14 +618,16 @@ export class Sites { * @param {string} buildCommand - Build Command. * @param {string} startCommand - Custom start command. Leave empty to use default. * @param {string} outputDirectory - Output Directory for site. - * @param {BuildRuntime} buildRuntime - Runtime to use during build step. - * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {SiteBuildRuntime} buildRuntime - Runtime to use during build step. + * @param {SiteAdapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr * @param {string} fallbackFile - Fallback file for single page application sites. * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. * @param {string} providerBranch - Production branch for the repo linked to the site. * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. * @param {string} providerRootDirectory - Path to site code in the linked repo. + * @param {string[]} providerBranches - List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. + * @param {string[]} providerPaths - List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. * @param {string} buildSpecification - Build specification for the site deployments. * @param {string} runtimeSpecification - Runtime specification for the SSR executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. @@ -618,20 +635,20 @@ export class Sites { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; + update(siteId: string, name: string, framework: SiteFramework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: SiteBuildRuntime, adapter?: SiteAdapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise; update( - paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, - ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + paramsOrFirst: { siteId: string, name: string, framework: SiteFramework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: SiteBuildRuntime, adapter?: SiteAdapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (SiteFramework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (SiteBuildRuntime)?, (SiteAdapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string[])?, (string[])?, (string)?, (string)?, (number)?] ): Promise { - let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + let params: { siteId: string, name: string, framework: SiteFramework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: SiteBuildRuntime, adapter?: SiteAdapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: SiteFramework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: SiteBuildRuntime, adapter?: SiteAdapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, providerBranches?: string[], providerPaths?: string[], buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; } else { params = { siteId: paramsOrFirst as string, name: rest[0] as string, - framework: rest[1] as Framework, + framework: rest[1] as SiteFramework, enabled: rest[2] as boolean, logging: rest[3] as boolean, timeout: rest[4] as number, @@ -639,17 +656,19 @@ export class Sites { buildCommand: rest[6] as string, startCommand: rest[7] as string, outputDirectory: rest[8] as string, - buildRuntime: rest[9] as BuildRuntime, - adapter: rest[10] as Adapter, + buildRuntime: rest[9] as SiteBuildRuntime, + adapter: rest[10] as SiteAdapter, fallbackFile: rest[11] as string, installationId: rest[12] as string, providerRepositoryId: rest[13] as string, providerBranch: rest[14] as string, providerSilentMode: rest[15] as boolean, providerRootDirectory: rest[16] as string, - buildSpecification: rest[17] as string, - runtimeSpecification: rest[18] as string, - deploymentRetention: rest[19] as number + providerBranches: rest[17] as string[], + providerPaths: rest[18] as string[], + buildSpecification: rest[19] as string, + runtimeSpecification: rest[20] as string, + deploymentRetention: rest[21] as number }; } @@ -671,6 +690,8 @@ export class Sites { const providerBranch = params.providerBranch; const providerSilentMode = params.providerSilentMode; const providerRootDirectory = params.providerRootDirectory; + const providerBranches = params.providerBranches; + const providerPaths = params.providerPaths; const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; @@ -738,6 +759,12 @@ export class Sites { if (typeof providerRootDirectory !== 'undefined') { payload['providerRootDirectory'] = providerRootDirectory; } + if (typeof providerBranches !== 'undefined') { + payload['providerBranches'] = providerBranches; + } + if (typeof providerPaths !== 'undefined') { + payload['providerPaths'] = providerPaths; + } if (typeof buildSpecification !== 'undefined') { payload['buildSpecification'] = buildSpecification; } diff --git a/src/services/usage.ts b/src/services/usage.ts index ba131a6d..b174a079 100644 --- a/src/services/usage.ts +++ b/src/services/usage.ts @@ -70,7 +70,7 @@ export class Usage { } /** - * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, and timestamp. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, timestamp, resourceType, and resourceId. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. * * @param {string[]} params.queries - Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. @@ -79,7 +79,7 @@ export class Usage { */ listGauges(params?: { queries?: string[], total?: boolean }): Promise; /** - * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, and timestamp. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, timestamp, resourceType, and resourceId. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. * * @param {string[]} queries - Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. diff --git a/src/services/vectors-db.ts b/src/services/vectors-db.ts index d06daece..300aec9c 100644 --- a/src/services/vectors-db.ts +++ b/src/services/vectors-db.ts @@ -2,7 +2,7 @@ import { Service } from '../service'; import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; -import { Model } from '../enums/model'; +import { EmbeddingModel } from '../enums/embedding-model'; import { UsageRange } from '../enums/usage-range'; import { VectorsDBIndexType } from '../enums/vectors-db-index-type'; import { OrderBy } from '../enums/order-by'; @@ -18,41 +18,37 @@ export class VectorsDB { * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} */ - list(params?: { queries?: string[], search?: string, total?: boolean }): Promise; + list(params?: { queries?: string[], total?: boolean }): Promise; /** * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. * * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - list(queries?: string[], search?: string, total?: boolean): Promise; + list(queries?: string[], total?: boolean): Promise; list( - paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], - ...rest: [(string)?, (boolean)?] + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] ): Promise { - let params: { queries?: string[], search?: string, total?: boolean }; + let params: { queries?: string[], total?: boolean }; if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; } else { params = { queries: paramsOrFirst as string[], - search: rest[0] as string, - total: rest[1] as boolean + total: rest[0] as boolean }; } const queries = params.queries; - const search = params.search; const total = params.total; @@ -61,9 +57,6 @@ export class VectorsDB { if (typeof queries !== 'undefined') { payload['queries'] = queries; } - if (typeof search !== 'undefined') { - payload['search'] = search; - } if (typeof total !== 'undefined') { payload['total'] = total; } @@ -159,33 +152,33 @@ export class VectorsDB { * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * * @param {string[]} params.texts - Array of text to generate embeddings. - * @param {Model} params.model - The embedding model to use for generating vector embeddings. + * @param {EmbeddingModel} params.model - The embedding model to use for generating vector embeddings. * @throws {AppwriteException} * @returns {Promise} */ - createTextEmbeddings(params: { texts: string[], model?: Model }): Promise; + createTextEmbeddings(params: { texts: string[], model?: EmbeddingModel }): Promise; /** * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. * * @param {string[]} texts - Array of text to generate embeddings. - * @param {Model} model - The embedding model to use for generating vector embeddings. + * @param {EmbeddingModel} model - The embedding model to use for generating vector embeddings. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createTextEmbeddings(texts: string[], model?: Model): Promise; + createTextEmbeddings(texts: string[], model?: EmbeddingModel): Promise; createTextEmbeddings( - paramsOrFirst: { texts: string[], model?: Model } | string[], - ...rest: [(Model)?] + paramsOrFirst: { texts: string[], model?: EmbeddingModel } | string[], + ...rest: [(EmbeddingModel)?] ): Promise { - let params: { texts: string[], model?: Model }; + let params: { texts: string[], model?: EmbeddingModel }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { texts: string[], model?: Model }; + params = (paramsOrFirst || {}) as { texts: string[], model?: EmbeddingModel }; } else { params = { texts: paramsOrFirst as string[], - model: rest[0] as Model + model: rest[0] as EmbeddingModel }; } From ca2dd4fdcdf853283d8f72a805136f7b32cc1f52 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 29 May 2026 07:53:05 +0000 Subject: [PATCH 3/3] chore: update Console SDK to 13.1.0 --- README.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/client.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a4922b73..8cf6f116 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/package-lock.json b/package-lock.json index 685364d8..bbeff03c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appwrite.io/console", - "version": "13.0.0", + "version": "13.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@appwrite.io/console", - "version": "13.0.0", + "version": "13.1.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index 93313761..17c9e470 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@appwrite.io/console", "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": "13.0.0", + "version": "13.1.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index cad02b2a..69b7e60f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -390,7 +390,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '13.0.0', + 'x-sdk-version': '13.1.0', 'X-Appwrite-Response-Format': '1.9.5', };