Skip to content

Commit

Permalink
feat: account delete
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jan 9, 2024
1 parent e979501 commit fd1201a
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@0.4.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@0.5.0"></script>
```


Expand Down
18 changes: 18 additions & 0 deletions docs/examples/account/delete.md
Original file line number Diff line number Diff line change
@@ -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
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down
102 changes: 100 additions & 2 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/services/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ export class Functions extends Service {
* @throws {AppwriteException}
* @returns {Promise}
*/
async getFunctionUsage(functionId: string, range?: string): Promise<Models.UsageFunctions> {
async getFunctionUsage(functionId: string, range?: string): Promise<Models.UsageFunction> {
if (typeof functionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "functionId"');
}
Expand Down

0 comments on commit fd1201a

Please sign in to comment.