Add biome

This commit is contained in:
Endeavorance 2025-04-06 19:28:42 -04:00
parent 09d25c926c
commit 6479d09196
9 changed files with 586 additions and 538 deletions

34
biome.json Normal file
View file

@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noArrayIndexKey": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}

BIN
bun.lockb

Binary file not shown.

View file

@ -5,14 +5,13 @@
"types": "./dist/index.d.ts",
"scripts": {
"build": "bun run ./build.ts",
"clean": "rm -rf dist"
"clean": "rm -rf dist",
"fmt": "biome check --fix"
},
"keywords": [],
"author": "Endeavorance <hello@endeavorance.camp> (https://endeavorance.camp)",
"license": "CC BY-NC-SA 4.0",
"files": [
"dist"
],
"files": ["dist"],
"type": "module",
"devDependencies": {
"@types/bun": "latest",
@ -20,5 +19,8 @@
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@biomejs/biome": "^1.9.4"
}
}

View file

@ -28,7 +28,7 @@ export const ColumnOf = {
type: otherTable.primaryColumnType(),
references: otherTable.reference(),
nullable: false,
cascade
cascade,
};
},
@ -36,7 +36,6 @@ export const ColumnOf = {
Text: {
type: "TEXT",
nullable: true,
},
Int: {
@ -94,7 +93,7 @@ export const ColumnOf = {
return {
type: "TEXT",
default: defaultValue,
}
};
},
Int(defaultValue: number): ColumnShorthand {
@ -109,7 +108,6 @@ export const ColumnOf = {
type: "REAL",
default: defaultValue,
} as const;
}
},
},
} as const;

View file

@ -1,6 +1,13 @@
import { ColumnOf } from "./column-types";
import type { Column, ColumnShorthand, DataType } from "./columns";
import { Prequel } from "./prequel";
import { Table } from "./table";
import { ColumnOf } from "./column-types";
export { Prequel, Table, ColumnOf, type DataType, type Column, type ColumnShorthand };
export {
Prequel,
Table,
ColumnOf,
type DataType,
type Column,
type ColumnShorthand,
};

View file

@ -37,9 +37,15 @@ function shapeForQuery<T>(obj: Partial<T>): ArbitraryRow {
for (const key of keys) {
const val = obj[key as keyof T];
if (typeof val !== "string" && typeof val !== "number" && val !== null) {
if (
typeof val === "string" &&
typeof val === "number" &&
typeof val === "boolean" &&
typeof val === "bigint" &&
val !== null
) {
throw new SchemaError(
`Invalid value in query: ${key}: ${val} (type: ${typeof val})`,
`Invalid value in query: ${key} -> ${val} (type: ${typeof val})`,
);
}
@ -160,7 +166,8 @@ export class Table<RowShape> {
}
public primaryColumnType(): DataType {
const primary = this._primaryColumnName as keyof typeof this._columnDefinitions;
const primary = this
._primaryColumnName as keyof typeof this._columnDefinitions;
return this._columnDefinitions[primary].type;
}