@kadirgun/lucid-bravo 0.0.3 → 0.0.5
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stubsRoot } from "../stubs/main.js";
|
|
2
2
|
import { BaseCommand, args } from "@adonisjs/core/ace";
|
|
3
3
|
//#region \0@oxc-project+runtime@0.122.0/helpers/decorate.js
|
|
4
4
|
function __decorate(decorators, target, key, desc) {
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { configure } from "./configure.js";
|
|
2
|
-
import {
|
|
2
|
+
import { stubsRoot } from "./stubs/main.js";
|
|
3
3
|
import stringHelpers from "@adonisjs/core/helpers/string";
|
|
4
4
|
import { HttpContext } from "@adonisjs/core/http";
|
|
5
5
|
//#region src/lucid_bravo.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LucidModel,
|
|
2
|
-
import type { BravoParams, BravoSortOption } from './types.ts';
|
|
1
|
+
import type { LucidModel, ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
|
|
2
|
+
import type { BravoParams, BravoSortOption, LucidBravoRelations, LucidBravoAttributes } from './types.ts';
|
|
3
3
|
import { HttpContext } from '@adonisjs/core/http';
|
|
4
4
|
import type { Constructor } from '@adonisjs/core/types/common';
|
|
5
5
|
export declare abstract class LucidBravo<T extends LucidModel> {
|
|
@@ -16,11 +16,11 @@ export declare abstract class LucidBravo<T extends LucidModel> {
|
|
|
16
16
|
/**
|
|
17
17
|
* Return a whitelist of sortable columns
|
|
18
18
|
*/
|
|
19
|
-
getSortable():
|
|
19
|
+
getSortable(): LucidBravoAttributes<T>[];
|
|
20
20
|
/**
|
|
21
21
|
* Return a whitelist of allowed relations for preload include
|
|
22
22
|
*/
|
|
23
|
-
getAllowedIncludes():
|
|
23
|
+
getAllowedIncludes(): LucidBravoRelations<InstanceType<T>>[];
|
|
24
24
|
/**
|
|
25
25
|
* Main entry point to apply all filters, includes, sorting and pagination
|
|
26
26
|
*/
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { LucidModel, LucidRow, ModelAttributes } from '@adonisjs/lucid/types/model';
|
|
2
|
+
import type { ExtractModelRelations } from '@adonisjs/lucid/types/relations';
|
|
1
3
|
export type SortOrder = 'asc' | 'desc';
|
|
2
4
|
export interface BravoSortOption {
|
|
3
5
|
field: string;
|
|
@@ -13,3 +15,5 @@ export interface BravoParams {
|
|
|
13
15
|
include?: string[];
|
|
14
16
|
[key: string]: any;
|
|
15
17
|
}
|
|
18
|
+
export type LucidBravoAttributes<T extends LucidModel> = keyof ModelAttributes<InstanceType<T>> | {};
|
|
19
|
+
export type LucidBravoRelations<T extends LucidRow> = ExtractModelRelations<T> | {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
//#region stubs/main.ts
|
|
4
|
+
/**
|
|
5
|
+
* Path to the root directory where the stubs are stored. We use
|
|
6
|
+
* this path within commands and the configure hook
|
|
7
|
+
*/
|
|
8
|
+
const stubsRoot = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
//#endregion
|
|
10
|
+
export { stubsRoot };
|
|
@@ -7,15 +7,22 @@
|
|
|
7
7
|
to: app.makePath('app/bravos', entity.path, bravoFileName)
|
|
8
8
|
})
|
|
9
9
|
}}}
|
|
10
|
+
|
|
11
|
+
import type { LucidBravoAttributes, LucidBravoRelations } from '@kadirgun/lucid-bravo/types'
|
|
10
12
|
import { LucidBravo } from '@kadirgun/lucid-bravo'
|
|
11
13
|
import {{ entity.name }} from '{{ modelImportPath }}'
|
|
12
|
-
import type { ModelAttributes } from '@adonisjs/lucid/types/model'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
type ModelType = typeof {{ entity.name }}
|
|
16
|
+
|
|
17
|
+
export default class {{ modelName }}Bravo extends LucidBravo<ModelType> {
|
|
15
18
|
protected $model = {{ entity.name }}
|
|
16
19
|
|
|
17
|
-
public override getSortable():
|
|
18
|
-
return []
|
|
20
|
+
public override getSortable(): LucidBravoAttributes<ModelType>[] {
|
|
21
|
+
return ['id', 'title']
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public override getAllowedIncludes(): LucidBravoRelations<{{ entity.name }}>[] {
|
|
25
|
+
return ['user']
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
protected defaultLimit = 20
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kadirgun/lucid-bravo",
|
|
3
3
|
"description": "A powerful, fluent query builder for AdonisJS Lucid to handle filtering, sorting and pagination in a single flow",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"entry": [
|
|
96
96
|
"./index.ts",
|
|
97
97
|
"./configure.ts",
|
|
98
|
+
"./stubs/main.ts",
|
|
98
99
|
"./commands/make_bravo.ts"
|
|
99
100
|
],
|
|
100
101
|
"outDir": "./build",
|
package/build/main-C9qVc2Ss.js
DELETED