refactor: 🏷️ Update tsconfig.json and fix resulting errors
Some checks failed
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / build (push) Failing after 1s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 0s
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 0s
Build Docker Images / lint (push) Failing after 8s
Build Docker Images / check (push) Failing after 8s
Build Docker Images / tests (push) Failing after 8s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s

This commit is contained in:
Jesse Wierzbinski 2025-05-23 17:29:27 +02:00
parent 64068f9d23
commit 99a7658956
No known key found for this signature in database
18 changed files with 124 additions and 85 deletions

View file

@ -18,7 +18,7 @@ export class ApiError extends Error {
*/ */
public constructor( public constructor(
public status: ContentfulStatusCode, public status: ContentfulStatusCode,
public message: string, public override message: string,
public details?: string | JSONObject, public details?: string | JSONObject,
) { ) {
super(message); super(message);

View file

@ -72,6 +72,8 @@ export class PluginLoader {
if (manifestFile.endsWith(".jsonc")) { if (manifestFile.endsWith(".jsonc")) {
return parseJSONC(manifestText); return parseJSONC(manifestText);
} }
throw new Error(`Unsupported manifest file type: ${manifestFile}`);
} catch (e) { } catch (e) {
this.logger this.logger
.fatal`Could not parse plugin manifest ${chalk.blue(manifestPath)} as ${manifestFile.split(".").pop()?.toUpperCase()}.`; .fatal`Could not parse plugin manifest ${chalk.blue(manifestPath)} as ${manifestFile.split(".").pop()?.toUpperCase()}.`;

View file

@ -36,4 +36,5 @@ export const ipBans = createMiddleware(async (context, next) => {
} }
await next(); await next();
return;
}); });

View file

@ -15,4 +15,5 @@ export const urlCheck = createMiddleware(async (context, next) => {
} }
await next(); await next();
return;
}); });

View file

@ -7,21 +7,23 @@ import type { JSONObject } from "../types.ts";
import { Entity } from "./entity.ts"; import { Entity } from "./entity.ts";
export class Collection extends Entity { export class Collection extends Entity {
public constructor(public data: z.infer<typeof CollectionSchema>) { public constructor(public override data: z.infer<typeof CollectionSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Collection> { public static override fromJSON(json: JSONObject): Promise<Collection> {
return CollectionSchema.parseAsync(json).then((u) => new Collection(u)); return CollectionSchema.parseAsync(json).then((u) => new Collection(u));
} }
} }
export class URICollection extends Entity { export class URICollection extends Entity {
public constructor(public data: z.infer<typeof URICollectionSchema>) { public constructor(
public override data: z.infer<typeof URICollectionSchema>,
) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<URICollection> { public static override fromJSON(json: JSONObject): Promise<URICollection> {
return URICollectionSchema.parseAsync(json).then( return URICollectionSchema.parseAsync(json).then(
(u) => new URICollection(u), (u) => new URICollection(u),
); );

View file

@ -20,63 +20,81 @@ export class ContentFormat {
} }
export class TextContentFormat extends ContentFormat { export class TextContentFormat extends ContentFormat {
public static fromJSON(data: JSONObject): Promise<TextContentFormat> { public static override fromJSON(
data: JSONObject,
): Promise<TextContentFormat> {
return TextContentFormatSchema.parseAsync(data).then( return TextContentFormatSchema.parseAsync(data).then(
(d) => new TextContentFormat(d), (d) => new TextContentFormat(d),
); );
} }
public constructor(public data: z.infer<typeof TextContentFormatSchema>) { public constructor(
public override data: z.infer<typeof TextContentFormatSchema>,
) {
super(data); super(data);
} }
} }
export class NonTextContentFormat extends ContentFormat { export class NonTextContentFormat extends ContentFormat {
public static fromJSON(data: JSONObject): Promise<NonTextContentFormat> { public static override fromJSON(
data: JSONObject,
): Promise<NonTextContentFormat> {
return NonTextContentFormatSchema.parseAsync(data).then( return NonTextContentFormatSchema.parseAsync(data).then(
(d) => new NonTextContentFormat(d), (d) => new NonTextContentFormat(d),
); );
} }
public constructor( public constructor(
public data: z.infer<typeof NonTextContentFormatSchema>, public override data: z.infer<typeof NonTextContentFormatSchema>,
) { ) {
super(data); super(data);
} }
} }
export class ImageContentFormat extends ContentFormat { export class ImageContentFormat extends ContentFormat {
public static fromJSON(data: JSONObject): Promise<ImageContentFormat> { public static override fromJSON(
data: JSONObject,
): Promise<ImageContentFormat> {
return ImageContentFormatSchema.parseAsync(data).then( return ImageContentFormatSchema.parseAsync(data).then(
(d) => new ImageContentFormat(d), (d) => new ImageContentFormat(d),
); );
} }
public constructor(public data: z.infer<typeof ImageContentFormatSchema>) { public constructor(
public override data: z.infer<typeof ImageContentFormatSchema>,
) {
super(data); super(data);
} }
} }
export class VideoContentFormat extends ContentFormat { export class VideoContentFormat extends ContentFormat {
public static fromJSON(data: JSONObject): Promise<VideoContentFormat> { public static override fromJSON(
data: JSONObject,
): Promise<VideoContentFormat> {
return VideoContentFormatSchema.parseAsync(data).then( return VideoContentFormatSchema.parseAsync(data).then(
(d) => new VideoContentFormat(d), (d) => new VideoContentFormat(d),
); );
} }
public constructor(public data: z.infer<typeof VideoContentFormatSchema>) { public constructor(
public override data: z.infer<typeof VideoContentFormatSchema>,
) {
super(data); super(data);
} }
} }
export class AudioContentFormat extends ContentFormat { export class AudioContentFormat extends ContentFormat {
public static fromJSON(data: JSONObject): Promise<AudioContentFormat> { public static override fromJSON(
data: JSONObject,
): Promise<AudioContentFormat> {
return AudioContentFormatSchema.parseAsync(data).then( return AudioContentFormatSchema.parseAsync(data).then(
(d) => new AudioContentFormat(d), (d) => new AudioContentFormat(d),
); );
} }
public constructor(public data: z.infer<typeof AudioContentFormatSchema>) { public constructor(
public override data: z.infer<typeof AudioContentFormatSchema>,
) {
super(data); super(data);
} }
} }

View file

@ -4,13 +4,13 @@ import type { JSONObject } from "../types.ts";
import { Entity } from "./entity.ts"; import { Entity } from "./entity.ts";
export class Delete extends Entity { export class Delete extends Entity {
public static name = "Delete"; public static override name = "Delete";
public constructor(public data: z.infer<typeof DeleteSchema>) { public constructor(public override data: z.infer<typeof DeleteSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Delete> { public static override fromJSON(json: JSONObject): Promise<Delete> {
return DeleteSchema.parseAsync(json).then((u) => new Delete(u)); return DeleteSchema.parseAsync(json).then((u) => new Delete(u));
} }
} }

View file

@ -4,25 +4,25 @@ import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts"; import { Entity } from "../entity.ts";
export class Like extends Entity { export class Like extends Entity {
public static name = "pub.versia:likes/Like"; public static override name = "pub.versia:likes/Like";
public constructor(public data: z.infer<typeof LikeSchema>) { public constructor(public override data: z.infer<typeof LikeSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Like> { public static override fromJSON(json: JSONObject): Promise<Like> {
return LikeSchema.parseAsync(json).then((u) => new Like(u)); return LikeSchema.parseAsync(json).then((u) => new Like(u));
} }
} }
export class Dislike extends Entity { export class Dislike extends Entity {
public static name = "pub.versia:likes/Dislike"; public static override name = "pub.versia:likes/Dislike";
public constructor(public data: z.infer<typeof DislikeSchema>) { public constructor(public override data: z.infer<typeof DislikeSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Dislike> { public static override fromJSON(json: JSONObject): Promise<Dislike> {
return DislikeSchema.parseAsync(json).then((u) => new Dislike(u)); return DislikeSchema.parseAsync(json).then((u) => new Dislike(u));
} }
} }

View file

@ -4,13 +4,13 @@ import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts"; import { Entity } from "../entity.ts";
export class Vote extends Entity { export class Vote extends Entity {
public static name = "pub.versia:polls/Vote"; public static override name = "pub.versia:polls/Vote";
public constructor(public data: z.infer<typeof VoteSchema>) { public constructor(public override data: z.infer<typeof VoteSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Vote> { public static override fromJSON(json: JSONObject): Promise<Vote> {
return VoteSchema.parseAsync(json).then((u) => new Vote(u)); return VoteSchema.parseAsync(json).then((u) => new Vote(u));
} }
} }

View file

@ -4,13 +4,13 @@ import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts"; import { Entity } from "../entity.ts";
export class Reaction extends Entity { export class Reaction extends Entity {
public static name = "pub.versia:reactions/Reaction"; public static override name = "pub.versia:reactions/Reaction";
public constructor(public data: z.infer<typeof ReactionSchema>) { public constructor(public override data: z.infer<typeof ReactionSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Reaction> { public static override fromJSON(json: JSONObject): Promise<Reaction> {
return ReactionSchema.parseAsync(json).then((u) => new Reaction(u)); return ReactionSchema.parseAsync(json).then((u) => new Reaction(u));
} }
} }

View file

@ -4,13 +4,13 @@ import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts"; import { Entity } from "../entity.ts";
export class Report extends Entity { export class Report extends Entity {
public static name = "pub.versia:reports/Report"; public static override name = "pub.versia:reports/Report";
public constructor(public data: z.infer<typeof ReportSchema>) { public constructor(public override data: z.infer<typeof ReportSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Report> { public static override fromJSON(json: JSONObject): Promise<Report> {
return ReportSchema.parseAsync(json).then((u) => new Report(u)); return ReportSchema.parseAsync(json).then((u) => new Report(u));
} }
} }

View file

@ -4,13 +4,13 @@ import type { JSONObject } from "../../types.ts";
import { Entity } from "../entity.ts"; import { Entity } from "../entity.ts";
export class Share extends Entity { export class Share extends Entity {
public static name = "pub.versia:share/Share"; public static override name = "pub.versia:share/Share";
public constructor(public data: z.infer<typeof ShareSchema>) { public constructor(public override data: z.infer<typeof ShareSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Share> { public static override fromJSON(json: JSONObject): Promise<Share> {
return ShareSchema.parseAsync(json).then((u) => new Share(u)); return ShareSchema.parseAsync(json).then((u) => new Share(u));
} }
} }

View file

@ -9,25 +9,27 @@ import type { JSONObject } from "../types.ts";
import { Entity } from "./entity.ts"; import { Entity } from "./entity.ts";
export class Follow extends Entity { export class Follow extends Entity {
public static name = "Follow"; public static override name = "Follow";
public constructor(public data: z.infer<typeof FollowSchema>) { public constructor(public override data: z.infer<typeof FollowSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Follow> { public static override fromJSON(json: JSONObject): Promise<Follow> {
return FollowSchema.parseAsync(json).then((u) => new Follow(u)); return FollowSchema.parseAsync(json).then((u) => new Follow(u));
} }
} }
export class FollowAccept extends Entity { export class FollowAccept extends Entity {
public static name = "FollowAccept"; public static override name = "FollowAccept";
public constructor(public data: z.infer<typeof FollowAcceptSchema>) { public constructor(
public override data: z.infer<typeof FollowAcceptSchema>,
) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<FollowAccept> { public static override fromJSON(json: JSONObject): Promise<FollowAccept> {
return FollowAcceptSchema.parseAsync(json).then( return FollowAcceptSchema.parseAsync(json).then(
(u) => new FollowAccept(u), (u) => new FollowAccept(u),
); );
@ -35,13 +37,15 @@ export class FollowAccept extends Entity {
} }
export class FollowReject extends Entity { export class FollowReject extends Entity {
public static name = "FollowReject"; public static override name = "FollowReject";
public constructor(public data: z.infer<typeof FollowRejectSchema>) { public constructor(
public override data: z.infer<typeof FollowRejectSchema>,
) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<FollowReject> { public static override fromJSON(json: JSONObject): Promise<FollowReject> {
return FollowRejectSchema.parseAsync(json).then( return FollowRejectSchema.parseAsync(json).then(
(u) => new FollowReject(u), (u) => new FollowReject(u),
); );
@ -49,13 +53,13 @@ export class FollowReject extends Entity {
} }
export class Unfollow extends Entity { export class Unfollow extends Entity {
public static name = "Unfollow"; public static override name = "Unfollow";
public constructor(public data: z.infer<typeof UnfollowSchema>) { public constructor(public override data: z.infer<typeof UnfollowSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Unfollow> { public static override fromJSON(json: JSONObject): Promise<Unfollow> {
return UnfollowSchema.parseAsync(json).then((u) => new Unfollow(u)); return UnfollowSchema.parseAsync(json).then((u) => new Unfollow(u));
} }
} }

View file

@ -5,9 +5,11 @@ import { ImageContentFormat } from "./contentformat.ts";
import { Entity } from "./entity.ts"; import { Entity } from "./entity.ts";
export class InstanceMetadata extends Entity { export class InstanceMetadata extends Entity {
public static name = "InstanceMetadata"; public static override name = "InstanceMetadata";
public constructor(public data: z.infer<typeof InstanceMetadataSchema>) { public constructor(
public override data: z.infer<typeof InstanceMetadataSchema>,
) {
super(data); super(data);
} }
@ -23,7 +25,9 @@ export class InstanceMetadata extends Entity {
: undefined; : undefined;
} }
public static fromJSON(json: JSONObject): Promise<InstanceMetadata> { public static override fromJSON(
json: JSONObject,
): Promise<InstanceMetadata> {
return InstanceMetadataSchema.parseAsync(json).then( return InstanceMetadataSchema.parseAsync(json).then(
(u) => new InstanceMetadata(u), (u) => new InstanceMetadata(u),
); );

View file

@ -5,13 +5,13 @@ import { NonTextContentFormat, TextContentFormat } from "./contentformat.ts";
import { Entity } from "./entity.ts"; import { Entity } from "./entity.ts";
export class Note extends Entity { export class Note extends Entity {
public static name = "Note"; public static override name = "Note";
public constructor(public data: z.infer<typeof NoteSchema>) { public constructor(public override data: z.infer<typeof NoteSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<Note> { public static override fromJSON(json: JSONObject): Promise<Note> {
return NoteSchema.parseAsync(json).then((n) => new Note(n)); return NoteSchema.parseAsync(json).then((n) => new Note(n));
} }

View file

@ -5,13 +5,13 @@ import { ImageContentFormat, TextContentFormat } from "./contentformat.ts";
import { Entity } from "./entity.ts"; import { Entity } from "./entity.ts";
export class User extends Entity { export class User extends Entity {
public static name = "User"; public static override name = "User";
public constructor(public data: z.infer<typeof UserSchema>) { public constructor(public override data: z.infer<typeof UserSchema>) {
super(data); super(data);
} }
public static fromJSON(json: JSONObject): Promise<User> { public static override fromJSON(json: JSONObject): Promise<User> {
return UserSchema.parseAsync(json).then((u) => new User(u)); return UserSchema.parseAsync(json).then((u) => new User(u));
} }

View file

@ -1,40 +1,45 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": ["ESNext", "DOM", "DOM.Iterable"], "alwaysStrict": true,
"module": "esnext", "exactOptionalPropertyTypes": false,
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"noImplicitAny": true, "noImplicitAny": true,
"jsx": "preserve", "noImplicitOverride": true,
"allowSyntheticDefaultImports": true, "noImplicitReturns": true,
"strictNullChecks": true, "noImplicitThis": true,
"strictFunctionTypes": true, "noPropertyAccessFromIndexSignature": false,
"noUncheckedIndexedAccess": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"useUnknownInCatchVariables": true,
"allowImportingTsExtensions": true,
"module": "preserve",
"moduleResolution": "bundler",
"noUncheckedSideEffectImports": true,
"resolveJsonModule": true,
"noEmit": true,
"allowJs": false,
// Soon...
//"erasableSyntaxOnly": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"allowJs": true, //"isolatedDeclarations": true,
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"verbatimModuleSyntax": true, "verbatimModuleSyntax": true,
"moduleDetection": "force",
"target": "esnext",
"jsx": "preserve",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"composite": true,
"incremental": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": false,
"paths": { "paths": {
"@/*": ["./utils/*"], "@/*": ["./utils/*"],
"~/*": ["./*"], "~/*": ["./*"],
"+/*": ["./api/*"] "+/*": ["./api/*"]
}, }
"noUnusedLocals": true
}, },
"exclude": ["node_modules"], "exclude": ["node_modules"],
"include": [ "include": ["*.ts", "*.d.ts", "**/*.ts", "**/*.d.ts"]
"*.ts",
"*.d.ts",
"**/*.ts",
"**/*.d.ts",
"api/well-known/**/*.ts",
"packages/cli/index.mts"
]
} }

View file

@ -99,6 +99,8 @@ export const handleZodError = (
422, 422,
); );
} }
return undefined;
}; };
const checkPermissions = ( const checkPermissions = (