pl-api: try to work on tree-shaking, i guess

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk
2025-01-02 15:41:08 +01:00
parent 781fb7a86d
commit e3fc390fc6
11 changed files with 512 additions and 359 deletions

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@ export * from './backup';
export * from './bookmark-folder';
export * from './chat';
export * from './chat-message';
export * from './circle';
export * from './context';
export * from './conversation';
export * from './custom-emoji';
@ -57,6 +58,7 @@ export * from './notification-request';
export * from './oauth-token';
export * from './poll';
export * from './preview-card';
export * from './preview-card-author';
export * from './relationship';
export * from './relationship-severance-event';
export * from './report';

View File

@ -5,3 +5,5 @@ export * from './entities';
export * from './features';
export * from './params';
export * from './responses';
export * from './schemas';
export * from './schemas/all-schemas';

View File

@ -0,0 +1,193 @@
import {
accountSchema,
accountWarningSchema,
adminAccountSchema,
adminAnnouncementSchema,
adminCanonicalEmailBlockSchema,
adminCohortSchema,
adminDimensionSchema,
adminDomainAllowSchema,
adminDomainBlockSchema,
adminDomainSchema,
adminEmailDomainBlockSchema,
adminIpBlockSchema,
adminIpSchema,
adminMeasureSchema,
adminModerationLogEntrySchema,
adminRelaySchema,
adminReportSchema,
adminRuleSchema,
adminTagSchema,
announcementReactionSchema,
announcementSchema,
antennaSchema,
applicationSchema,
backupSchema,
blurhashSchema,
bookmarkFolderSchema,
chatMessageSchema,
chatSchema,
circleSchema,
contextSchema,
conversationSchema,
credentialAccountSchema,
credentialApplicationSchema,
customEmojiSchema,
domainBlockSchema,
emojiReactionSchema,
extendedDescriptionSchema,
familiarFollowersSchema,
featuredTagSchema,
filterKeywordSchema,
filterSchema,
filterStatusSchema,
followRelationshipUpdateSchema,
groupedNotificationsResultsSchema,
groupMemberSchema,
groupRelationshipSchema,
groupSchema,
historySchema,
instanceSchema,
interactionPoliciesSchema,
interactionPolicySchema,
interactionRequestSchema,
listSchema,
locationSchema,
markerSchema,
markersSchema,
mediaAttachmentSchema,
mentionSchema,
mutedAccountSchema,
notificationGroupSchema,
notificationPolicySchema,
notificationRequestSchema,
notificationSchema,
oauthTokenSchema,
pleromaConfigSchema,
pollSchema,
previewCardAuthorSchema,
previewCardSchema,
relationshipSchema,
relationshipSeveranceEventSchema,
reportSchema,
roleSchema,
ruleSchema,
scheduledStatusSchema,
scrobbleSchema,
searchSchema,
statusEditSchema,
statusSchema,
statusSourceSchema,
statusWithoutAccountSchema,
streamingEventSchema,
suggestionSchema,
tagSchema,
tokenSchema,
translationSchema,
trendsLinkSchema,
webPushSubscriptionSchema,
} from '../entities';
const NON_ADMIN_SCHEMAS = {
accountSchema,
accountWarningSchema,
announcementReactionSchema,
announcementSchema,
antennaSchema,
applicationSchema,
backupSchema,
blurhashSchema,
bookmarkFolderSchema,
chatMessageSchema,
chatSchema,
circleSchema,
contextSchema,
conversationSchema,
credentialAccountSchema,
credentialApplicationSchema,
customEmojiSchema,
domainBlockSchema,
emojiReactionSchema,
extendedDescriptionSchema,
familiarFollowersSchema,
featuredTagSchema,
filterKeywordSchema,
filterSchema,
filterStatusSchema,
followRelationshipUpdateSchema,
groupedNotificationsResultsSchema,
groupMemberSchema,
groupRelationshipSchema,
groupSchema,
historySchema,
instanceSchema,
interactionPoliciesSchema,
interactionPolicySchema,
interactionRequestSchema,
listSchema,
locationSchema,
markerSchema,
markersSchema,
mediaAttachmentSchema,
mentionSchema,
mutedAccountSchema,
notificationGroupSchema,
notificationPolicySchema,
notificationRequestSchema,
notificationSchema,
oauthTokenSchema,
pollSchema,
previewCardAuthorSchema,
previewCardSchema,
relationshipSchema,
relationshipSeveranceEventSchema,
reportSchema,
roleSchema,
ruleSchema,
scheduledStatusSchema,
scrobbleSchema,
searchSchema,
statusEditSchema,
statusSchema,
statusSourceSchema,
statusWithoutAccountSchema,
streamingEventSchema,
suggestionSchema,
tagSchema,
tokenSchema,
translationSchema,
trendsLinkSchema,
webPushSubscriptionSchema,
};
const ADMIN_SCHEMAS = {
adminAccountSchema,
adminAnnouncementSchema,
adminCanonicalEmailBlockSchema,
adminCohortSchema,
adminDimensionSchema,
adminDomainAllowSchema,
adminDomainBlockSchema,
adminDomainSchema,
adminEmailDomainBlockSchema,
adminIpBlockSchema,
adminIpSchema,
adminMeasureSchema,
adminModerationLogEntrySchema,
adminRelaySchema,
adminReportSchema,
adminRuleSchema,
adminTagSchema,
pleromaConfigSchema,
};
const ALL_SCHEMAS = {
...ADMIN_SCHEMAS,
...NON_ADMIN_SCHEMAS,
};
export {
ALL_SCHEMAS,
ADMIN_SCHEMAS,
NON_ADMIN_SCHEMAS,
};

View File

@ -0,0 +1,17 @@
import * as v from 'valibot';
import type { ALL_SCHEMAS } from './all-schemas';
const nullSchema = v.fallback(v.null(), null);
const IMPORTED_SCHEMAS = {} as typeof ALL_SCHEMAS;
const SCHEMAS = new Proxy(IMPORTED_SCHEMAS, {
get: (target, p: keyof typeof ALL_SCHEMAS) => p in target ? target[p] : nullSchema,
});
const importSchemas = (schemas: Partial<typeof ALL_SCHEMAS>) =>
// @ts-ignore
Object.entries(schemas).forEach(([key, value]) => IMPORTED_SCHEMAS[key] = value);
export { SCHEMAS, importSchemas };