@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { accountSchema } from './account';
|
||||
import { dateSchema } from './utils';
|
||||
|
||||
@@ -22,6 +20,6 @@ const accountWarningSchema = z.object({
|
||||
created_at: dateSchema,
|
||||
});
|
||||
|
||||
type AccountWarning = Resolve<z.infer<typeof accountWarningSchema>>;
|
||||
type AccountWarning = z.infer<typeof accountWarningSchema>;
|
||||
|
||||
export { accountWarningSchema, type AccountWarning };
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import pick from 'lodash.pick';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../../utils/types';
|
||||
import { announcementSchema } from '../announcement';
|
||||
|
||||
/** @see {@link https://docs.pleroma.social/backend/development/API/admin_api/#get-apiv1pleromaadminannouncements} */
|
||||
@@ -12,6 +11,6 @@ const adminAnnouncementSchema = z.preprocess((announcement: any) => ({
|
||||
raw_content: z.string().catch(''),
|
||||
}));
|
||||
|
||||
type AdminAnnouncement = Resolve<z.infer<typeof adminAnnouncementSchema>>;
|
||||
type AdminAnnouncement = z.infer<typeof adminAnnouncementSchema>;
|
||||
|
||||
export { adminAnnouncementSchema, type AdminAnnouncement };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/announcement/} */
|
||||
const announcementReactionSchema = z.object({
|
||||
name: z.string().catch(''),
|
||||
@@ -12,6 +10,6 @@ const announcementReactionSchema = z.object({
|
||||
announcement_id: z.string().catch(''),
|
||||
});
|
||||
|
||||
type AnnouncementReaction = Resolve<z.infer<typeof announcementReactionSchema>>;
|
||||
type AnnouncementReaction = z.infer<typeof announcementReactionSchema>;
|
||||
|
||||
export { announcementReactionSchema, type AnnouncementReaction };
|
||||
|
||||
@@ -6,8 +6,6 @@ import { mentionSchema } from './mention';
|
||||
import { tagSchema } from './tag';
|
||||
import { dateSchema, filteredArray } from './utils';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/announcement/} */
|
||||
const announcementSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -30,6 +28,6 @@ const announcementSchema = z.object({
|
||||
updated_at: dateSchema,
|
||||
});
|
||||
|
||||
type Announcement = Resolve<z.infer<typeof announcementSchema>>;
|
||||
type Announcement = z.infer<typeof announcementSchema>;
|
||||
|
||||
export { announcementSchema, type Announcement };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/Application/} */
|
||||
const applicationSchema = z.object({
|
||||
name: z.string().catch(''),
|
||||
@@ -16,6 +14,6 @@ const applicationSchema = z.object({
|
||||
vapid_key: z.string().optional().catch(undefined),
|
||||
});
|
||||
|
||||
type Application = Resolve<z.infer<typeof applicationSchema>>;
|
||||
type Application = z.infer<typeof applicationSchema>;
|
||||
|
||||
export { applicationSchema, type Application };
|
||||
|
||||
@@ -2,8 +2,6 @@ import { z } from 'zod';
|
||||
|
||||
import { dateSchema, mimeSchema } from './utils';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
/** @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#post-apiv1pleromabackups} */
|
||||
const backupSchema = z.object({
|
||||
id: z.coerce.string(),
|
||||
@@ -14,6 +12,6 @@ const backupSchema = z.object({
|
||||
url: z.string().catch(''),
|
||||
});
|
||||
|
||||
type Backup = Resolve<z.infer<typeof backupSchema>>;
|
||||
type Backup = z.infer<typeof backupSchema>;
|
||||
|
||||
export { backupSchema, type Backup };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
const bookmarkFolderSchema = z.object({
|
||||
id: z.coerce.string(),
|
||||
name: z.string().catch(''),
|
||||
@@ -9,6 +7,6 @@ const bookmarkFolderSchema = z.object({
|
||||
emoji_url: z.string().nullable().catch(null),
|
||||
});
|
||||
|
||||
type BookmarkFolder = Resolve<z.infer<typeof bookmarkFolderSchema>>;
|
||||
type BookmarkFolder = z.infer<typeof bookmarkFolderSchema>;
|
||||
|
||||
export { bookmarkFolderSchema, type BookmarkFolder };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { statusSchema } from './status';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/Context/} */
|
||||
@@ -10,6 +8,6 @@ const contextSchema = z.object({
|
||||
descendants: z.array(statusSchema),
|
||||
});
|
||||
|
||||
type Context = Resolve<z.infer<typeof contextSchema>>;
|
||||
type Context = z.infer<typeof contextSchema>;
|
||||
|
||||
export { contextSchema, type Context };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { filterSchema } from './filter';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/FilterResult/} */
|
||||
@@ -11,6 +9,6 @@ const filterResultSchema = z.object({
|
||||
status_matches: z.array(z.string()).nullable().catch(null),
|
||||
});
|
||||
|
||||
type FilterResult = Resolve<z.infer<typeof filterResultSchema>>;
|
||||
type FilterResult = z.infer<typeof filterResultSchema>;
|
||||
|
||||
export { filterResultSchema, type FilterResult };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { filteredArray } from './utils';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/FilterKeyword/} */
|
||||
@@ -42,6 +40,6 @@ const filterSchema = z.preprocess((filter: any) => {
|
||||
statuses: filteredArray(filterStatusSchema),
|
||||
}));
|
||||
|
||||
type Filter = Resolve<z.infer<typeof filterSchema>>;
|
||||
type Filter = z.infer<typeof filterSchema>;
|
||||
|
||||
export { filterKeywordSchema, filterStatusSchema, filterSchema, type Filter };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { coerceObject } from './utils';
|
||||
|
||||
const interactionPolicyEntrySchema = z.enum(['public', 'followers', 'following', 'mutuals', 'mentioned', 'author', 'me']);
|
||||
@@ -18,7 +16,7 @@ const interactionPolicySchema = coerceObject({
|
||||
can_reply: interactionPolicyRuleSchema,
|
||||
});
|
||||
|
||||
type InteractionPolicy = Resolve<z.infer<typeof interactionPolicySchema>>;
|
||||
type InteractionPolicy = z.infer<typeof interactionPolicySchema>;
|
||||
|
||||
const interactionPoliciesSchema = coerceObject({
|
||||
public: interactionPolicySchema,
|
||||
@@ -27,7 +25,7 @@ const interactionPoliciesSchema = coerceObject({
|
||||
direct: interactionPolicySchema,
|
||||
});
|
||||
|
||||
type InteractionPolicies = Resolve<z.infer<typeof interactionPoliciesSchema>>;
|
||||
type InteractionPolicies = z.infer<typeof interactionPoliciesSchema>;
|
||||
|
||||
export { interactionPolicySchema, interactionPoliciesSchema, type InteractionPolicy, type InteractionPolicies };
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { accountSchema } from './account';
|
||||
import { statusSchema } from './status';
|
||||
|
||||
@@ -18,6 +16,6 @@ const interactionRequestSchema = z.object({
|
||||
uri: z.string().nullable().catch(null),
|
||||
});
|
||||
|
||||
type InteractionRequest = Resolve<z.infer<typeof interactionRequestSchema>>;
|
||||
type InteractionRequest = z.infer<typeof interactionRequestSchema>;
|
||||
|
||||
export { interactionRequestSchema, type InteractionRequest };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { dateSchema } from './utils';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/RelationshipSeveranceEvent/} */
|
||||
@@ -13,6 +11,6 @@ const relationshipSeveranceEventSchema = z.object({
|
||||
created_at: dateSchema,
|
||||
});
|
||||
|
||||
type RelationshipSeveranceEvent = Resolve<z.infer<typeof relationshipSeveranceEventSchema>>;
|
||||
type RelationshipSeveranceEvent = z.infer<typeof relationshipSeveranceEventSchema>;
|
||||
|
||||
export { relationshipSeveranceEventSchema, type RelationshipSeveranceEvent };
|
||||
|
||||
@@ -3,8 +3,6 @@ import { z } from 'zod';
|
||||
import { mediaAttachmentSchema } from './media-attachment';
|
||||
import { filteredArray } from './utils';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/ScheduledStatus/} */
|
||||
const scheduledStatusSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -33,6 +31,6 @@ const scheduledStatusSchema = z.object({
|
||||
media_attachments: filteredArray(mediaAttachmentSchema),
|
||||
});
|
||||
|
||||
type ScheduledStatus = Resolve<z.infer<typeof scheduledStatusSchema>>;
|
||||
type ScheduledStatus = z.infer<typeof scheduledStatusSchema>;
|
||||
|
||||
export { scheduledStatusSchema, type ScheduledStatus };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { accountSchema } from './account';
|
||||
import { customEmojiSchema } from './custom-emoji';
|
||||
import { mediaAttachmentSchema } from './media-attachment';
|
||||
@@ -23,6 +21,6 @@ const statusEditSchema = z.object({
|
||||
emojis: filteredArray(customEmojiSchema),
|
||||
});
|
||||
|
||||
type StatusEdit = Resolve<z.infer<typeof statusEditSchema>>;
|
||||
type StatusEdit = z.infer<typeof statusEditSchema>;
|
||||
|
||||
export { statusEditSchema, type StatusEdit };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { locationSchema } from './location';
|
||||
|
||||
/** @see {@link https://docs.joinmastodon.org/entities/StatusSource/} */
|
||||
@@ -17,6 +15,6 @@ const statusSourceSchema = z.object({
|
||||
spoiler_text_map: z.record(z.string()).nullable().catch(null),
|
||||
});
|
||||
|
||||
type StatusSource = Resolve<z.infer<typeof statusSourceSchema>>;
|
||||
type StatusSource = z.infer<typeof statusSourceSchema>;
|
||||
|
||||
export { statusSourceSchema, type StatusSource };
|
||||
|
||||
@@ -15,8 +15,6 @@ import { tagSchema } from './tag';
|
||||
import { translationSchema } from './translation';
|
||||
import { dateSchema, filteredArray } from './utils';
|
||||
|
||||
import type { Resolve } from '../utils/types';
|
||||
|
||||
const statusEventSchema = z.object({
|
||||
name: z.string().catch(''),
|
||||
start_time: z.string().datetime().nullable().catch(null),
|
||||
@@ -133,19 +131,22 @@ const preprocess = (status: any) => {
|
||||
return status;
|
||||
};
|
||||
|
||||
const statusSchema = z.preprocess(preprocess, baseStatusSchema.extend({
|
||||
reblog: z.lazy(() => baseStatusSchema).nullable().catch(null),
|
||||
const statusSchema: z.ZodType<Status> = baseStatusSchema.extend({
|
||||
reblog: z.lazy(() => statusSchema).nullable().catch(null),
|
||||
|
||||
quote: z.lazy(() => baseStatusSchema).nullable().catch(null),
|
||||
}));
|
||||
quote: z.lazy(() => statusSchema).nullable().catch(null),
|
||||
}) as any;
|
||||
|
||||
const statusWithoutAccountSchema = z.preprocess(preprocess, baseStatusSchema.omit({ account: true }).extend({
|
||||
account: accountSchema.nullable().catch(null),
|
||||
reblog: z.lazy(() => baseStatusSchema).nullable().catch(null),
|
||||
reblog: z.lazy(() => statusSchema).nullable().catch(null),
|
||||
|
||||
quote: z.lazy(() => baseStatusSchema).nullable().catch(null),
|
||||
quote: z.lazy(() => statusSchema).nullable().catch(null),
|
||||
}));
|
||||
|
||||
type Status = Resolve<z.infer<typeof statusSchema>>;
|
||||
type Status = z.infer<typeof baseStatusSchema> & {
|
||||
reblog: Status | null;
|
||||
quote: Status | null;
|
||||
}
|
||||
|
||||
export { statusSchema, statusWithoutAccountSchema, type Status };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Resolve } from '../utils/types';
|
||||
|
||||
import { filteredArray } from './utils';
|
||||
|
||||
const translationPollSchema = z.object({
|
||||
@@ -39,6 +37,6 @@ const translationSchema = z.preprocess((translation: any) => {
|
||||
provider: z.string(),
|
||||
}));
|
||||
|
||||
type Translation = Resolve<z.infer<typeof translationSchema>>;
|
||||
type Translation = z.infer<typeof translationSchema>;
|
||||
|
||||
export { translationSchema, type Translation };
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/**
|
||||
* Resolve a type into a flat POJO interface if it's been wrapped by generics.
|
||||
* https://gleasonator.com/@alex/posts/AWfK4hyppMDCqrT2y8
|
||||
*/
|
||||
type Resolve<T> = Pick<T, keyof T>;
|
||||
|
||||
export type { Resolve };
|
||||
@@ -19,7 +19,5 @@ const buildFullPath = (requestedURL: string, baseURL?: string, params?: Record<s
|
||||
};
|
||||
|
||||
export {
|
||||
isAbsoluteURL,
|
||||
combineURLs,
|
||||
buildFullPath,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pl-api",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"type": "module",
|
||||
"homepage": "https://github.com/mkljczk/pl-fe/tree/fork/packages/pl-api",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user