@bejibun/core 0.1.48 → 0.1.50
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.
- package/CHANGELOG.md +17 -0
- package/README.md +5 -1
- package/commands/make/MakeModelCommand.d.ts +27 -0
- package/commands/make/MakeModelCommand.js +51 -0
- package/commands/make/MakeValidatorCommand.d.ts +27 -0
- package/commands/make/MakeValidatorCommand.js +51 -0
- package/package.json +1 -1
- package/stubs/models/TemplateModel.ts +17 -0
- package/stubs/validators/TemplateValidator.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
## [v0.1.49](https://github.com/crenata/bejibun-core/compare/v0.1.47...v0.1.49) - 2025-10-27
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
|
|
10
|
+
### 📖 Changes
|
|
11
|
+
What's New :
|
|
12
|
+
- Adding `make:model <file>` to create a new model file
|
|
13
|
+
- Adding `make:validator <file>` to create a new validator file
|
|
14
|
+
|
|
15
|
+
### ❤️Contributors
|
|
16
|
+
- Havea Crenata ([@crenata](https://github.com/crenata))
|
|
17
|
+
- Ghulje ([@ghulje](https://github.com/ghulje))
|
|
18
|
+
|
|
19
|
+
**Full Changelog**: https://github.com/crenata/bejibun-core/blob/master/CHANGELOG.md
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
6
23
|
## [v0.1.47](https://github.com/crenata/bejibun-core/compare/v0.1.44...v0.1.47) - 2025-10-26
|
|
7
24
|
|
|
8
25
|
### 🩹 Fixes
|
package/README.md
CHANGED
|
@@ -45,7 +45,9 @@ Commands:
|
|
|
45
45
|
make:controller <file> Create a new controller file
|
|
46
46
|
make:middleware <file> Create a new middleware file
|
|
47
47
|
make:migration <file> Create a new migration file
|
|
48
|
+
make:model <file> Create a new model file
|
|
48
49
|
make:seeder <file> Create a new seeder file
|
|
50
|
+
make:validator <file> Create a new validator file
|
|
49
51
|
migrate:fresh [options] Rollback all migrations and re-run migrations
|
|
50
52
|
migrate:latest Run latest migration
|
|
51
53
|
migrate:rollback [options] Rollback the latest migrations
|
|
@@ -91,4 +93,6 @@ Or if you are prefer using crypto :
|
|
|
91
93
|
| EVM | Solana |
|
|
92
94
|
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
93
95
|
| <img src="https://github.com/crenata/bejibun/blob/master/public/images/EVM.png?raw=true" width="150" /> | <img src="https://github.com/crenata/bejibun/blob/master/public/images/SOL.png?raw=true" width="150" /> |
|
|
94
|
-
| 0xdABe8750061410D35cE52EB2a418c8cB004788B3 | GAnoyvy9p3QFyxikWDh9hA3fmSk2uiPLNWyQ579cckMn |
|
|
96
|
+
| 0xdABe8750061410D35cE52EB2a418c8cB004788B3 | GAnoyvy9p3QFyxikWDh9hA3fmSk2uiPLNWyQ579cckMn |
|
|
97
|
+
|
|
98
|
+
Or you can buy this `$BJBN (Bejibun)` tokens [here](https://pump.fun/coin/CQhbNnCGKfDaKXt8uE61i5DrBYJV7NPsCDD9vQgypump), beware of bots.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default class MakeModelCommand {
|
|
2
|
+
/**
|
|
3
|
+
* The name and signature of the console command.
|
|
4
|
+
*
|
|
5
|
+
* @var $signature string
|
|
6
|
+
*/
|
|
7
|
+
protected $signature: string;
|
|
8
|
+
/**
|
|
9
|
+
* The console command description.
|
|
10
|
+
*
|
|
11
|
+
* @var $description string
|
|
12
|
+
*/
|
|
13
|
+
protected $description: string;
|
|
14
|
+
/**
|
|
15
|
+
* The options or optional flag of the console command.
|
|
16
|
+
*
|
|
17
|
+
* @var $options Array<Array<any>>
|
|
18
|
+
*/
|
|
19
|
+
protected $options: Array<Array<any>>;
|
|
20
|
+
/**
|
|
21
|
+
* The arguments of the console command.
|
|
22
|
+
*
|
|
23
|
+
* @var $arguments Array<Array<string>>
|
|
24
|
+
*/
|
|
25
|
+
protected $arguments: Array<Array<string>>;
|
|
26
|
+
handle(options: any, args: string): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import App from "@bejibun/app";
|
|
2
|
+
import Logger from "@bejibun/logger";
|
|
3
|
+
import { isEmpty } from "@bejibun/utils";
|
|
4
|
+
import Str from "@bejibun/utils/facades/Str";
|
|
5
|
+
import path from "path";
|
|
6
|
+
export default class MakeModelCommand {
|
|
7
|
+
/**
|
|
8
|
+
* The name and signature of the console command.
|
|
9
|
+
*
|
|
10
|
+
* @var $signature string
|
|
11
|
+
*/
|
|
12
|
+
$signature = "make:model";
|
|
13
|
+
/**
|
|
14
|
+
* The console command description.
|
|
15
|
+
*
|
|
16
|
+
* @var $description string
|
|
17
|
+
*/
|
|
18
|
+
$description = "Create a new model file";
|
|
19
|
+
/**
|
|
20
|
+
* The options or optional flag of the console command.
|
|
21
|
+
*
|
|
22
|
+
* @var $options Array<Array<any>>
|
|
23
|
+
*/
|
|
24
|
+
$options = [];
|
|
25
|
+
/**
|
|
26
|
+
* The arguments of the console command.
|
|
27
|
+
*
|
|
28
|
+
* @var $arguments Array<Array<string>>
|
|
29
|
+
*/
|
|
30
|
+
$arguments = [
|
|
31
|
+
["<file>", "The name of the model file"]
|
|
32
|
+
];
|
|
33
|
+
async handle(options, args) {
|
|
34
|
+
if (isEmpty(args)) {
|
|
35
|
+
Logger.setContext("APP").error("There is no filename provided.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const file = args;
|
|
39
|
+
const modelsDirectory = "models";
|
|
40
|
+
const template = Bun.file(path.resolve(__dirname, `../../stubs/${modelsDirectory}/TemplateModel.ts`));
|
|
41
|
+
if (!await template.exists()) {
|
|
42
|
+
Logger.setContext("APP").error("Whoops, something went wrong, the model template not found.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const name = Str.toPascalCase(file.replace(/\s+/g, "").replace(/model/gi, ""));
|
|
46
|
+
const destination = `${name}Model.ts`;
|
|
47
|
+
const content = await template.text();
|
|
48
|
+
await Bun.write(App.Path.modelsPath(destination), content.replace(/template/gi, name));
|
|
49
|
+
Logger.setContext("APP").info(`Model [app/models/${destination}] created successfully.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default class MakeValidatorCommand {
|
|
2
|
+
/**
|
|
3
|
+
* The name and signature of the console command.
|
|
4
|
+
*
|
|
5
|
+
* @var $signature string
|
|
6
|
+
*/
|
|
7
|
+
protected $signature: string;
|
|
8
|
+
/**
|
|
9
|
+
* The console command description.
|
|
10
|
+
*
|
|
11
|
+
* @var $description string
|
|
12
|
+
*/
|
|
13
|
+
protected $description: string;
|
|
14
|
+
/**
|
|
15
|
+
* The options or optional flag of the console command.
|
|
16
|
+
*
|
|
17
|
+
* @var $options Array<Array<any>>
|
|
18
|
+
*/
|
|
19
|
+
protected $options: Array<Array<any>>;
|
|
20
|
+
/**
|
|
21
|
+
* The arguments of the console command.
|
|
22
|
+
*
|
|
23
|
+
* @var $arguments Array<Array<string>>
|
|
24
|
+
*/
|
|
25
|
+
protected $arguments: Array<Array<string>>;
|
|
26
|
+
handle(options: any, args: string): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import App from "@bejibun/app";
|
|
2
|
+
import Logger from "@bejibun/logger";
|
|
3
|
+
import { isEmpty } from "@bejibun/utils";
|
|
4
|
+
import Str from "@bejibun/utils/facades/Str";
|
|
5
|
+
import path from "path";
|
|
6
|
+
export default class MakeValidatorCommand {
|
|
7
|
+
/**
|
|
8
|
+
* The name and signature of the console command.
|
|
9
|
+
*
|
|
10
|
+
* @var $signature string
|
|
11
|
+
*/
|
|
12
|
+
$signature = "make:validator";
|
|
13
|
+
/**
|
|
14
|
+
* The console command description.
|
|
15
|
+
*
|
|
16
|
+
* @var $description string
|
|
17
|
+
*/
|
|
18
|
+
$description = "Create a new validator file";
|
|
19
|
+
/**
|
|
20
|
+
* The options or optional flag of the console command.
|
|
21
|
+
*
|
|
22
|
+
* @var $options Array<Array<any>>
|
|
23
|
+
*/
|
|
24
|
+
$options = [];
|
|
25
|
+
/**
|
|
26
|
+
* The arguments of the console command.
|
|
27
|
+
*
|
|
28
|
+
* @var $arguments Array<Array<string>>
|
|
29
|
+
*/
|
|
30
|
+
$arguments = [
|
|
31
|
+
["<file>", "The name of the validator file"]
|
|
32
|
+
];
|
|
33
|
+
async handle(options, args) {
|
|
34
|
+
if (isEmpty(args)) {
|
|
35
|
+
Logger.setContext("APP").error("There is no filename provided.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const file = args;
|
|
39
|
+
const validatorsDirectory = "validators";
|
|
40
|
+
const template = Bun.file(path.resolve(__dirname, `../../stubs/${validatorsDirectory}/TemplateValidator.ts`));
|
|
41
|
+
if (!await template.exists()) {
|
|
42
|
+
Logger.setContext("APP").error("Whoops, something went wrong, the validator template not found.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const name = Str.toPascalCase(file.replace(/\s+/g, "").replace(/validator/gi, ""));
|
|
46
|
+
const destination = `${name}Validator.ts`;
|
|
47
|
+
const content = await template.text();
|
|
48
|
+
await Bun.write(App.Path.validatorsPath(destination), content.replace(/template/gi, name));
|
|
49
|
+
Logger.setContext("APP").info(`Validator [app/validators/${destination}] created successfully.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import BaseModel, {BaseColumns} from "@bejibun/core/bases/BaseModel";
|
|
2
|
+
import Luxon from "@bejibun/utils/facades/Luxon";
|
|
3
|
+
|
|
4
|
+
export interface TemplateColumns extends BaseColumns {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default class TemplateModel extends BaseModel implements TemplateColumns {
|
|
9
|
+
public static tableName: string = "templates";
|
|
10
|
+
public static idColumn: string = "id";
|
|
11
|
+
|
|
12
|
+
declare id: bigint;
|
|
13
|
+
declare name: string;
|
|
14
|
+
declare created_at: Luxon.DateTime | string;
|
|
15
|
+
declare updated_at: Luxon.DateTime | string;
|
|
16
|
+
declare deleted_at: Luxon.DateTime | string | null;
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {ValidatorType} from "@bejibun/core/types/ValidatorType";
|
|
2
|
+
import BaseValidator from "@bejibun/core/bases/BaseValidator";
|
|
3
|
+
import TemplateModel from "@/app/models/TemplateModel";
|
|
4
|
+
|
|
5
|
+
export default class TemplateValidator extends BaseValidator {
|
|
6
|
+
public static get index(): ValidatorType {
|
|
7
|
+
return super.validator.compile(
|
|
8
|
+
super.validator.object({
|
|
9
|
+
search: super.validator.string().nullable().optional()
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static get store(): ValidatorType {
|
|
15
|
+
return super.validator.compile(
|
|
16
|
+
super.validator.object({
|
|
17
|
+
name: super.validator.string()
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static get show(): ValidatorType {
|
|
23
|
+
return super.validator.compile(
|
|
24
|
+
super.validator.object({
|
|
25
|
+
id: super.validator.number().min(1).exists(TemplateModel, "id")
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static get update(): ValidatorType {
|
|
31
|
+
return super.validator.compile(
|
|
32
|
+
super.validator.object({
|
|
33
|
+
id: super.validator.number().min(1).exists(TemplateModel, "id"),
|
|
34
|
+
name: super.validator.string()
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public static get destroy(): ValidatorType {
|
|
40
|
+
return super.validator.compile(
|
|
41
|
+
super.validator.object({
|
|
42
|
+
id: super.validator.number().min(1).exists(TemplateModel, "id")
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|