diff --git a/build.ts b/build.ts index 7a168a2..222acf7 100644 --- a/build.ts +++ b/build.ts @@ -2,7 +2,7 @@ import dts from "bun-plugin-dts"; import ora from "ora"; const entrypoints = { - federation: ["index.ts", "validators.ts", "types.ts"], + federation: ["index.ts", "schemas.ts", "types.ts"], client: ["index.ts", "types.ts"], }; diff --git a/federation/index.ts b/federation/index.ts index 0dbbbde..0fde9dd 100644 --- a/federation/index.ts +++ b/federation/index.ts @@ -2,7 +2,7 @@ * @file index.ts * @fileoverview Main entrypoint and export for the module * @module federation - * @see module:federation/validators/base + * @see module:federation/schemas/base */ import type { ValidationError } from "zod-validation-error"; diff --git a/federation/jsr.jsonc b/federation/jsr.jsonc index 90d942b..f74dd7b 100644 --- a/federation/jsr.jsonc +++ b/federation/jsr.jsonc @@ -5,6 +5,6 @@ "exports": { ".": "./index.ts", "./types": "./types.ts", - "./validators": "./validators.ts" + "./schemas": "./schemas.ts" } } diff --git a/federation/package.json b/federation/package.json index a5511c1..fb38a98 100644 --- a/federation/package.json +++ b/federation/package.json @@ -48,10 +48,10 @@ "default": "./dist/types.js", "types": "./dist/types.d.ts" }, - "./validators": { - "import": "./dist/validators.js", - "default": "./dist/validators.js", - "types": "./dist/validators.d.ts" + "./schemas": { + "import": "./dist/schemas.js", + "default": "./dist/schemas.js", + "types": "./dist/schemas.d.ts" } }, "funding": { diff --git a/federation/requester/index.ts b/federation/requester/index.ts index 3a7a530..a347ec8 100644 --- a/federation/requester/index.ts +++ b/federation/requester/index.ts @@ -1,6 +1,6 @@ import { fromZodError } from "zod-validation-error"; import type { SignatureConstructor } from "../cryptography/index.ts"; -import { WebFingerSchema } from "../validators/webfinger.ts"; +import { WebFingerSchema } from "../schemas/webfinger.ts"; import type { User } from "../types.ts"; import { DEFAULT_UA } from "./constants.ts"; diff --git a/federation/schemas.ts b/federation/schemas.ts new file mode 100644 index 0000000..8d064cc --- /dev/null +++ b/federation/schemas.ts @@ -0,0 +1,31 @@ +/** + * @file Zod schema definitions + * @module federation/schemas + */ + +// biome-ignore lint/performance/noBarrelFile: library export +export { + CollectionSchema as Collection, + DeleteSchema as Delete, + EntitySchema as Entity, + FollowAcceptSchema as FollowAccept, + FollowRejectSchema as FollowReject, + FollowSchema as Follow, + GroupSchema as Group, + InstanceMetadataSchema as InstanceMetadata, + NoteSchema as Note, + UnfollowSchema as Unfollow, + UserSchema as User, +} from "./schemas/base.ts"; +export { ContentFormatSchema as ContentFormat } from "./schemas/content_format.ts"; +export { ExtensionPropertySchema as EntityExtensionProperty } from "./schemas/extensions.ts"; +export { CustomEmojiExtensionSchema as CustomEmojiExtension } from "./schemas/extensions/custom_emojis.ts"; +export { + DislikeSchema as DislikeExtension, + LikeSchema as LikeExtension, +} from "./schemas/extensions/likes.ts"; +export { VoteSchema as PollVoteExtension } from "./schemas/extensions/polls.ts"; +export { ReactionSchema as ReactionExtension } from "./schemas/extensions/reactions.ts"; +export { ShareSchema as ShareExtension } from "./schemas/extensions/share.ts"; +export { VanityExtensionSchema as VanityExtension } from "./schemas/extensions/vanity.ts"; +export { WebFingerSchema as WebFinger } from "./schemas/webfinger.ts"; diff --git a/federation/validators/base.ts b/federation/schemas/base.ts similarity index 100% rename from federation/validators/base.ts rename to federation/schemas/base.ts diff --git a/federation/validators/content_format.ts b/federation/schemas/content_format.ts similarity index 100% rename from federation/validators/content_format.ts rename to federation/schemas/content_format.ts diff --git a/federation/validators/extensions.ts b/federation/schemas/extensions.ts similarity index 100% rename from federation/validators/extensions.ts rename to federation/schemas/extensions.ts diff --git a/federation/validators/extensions/custom_emojis.ts b/federation/schemas/extensions/custom_emojis.ts similarity index 100% rename from federation/validators/extensions/custom_emojis.ts rename to federation/schemas/extensions/custom_emojis.ts diff --git a/federation/validators/extensions/likes.ts b/federation/schemas/extensions/likes.ts similarity index 100% rename from federation/validators/extensions/likes.ts rename to federation/schemas/extensions/likes.ts diff --git a/federation/validators/extensions/polls.ts b/federation/schemas/extensions/polls.ts similarity index 100% rename from federation/validators/extensions/polls.ts rename to federation/schemas/extensions/polls.ts diff --git a/federation/validators/extensions/reactions.ts b/federation/schemas/extensions/reactions.ts similarity index 100% rename from federation/validators/extensions/reactions.ts rename to federation/schemas/extensions/reactions.ts diff --git a/federation/validators/extensions/share.ts b/federation/schemas/extensions/share.ts similarity index 100% rename from federation/validators/extensions/share.ts rename to federation/schemas/extensions/share.ts diff --git a/federation/validators/extensions/vanity.ts b/federation/schemas/extensions/vanity.ts similarity index 100% rename from federation/validators/extensions/vanity.ts rename to federation/schemas/extensions/vanity.ts diff --git a/federation/validators/regex.ts b/federation/schemas/regex.ts similarity index 100% rename from federation/validators/regex.ts rename to federation/schemas/regex.ts diff --git a/federation/validators/webfinger.ts b/federation/schemas/webfinger.ts similarity index 100% rename from federation/validators/webfinger.ts rename to federation/schemas/webfinger.ts diff --git a/federation/types.ts b/federation/types.ts index 1a66e65..daecd86 100644 --- a/federation/types.ts +++ b/federation/types.ts @@ -16,18 +16,15 @@ import type { NoteSchema, UnfollowSchema, UserSchema, -} from "./validators/base.ts"; -import type { ContentFormatSchema } from "./validators/content_format.ts"; -import type { ExtensionPropertySchema } from "./validators/extensions.ts"; -import type { CustomEmojiExtensionSchema } from "./validators/extensions/custom_emojis.ts"; -import type { - DislikeSchema, - LikeSchema, -} from "./validators/extensions/likes.ts"; -import type { VoteSchema } from "./validators/extensions/polls.ts"; -import type { ReactionSchema } from "./validators/extensions/reactions.ts"; -import type { ShareSchema } from "./validators/extensions/share.ts"; -import type { VanityExtensionSchema } from "./validators/extensions/vanity.ts"; +} from "./schemas/base.ts"; +import type { ContentFormatSchema } from "./schemas/content_format.ts"; +import type { ExtensionPropertySchema } from "./schemas/extensions.ts"; +import type { CustomEmojiExtensionSchema } from "./schemas/extensions/custom_emojis.ts"; +import type { DislikeSchema, LikeSchema } from "./schemas/extensions/likes.ts"; +import type { VoteSchema } from "./schemas/extensions/polls.ts"; +import type { ReactionSchema } from "./schemas/extensions/reactions.ts"; +import type { ShareSchema } from "./schemas/extensions/share.ts"; +import type { VanityExtensionSchema } from "./schemas/extensions/vanity.ts"; // biome-ignore lint/suspicious/noExplicitAny: Used only as a base type type AnyZod = z.ZodType; diff --git a/federation/validator.ts b/federation/validator.ts index d4f6fb1..da5fc37 100644 --- a/federation/validator.ts +++ b/federation/validator.ts @@ -12,15 +12,15 @@ import { NoteSchema, UnfollowSchema, UserSchema, -} from "./validators/base.ts"; -import { ContentFormatSchema } from "./validators/content_format.ts"; -import { ExtensionPropertySchema } from "./validators/extensions.ts"; -import { CustomEmojiExtensionSchema } from "./validators/extensions/custom_emojis.ts"; -import { DislikeSchema, LikeSchema } from "./validators/extensions/likes.ts"; -import { VoteSchema } from "./validators/extensions/polls.ts"; -import { ReactionSchema } from "./validators/extensions/reactions.ts"; -import { ShareSchema } from "./validators/extensions/share.ts"; -import { VanityExtensionSchema } from "./validators/extensions/vanity.ts"; +} from "./schemas/base.ts"; +import { ContentFormatSchema } from "./schemas/content_format.ts"; +import { ExtensionPropertySchema } from "./schemas/extensions.ts"; +import { CustomEmojiExtensionSchema } from "./schemas/extensions/custom_emojis.ts"; +import { DislikeSchema, LikeSchema } from "./schemas/extensions/likes.ts"; +import { VoteSchema } from "./schemas/extensions/polls.ts"; +import { ReactionSchema } from "./schemas/extensions/reactions.ts"; +import { ShareSchema } from "./schemas/extensions/share.ts"; +import { VanityExtensionSchema } from "./schemas/extensions/vanity.ts"; import type { Collection, ContentFormat, @@ -52,7 +52,7 @@ type InferType = z.infer; /** * Validates entities against their respective schemas. * @module federation/validator - * @see module:federation/validators/base + * @see module:federation/schemas/base * @example * import { EntityValidator, type ValidationError } from "@versia/federation"; * const validator = new EntityValidator(); diff --git a/federation/validators.ts b/federation/validators.ts deleted file mode 100644 index e025ebe..0000000 --- a/federation/validators.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file Zod schema definitions - * @module federation/schemas - */ - -import { - CollectionSchema, - DeleteSchema, - EntitySchema, - FollowAcceptSchema, - FollowRejectSchema, - FollowSchema, - GroupSchema, - InstanceMetadataSchema, - NoteSchema, - UnfollowSchema, - UserSchema, -} from "./validators/base.ts"; -import { ContentFormatSchema } from "./validators/content_format.ts"; -import { ExtensionPropertySchema } from "./validators/extensions.ts"; -import { CustomEmojiExtensionSchema } from "./validators/extensions/custom_emojis.ts"; -import { DislikeSchema, LikeSchema } from "./validators/extensions/likes.ts"; -import { VoteSchema } from "./validators/extensions/polls.ts"; -import { ReactionSchema } from "./validators/extensions/reactions.ts"; -import { ShareSchema } from "./validators/extensions/share.ts"; -import { VanityExtensionSchema } from "./validators/extensions/vanity.ts"; -import { WebFingerSchema } from "./validators/webfinger.ts"; - -export { - NoteSchema as Note, - CollectionSchema as Collection, - EntitySchema as Entity, - FollowSchema as Follow, - UnfollowSchema as Unfollow, - FollowAcceptSchema as FollowAccept, - FollowRejectSchema as FollowReject, - GroupSchema as Group, - InstanceMetadataSchema as InstanceMetadata, - UserSchema as User, - ContentFormatSchema as ContentFormat, - ExtensionPropertySchema as EntityExtensionProperty, - CustomEmojiExtensionSchema as CustomEmojiExtension, - DeleteSchema as Delete, - VanityExtensionSchema as VanityExtension, - LikeSchema as LikeExtension, - DislikeSchema as DislikeExtension, - VoteSchema as PollVoteExtension, - ReactionSchema as ReactionExtension, - ShareSchema as ShareExtension, - WebFingerSchema as WebFinger, -};