mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
types fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageUsers } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
@@ -6,10 +6,10 @@ import { error } from '@sveltejs/kit';
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const { period } = params;
|
||||
try {
|
||||
const response = await sdk.forProject.users.getUsage(period ?? '30d');
|
||||
const response = (await sdk.forProject.users.getUsage(period ?? '30d')) as unknown as UsageUsers;
|
||||
return {
|
||||
usersTotal: response.usersTotal,
|
||||
users: response.users as unknown as Metric[]
|
||||
users: response.users as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageCollection } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const response = await sdk.forProject.databases.getCollectionUsage(
|
||||
const response = (await sdk.forProject.databases.getCollectionUsage(
|
||||
params.database,
|
||||
params.collection,
|
||||
params.period ?? '30d'
|
||||
);
|
||||
)) as unknown as UsageCollection;
|
||||
|
||||
return {
|
||||
documentsTotal: response.documentsTotal,
|
||||
documents: response.documents as unknown as Metric[]
|
||||
documents: response.documents as Metric[]
|
||||
};
|
||||
};
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageDatabase} from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const response = await sdk.forProject.databases.getDatabaseUsage(
|
||||
const response = (await sdk.forProject.databases.getDatabaseUsage(
|
||||
params.database,
|
||||
params.period ?? '30d'
|
||||
);
|
||||
)) as unknown as UsageDatabase;
|
||||
|
||||
return {
|
||||
collectionsTotal: response.collectionsTotal,
|
||||
collections: response.collections as unknown as Metric[]
|
||||
collections: response.collections as Metric[]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageDatabases } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
@@ -6,12 +6,14 @@ import { error } from '@sveltejs/kit';
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const { period } = params;
|
||||
try {
|
||||
const response = await sdk.forProject.databases.getUsage(period ?? '30d');
|
||||
const response = (await sdk.forProject.databases.getUsage(period ?? '30d')) as unknown as UsageDatabases;
|
||||
return {
|
||||
databasesTotal: response.databasesTotal,
|
||||
databases: response.databases as unknown as Metric[]
|
||||
databases: response.databases as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -1,18 +1,18 @@
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageFunctions } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
try {
|
||||
const response = await sdk.forProject.functions.getFunctionUsage(
|
||||
const response = (await sdk.forProject.functions.getFunctionUsage(
|
||||
params.function,
|
||||
params.period ?? '30d'
|
||||
);
|
||||
)) as unknown as UsageFunctions;
|
||||
|
||||
return {
|
||||
executionsTotal: response.executionsTotal,
|
||||
executions: response.executions as unknown as Metric[]
|
||||
executions: response.executions as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import type { UsagePeriods } from '$lib/layout';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { BarChart } from '$lib/charts';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
|
||||
export let period: UsagePeriods;
|
||||
|
||||
@@ -13,11 +14,8 @@
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
$: network = $usage?.network as unknown as Array<{
|
||||
date: number;
|
||||
value: number;
|
||||
}>;
|
||||
$: bandwith = humanFileSize(totalMetrics($usage?.network));
|
||||
$: network = $usage?.network as Metric[];
|
||||
$: bandwith = humanFileSize(totalMetrics($usage?.network as Metric[]));
|
||||
|
||||
$: if (period) {
|
||||
showPeriod = false;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { LineChart } from '$lib/charts';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
|
||||
export let period: UsagePeriods;
|
||||
|
||||
@@ -13,10 +14,7 @@
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
$: requests = $usage?.requests as unknown as Array<{
|
||||
date: number;
|
||||
value: number;
|
||||
}>;
|
||||
$: requests = $usage?.requests as Metric[];
|
||||
|
||||
$: if (period) {
|
||||
showPeriod = false;
|
||||
|
||||
@@ -11,7 +11,7 @@ export const usage = cachedStore<
|
||||
>('projectUsage', function ({ set }) {
|
||||
return {
|
||||
load: async (range) => {
|
||||
const usages: UsageProject = await sdk.forProject.project.getUsage(range);
|
||||
const usages: UsageProject = (await sdk.forProject.project.getUsage(range)) as unknown as UsageProject;
|
||||
set(usages);
|
||||
}
|
||||
};
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageBuckets } from '$lib/sdk/usage';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const response = await sdk.forProject.storage.getBucketUsage(
|
||||
const response = (await sdk.forProject.storage.getBucketUsage(
|
||||
params.bucket,
|
||||
params.period ?? '30d'
|
||||
);
|
||||
)) as unknown as UsageBuckets;
|
||||
|
||||
return {
|
||||
filesTotal: response.filesTotal,
|
||||
files: response.files as unknown as Metric[]
|
||||
files: response.files as Metric[]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import type { Metric, UsageStorage } from '$lib/sdk/usage';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
try {
|
||||
const response = await sdk.forProject.storage.getUsage(params.period ?? '30d');
|
||||
const response = (await sdk.forProject.storage.getUsage(params.period ?? '30d')) as unknown as UsageStorage;
|
||||
|
||||
return {
|
||||
bucketsTotal: response.bucketsTotal,
|
||||
buckets: response.buckets as unknown as Metric[]
|
||||
buckets: response.buckets as Metric[]
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
|
||||
Reference in New Issue
Block a user