pl-api: add pleroma config description schema
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -18,6 +18,7 @@ import {
|
||||
adminReportSchema,
|
||||
adminRuleSchema,
|
||||
adminTagSchema,
|
||||
pleromaConfigDescriptionSchema,
|
||||
pleromaConfigSchema,
|
||||
statusSchema,
|
||||
statusSourceSchema,
|
||||
@ -1458,6 +1459,12 @@ const admin = (client: PlApiBaseClient) => {
|
||||
},
|
||||
|
||||
config: {
|
||||
getPleromaConfigDescriptions: async () => {
|
||||
const response = await client.request('/api/v1/pleroma/admin/config/descriptions');
|
||||
|
||||
return v.parse(v.array(pleromaConfigDescriptionSchema), response.json);
|
||||
},
|
||||
|
||||
getPleromaConfig: async () => {
|
||||
const response = await client.request('/api/v1/pleroma/admin/config');
|
||||
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
import * as v from 'valibot';
|
||||
|
||||
/**
|
||||
* @category Admin schemas
|
||||
*/
|
||||
const pleromaConfigDescriptionChildSchema: v.GenericSchema<PleromaConfigDescriptionChild> =
|
||||
v.looseObject({
|
||||
key: v.optional(v.string()),
|
||||
type: v.union([v.string(), v.array(v.string())]),
|
||||
description: v.optional(v.string()),
|
||||
label: v.optional(v.string()),
|
||||
suggestions: v.optional(v.array(v.any())),
|
||||
children: v.optional(v.lazy(() => v.array(pleromaConfigDescriptionChildSchema))),
|
||||
group: v.optional(v.union([v.string(), v.array(v.string())])),
|
||||
});
|
||||
|
||||
/**
|
||||
* @category Admin schemas
|
||||
*/
|
||||
const pleromaConfigDescriptionSchema = v.object({
|
||||
group: v.optional(v.string()),
|
||||
key: v.optional(v.string()),
|
||||
type: v.union([v.string(), v.array(v.string())]),
|
||||
description: v.optional(v.string()),
|
||||
label: v.optional(v.string()),
|
||||
children: v.array(pleromaConfigDescriptionChildSchema),
|
||||
tab: v.optional(v.string()),
|
||||
related_policy: v.optional(v.string()),
|
||||
});
|
||||
|
||||
/**
|
||||
* @category Admin entity types
|
||||
*/
|
||||
type PleromaConfigDescription = v.InferOutput<typeof pleromaConfigDescriptionSchema>;
|
||||
|
||||
/**
|
||||
* @category Admin entity types
|
||||
*/
|
||||
type PleromaConfigDescriptionChild = {
|
||||
key?: string;
|
||||
type: string | string[];
|
||||
description?: string;
|
||||
label?: string;
|
||||
suggestions?: unknown[];
|
||||
children?: PleromaConfigDescriptionChild[];
|
||||
group?: string | string[];
|
||||
};
|
||||
|
||||
export {
|
||||
pleromaConfigDescriptionSchema,
|
||||
pleromaConfigDescriptionChildSchema,
|
||||
type PleromaConfigDescription,
|
||||
type PleromaConfigDescriptionChild,
|
||||
};
|
||||
@ -15,6 +15,7 @@ export * from './admin/ip-block';
|
||||
export * from './admin/measure';
|
||||
export * from './admin/moderation-log-entry';
|
||||
export * from './admin/pleroma-config';
|
||||
export * from './admin/pleroma-config-description';
|
||||
export * from './admin/relay';
|
||||
export * from './admin/report';
|
||||
export * from './admin/rule';
|
||||
|
||||
@ -1361,6 +1361,14 @@ const getFeatures = (instance: Instance) => {
|
||||
*/
|
||||
pleromaAdminAnnouncements: any([v.software === AKKOMA, v.software === PLEROMA]),
|
||||
|
||||
/**
|
||||
* @see GET /api/v1/pleroma/admin/config/descriptions
|
||||
* @see GET /api/v1/pleroma/admin/config
|
||||
* @see POST /api/v1/pleroma/admin/config
|
||||
* @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminconfig}
|
||||
*/
|
||||
pleromaAdminConfig: any([v.software === AKKOMA, v.software === PLEROMA]),
|
||||
|
||||
pleromaAdminModerationLog: any([v.software === AKKOMA, v.software === PLEROMA]),
|
||||
|
||||
pleromaAdminRelays: any([v.software === AKKOMA, v.software === PLEROMA]),
|
||||
|
||||
Reference in New Issue
Block a user