Skip to content

Commit

Permalink
refactor(federation): 👽 Update all schemas to Working Draft 4
Browse files Browse the repository at this point in the history
  • Loading branch information
CPlusPatch committed Aug 25, 2024
1 parent b462718 commit 4a470f5
Show file tree
Hide file tree
Showing 13 changed files with 522 additions and 430 deletions.
34 changes: 18 additions & 16 deletions federation/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,42 @@ const validUser = {
uri: "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a",
bio: {
"text/html": {
content: "<p>Hey</p>\n",
content: "<p>Hey</p>",
remote: false,
},
},
created_at: "2024-04-07T11:48:29.623Z",
dislikes:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/dislikes",
featured:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/featured",
likes: "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/likes",
followers:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/followers",
following:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/following",
inbox: "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/inbox",
outbox: "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/outbox",
indexable: false,
created_at: "2024-04-07T11:48:29.623Z",
collections: {
featured:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/featured",
followers:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/followers",
following:
"https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/following",
outbox: "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a/outbox",
},
username: "jessew",
display_name: "Jesse Wierzbinski",
fields: [
{
key: { "text/html": { content: "<p>Identity</p>\n" } },
key: { "text/html": { content: "<p>Identity</p>", remote: false } },
value: {
"text/html": {
content:
'<p><a href="https://keyoxide.org/aspe:keyoxide.org:NKLLPWPV7P35NEU7JP4K4ID4CA">https://keyoxide.org/aspe:keyoxide.org:NKLLPWPV7P35NEU7JP4K4ID4CA</a></p>\n',
'<p><a href="https://keyoxide.org/aspe:keyoxide.org:NKLLPWPV7P35NEU7JP4K4ID4CA">https://keyoxide.org/aspe:keyoxide.org:NKLLPWPV7P35NEU7JP4K4ID4CA</a></p>',
remote: false,
},
},
},
],
public_key: {
actor: "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a",
public_key: "XXXXXXXX",
key: "XXXXXXXX",
algorithm: "ed25519",
},
extensions: { "org.lysand:custom_emojis": { emojis: [] } },
extensions: { "pub.versia:custom_emojis": { emojis: [] } },
};

describe("RequestParserHandler", () => {
Expand Down
32 changes: 10 additions & 22 deletions federation/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@

import type { z } from "zod";
import type {
ActionSchema,
ActorPublicKeyDataSchema,
DislikeSchema,
DeleteSchema,
EntitySchema,
ExtensionSchema,
FollowAcceptSchema,
FollowRejectSchema,
FollowSchema,
LikeSchema,
GroupSchema,
InstanceMetadataSchema,
NoteSchema,
PatchSchema,
PublicationSchema,
ReportSchema,
ServerMetadataSchema,
UndoSchema,
PublicKeyDataSchema,
UnfollowSchema,
UserSchema,
VisibilitySchema,
} from "./schemas/base";
import type { ContentFormatSchema } from "./schemas/content_format";
import type { ExtensionPropertySchema } from "./schemas/extensions";
Expand All @@ -34,23 +28,17 @@ type AnyZod = z.ZodType<any, any, any>;
type InferType<T extends AnyZod> = z.infer<T>;

export type Note = InferType<typeof NoteSchema>;
export type Patch = InferType<typeof PatchSchema>;
export type ActorPublicKeyData = InferType<typeof ActorPublicKeyDataSchema>;
export type ActorPublicKeyData = InferType<typeof PublicKeyDataSchema>;
export type ExtensionProperty = InferType<typeof ExtensionPropertySchema>;
export type VanityExtension = InferType<typeof VanityExtensionSchema>;
export type User = InferType<typeof UserSchema>;
export type Action = InferType<typeof ActionSchema>;
export type Like = InferType<typeof LikeSchema>;
export type Undo = InferType<typeof UndoSchema>;
export type Dislike = InferType<typeof DislikeSchema>;
export type Follow = InferType<typeof FollowSchema>;
export type FollowAccept = InferType<typeof FollowAcceptSchema>;
export type FollowReject = InferType<typeof FollowRejectSchema>;
export type Extension = InferType<typeof ExtensionSchema>;
export type Report = InferType<typeof ReportSchema>;
export type ServerMetadata = InferType<typeof ServerMetadataSchema>;
export type ContentFormat = InferType<typeof ContentFormatSchema>;
export type CustomEmojiExtension = InferType<typeof CustomEmojiExtensionSchema>;
export type Visibility = InferType<typeof VisibilitySchema>;
export type Publication = InferType<typeof PublicationSchema>;
export type Entity = InferType<typeof EntitySchema>;
export type Delete = InferType<typeof DeleteSchema>;
export type Group = InferType<typeof GroupSchema>;
export type InstanceMetadata = InferType<typeof InstanceMetadataSchema>;
export type Unfollow = InferType<typeof UnfollowSchema>;
Loading

0 comments on commit 4a470f5

Please sign in to comment.