Skip to content

Commit

Permalink
refactor(federation): 🚚 Rename schemas to validators
Browse files Browse the repository at this point in the history
Fixes issues with Bun bundling
  • Loading branch information
CPlusPatch committed Sep 22, 2024
1 parent ebf16a8 commit f80cffd
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 37 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", "schemas.ts", "types.ts"],
federation: ["index.ts", "validators.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/schemas/base
* @see module:federation/validators/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",
"./schemas": "./schemas.ts"
"./validators": "./validators.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"
},
"./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": {
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 "../schemas/webfinger.ts";
import { WebFingerSchema } from "../validators/webfinger.ts";
import type { User } from "../types.ts";
import { DEFAULT_UA } from "./constants.ts";

Expand Down
21 changes: 12 additions & 9 deletions federation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 "./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,
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/schemas/base
* @see module:federation/validators/base
* @example
* import { EntityValidator, type ValidationError } from "@versia/federation";
* const validator = new EntityValidator();
Expand Down
20 changes: 10 additions & 10 deletions federation/schemas.ts → federation/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
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.

0 comments on commit f80cffd

Please sign in to comment.