pl-api: More blind search and replace before actual testing

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-10-14 20:54:44 +02:00
parent a6bc160caa
commit ea3addf388
47 changed files with 253 additions and 251 deletions

View File

@@ -42,7 +42,7 @@ const adminAccountSchema = z.preprocess((account: any) => {
domain: v.fallback(v.nullable(v.string()), null),
created_at: dateSchema,
email: v.fallback(v.nullable(v.string()), null),
ip: z.string().ip().nullable().catch(null),
ip: v.fallback(v.nullable(z.string().ip()), null),
ips: filteredArray(adminIpSchema),
locale: v.fallback(v.nullable(v.string()), null),
invite_request: v.fallback(v.nullable(v.string()), null),
@@ -58,7 +58,7 @@ const adminAccountSchema = z.preprocess((account: any) => {
actor_type: v.fallback(v.nullable(v.string()), null),
display_name: v.fallback(v.nullable(v.string()), null),
suggested: v.fallback(v.optional(v.nullable()), null),
suggested: v.fallback(v.nullable(v.boolean()), null),
}));
type AdminAccount = v.InferOutput<typeof adminAccountSchema>;

View File

@@ -3,11 +3,11 @@ import * as v from 'valibot';
/** @see {@link https://docs.joinmastodon.org/entities/Admin_Cohort/} */
const adminCohortSchema = v.object({
period: z.string().datetime({ offset: true }),
frequency: z.enum(['day', 'month']),
frequency: v.picklist(['day', 'month']),
data: z.array(v.object({
date: z.string().datetime({ offset: true }),
rate: z.number(),
value: z.number().int(),
rate: v.number(),
value: v.pipe(v.number(), v.integer()),
})),
});

View File

@@ -8,7 +8,7 @@ const adminDomainBlockSchema = v.object({
domain: v.string(),
digest: v.string(),
created_at: dateSchema,
severity: z.enum(['silence', 'suspend', 'noop']),
severity: v.picklist(['silence', 'suspend', 'noop']),
reject_media: v.boolean(),
reject_reports: v.boolean(),
private_comment: v.fallback(v.nullable(v.string()), null),

View File

@@ -6,7 +6,7 @@ import { dateSchema } from '../utils';
const adminIpBlockSchema = v.object({
id: v.string(),
ip: z.string().ip(),
severity: z.enum(['sign_up_requires_approval', 'sign_up_block', 'no_access']),
severity: v.picklist(['sign_up_requires_approval', 'sign_up_block', 'no_access']),
comment: v.fallback(v.string(), ''),
created_at: dateSchema,
expires_at: z.string().datetime({ offset: true }),

View File

@@ -3,7 +3,7 @@ import * as v from 'valibot';
/** @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminmoderation_log} */
const adminModerationLogEntrySchema = v.object({
id: z.coerce.string(),
data: z.record(v.string(), z.any()).catch({}),
data: v.fallback(v.record(v.string(), v.any()), {}),
time: v.fallback(v.number(), 0),
message: v.fallback(v.string(), ''),
});

View File

@@ -1,8 +1,8 @@
import * as v from 'valibot';
const pleromaConfigSchema = v.object({
configs: z.array(v.object({
value: z.any(),
configs: v.array(v.object({
value: v.any(),
group: v.string(),
key: v.string(),
})),

View File

@@ -31,8 +31,8 @@ const adminReportSchema = z.preprocess((report: any) => {
category: v.fallback(v.optional(v.string()), undefined),
comment: v.fallback(v.optional(v.string()), undefined),
forwarded: v.fallback(v.optional(v.boolean()), undefined),
created_at: dateSchema.optional().catch(undefined),
updated_at: dateSchema.optional().catch(undefined),
created_at: v.fallback(v.optional(dateSchema), undefined),
updated_at: v.fallback(v.optional(dateSchema), undefined),
account: adminAccountSchema,
target_account: adminAccountSchema,
assigned_account: v.fallback(v.nullable(adminAccountSchema), null),