@bejibun/database 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ # dependencies (bun install)
2
+ node_modules
3
+
4
+ # output
5
+ out
6
+ dist
7
+ *.tgz
8
+
9
+ # code coverage
10
+ coverage
11
+ *.lcov
12
+
13
+ # logs
14
+ logs
15
+ _.log
16
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17
+
18
+ # dotenv environment variable files
19
+ .env
20
+ .env.development.local
21
+ .env.test.local
22
+ .env.production.local
23
+ .env.local
24
+
25
+ # caches
26
+ .eslintcache
27
+ .cache
28
+ *.tsbuildinfo
29
+
30
+ # storage (runtime/framework generated content)
31
+ storage/app
32
+ storage/cache
33
+ storage/framework
34
+
35
+ # public
36
+ public
37
+
38
+ # bun
39
+ bun.lock
40
+
41
+ # IntelliJ based IDEs
42
+ .idea
43
+
44
+ # Finder (MacOS) folder config
45
+ .DS_Store
@@ -0,0 +1,14 @@
1
+ {
2
+ "tabWidth": 4,
3
+ "useTabs": false,
4
+ "semi": true,
5
+ "singleQuote": false,
6
+ "quoteProps": "as-needed",
7
+ "trailingComma": "none",
8
+ "bracketSpacing": false,
9
+ "bracketSameLine": false,
10
+ "arrowParens": "always",
11
+ "printWidth": 100,
12
+ "endOfLine": "lf",
13
+ "jsxSingleQuote": false
14
+ }
package/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ---
5
5
 
6
+ ## [v0.1.22](https://github.com/Bejibun-Framework/bejibun-database/compare/v0.1.21...v0.1.22) - 2026-08-20
7
+
8
+ ### 🩹 Fixes
9
+
10
+ ### 📖 Changes
11
+ #### Tooling
12
+ - Added `prettier` + `.prettierrc.json` / `.prettierignore` and an `eslint.config.js` (flat config, `typescript-eslint`) for consistent formatting/linting across `src`
13
+ - Added `bun run format`, `bun run eslint`, and `bun run lint` scripts; `bun run build` now runs `lint` before compiling
14
+ - `alias` script now runs `tsc-alias` directly instead of via `bunx`
15
+
16
+ ### 📦 Dependencies
17
+
18
+ - Bumped [`@bejibun/app`](https://github.com/Bejibun-Framework/bejibun-app) from `^0.1.24` to `^0.1.25`
19
+ - Bumped [`@bejibun/logger`](https://github.com/Bejibun-Framework/bejibun-logger) from `^0.1.22` to `^0.1.23`
20
+ - Bumped [`@bejibun/utils`](https://github.com/Bejibun-Framework/bejibun-utils) from `^0.1.28` to `^0.1.29`
21
+ - Bumped `knex` (devDependency) from `^3.2.10` to `^3.3.0`
22
+ - Bumped `ora` (devDependency) from `^9.4.0` to `^9.4.1`
23
+ - Bumped `pg` (devDependency) from `^8.21.0` to `^8.23.0`
24
+ - Bumped `tsc-alias` (devDependency) from `^1.8.17` to `^1.9.2`
25
+ - Added `@eslint/js` (devDependency) `^10.0.1`
26
+ - Added `eslint` (devDependency) `^10.8.1`
27
+ - Added `eslint-config-prettier` (devDependency) `^10.1.8`
28
+ - Added `globals` (devDependency) `^17.11.0`
29
+ - Added `prettier` (devDependency) `^3.9.6`
30
+ - Added `typescript` (devDependency) `^6.0.3`
31
+ - Added `typescript-eslint` (devDependency) `^8.67.0`
32
+
33
+ ### ❤️Contributors
34
+ - Havea Crenata ([@crenata](https://github.com/crenata))
35
+
36
+ **Full Changelog**: https://github.com/Bejibun-Framework/bejibun-database/blob/master/CHANGELOG.md
37
+
38
+ ---
39
+
6
40
  ## [v0.1.21](https://github.com/Bejibun-Framework/bejibun-database/compare/v0.1.20...v0.1.21) - 2026-06-01
7
41
 
8
42
  ### 🩹 Fixes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="https://github.com/Bejibun-Framework/bejibun/blob/master/public/images/bejibun.png?raw=true" width="150" alt="Bejibun" />
4
4
 
5
5
  ![GitHub top language](https://img.shields.io/github/languages/top/Bejibun-Framework/bejibun-database)
6
- ![GitHub all releases](https://img.shields.io/github/downloads/Bejibun-Framework/bejibun-database/total)
6
+ ![NPM Downloads](https://img.shields.io/npm/d18m/%40bejibun%2Fdatabase)
7
7
  ![GitHub issues](https://img.shields.io/github/issues/Bejibun-Framework/bejibun-database)
8
8
  ![GitHub](https://img.shields.io/github/license/Bejibun-Framework/bejibun-database)
9
9
  ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Bejibun-Framework/bejibun-database?display_name=tag&include_prereleases)
@@ -66,16 +66,10 @@ import Database from "@bejibun/database";
66
66
  Database.knex();
67
67
  ```
68
68
 
69
- ## Contributors
70
- - [Havea Crenata](mailto:havea.crenata@gmail.com)
71
-
72
69
  ## ☕ Support / Donate
73
70
 
74
- If you find this project helpful and want to support it, you can donate via crypto :
71
+ If you find this project helpful and want to support it:
75
72
 
76
- | EVM | Solana |
77
- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
78
- | <img src="https://github.com/Bejibun-Framework/bejibun/blob/master/public/images/EVM.png?raw=true" width="150" /> | <img src="https://github.com/Bejibun-Framework/bejibun/blob/master/public/images/SOL.png?raw=true" width="150" /> |
79
- | 0xdABe8750061410D35cE52EB2a418c8cB004788B3 | GAnoyvy9p3QFyxikWDh9hA3fmSk2uiPLNWyQ579cckMn |
73
+ [![Donate](https://img.shields.io/badge/Donate-Support%20Me-orange?style=for-the-badge)](https://donate.bejibun.com)
80
74
 
81
- Or you can buy this `$BJBN (Bejibun)` tokens [here](https://pump.fun/coin/CQhbNnCGKfDaKXt8uE61i5DrBYJV7NPsCDD9vQgypump), beware of bots.
75
+ Or you can buy this `$BJBN (Bejibun)` tokens [here](https://pump.fun/coin/CQhbNnCGKfDaKXt8uE61i5DrBYJV7NPsCDD9vQgypump).
@@ -23,5 +23,5 @@ export default class DbSeedCommand {
23
23
  * @var $arguments Array<Array<string>>
24
24
  */
25
25
  protected $arguments: Array<Array<string>>;
26
- handle(options: any, args: Array<string>): Promise<void>;
26
+ handle(options: any): Promise<void>;
27
27
  }
@@ -31,7 +31,7 @@ export default class DbSeedCommand {
31
31
  * @var $arguments Array<Array<string>>
32
32
  */
33
33
  $arguments = [];
34
- async handle(options, args) {
34
+ async handle(options) {
35
35
  const database = Database.knex();
36
36
  const environment = defineValue(Bun.env.APP_ENV, "development");
37
37
  const bypass = isNotEmpty(options.force);
@@ -43,9 +43,7 @@ export default class DbSeedCommand {
43
43
  .error()
44
44
  .show());
45
45
  if (confirm.toUpperCase() === "Y") {
46
- const spinner = ora(Chalk.setValue("Seeding...")
47
- .info()
48
- .show()).start();
46
+ const spinner = ora(Chalk.setValue("Seeding...").info().show()).start();
49
47
  try {
50
48
  const logs = (await database.seed.run({
51
49
  specific: seeder
@@ -27,9 +27,7 @@ export default class MakeMigrationCommand {
27
27
  *
28
28
  * @var $arguments Array<Array<string>>
29
29
  */
30
- $arguments = [
31
- ["<file>", "The name of the migration file"]
32
- ];
30
+ $arguments = [["<file>", "The name of the migration file"]];
33
31
  async handle(options, args) {
34
32
  if (isEmpty(args)) {
35
33
  Logger.setContext("APP").error("There is no filename provided.");
@@ -38,22 +36,27 @@ export default class MakeMigrationCommand {
38
36
  const file = args;
39
37
  const migrationsDirectory = "migrations";
40
38
  const template = Bun.file(path.resolve(__dirname, `../../stubs/database/${migrationsDirectory}/migration_template.ts`));
41
- if (!await template.exists()) {
39
+ if (!(await template.exists())) {
42
40
  Logger.setContext("APP").error("Whoops, something went wrong, the migration template not found.");
43
41
  return;
44
42
  }
45
43
  const now = Luxon.DateTime.now().toFormat("yyyyMMdd");
46
44
  const latest = Array.from(new Bun.Glob("**/*").scanSync({
47
45
  cwd: App.Path.databasePath(migrationsDirectory)
48
- })).map((value) => {
46
+ }))
47
+ .map((value) => {
49
48
  const split = value.split("_").slice(0, 2);
50
49
  return {
51
50
  date: split[0],
52
51
  count: split[1]
53
52
  };
54
- }).filter((value) => {
53
+ })
54
+ .filter((value) => {
55
55
  return value.date === now;
56
- }).map((value) => value.count).sort().reverse()[0];
56
+ })
57
+ .map((value) => value.count)
58
+ .sort()
59
+ .reverse()[0];
57
60
  const counter = defineValue(parseInt(latest), 0);
58
61
  const destination = `${migrationsDirectory}/${now}_${String(counter + 1).padStart(6, "0")}_${file}.ts`;
59
62
  await Bun.write(App.Path.databasePath(destination), await template.text());
@@ -27,9 +27,7 @@ export default class MakeSeederCommand {
27
27
  *
28
28
  * @var $arguments Array<Array<string>>
29
29
  */
30
- $arguments = [
31
- ["<file>", "The name of the seeder file"]
32
- ];
30
+ $arguments = [["<file>", "The name of the seeder file"]];
33
31
  async handle(options, args) {
34
32
  if (isEmpty(args)) {
35
33
  Logger.setContext("APP").error("There is no filename provided.");
@@ -38,22 +36,27 @@ export default class MakeSeederCommand {
38
36
  const file = args;
39
37
  const seedersDirectory = "seeders";
40
38
  const template = Bun.file(path.resolve(__dirname, `../../stubs/database/${seedersDirectory}/seeder_template.ts`));
41
- if (!await template.exists()) {
39
+ if (!(await template.exists())) {
42
40
  Logger.setContext("APP").error("Whoops, something went wrong, the seeder template not found.");
43
41
  return;
44
42
  }
45
43
  const now = Luxon.DateTime.now().toFormat("yyyyMMdd");
46
44
  const latest = Array.from(new Bun.Glob("**/*").scanSync({
47
45
  cwd: App.Path.databasePath(seedersDirectory)
48
- })).map((value) => {
46
+ }))
47
+ .map((value) => {
49
48
  const split = value.split("_").slice(0, 2);
50
49
  return {
51
50
  date: split[0],
52
51
  count: split[1]
53
52
  };
54
- }).filter((value) => {
53
+ })
54
+ .filter((value) => {
55
55
  return value.date === now;
56
- }).map((value) => value.count).sort().reverse()[0];
56
+ })
57
+ .map((value) => value.count)
58
+ .sort()
59
+ .reverse()[0];
57
60
  const counter = defineValue(parseInt(latest), 0);
58
61
  const destination = `${seedersDirectory}/${now}_${String(counter + 1).padStart(6, "0")}_${file}.ts`;
59
62
  await Bun.write(App.Path.databasePath(destination), await template.text());
@@ -23,5 +23,5 @@ export default class MigrateFreshCommand {
23
23
  * @var $arguments Array<Array<string>>
24
24
  */
25
25
  protected $arguments: Array<Array<string>>;
26
- handle(options: any, args: Array<string>): Promise<void>;
26
+ handle(options: any): Promise<void>;
27
27
  }
@@ -21,16 +21,14 @@ export default class MigrateFreshCommand {
21
21
  *
22
22
  * @var $options Array<Array<any>>
23
23
  */
24
- $options = [
25
- ["-f, --force", "Skip command confirmation"]
26
- ];
24
+ $options = [["-f, --force", "Skip command confirmation"]];
27
25
  /**
28
26
  * The arguments of the console command.
29
27
  *
30
28
  * @var $arguments Array<Array<string>>
31
29
  */
32
30
  $arguments = [];
33
- async handle(options, args) {
31
+ async handle(options) {
34
32
  const database = Database.knex();
35
33
  const bypass = isNotEmpty(options.force);
36
34
  let confirm = "Y";
@@ -42,9 +40,7 @@ export default class MigrateFreshCommand {
42
40
  if (confirm.toUpperCase() === "Y") {
43
41
  if (!bypass)
44
42
  Logger.empty();
45
- const spinner = ora(Chalk.setValue("Rollback...")
46
- .info()
47
- .show()).start();
43
+ const spinner = ora(Chalk.setValue("Rollback...").info().show()).start();
48
44
  try {
49
45
  await database.migrate.rollback({}, true);
50
46
  spinner.succeed("Rolled back all migrations");
@@ -23,5 +23,5 @@ export default class MigrateLatestCommand {
23
23
  * @var $arguments Array<Array<string>>
24
24
  */
25
25
  protected $arguments: Array<Array<string>>;
26
- handle(options: any, args: Array<string>): Promise<void>;
26
+ handle(): Promise<void>;
27
27
  }
@@ -26,11 +26,9 @@ export default class MigrateLatestCommand {
26
26
  * @var $arguments Array<Array<string>>
27
27
  */
28
28
  $arguments = [];
29
- async handle(options, args) {
29
+ async handle() {
30
30
  const database = Database.knex();
31
- const spinner = ora(Chalk.setValue("Migrating...")
32
- .info()
33
- .show()).start();
31
+ const spinner = ora(Chalk.setValue("Migrating...").info().show()).start();
34
32
  try {
35
33
  const [batchNo, logs] = await database.migrate.latest();
36
34
  spinner.succeed(`Batch ${batchNo} finished`);
@@ -23,5 +23,5 @@ export default class MigrateRollbackCommand {
23
23
  * @var $arguments Array<Array<string>>
24
24
  */
25
25
  protected $arguments: Array<Array<string>>;
26
- handle(options: any, args: Array<string>): Promise<void>;
26
+ handle(options: any): Promise<void>;
27
27
  }
@@ -21,16 +21,14 @@ export default class MigrateRollbackCommand {
21
21
  *
22
22
  * @var $options Array<Array<any>>
23
23
  */
24
- $options = [
25
- ["-f, --force", "Skip command confirmation"]
26
- ];
24
+ $options = [["-f, --force", "Skip command confirmation"]];
27
25
  /**
28
26
  * The arguments of the console command.
29
27
  *
30
28
  * @var $arguments Array<Array<string>>
31
29
  */
32
30
  $arguments = [];
33
- async handle(options, args) {
31
+ async handle(options) {
34
32
  const database = Database.knex();
35
33
  const bypass = isNotEmpty(options.force);
36
34
  let confirm = "Y";
@@ -42,9 +40,7 @@ export default class MigrateRollbackCommand {
42
40
  if (confirm.toUpperCase() === "Y") {
43
41
  if (!bypass)
44
42
  Logger.empty();
45
- const spinner = ora(Chalk.setValue("Rollback...")
46
- .info()
47
- .show()).start();
43
+ const spinner = ora(Chalk.setValue("Rollback...").info().show()).start();
48
44
  try {
49
45
  const [batchNo, logs] = await database.migrate.rollback();
50
46
  spinner.succeed(`Batch ${batchNo} finished`);
@@ -23,5 +23,5 @@ export default class MigrateStatusCommand {
23
23
  * @var $arguments Array<Array<string>>
24
24
  */
25
25
  protected $arguments: Array<Array<string>>;
26
- handle(options: any, args: Array<string>): Promise<void>;
26
+ handle(): Promise<void>;
27
27
  }
@@ -20,20 +20,16 @@ export default class MigrateStatusCommand {
20
20
  *
21
21
  * @var $options Array<Array<any>>
22
22
  */
23
- $options = [
24
- ["-f, --force", "Skip command confirmation"]
25
- ];
23
+ $options = [["-f, --force", "Skip command confirmation"]];
26
24
  /**
27
25
  * The arguments of the console command.
28
26
  *
29
27
  * @var $arguments Array<Array<string>>
30
28
  */
31
29
  $arguments = [];
32
- async handle(options, args) {
30
+ async handle() {
33
31
  const database = Database.knex();
34
- const spinner = ora(Chalk.setValue("Fetching...")
35
- .info()
36
- .show()).start();
32
+ const spinner = ora(Chalk.setValue("Fetching...").info().show()).start();
37
33
  try {
38
34
  const [completed, pending] = await database.migrate.list();
39
35
  spinner.succeed("Completed Migrations :");
package/configure.js CHANGED
@@ -5,8 +5,7 @@ const configPath = path.resolve(__dirname, "config");
5
5
  const regex = /\.(m?js|ts)$/;
6
6
  const configs = Array.from(new Bun.Glob("**/*").scanSync({
7
7
  cwd: configPath
8
- })).filter(value => (regex.test(value) &&
9
- !value.endsWith(".d.ts")));
8
+ })).filter((value) => regex.test(value) && !value.endsWith(".d.ts"));
10
9
  for (const config of configs) {
11
10
  const destination = config.replace(regex, ".ts");
12
11
  await Bun.write(App.Path.configPath(destination), await Bun.file(path.resolve(configPath, config)).text());
@@ -0,0 +1,61 @@
1
+ import js from "@eslint/js";
2
+ import eslintConfigPrettier from "eslint-config-prettier";
3
+ import globals from "globals";
4
+ import tseslint from "typescript-eslint";
5
+
6
+ export default tseslint.config(
7
+ {
8
+ ignores: [
9
+ "node_modules/**",
10
+ "dist/**",
11
+ "out/**",
12
+ "coverage/**",
13
+ "public/**",
14
+ "storage/app/**",
15
+ "storage/cache/**",
16
+ "storage/framework/**",
17
+ "bun.lock",
18
+ "*.tsbuildinfo"
19
+ ]
20
+ },
21
+
22
+ js.configs.recommended,
23
+ ...tseslint.configs.recommended,
24
+
25
+ // All TypeScript (server code + resources/views), no React-specific rules
26
+ {
27
+ files: ["**/*.{ts,tsx}"],
28
+ languageOptions: {
29
+ ecmaVersion: "latest",
30
+ sourceType: "module",
31
+ parserOptions: {
32
+ ecmaFeatures: {
33
+ experimentalDecorators: true
34
+ }
35
+ },
36
+ globals: {
37
+ ...globals.node,
38
+ ...globals.browser,
39
+ Bun: "readonly"
40
+ }
41
+ },
42
+ rules: {
43
+ "no-unused-vars": "off",
44
+ "@typescript-eslint/no-unused-vars": [
45
+ "warn",
46
+ {
47
+ argsIgnorePattern: "^_",
48
+ varsIgnorePattern: "^_"
49
+ }
50
+ ],
51
+ "@typescript-eslint/no-explicit-any": "off",
52
+ "@typescript-eslint/no-empty-object-type": "off",
53
+ "@typescript-eslint/no-inferrable-types": "off",
54
+ "@typescript-eslint/no-require-imports": "off",
55
+ "no-console": "off"
56
+ }
57
+ },
58
+
59
+ // Prettier must be last: turns off stylistic rules that conflict with formatting
60
+ eslintConfigPrettier
61
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/database",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,8 +9,15 @@
9
9
  "main": "index.js",
10
10
  "module": "index.js",
11
11
  "devDependencies": {
12
- "@types/bun": "latest",
13
- "tsc-alias": "^1.8.17"
12
+ "@eslint/js": "^10.0.1",
13
+ "@types/bun": "^1.3.14",
14
+ "eslint": "^10.8.1",
15
+ "eslint-config-prettier": "^10.1.8",
16
+ "globals": "^17.11.0",
17
+ "prettier": "^3.9.6",
18
+ "tsc-alias": "^1.9.2",
19
+ "typescript": "^6.0.3",
20
+ "typescript-eslint": "^8.67.0"
14
21
  },
15
22
  "bugs": {
16
23
  "url": "https://github.com/Bejibun-Framework/bejibun-database/issues"
@@ -26,22 +33,25 @@
26
33
  ],
27
34
  "license": "MIT",
28
35
  "scripts": {
29
- "alias": "bunx tsc-alias -p tsconfig.json",
36
+ "alias": "tsc-alias -p tsconfig.json",
30
37
  "clean-stubs": "rm -rf stubs",
31
38
  "stubs": "cp -rf src/stubs dist",
32
39
  "rsync": "rsync -a dist/ ./",
33
40
  "clean": "rm -rf dist",
34
- "build": "bun run clean-stubs && bunx tsc -p tsconfig.json && bun run alias && bun run stubs && bun run rsync && bun run clean",
41
+ "format": "prettier --write src --log-level=silent",
42
+ "eslint": "eslint src",
43
+ "lint": "bun run format && bun run eslint",
44
+ "build": "bun run lint && bun run clean-stubs && tsc -p tsconfig.json && bun run alias && bun run stubs && bun run rsync && bun run clean",
35
45
  "deploy": "bun run build && bun publish --access public"
36
46
  },
37
47
  "type": "module",
38
48
  "types": "index.d.ts",
39
49
  "dependencies": {
40
- "@bejibun/app": "^0.1.24",
41
- "@bejibun/logger": "^0.1.22",
42
- "@bejibun/utils": "^0.1.28",
43
- "knex": "^3.2.10",
44
- "ora": "^9.4.0",
45
- "pg": "^8.21.0"
50
+ "@bejibun/app": "^0.1.25",
51
+ "@bejibun/logger": "^0.1.23",
52
+ "@bejibun/utils": "^0.1.29",
53
+ "knex": "^3.3.0",
54
+ "ora": "^9.4.1",
55
+ "pg": "^8.23.0"
46
56
  }
47
57
  }
@@ -1,13 +1,13 @@
1
- import type {Knex} from "knex";
2
-
3
- export function up(knex: Knex): Knex.SchemaBuilder {
4
- return knex.schema.createTable("tests", (table: Knex.TableBuilder) => {
5
- table.bigIncrements("id");
6
- table.timestamps(true, true);
7
- table.timestamp("deleted_at");
8
- });
9
- }
10
-
11
- export function down(knex: Knex): Knex.SchemaBuilder {
12
- return knex.schema.dropTable("tests");
13
- }
1
+ import type {Knex} from "knex";
2
+
3
+ export function up(knex: Knex): Knex.SchemaBuilder {
4
+ return knex.schema.createTable("tests", (table: Knex.TableBuilder) => {
5
+ table.bigIncrements("id");
6
+ table.timestamps(true, true);
7
+ table.timestamp("deleted_at");
8
+ });
9
+ }
10
+
11
+ export function down(knex: Knex): Knex.SchemaBuilder {
12
+ return knex.schema.dropTable("tests");
13
+ }
@@ -1,2 +1 @@
1
- import type { Knex } from "knex";
2
- export declare function seed(knex: Knex): Promise<void>;
1
+ export declare function seed(knex: any): Promise<void>;
@@ -1,3 +1,6 @@
1
1
  export async function seed(knex) {
2
- // Your code goes here...
2
+ // @ts-expect-error for sample purposes
3
+ await TestModel.query(knex).insert({
4
+ name: "Sample"
5
+ });
3
6
  }
@@ -1,5 +1,6 @@
1
- import type {Knex} from "knex";
2
-
3
- export async function seed(knex: Knex): Promise<void> {
4
- // Your code goes here...
5
- }
1
+ export async function seed(knex: any): Promise<void> {
2
+ // @ts-expect-error for sample purposes
3
+ await TestModel.query(knex).insert({
4
+ name: "Sample"
5
+ });
6
+ }