From fd1201ade43e4ba0444d71121f205db6b0e32ca0 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 9 Jan 2024 12:06:36 +0100 Subject: [PATCH] feat: account delete --- LICENSE | 2 +- README.md | 2 +- docs/examples/account/delete.md | 18 ++++++ package.json | 2 +- src/client.ts | 2 +- src/models.ts | 102 +++++++++++++++++++++++++++++++- src/services/account.ts | 18 ++++++ src/services/functions.ts | 2 +- 8 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 docs/examples/account/delete.md diff --git a/LICENSE b/LICENSE index 47cfdfb..5479bb8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index bb70148..7288a69 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/delete.md b/docs/examples/account/delete.md new file mode 100644 index 0000000..c53d0e2 --- /dev/null +++ b/docs/examples/account/delete.md @@ -0,0 +1,18 @@ +import { Client, Account } from "@appwrite.io/console"; + +const client = new Client(); + +const account = new Account(client); + +client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID +; + +const promise = account.delete(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/package.json b/package.json index 01d58b4..fe5d00f 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 abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.4.0", + "version": "0.5.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index fbb56cd..343fc4a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -104,7 +104,7 @@ class Client { 'x-sdk-name': 'Console', 'x-sdk-platform': 'console', 'x-sdk-language': 'web', - 'x-sdk-version': '0.4.0', + 'x-sdk-version': '0.5.0', 'X-Appwrite-Response-Format': '1.4.0', }; diff --git a/src/models.ts b/src/models.ts index 37dc37d..a6a995a 100644 --- a/src/models.ts +++ b/src/models.ts @@ -2573,6 +2573,23 @@ export namespace Models { */ date: string; } + /** + * Metric Breakdown + */ + export type MetricBreakdown = { + /** + * Resource ID. + */ + resourceId: string; + /** + * Resource name. + */ + name: string; + /** + * The value of this metric at the timestamp. + */ + value: number; + } /** * UsageDatabases */ @@ -2804,6 +2821,71 @@ export namespace Models { */ executionsTime: Metric[]; } + /** + * UsageFunction + */ + export type UsageFunction = { + /** + * The time range of the usage stats. + */ + range: string; + /** + * Total aggregated number of function deployments. + */ + deploymentsTotal: number; + /** + * Total aggregated sum of function deployments storage. + */ + deploymentsStorageTotal: number; + /** + * Total aggregated number of function builds. + */ + buildsTotal: number; + /** + * total aggregated sum of function builds storage. + */ + buildsStorageTotal: number; + /** + * Total aggregated sum of function builds compute time. + */ + buildsTimeTotal: number; + /** + * Total aggregated number of function executions. + */ + executionsTotal: number; + /** + * Total aggregated sum of function executions compute time. + */ + executionsTimeTotal: number; + /** + * Aggregated number of function deployments per period. + */ + deployments: Metric[]; + /** + * Aggregated number of function deployments storage per period. + */ + deploymentsStorage: Metric[]; + /** + * Aggregated number of function builds per period. + */ + builds: Metric[]; + /** + * Aggregated sum of function builds storage per period. + */ + buildsStorage: Metric[]; + /** + * Aggregated sum of function builds compute time per period. + */ + buildsTime: Metric[]; + /** + * Aggregated number of function executions per period. + */ + executions: Metric[]; + /** + * Aggregated number of function executions compute time per period. + */ + executionsTime: Metric[]; + } /** * UsageProject */ @@ -2835,11 +2917,27 @@ export namespace Models { /** * Aggregated number of requests per period. */ - requests: string[]; + requests: Metric[]; /** * Aggregated number of consumed bandwidth per period. */ - network: string[]; + network: Metric[]; + /** + * Aggregated number of users per period. + */ + users: Metric[]; + /** + * Aggregated number of executions per period. + */ + executions: Metric[]; + /** + * Aggregated breakdown in totals of executions by functions. + */ + executionsBreakdown: MetricBreakdown[]; + /** + * Aggregated breakdown in totals of usage by buckets. + */ + bucketsBreakdown: MetricBreakdown[]; } /** * Headers diff --git a/src/services/account.ts b/src/services/account.ts index 29d4b6a..5261e7f 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -84,6 +84,24 @@ export class Account extends Service { }, payload); } + /** + * Delete account + * + * Delete the currently logged in user. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + async delete(): Promise<{}> { + const apiPath = '/account'; + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return await this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } + /** * Update email * diff --git a/src/services/functions.ts b/src/services/functions.ts index 42c0df0..5867edd 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -770,7 +770,7 @@ export class Functions extends Service { * @throws {AppwriteException} * @returns {Promise} */ - async getFunctionUsage(functionId: string, range?: string): Promise { + async getFunctionUsage(functionId: string, range?: string): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); }