mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
usage sdk
This commit is contained in:
Generated
+5
@@ -0,0 +1,5 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/console.iml" filepath="$PROJECT_DIR$/.idea/console.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+339
-504
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -18,9 +18,9 @@
|
||||
"e2e": "playwright test tests/e2e"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appwrite.io/console": "npm:shimon-appwrite-console@0.3.3",
|
||||
"@appwrite.io/pink": "0.1.0-next.9",
|
||||
"@appwrite.io/pink-icons": "^0.1.0-next.9",
|
||||
"@appwrite.io/console": "^0.3.0",
|
||||
"@appwrite.io/pink": "0.1.0",
|
||||
"@appwrite.io/pink-icons": "^0.1.0",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@sentry/svelte": "^7.66.0",
|
||||
"@sentry/tracing": "^7.66.0",
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
export type Metric = {
|
||||
/**
|
||||
* The value of this metric at the timestamp.
|
||||
*/
|
||||
value: number;
|
||||
/**
|
||||
* The date at which this metric was aggregated in ISO 8601 format.
|
||||
*/
|
||||
date: string;
|
||||
};
|
||||
/**
|
||||
* UsageDatabases
|
||||
*/
|
||||
export type UsageDatabases = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of documents.
|
||||
*/
|
||||
databasesTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of collections.
|
||||
*/
|
||||
collectionsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of documents.
|
||||
*/
|
||||
documentsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of documents per period.
|
||||
*/
|
||||
databases: Metric[];
|
||||
/**
|
||||
* Aggregated total statistics of collections per period.
|
||||
*/
|
||||
collections: Metric[];
|
||||
/**
|
||||
* Aggregated total statistics of documents per period.
|
||||
*/
|
||||
documents: Metric[];
|
||||
};
|
||||
/**
|
||||
* UsageDatabase
|
||||
*/
|
||||
export type UsageDatabase = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of collections.
|
||||
*/
|
||||
collectionsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of documents.
|
||||
*/
|
||||
documentsTotal: number;
|
||||
/**
|
||||
* Aggregated statistics collections per period.
|
||||
*/
|
||||
collections: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of documents per period.
|
||||
*/
|
||||
documents: Metric[];
|
||||
};
|
||||
/**
|
||||
* UsageCollection
|
||||
*/
|
||||
export type UsageCollection = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of documents.
|
||||
*/
|
||||
documentsTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of documents per period.
|
||||
*/
|
||||
documents: Metric[];
|
||||
};
|
||||
/**
|
||||
* UsageUsers
|
||||
*/
|
||||
export type UsageUsers = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of users.
|
||||
*/
|
||||
usersTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics sessions created.
|
||||
*/
|
||||
sessionsTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of users per period.
|
||||
*/
|
||||
users: Metric[];
|
||||
/**
|
||||
* Aggregated statistics sessions created per period.
|
||||
*/
|
||||
sessions: Metric[];
|
||||
};
|
||||
/**
|
||||
* StorageUsage
|
||||
*/
|
||||
export type UsageStorage = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of buckets
|
||||
*/
|
||||
bucketsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of files.
|
||||
*/
|
||||
filesTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of files storage (in bytes).
|
||||
*/
|
||||
filesStorageTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of buckets per period.
|
||||
*/
|
||||
buckets: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of files per period.
|
||||
*/
|
||||
files: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of storage (in bytes) per period .
|
||||
*/
|
||||
storage: Metric[];
|
||||
};
|
||||
/**
|
||||
* UsageBuckets
|
||||
*/
|
||||
export type UsageBuckets = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of bucket files.
|
||||
*/
|
||||
filesTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of bucket files storage.
|
||||
*/
|
||||
filesStorageTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of bucket files per period.
|
||||
*/
|
||||
files: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of bucket storage files per period.
|
||||
*/
|
||||
storage: Metric[];
|
||||
};
|
||||
/**
|
||||
* UsageFunctions
|
||||
*/
|
||||
export type UsageFunctions = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: string;
|
||||
/**
|
||||
* Aggregated total statistics of functions.
|
||||
*/
|
||||
functionsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of function deployments.
|
||||
*/
|
||||
deploymentsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of function deployments storage.
|
||||
*/
|
||||
deploymentsStorageTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of function builds.
|
||||
*/
|
||||
buildsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of builds storage.
|
||||
*/
|
||||
buildsStorageTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of build compute time.
|
||||
*/
|
||||
buildsTimeTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of functions executions.
|
||||
*/
|
||||
executionsTotal: number;
|
||||
/**
|
||||
* Aggregated total statistics of functions execution compute time.
|
||||
*/
|
||||
executionsTimeTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of functions per period.
|
||||
*/
|
||||
functions: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of deployments per period.
|
||||
*/
|
||||
deployments: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of deployments storage per period.
|
||||
*/
|
||||
deploymentsStorage: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of builds per period.
|
||||
*/
|
||||
builds: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of storage per period.
|
||||
*/
|
||||
buildsStorage: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of builds compute time per period.
|
||||
*/
|
||||
buildsTime: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of executions per period.
|
||||
*/
|
||||
executions: Metric[];
|
||||
/**
|
||||
* Aggregated statistics of execution compute time per period.
|
||||
*/
|
||||
executionsTime: Metric[];
|
||||
};
|
||||
/**
|
||||
* UsageProject
|
||||
*/
|
||||
export type UsageProject = {
|
||||
/**
|
||||
* The time range of the usage stats.
|
||||
*/
|
||||
range: number;
|
||||
/**
|
||||
* Aggregated statistics of number of requests per period.
|
||||
*/
|
||||
requests: string[];
|
||||
/**
|
||||
* Aggregated statistics of consumed bandwidth per period.
|
||||
*/
|
||||
network: string[];
|
||||
/**
|
||||
* Aggregated statistics of total function executions.
|
||||
*/
|
||||
executionsTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of total number of documents.
|
||||
*/
|
||||
documentsTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of total number of databases.
|
||||
*/
|
||||
databasesTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of total number of users.
|
||||
*/
|
||||
usersTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of total occupied storage size (in bytes).
|
||||
*/
|
||||
filesStorageTotal: number;
|
||||
/**
|
||||
* Aggregated statistics of total number of buckets.
|
||||
*/
|
||||
bucketsTotal: number;
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
@@ -9,7 +9,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
const response = await sdk.forProject.users.getUsage(period ?? '30d');
|
||||
return {
|
||||
usersTotal: response.usersTotal,
|
||||
users: response.users as unknown as Models.Metric[]
|
||||
users: response.users as unknown as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
@@ -11,6 +11,6 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
documentsTotal: response.documentsTotal,
|
||||
documents: response.documents as unknown as Models.Metric[]
|
||||
documents: response.documents as unknown as Metric[]
|
||||
};
|
||||
};
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
@@ -10,6 +10,6 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
collectionsTotal: response.collectionsTotal,
|
||||
collections: response.collections as unknown as Models.Metric[]
|
||||
collections: response.collections as unknown as Metric[]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
@@ -8,7 +8,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
try {
|
||||
const response = await sdk.forProject.databases.getUsage(period ?? '30d');
|
||||
return {
|
||||
databasesTotal: response.databasesTotal as unknown as Models.Metric[],
|
||||
databasesTotal: response.databasesTotal as unknown as Metric[],
|
||||
databases: response.databases
|
||||
};
|
||||
} catch (e) {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
@@ -12,7 +12,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
executionsTotal: response.executionsTotal,
|
||||
executions: response.executions as unknown as Models.Metric[]
|
||||
executions: response.executions as unknown as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
export function totalMetrics(set: Array<unknown>): number {
|
||||
if (!set) return 0;
|
||||
return total((set as Models.Metric[]).map((c) => c.value));
|
||||
return total((set as Metric[]).map((c) => c.value));
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
import { Heading, Tab } from '$lib/components';
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { Container, type UsagePeriods } from '$lib/layout';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import { onboarding, project } from '../store';
|
||||
import Bandwith from './bandwith.svelte';
|
||||
@@ -25,6 +24,7 @@
|
||||
import { usage } from './store';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import { total } from '$lib/helpers/array';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
|
||||
$: projectId = $page.params.project;
|
||||
$: path = `/console/project-${projectId}/overview`;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { UsageProject } from '$lib/sdk/usage';
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
|
||||
export const usage = cachedStore<
|
||||
Models.UsageProject,
|
||||
UsageProject,
|
||||
{
|
||||
load: (range: string) => Promise<void>;
|
||||
}
|
||||
>('projectUsage', function ({ set }) {
|
||||
return {
|
||||
load: async (range) => {
|
||||
const usages = await sdk.forProject.project.getUsage(range);
|
||||
const usages: UsageProject = await sdk.forProject.project.getUsage(range);
|
||||
set(usages);
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
@@ -10,6 +10,6 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
filesTotal: response.filesTotal,
|
||||
files: response.files as unknown as Models.Metric[]
|
||||
files: response.files as unknown as Metric[]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
@@ -9,7 +9,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return {
|
||||
bucketsTotal: response.bucketsTotal,
|
||||
buckets: response.buckets as unknown as Models.Metric[]
|
||||
buckets: response.buckets as unknown as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
Reference in New Issue
Block a user