Skip to content

Commit

Permalink
refactor(federation): 🚚 Rename validators back to schemas, fix barrel…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
CPlusPatch committed Sep 23, 2024
1 parent d43775e commit ce9be7e
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 81 deletions.
2 changes: 1 addition & 1 deletion build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
};

Expand Down
2 changes: 1 addition & 1 deletion federation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion federation/jsr.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"exports": {
".": "./index.ts",
"./types": "./types.ts",
"./validators": "./validators.ts"
"./schemas": "./schemas.ts"
}
}
8 changes: 4 additions & 4 deletions federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion federation/requester/index.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
31 changes: 31 additions & 0 deletions federation/schemas.ts
Original file line number Diff line number Diff line change
@@ -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";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 9 additions & 12 deletions federation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, any, any>;
Expand Down
20 changes: 10 additions & 10 deletions federation/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -52,7 +52,7 @@ type InferType<T extends AnyZod> = z.infer<T>;
/**
* 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();
Expand Down
51 changes: 0 additions & 51 deletions federation/validators.ts

This file was deleted.

0 comments on commit ce9be7e

Please sign in to comment.