Add biome
This commit is contained in:
parent
09d25c926c
commit
6479d09196
9 changed files with 586 additions and 538 deletions
34
biome.json
Normal file
34
biome.json
Normal 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
BIN
bun.lockb
Binary file not shown.
10
package.json
10
package.json
|
@ -5,14 +5,13 @@
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bun run ./build.ts",
|
"build": "bun run ./build.ts",
|
||||||
"clean": "rm -rf dist"
|
"clean": "rm -rf dist",
|
||||||
|
"fmt": "biome check --fix"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Endeavorance <hello@endeavorance.camp> (https://endeavorance.camp)",
|
"author": "Endeavorance <hello@endeavorance.camp> (https://endeavorance.camp)",
|
||||||
"license": "CC BY-NC-SA 4.0",
|
"license": "CC BY-NC-SA 4.0",
|
||||||
"files": [
|
"files": ["dist"],
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest",
|
"@types/bun": "latest",
|
||||||
|
@ -20,5 +19,8 @@
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@biomejs/biome": "^1.9.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const ColumnOf = {
|
||||||
type: otherTable.primaryColumnType(),
|
type: otherTable.primaryColumnType(),
|
||||||
references: otherTable.reference(),
|
references: otherTable.reference(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
cascade
|
cascade,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ export const ColumnOf = {
|
||||||
Text: {
|
Text: {
|
||||||
type: "TEXT",
|
type: "TEXT",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Int: {
|
Int: {
|
||||||
|
@ -94,7 +93,7 @@ export const ColumnOf = {
|
||||||
return {
|
return {
|
||||||
type: "TEXT",
|
type: "TEXT",
|
||||||
default: defaultValue,
|
default: defaultValue,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
Int(defaultValue: number): ColumnShorthand {
|
Int(defaultValue: number): ColumnShorthand {
|
||||||
|
@ -109,7 +108,6 @@ export const ColumnOf = {
|
||||||
type: "REAL",
|
type: "REAL",
|
||||||
default: defaultValue,
|
default: defaultValue,
|
||||||
} as const;
|
} as const;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
11
src/index.ts
11
src/index.ts
|
@ -1,6 +1,13 @@
|
||||||
|
import { ColumnOf } from "./column-types";
|
||||||
import type { Column, ColumnShorthand, DataType } from "./columns";
|
import type { Column, ColumnShorthand, DataType } from "./columns";
|
||||||
import { Prequel } from "./prequel";
|
import { Prequel } from "./prequel";
|
||||||
import { Table } from "./table";
|
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,
|
||||||
|
};
|
||||||
|
|
13
src/table.ts
13
src/table.ts
|
@ -37,9 +37,15 @@ function shapeForQuery<T>(obj: Partial<T>): ArbitraryRow {
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
const val = obj[key as keyof T];
|
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(
|
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 {
|
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;
|
return this._columnDefinitions[primary].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue