From f80cffd01aa7105c2a84a88a9f178c3d647520a9 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Sun, 22 Sep 2024 17:15:19 +0200 Subject: [PATCH] refactor(federation): :truck: Rename schemas to validators Fixes issues with Bun bundling --- build.ts | 2 +- federation/index.ts | 2 +- federation/jsr.jsonc | 2 +- federation/package.json | 8 +++---- federation/requester/index.ts | 2 +- federation/types.ts | 21 +++++++++++-------- federation/validator.ts | 20 +++++++++--------- federation/{schemas.ts => validators.ts} | 20 +++++++++--------- federation/{schemas => validators}/base.ts | 0 .../{schemas => validators}/content_format.ts | 0 .../{schemas => validators}/extensions.ts | 0 .../extensions/custom_emojis.ts | 0 .../extensions/likes.ts | 0 .../extensions/polls.ts | 0 .../extensions/reactions.ts | 0 .../extensions/share.ts | 0 .../extensions/vanity.ts | 0 federation/{schemas => validators}/regex.ts | 0 .../{schemas => validators}/webfinger.ts | 0 19 files changed, 40 insertions(+), 37 deletions(-) rename federation/{schemas.ts => validators.ts} (61%) rename federation/{schemas => validators}/base.ts (100%) rename federation/{schemas => validators}/content_format.ts (100%) rename federation/{schemas => validators}/extensions.ts (100%) rename federation/{schemas => validators}/extensions/custom_emojis.ts (100%) rename federation/{schemas => validators}/extensions/likes.ts (100%) rename federation/{schemas => validators}/extensions/polls.ts (100%) rename federation/{schemas => validators}/extensions/reactions.ts (100%) rename federation/{schemas => validators}/extensions/share.ts (100%) rename federation/{schemas => validators}/extensions/vanity.ts (100%) rename federation/{schemas => validators}/regex.ts (100%) rename federation/{schemas => validators}/webfinger.ts (100%) diff --git a/build.ts b/build.ts index 222acf7..7a168a2 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", "schemas.ts", "types.ts"], + federation: ["index.ts", "validators.ts", "types.ts"], client: ["index.ts", "types.ts"], }; diff --git a/federation/index.ts b/federation/index.ts index 0fde9dd..0dbbbde 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/schemas/base + * @see module:federation/validators/base */ import type { ValidationError } from "zod-validation-error"; diff --git a/federation/jsr.jsonc b/federation/jsr.jsonc index 2438ba0..bcdedeb 100644 --- a/federation/jsr.jsonc +++ b/federation/jsr.jsonc @@ -5,6 +5,6 @@ "exports": { ".": "./index.ts", "./types": "./types.ts", - "./schemas": "./schemas.ts" + "./validators": "./validators.ts" } } diff --git a/federation/package.json b/federation/package.json index 04e1dce..1783e72 100644 --- a/federation/package.json +++ b/federation/package.json @@ -48,10 +48,10 @@ "default": "./dist/types.js", "types": "./dist/types.d.ts" }, - "./schemas": { - "import": "./dist/schemas.js", - "default": "./dist/schemas.js", - "types": "./dist/schemas.d.ts" + "./validators": { + "import": "./dist/validators.js", + "default": "./dist/validators.js", + "types": "./dist/validators.d.ts" } }, "funding": { diff --git a/federation/requester/index.ts b/federation/requester/index.ts index a347ec8..3a7a530 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 "../schemas/webfinger.ts"; +import { WebFingerSchema } from "../validators/webfinger.ts"; import type { User } from "../types.ts"; import { DEFAULT_UA } from "./constants.ts"; diff --git a/federation/types.ts b/federation/types.ts index daecd86..1a66e65 100644 --- a/federation/types.ts +++ b/federation/types.ts @@ -16,15 +16,18 @@ import type { NoteSchema, UnfollowSchema, UserSchema, -} 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"; +} 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"; // 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 da5fc37..d4f6fb1 100644 --- a/federation/validator.ts +++ b/federation/validator.ts @@ -12,15 +12,15 @@ import { NoteSchema, UnfollowSchema, UserSchema, -} 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"; +} 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 type { Collection, ContentFormat, @@ -52,7 +52,7 @@ type InferType = z.infer; /** * Validates entities against their respective schemas. * @module federation/validator - * @see module:federation/schemas/base + * @see module:federation/validators/base * @example * import { EntityValidator, type ValidationError } from "@versia/federation"; * const validator = new EntityValidator(); diff --git a/federation/schemas.ts b/federation/validators.ts similarity index 61% rename from federation/schemas.ts rename to federation/validators.ts index d292e6a..e025ebe 100644 --- a/federation/schemas.ts +++ b/federation/validators.ts @@ -15,16 +15,16 @@ import { NoteSchema, UnfollowSchema, UserSchema, -} 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 { WebFingerSchema } from "./schemas/webfinger.ts"; +} 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, diff --git a/federation/schemas/base.ts b/federation/validators/base.ts similarity index 100% rename from federation/schemas/base.ts rename to federation/validators/base.ts diff --git a/federation/schemas/content_format.ts b/federation/validators/content_format.ts similarity index 100% rename from federation/schemas/content_format.ts rename to federation/validators/content_format.ts diff --git a/federation/schemas/extensions.ts b/federation/validators/extensions.ts similarity index 100% rename from federation/schemas/extensions.ts rename to federation/validators/extensions.ts diff --git a/federation/schemas/extensions/custom_emojis.ts b/federation/validators/extensions/custom_emojis.ts similarity index 100% rename from federation/schemas/extensions/custom_emojis.ts rename to federation/validators/extensions/custom_emojis.ts diff --git a/federation/schemas/extensions/likes.ts b/federation/validators/extensions/likes.ts similarity index 100% rename from federation/schemas/extensions/likes.ts rename to federation/validators/extensions/likes.ts diff --git a/federation/schemas/extensions/polls.ts b/federation/validators/extensions/polls.ts similarity index 100% rename from federation/schemas/extensions/polls.ts rename to federation/validators/extensions/polls.ts diff --git a/federation/schemas/extensions/reactions.ts b/federation/validators/extensions/reactions.ts similarity index 100% rename from federation/schemas/extensions/reactions.ts rename to federation/validators/extensions/reactions.ts diff --git a/federation/schemas/extensions/share.ts b/federation/validators/extensions/share.ts similarity index 100% rename from federation/schemas/extensions/share.ts rename to federation/validators/extensions/share.ts diff --git a/federation/schemas/extensions/vanity.ts b/federation/validators/extensions/vanity.ts similarity index 100% rename from federation/schemas/extensions/vanity.ts rename to federation/validators/extensions/vanity.ts diff --git a/federation/schemas/regex.ts b/federation/validators/regex.ts similarity index 100% rename from federation/schemas/regex.ts rename to federation/validators/regex.ts diff --git a/federation/schemas/webfinger.ts b/federation/validators/webfinger.ts similarity index 100% rename from federation/schemas/webfinger.ts rename to federation/validators/webfinger.ts