Template
1
0

feat: biome check

This commit is contained in:
2025-09-25 14:29:15 +02:00
parent f2ba21a7e3
commit 0819534901
68 changed files with 211 additions and 802 deletions

View File

@@ -12,4 +12,4 @@
"@platform/logger": "workspace:*",
"zod": "4.1.11"
}
}
}

View File

@@ -1,5 +1,5 @@
import { load } from "@std/dotenv";
import { z, type ZodType } from "zod";
import type { ZodType, z } from "zod";
import { InvalidEnvironmentKeyError } from "./errors.ts";
import { getServiceEnvironment, type ServiceEnvironment } from "./service.ts";

View File

@@ -7,4 +7,4 @@
"@std/dotenv": "npm:@jsr/std__dotenv@0.225.5",
"zod": "4.1.11"
}
}
}

View File

@@ -1,4 +1,4 @@
import { Collection, type CollectionOptions, type Db, type Document, type MongoClient } from "mongodb";
import type { Collection, CollectionOptions, Db, Document, MongoClient } from "mongodb";
import { mongo } from "./client.ts";

View File

@@ -9,4 +9,4 @@
"mongodb": "6.20.0",
"zod": "4.1.11"
}
}
}

View File

@@ -1,5 +1,5 @@
import type { Db } from "mongodb";
import z, { type ZodObject, type ZodType } from "zod";
import type { ZodObject, ZodType, z } from "zod";
/**
* TODO ...
@@ -29,7 +29,7 @@ export function makeDocumentParser<TSchema extends ZodObject>(schema: TSchema):
export function toParsedDocuments<TSchema extends ZodType>(
schema: TSchema,
): (documents: unknown[]) => Promise<z.infer<TSchema>[]> {
return async function (documents: unknown[]) {
return async (documents: unknown[]) => {
const parsed = [];
for (const document of documents) {
parsed.push(await schema.parseAsync(document));
@@ -44,7 +44,7 @@ export function toParsedDocuments<TSchema extends ZodType>(
export function toParsedDocument<TSchema extends ZodType>(
schema: TSchema,
): (document?: unknown) => Promise<z.infer<TSchema> | undefined> {
return async function (document: unknown) {
return async (document: unknown) => {
if (document === undefined || document === null) {
return undefined;
}

View File

@@ -1,4 +1,4 @@
import { HexValue } from "./color/hex.ts";
import type { HexValue } from "./color/hex.ts";
import { type BGColor, type Color, hexToBgColor, hexToColor, type Modifier, styles } from "./color/styles.ts";
export const chalk = {
@@ -13,21 +13,15 @@ export const chalk = {
} as Chalk;
for (const key in styles.modifier) {
chalk[key as Modifier] = function (value: string) {
return toModifiedValue(key as Modifier, value);
};
chalk[key as Modifier] = (value: string) => toModifiedValue(key as Modifier, value);
}
for (const key in styles.color) {
chalk[key as Color] = function (value: string) {
return toColorValue(key as Color, value);
};
chalk[key as Color] = (value: string) => toColorValue(key as Color, value);
}
for (const key in styles.bgColor) {
chalk[key as BGColor] = function (value: string) {
return toBGColorValue(key as BGColor, value);
};
chalk[key as BGColor] = (value: string) => toBGColorValue(key as BGColor, value);
}
function toModifiedValue(key: Modifier, value: string): string {

View File

@@ -1,4 +1,4 @@
import { hexToAnsi256, HexValue } from "./hex.ts";
import { type HexValue, hexToAnsi256 } from "./hex.ts";
import { toEscapeSequence } from "./utilities.ts";
export const styles = {

View File

@@ -12,4 +12,4 @@
"@valkyr/event-store": "npm:@jsr/valkyr__event-store@2.0.1",
"zod": "4.1.11"
}
}
}

View File

@@ -2,12 +2,12 @@ import { encrypt } from "@platform/vault";
import {
assertServerErrorResponse,
RelayAdapter,
RelayInput,
RelayResponse,
ServerErrorResponse,
type RelayAdapter,
type RelayInput,
type RelayResponse,
type ServerErrorResponse,
} from "../libraries/adapter.ts";
import { ServerError, ServerErrorType } from "../libraries/errors.ts";
import { ServerError, type ServerErrorType } from "../libraries/errors.ts";
/**
* HttpAdapter provides a unified transport layer for Relay.

View File

@@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface ServerContext {}
export type ServerContext = {};
export const context: ServerContext = {} as any;

View File

@@ -1,4 +1,4 @@
import { ZodError } from "zod";
import type { ZodError } from "zod";
export abstract class ServerError<TData = unknown> extends Error {
abstract readonly code: string;

View File

@@ -1,8 +1,9 @@
import z, { ZodType } from "zod";
import type z from "zod";
import type { ZodType } from "zod";
import { ServerContext } from "./context.ts";
import { ServerError, ServerErrorClass } from "./errors.ts";
import { RouteAccess } from "./route.ts";
import type { ServerContext } from "./context.ts";
import type { ServerError, ServerErrorClass } from "./errors.ts";
import type { RouteAccess } from "./route.ts";
export class Procedure<const TState extends State = State> {
readonly type = "procedure" as const;
@@ -234,7 +235,8 @@ type HandleFn<TArgs extends Array<any> = any[], TResponse = any> = (
? Promise<z.infer<TResponse> | Response | ServerError>
: Promise<Response | ServerError | void>;
type ServerArgs<TState extends State> =
HasInputArgs<TState> extends true ? [z.output<TState["params"]>, ServerContext] : [ServerContext];
type ServerArgs<TState extends State> = HasInputArgs<TState> extends true
? [z.output<TState["params"]>, ServerContext]
: [ServerContext];
type HasInputArgs<TState extends State> = TState["params"] extends ZodType ? true : false;

View File

@@ -1,9 +1,9 @@
import { match, type MatchFunction } from "path-to-regexp";
import z, { ZodObject, ZodRawShape, ZodType } from "zod";
import { type MatchFunction, match } from "path-to-regexp";
import z, { type ZodObject, type ZodRawShape, type ZodType } from "zod";
import { ServerContext } from "./context.ts";
import { ServerError, ServerErrorClass } from "./errors.ts";
import { Hooks } from "./hooks.ts";
import type { ServerContext } from "./context.ts";
import { ServerError, type ServerErrorClass } from "./errors.ts";
import type { Hooks } from "./hooks.ts";
export class Route<const TState extends RouteState = RouteState> {
readonly type = "route" as const;
@@ -480,15 +480,14 @@ type HandleFn<TArgs extends Array<any> = any[], TResponse = any> = (
? Promise<z.infer<TResponse> | Response | ServerError>
: Promise<Response | ServerError | void>;
type ServerArgs<TState extends RouteState> =
HasInputArgs<TState> extends true
? [
(TState["params"] extends ZodObject ? { params: z.output<TState["params"]> } : unknown) &
(TState["query"] extends ZodObject ? { query: z.output<TState["query"]> } : unknown) &
(TState["body"] extends ZodType ? { body: z.output<TState["body"]> } : unknown),
ServerContext,
]
: [ServerContext];
type ServerArgs<TState extends RouteState> = HasInputArgs<TState> extends true
? [
(TState["params"] extends ZodObject ? { params: z.output<TState["params"]> } : unknown) &
(TState["query"] extends ZodObject ? { query: z.output<TState["query"]> } : unknown) &
(TState["body"] extends ZodType ? { body: z.output<TState["body"]> } : unknown),
ServerContext,
]
: [ServerContext];
type HasInputArgs<TState extends RouteState> = TState["params"] extends ZodObject
? true

View File

@@ -15,4 +15,4 @@
"path-to-regexp": "8",
"zod": "4.1.11"
}
}
}

View File

@@ -6,8 +6,8 @@ import {
InternalServerError,
NotFoundError,
NotImplementedError,
Route,
RouteMethod,
type Route,
type RouteMethod,
ServerError,
type ServerErrorResponse,
UnauthorizedError,

View File

@@ -13,4 +13,4 @@
"@valkyr/json-rpc": "npm:@jsr/valkyr__json-rpc@1.1.0",
"zod": "4.1.11"
}
}
}

View File

@@ -1,9 +1,7 @@
import "./types.ts";
import { context } from "@platform/relay";
import { InternalServerError } from "@platform/relay";
import { storage } from "@platform/storage";
import { getStorageContext } from "@platform/storage";
import { context, InternalServerError } from "@platform/relay";
import { getStorageContext, storage } from "@platform/storage";
export default {
/**

View File

@@ -8,7 +8,7 @@ import type { Api } from "./api.ts";
/**
* TODO ...
*/
export function upgradeWebSocket(request: Request, api: Api) {
export function upgradeWebSocket(request: Request, _api: Api) {
const { socket, response } = Deno.upgradeWebSocket(request);
socket.addEventListener("open", () => {

View File

@@ -11,4 +11,4 @@
"@platform/storage": "workspace:*",
"@valkyr/json-rpc": "npm:@jsr/valkyr__json-rpc@1.1.0"
}
}
}

View File

@@ -1,7 +1,6 @@
import "./types.d.ts";
import { InternalServerError } from "@platform/relay";
import { context } from "@platform/relay";
import { context, InternalServerError } from "@platform/relay";
import { getStorageContext, storage } from "@platform/storage";
import { SocketRegistry } from "./sockets.ts";

View File

@@ -41,7 +41,9 @@ export class SocketRegistry {
* @param data - Data to send to each connected socket.
*/
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): this {
this.#sockets.forEach((socket) => socket.send(data));
this.#sockets.forEach((socket) => {
socket.send(data);
});
return this;
}
}

View File

@@ -8,4 +8,4 @@
"@platform/relay": "workspace:*",
"zod": "4.1.11"
}
}
}

View File

@@ -10,4 +10,4 @@
"dependencies": {
"@platform/relay": "workspace:*"
}
}
}

View File

@@ -18,4 +18,4 @@ export function getStorageContext(): StorageContext {
}
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface StorageContext {}
export type StorageContext = {};

View File

@@ -46,6 +46,9 @@ function bufferToHex(buffer: ArrayBuffer): string {
}
function hexToBuffer(hex: string): ArrayBuffer {
const bytes = new Uint8Array(hex.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)));
return bytes.buffer;
const match = hex.match(/.{1,2}/g);
if (match === null) {
return new Uint8Array().buffer;
}
return new Uint8Array(match.map((byte) => parseInt(byte, 16))).buffer;
}

View File

@@ -7,4 +7,4 @@
"jose": "6.1.0",
"nanoid": "5.1.5"
}
}
}

View File

@@ -1,6 +1,13 @@
import * as Jose from "jose";
import { createKeyPair, ExportedKeyPair, importPrivateKey, importPublicKey, KeyPair, loadKeyPair } from "./key-pair.ts";
import {
createKeyPair,
type ExportedKeyPair,
importPrivateKey,
importPublicKey,
type KeyPair,
loadKeyPair,
} from "./key-pair.ts";
/*
|--------------------------------------------------------------------------------