@codenameryuu/adonis-lucid-filter 2.5.0 → 2.6.0

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/README.md CHANGED
@@ -12,7 +12,7 @@ This addon adds the functionality to filter Lucid Models
12
12
 
13
13
  Example, we want to return a list of users filtered by multiple parameters. When we navigate to:
14
14
 
15
- `/users?name=Tony&lastName=&companyId=2&industry=5`
15
+ `/users?name=Tony&lastName=&companyId=2&industry=5`
16
16
 
17
17
  `request.all()` or `request.qs()` will return:
18
18
 
@@ -65,13 +65,13 @@ export default class UsersController {
65
65
 
66
66
  ## Installation
67
67
 
68
- * Install the package
68
+ - Install the package
69
69
 
70
70
  ```bash
71
71
  yarn add @codenameryuu/adonis-lucid-filter
72
72
  ```
73
73
 
74
- * Configure the package
74
+ - Configure the package
75
75
 
76
76
  ```bash
77
77
  node ace configure @codenameryuu/adonis-lucid-filter
@@ -79,7 +79,7 @@ node ace configure @codenameryuu/adonis-lucid-filter
79
79
 
80
80
  ## Usage
81
81
 
82
- * Register the provider and commands inside `adonisrc.ts` file.
82
+ - Register the provider and commands inside `adonisrc.ts` file.
83
83
 
84
84
  ```ts
85
85
  providers: [
@@ -108,13 +108,13 @@ Where `user` is the Lucid Model you are creating the filter for. This will creat
108
108
 
109
109
  Define the filter logic based on the camel cased input key passed to the `filter()` method.
110
110
 
111
- * Empty strings are ignored
112
- * `setup()` will be called regardless of input
113
- * `_id` is dropped from the end of the input to define the method so filtering `user_id` would use the `user()` method
114
- * Input without a corresponding filter method are ignored
115
- * The value of the key is injected into the method
116
- * All values are accessible through the `this.$input` a property
117
- * All QueryBuilder methods are accessible in `this.$query` object in the model filter class.
111
+ - Empty strings are ignored
112
+ - `setup()` will be called regardless of input
113
+ - `_id` is dropped from the end of the input to define the method so filtering `user_id` would use the `user()` method
114
+ - Input without a corresponding filter method are ignored
115
+ - The value of the key is injected into the method
116
+ - All values are accessible through the `this.$input` a property
117
+ - All QueryBuilder methods are accessible in `this.$query` object in the model filter class.
118
118
 
119
119
  To define methods for the following input:
120
120
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codenameryuu/adonis-lucid-filter",
3
3
  "description": "Addon for filtering Adonis JS 7 Lucid ORM",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "author": "codenameryuu",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/codenameryuu/adonis-lucid-filter#readme",
@@ -12,7 +12,6 @@
12
12
  "engines": {
13
13
  "node": ">=24.0.0"
14
14
  },
15
- "main": "./build/index.js",
16
15
  "type": "module",
17
16
  "files": [
18
17
  "build",
@@ -31,18 +30,17 @@
31
30
  "format": "prettier --write .",
32
31
  "clean": "del-cli build",
33
32
  "precompile": "npm run lint && npm run clean",
34
- "postcompile": "npm run copy:stubs && npm run index:commands",
35
33
  "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
36
34
  "build": "npm run compile",
37
- "copy:stubs": "copyfiles \"stubs/**/**/*.stub\" --up=\"1\" build",
38
- "index:commands": "adonis-kit index build/commands",
39
- "quick:test": "NODE_DEBUG=\"adonis-lucid-filter\" node --enable-source-maps --loader=ts-node/esm bin/test.ts",
40
35
  "pretest": "npm run lint",
41
36
  "test": "c8 npm run quick:test",
42
37
  "typecheck": "tsc --noEmit",
43
38
  "version": "npm run build",
44
39
  "prepublishOnly": "npm run build",
45
- "release": "np"
40
+ "release": "np",
41
+ "quick:test": "NODE_DEBUG=\"adonis-lucid-filter\" node --enable-source-maps --loader=ts-node/esm bin/test.ts",
42
+ "copy:stubs": "copyfiles \"stubs/**/**/*.stub\" --up=\"1\" build",
43
+ "index:commands": "adonis-kit index build/commands"
46
44
  },
47
45
  "devDependencies": {
48
46
  "@adonisjs/assembler": "^7.7.0",
@@ -66,17 +64,15 @@
66
64
  "knex": "^3.1.0",
67
65
  "lodash": "^4.17.23",
68
66
  "luxon": "^3.4.4",
67
+ "np": "^11.0.2",
69
68
  "prettier": "^3.8.1",
70
69
  "reflect-metadata": "^0.2.2",
71
- "sqlite3": "^5.1.7",
72
70
  "ts-node": "^10.9.2",
73
71
  "tsup": "^8.1.0",
72
+ "type-fest": "^4.21.0",
74
73
  "typescript": "^5.5.3",
75
74
  "youch": "^4.1.0"
76
75
  },
77
- "dependencies": {
78
- "type-fest": "^4.21.0"
79
- },
80
76
  "peerDependencies": {
81
77
  "@adonisjs/core": "^7.0.0",
82
78
  "@adonisjs/lucid": "^22.0.0"
@@ -91,9 +87,6 @@
91
87
  "adonis-filter",
92
88
  "adonis-lucid-filter"
93
89
  ],
94
- "eslintConfig": {
95
- "extends": "@adonisjs/eslint-config/package"
96
- },
97
90
  "prettier": "@adonisjs/prettier-config",
98
91
  "publishConfig": {
99
92
  "access": "public",
@@ -1 +0,0 @@
1
- {"commands":[{"commandName":"make:filter","description":"Make a new Lucid filter","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the model file","type":"string"}],"options":{},"filePath":"make_filter.js"}],"version":1}
@@ -1,4 +0,0 @@
1
- import { CommandMetaData, Command } from '@adonisjs/ace/types';
2
-
3
- export function getMetaData(): Promise<CommandMetaData[]>
4
- export function getCommand(metaData: CommandMetaData): Promise<Command | null>
@@ -1,36 +0,0 @@
1
- import { readFile } from 'node:fs/promises'
2
-
3
- /**
4
- * In-memory cache of commands after they have been loaded
5
- */
6
- let commandsMetaData
7
-
8
- /**
9
- * Reads the commands from the "./commands.json" file. Since, the commands.json
10
- * file is generated automatically, we do not have to validate its contents
11
- */
12
- export async function getMetaData() {
13
- if (commandsMetaData) {
14
- return commandsMetaData
15
- }
16
-
17
- const commandsIndex = await readFile(new URL('./commands.json', import.meta.url), 'utf-8')
18
- commandsMetaData = JSON.parse(commandsIndex).commands
19
-
20
- return commandsMetaData
21
- }
22
-
23
- /**
24
- * Imports the command by lookingup its path from the commands
25
- * metadata
26
- */
27
- export async function getCommand(metaData) {
28
- const commands = await getMetaData()
29
- const command = commands.find(({ commandName }) => metaData.commandName === commandName)
30
- if (!command) {
31
- return null
32
- }
33
-
34
- const { default: commandConstructor } = await import(new URL(command.filePath, import.meta.url).href)
35
- return commandConstructor
36
- }
@@ -1,20 +0,0 @@
1
- {{#var entity = generators.createEntity(name)}}
2
- {{#var modelName = generators.modelName(entity.name)}}
3
- {{#var modelFileName = string(modelName).removeExtension().snakeCase().toString()}}
4
- {{#var modelFilterName = string(modelName).removeSuffix('filter').pascalCase().suffix(string.pascalCase('filter')).toString()}}
5
- {{#var modelFilterFileName = string(modelName).snakeCase().suffix('_filter').ext('.ts').toString()}}
6
- {{{
7
- exports({ to: app.modelsPath('filters', entity.path, modelFilterFileName) })
8
- }}}
9
-
10
- import { BaseModelFilter } from 'adonis-lucid-filter'
11
- import type { ModelQueryBuilderContract } from '@adonisjs/lucid/types/model'
12
- import {{ modelName }} from '#models/{{ modelFileName }}'
13
-
14
- export default class {{ modelFilterName }} extends BaseModelFilter {
15
- declare $query: ModelQueryBuilderContract<typeof {{ modelName }}>
16
-
17
- name(value: string): void {
18
- this.$query.where('name', value)
19
- }
20
- }