pl-fe: steal more dashboard code from mastodon

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-28 20:37:16 +02:00
parent 0f78abf9a9
commit c634684dbd
13 changed files with 319 additions and 30 deletions

View File

@ -4411,7 +4411,7 @@ class PlApiClient {
getRetention: async (start_at: string, end_at: string, frequency: 'day' | 'month') => {
const response = await this.request('/api/v1/admin/retention', { method: 'POST', params: { start_at, end_at, frequency } });
return v.parse(adminCohortSchema, response.json);
return v.parse(filteredArray(adminCohortSchema), response.json);
},
},

View File

@ -12,7 +12,7 @@ const adminCohortSchema = v.object({
data: v.array(v.object({
date: datetimeSchema,
rate: v.number(),
value: v.pipe(v.number(), v.integer()),
value: v.pipe(v.unknown(), v.transform(Number)),
})),
});

View File

@ -6,13 +6,13 @@ import * as v from 'valibot';
*/
const adminDimensionSchema = v.object({
key: v.string(),
data: v.object({
data: v.array(v.object({
key: v.string(),
human_key: v.string(),
value: v.string(),
unit: v.fallback(v.optional(v.string()), undefined),
human_value: v.fallback(v.optional(v.string()), undefined),
}),
})),
});
/**

View File

@ -1,6 +1,6 @@
{
"name": "pl-api",
"version": "1.0.0-rc.57",
"version": "1.0.0-rc.58",
"type": "module",
"homepage": "https://github.com/mkljczk/pl-fe/tree/develop/packages/pl-api",
"repository": {