pl-api: nice

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-05-27 20:49:04 +02:00
parent 67b8319146
commit 68651ed975
8 changed files with 62 additions and 17 deletions

View File

@@ -1,6 +1,8 @@
import * as v from 'valibot';
import { filterSchema } from './filter';
import { baseFilterSchema } from './filter';
const filterSchema = v.omit(baseFilterSchema, ['keywords', 'statuses']);
/**
* @category Schemas

View File

@@ -21,6 +21,16 @@ const filterStatusSchema = v.object({
status_id: v.string(),
});
const baseFilterSchema = v.object({
id: v.string(),
title: v.string(),
context: v.array(v.picklist(['home', 'notifications', 'public', 'thread', 'account'])),
expires_at: v.fallback(v.nullable(datetimeSchema), null),
filter_action: v.fallback(v.picklist(['warn', 'hide', 'blur']), 'warn'),
keywords: filteredArray(filterKeywordSchema),
statuses: filteredArray(filterStatusSchema),
});
/**
* @category Schemas
* @see {@link https://docs.joinmastodon.org/entities/Filter/}
@@ -42,15 +52,7 @@ const filterSchema = v.pipe(
}
return filter;
}),
v.object({
id: v.string(),
title: v.string(),
context: v.array(v.picklist(['home', 'notifications', 'public', 'thread', 'account'])),
expires_at: v.fallback(v.nullable(datetimeSchema), null),
filter_action: v.fallback(v.picklist(['warn', 'hide', 'blur']), 'warn'),
keywords: v.optional(filteredArray(filterKeywordSchema), undefined),
statuses: v.optional(filteredArray(filterStatusSchema), undefined),
}),
baseFilterSchema,
);
/**
@@ -58,4 +60,4 @@ const filterSchema = v.pipe(
*/
type Filter = v.InferOutput<typeof filterSchema>;
export { filterKeywordSchema, filterStatusSchema, filterSchema, type Filter };
export { filterKeywordSchema, filterStatusSchema, baseFilterSchema, filterSchema, type Filter };

View File

@@ -0,0 +1,19 @@
import * as v from 'valibot';
import { datetimeSchema } from './utils';
/**
* @category Schemas
* @see {@link https://docs.joinmastodon.org/entities/PrivacyPolicy/}
*/
const privacyPolicySchema = v.object({
updated_at: datetimeSchema,
content: v.string(),
});
/**
* @category Entity types
*/
type PrivacyPolicy = v.InferOutput<typeof privacyPolicySchema>;
export { privacyPolicySchema, type PrivacyPolicy };

View File

@@ -0,0 +1,21 @@
import * as v from 'valibot';
import { dateSchema } from './utils';
/**
* @category Schemas
* @see {@link https://docs.joinmastodon.org/entities/TermfsOfService/}
*/
const termfsOfServiceSchema = v.object({
effective_date: dateSchema,
effective: v.boolean(),
content: v.string(),
succeeded_by: v.fallback(v.nullable(dateSchema), null),
});
/**
* @category Entity types
*/
type TermfsOfService = v.InferOutput<typeof termfsOfServiceSchema>;
export { termfsOfServiceSchema, type TermfsOfService };

View File

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