@codenameryuu/adonis-lucid-filter 2.0.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.
Files changed (35) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +312 -0
  3. package/build/chunk-FZT5JNRL.js +15 -0
  4. package/build/chunk-FZT5JNRL.js.map +1 -0
  5. package/build/chunk-NBGNVIUM.js +9 -0
  6. package/build/chunk-NBGNVIUM.js.map +1 -0
  7. package/build/chunk-XUS63JTZ.js +18 -0
  8. package/build/chunk-XUS63JTZ.js.map +1 -0
  9. package/build/commands/commands.json +1 -0
  10. package/build/commands/main.d.ts +4 -0
  11. package/build/commands/main.js +36 -0
  12. package/build/commands/make_filter.d.ts +13 -0
  13. package/build/commands/make_filter.js +29 -0
  14. package/build/commands/make_filter.js.map +1 -0
  15. package/build/configure.d.ts +2 -0
  16. package/build/index.d.ts +4 -0
  17. package/build/index.js +111 -0
  18. package/build/index.js.map +1 -0
  19. package/build/make/filter/main.stub +20 -0
  20. package/build/providers/lucid_filter_provider.d.ts +6 -0
  21. package/build/providers/lucid_filter_provider.js +19 -0
  22. package/build/providers/lucid_filter_provider.js.map +1 -0
  23. package/build/src/base_model.d.ts +26 -0
  24. package/build/src/bindings/model_query_builder.d.ts +4 -0
  25. package/build/src/bindings/model_query_builder.js +8 -0
  26. package/build/src/bindings/model_query_builder.js.map +1 -0
  27. package/build/src/mixin.d.ts +154 -0
  28. package/build/src/types/filter.d.ts +47 -0
  29. package/build/src/types/filter.js +1 -0
  30. package/build/src/types/filter.js.map +1 -0
  31. package/build/src/types/querybuilder.d.ts +15 -0
  32. package/build/src/types/querybuilder.js +1 -0
  33. package/build/src/types/querybuilder.js.map +1 -0
  34. package/build/stubs/main.d.ts +1 -0
  35. package/package.json +134 -0
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # The MIT License
2
+
3
+ Copyright (c) 2024 Lookin Anton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,312 @@
1
+ # Adonis Lucid Filter
2
+ > Works with AdonisJS v6
3
+
4
+ [![npm-image]][npm-url] [![license-image]][license-url] [![typescript-image]][typescript-url]
5
+
6
+ This addon adds the functionality to filter Lucid Models
7
+ > Inspired by [EloquentFilter](https://github.com/Tucker-Eric/EloquentFilter)
8
+
9
+ ## Versions
10
+
11
+ > **Note**: Check before install :point_down:
12
+
13
+ | adonis-lucid-filter | @adonisjs/lucid |
14
+ |-------------------------------------|---------------------|
15
+ | ^5.\*.* | ^20.\*.* |
16
+ | ^4.\*.* | <=18.\*.* |
17
+ | ^3.\*.* (`@filterable()` decorator) | ^15.\*.* |
18
+ | ^2.\*.* | 14.\*.* |
19
+
20
+ - Docs [for **Adonis v5**](https://github.com/lookinlab/adonis-lucid-filter/tree/v4)
21
+ - Docs [for **Adonis v4**](https://github.com/lookinlab/adonis-lucid-filter/tree/v1)
22
+ - Docs [for `@filterable()` decorator](https://github.com/lookinlab/adonis-lucid-filter/tree/v3)
23
+
24
+ ## Introduction
25
+ Example, we want to return a list of users filtered by multiple parameters. When we navigate to:
26
+
27
+ `/users?name=Tony&lastName=&companyId=2&industry=5`
28
+
29
+ `request.all()` or `request.qs()` will return:
30
+
31
+ ```json
32
+ {
33
+ "name": "Tony",
34
+ "lastName": "",
35
+ "companyId": 2,
36
+ "industry": 5
37
+ }
38
+ ```
39
+
40
+ To filter by all those parameters we would need to do something like:
41
+
42
+ ```ts
43
+ import type { HttpContext } from '@adonisjs/core/http'
44
+ import User from '#models/user'
45
+
46
+ export default class UsersController {
47
+ async index({ request }: HttpContext): Promise<User[]> {
48
+ const { companyId, lastName, name, industry } = request.qs()
49
+
50
+ const query = User.query().where('company_id', +companyId)
51
+
52
+ if (lastName) {
53
+ query.where('last_name', 'LIKE', `%${lastName}%`)
54
+ }
55
+ if (name) {
56
+ query.where(function () {
57
+ this.where('first_name', 'LIKE', `%${name}%`)
58
+ .orWhere('last_name', 'LIKE', `%${name}%`)
59
+ })
60
+ }
61
+ return query.exec()
62
+ }
63
+
64
+ }
65
+ ```
66
+
67
+ To filter that same input with Lucid Filters:
68
+
69
+ ```ts
70
+ import type { HttpContext } from '@adonisjs/core/http'
71
+ import User from '#models/user'
72
+
73
+ export default class UsersController {
74
+ async index({ request }: HttpContext): Promise<User[]> {
75
+ return User.filter(request.qs()).exec()
76
+ }
77
+ }
78
+ ```
79
+
80
+ ## Installation
81
+
82
+ Make sure to install it using `npm`, `yarn` or `pnpm`.
83
+
84
+ ```bash
85
+ # npm
86
+ npm i adonis-lucid-filter
87
+
88
+ # yarn
89
+ yarn add adonis-lucid-filter
90
+
91
+ # pnpm
92
+ pnpm add adonis-lucid-filter
93
+ ```
94
+
95
+ After install call `configure`:
96
+
97
+ ```bash
98
+ node ace configure adonis-lucid-filter
99
+ ```
100
+
101
+ ## Usage
102
+
103
+ Make sure to register the provider and commands inside `adonisrc.ts` file.
104
+
105
+ ```ts
106
+ providers: [
107
+ // ...
108
+ () => import('adonis-lucid-filter/provider'),
109
+ ],
110
+ commands: [
111
+ // ...
112
+ () => import('adonis-lucid-filter/commands')
113
+ ]
114
+ ```
115
+
116
+ ### Generating The Filter
117
+ > Only available if you have added `adonis-lucid-filter/commands` in `commands` array in your `adonisrc.ts'
118
+
119
+ You can create a model filter with the following ace command:
120
+
121
+ ```bash
122
+ node ace make:filter user
123
+ ```
124
+
125
+ Where `user` is the Lucid Model you are creating the filter for. This will create `app/models/filters/user_filter.js`
126
+
127
+ ### Defining The Filter Logic
128
+ Define the filter logic based on the camel cased input key passed to the `filter()` method.
129
+
130
+ - Empty strings are ignored
131
+ - `setup()` will be called regardless of input
132
+ - `_id` is dropped from the end of the input to define the method so filtering `user_id` would use the `user()` method
133
+ - Input without a corresponding filter method are ignored
134
+ - The value of the key is injected into the method
135
+ - All values are accessible through the `this.$input` a property
136
+ - All QueryBuilder methods are accessible in `this.$query` object in the model filter class.
137
+
138
+ To define methods for the following input:
139
+
140
+ ```json
141
+ {
142
+ "companyId": 5,
143
+ "name": "Tony",
144
+ "mobilePhone": "888555"
145
+ }
146
+ ```
147
+
148
+ You would use the following methods:
149
+
150
+ ```ts
151
+ import { BaseModelFilter } from 'adonis-lucid-filter'
152
+ import type { ModelQueryBuilderContract } from '@adonisjs/lucid/types/model'
153
+ import User from '#models/user'
154
+
155
+ export default class UserFilter extends BaseModelFilter {
156
+ declare $query: ModelQueryBuilderContract<typeof User>
157
+
158
+ static blacklist: string[] = ['secretMethod']
159
+
160
+ // This will filter 'companyId', 'company_id' OR 'company'
161
+ company(id: number) {
162
+ this.$query.where('company_id', id)
163
+ }
164
+
165
+ name(name: string) {
166
+ this.$query.where((builder) => {
167
+ builder
168
+ .where('first_name', 'LIKE', `%${name}%`)
169
+ .orWhere('last_name', 'LIKE', `%${name}%`)
170
+ })
171
+ }
172
+
173
+ mobilePhone(phone: string) {
174
+ this.$query.where('mobile_phone', 'LIKE', `${phone}%`)
175
+ }
176
+
177
+ secretMethod(secretParameter: any) {
178
+ this.$query.where('some_column', true)
179
+ }
180
+ }
181
+ ```
182
+
183
+ #### Blacklist
184
+
185
+ Any methods defined in the `blacklist` array will not be called by the filter.
186
+ Those methods are normally used for internal filter logic.
187
+
188
+ The `whitelistMethod()` methods can be used to dynamically blacklist methods.
189
+
190
+ Example:
191
+ ```ts
192
+ setup($query) {
193
+ this.whitelistMethod('secretMethod')
194
+ this.$query.where('is_admin', true)
195
+ }
196
+ ```
197
+ > `setup()` not may be async
198
+
199
+ > **Note:** All methods inside `setup()` will be called every time `filter()` is called on the model
200
+
201
+ In the example above `secretMethod()` will not be called, even if there is a `secret_method` key in the input object.
202
+ In order to call this method it would need to be whitelisted dynamically:
203
+
204
+ #### Static properties
205
+
206
+ ```ts
207
+ export default class UserFilter extends BaseModelFilter {
208
+ // Blacklisted methods
209
+ static blacklist: string[] = []
210
+
211
+ // Dropped `_id` from the end of the input
212
+ // Doing this would allow you to have a `company()` filter method as well as a `companyId()` filter method.
213
+ static dropId: boolean = true
214
+
215
+ // Doing this would allow you to have a mobile_phone() filter method instead of mobilePhone().
216
+ // By default, mobilePhone() filter method can be called thanks to one of the following input key:
217
+ // mobile_phone, mobilePhone, mobile_phone_id, mobilePhoneId
218
+ static camelCase: boolean = true
219
+ }
220
+ ```
221
+
222
+ ### Applying The Filter To A Model
223
+
224
+ ```ts
225
+ import UserFilter from '#models/filters/user_filter'
226
+ import { compose } from '@adonisjs/core/helpers'
227
+ import { Filterable } from 'adonis-lucid-filter'
228
+
229
+ export default class User extends compose(BaseModel, Filterable) {
230
+ static $filter = () => UserFilter
231
+
232
+ // ...columns and props
233
+ }
234
+ ```
235
+
236
+ This gives you access to the `filter()` method that accepts an object of input:
237
+
238
+ ```ts
239
+ import type { HttpContext } from '@adonisjs/core/http'
240
+ import User from '#models/user'
241
+
242
+ export default class UsersController {
243
+ async index({ request }: HttpContext): Promise<User[]> {
244
+ return User.filter(request.qs()).exec()
245
+ }
246
+
247
+ // or with paginate method
248
+
249
+ async index({ request }: HttpContext): Promise<ModelPaginatorContract<User>> {
250
+ const { page = 1, ...input } = request.qs()
251
+ return User.filter(input).paginate(page, 15)
252
+ }
253
+ }
254
+ ```
255
+
256
+ ### Dynamic Filters
257
+
258
+ You can define the filter dynamically by passing the filter to use as the second parameter of the filter() method.
259
+ Defining a filter dynamically will take precedent over any other filters defined for the model.
260
+
261
+ ```ts
262
+ import type { HttpContext } from '@adonisjs/core/http'
263
+ import AdminFilter from '#models/filters/admin_filter'
264
+ import UserFilter from '#models/filters/user_filter'
265
+
266
+ export default class UsersController {
267
+ async index({ request, auth }: HttpContext): Promise<User[]> {
268
+ const filter = auth.user.isAdmin() ? AdminFilter : UserFilter
269
+ return User.filter(request.qs(), filter).exec()
270
+ }
271
+ }
272
+ ```
273
+
274
+ ### Filtering relations
275
+
276
+ For filtering relations of model may be use `.query().filter()` or scope `filtration`, example:
277
+
278
+ ```ts
279
+ import type { HttpContext } from '@adonisjs/core/http'
280
+ import User from '#models/user'
281
+
282
+ export default class UserPostsController {
283
+ /**
284
+ * Get a list posts of user
285
+ * GET /users/:user_id/posts
286
+ */
287
+ async index({ params, request }: HttpContext): Promise<Post[]> {
288
+ const user: User = await User.findOrFail(params.user_id)
289
+
290
+ return user.related('posts').query()
291
+ .apply(scopes => scopes.filtration(request.qs()))
292
+ .exec()
293
+
294
+ // or
295
+
296
+ return user.related('posts').query().filter(request.qs()).exec()
297
+ }
298
+ }
299
+ ```
300
+
301
+ Documentation by [Query Scopes](https://lucid.adonisjs.com/docs/model-query-scopes)
302
+
303
+ **Note:** The relation model must be `Filterable` and `$filter` must be defined in it
304
+
305
+ [npm-image]: https://img.shields.io/npm/v/adonis-lucid-filter?logo=npm&style=for-the-badge
306
+ [npm-url]: https://www.npmjs.com/package/adonis-lucid-filter
307
+
308
+ [license-image]: https://img.shields.io/npm/l/adonis-lucid-filter?style=for-the-badge&color=blueviolet
309
+ [license-url]: https://github.com/lookinlab/adonis-lucid-filter/blob/develop/LICENSE.md
310
+
311
+ [typescript-image]: https://img.shields.io/npm/types/adonis-lucid-filter?color=294E80&label=%20&logo=typescript&style=for-the-badge
312
+ [typescript-url]: https://github.com/lookinlab
@@ -0,0 +1,15 @@
1
+ // src/bindings/model_query_builder.ts
2
+ function extendModelQueryBuilder(builder) {
3
+ builder.macro(
4
+ "filter",
5
+ function(input, filter) {
6
+ const Filter = filter || this.model.$filter();
7
+ return new Filter(this, input).handle();
8
+ }
9
+ );
10
+ }
11
+
12
+ export {
13
+ extendModelQueryBuilder
14
+ };
15
+ //# sourceMappingURL=chunk-FZT5JNRL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bindings/model_query_builder.ts"],"sourcesContent":["/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\nimport type { ModelQueryBuilder } from '@adonisjs/lucid/orm'\r\nimport type { LucidFilterContract } from '@codenameryuu/adonis-lucid-filter/types/filter'\r\n\r\n/**\r\n * Define filter method to ModelQueryBuilder\r\n */\r\nexport function extendModelQueryBuilder(builder: any) {\r\n builder.macro(\r\n 'filter',\r\n function (this: ModelQueryBuilder, input: any, filter?: LucidFilterContract) {\r\n const Filter = filter || (this.model as any).$filter()\r\n return new Filter(this, input).handle()\r\n }\r\n )\r\n}\r\n"],"mappings":";AAeO,SAAS,wBAAwB,SAAc;AACpD,UAAQ;AAAA,IACN;AAAA,IACA,SAAmC,OAAY,QAA8B;AAC3E,YAAM,SAAS,UAAW,KAAK,MAAc,QAAQ;AACrD,aAAO,IAAI,OAAO,MAAM,KAAK,EAAE,OAAO;AAAA,IACxC;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,9 @@
1
+ // stubs/main.ts
2
+ import { fileURLToPath } from "url";
3
+ import { dirname } from "path";
4
+ var stubsRoot = dirname(fileURLToPath(import.meta.url));
5
+
6
+ export {
7
+ stubsRoot
8
+ };
9
+ //# sourceMappingURL=chunk-NBGNVIUM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../stubs/main.ts"],"sourcesContent":["/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\nimport { fileURLToPath } from 'node:url'\r\nimport { dirname } from 'node:path'\r\n\r\nexport const stubsRoot = dirname(fileURLToPath(import.meta.url))\r\n"],"mappings":";AASA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AAEjB,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;","names":[]}
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __decorateClass = (decorators, target, key, kind) => {
5
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
+ if (decorator = decorators[i])
8
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
+
14
+ export {
15
+ __decorateClass,
16
+ __publicField
17
+ };
18
+ //# sourceMappingURL=chunk-XUS63JTZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
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}
@@ -0,0 +1,4 @@
1
+ import { CommandMetaData, Command } from '@adonisjs/ace/types';
2
+
3
+ export function getMetaData(): Promise<CommandMetaData[]>
4
+ export function getCommand(metaData: CommandMetaData): Promise<Command | null>
@@ -0,0 +1,36 @@
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
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ export default class MakeFilter extends BaseCommand {
3
+ static commandName: string;
4
+ static description: string;
5
+ /**
6
+ * The name of the model file.
7
+ */
8
+ name: string;
9
+ /**
10
+ * Run command
11
+ */
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,29 @@
1
+ import {
2
+ stubsRoot
3
+ } from "../chunk-NBGNVIUM.js";
4
+ import {
5
+ __decorateClass
6
+ } from "../chunk-XUS63JTZ.js";
7
+
8
+ // commands/make_filter.ts
9
+ import { BaseCommand, args } from "@adonisjs/core/ace";
10
+ var MakeFilter = class extends BaseCommand {
11
+ static commandName = "make:filter";
12
+ static description = "Make a new Lucid filter";
13
+ /**
14
+ * Run command
15
+ */
16
+ async run() {
17
+ const codemods = await this.createCodemods();
18
+ await codemods.makeUsingStub(stubsRoot, "make/filter/main.stub", {
19
+ name: this.name
20
+ });
21
+ }
22
+ };
23
+ __decorateClass([
24
+ args.string({ description: "Name of the model file" })
25
+ ], MakeFilter.prototype, "name", 2);
26
+ export {
27
+ MakeFilter as default
28
+ };
29
+ //# sourceMappingURL=make_filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../commands/make_filter.ts"],"sourcesContent":["/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\nimport { BaseCommand, args } from '@adonisjs/core/ace'\r\nimport { stubsRoot } from '../stubs/main.js'\r\n\r\nexport default class MakeFilter extends BaseCommand {\r\n static commandName = 'make:filter'\r\n static description = 'Make a new Lucid filter'\r\n\r\n /**\r\n * The name of the model file.\r\n */\r\n @args.string({ description: 'Name of the model file' })\r\n declare name: string\r\n\r\n /**\r\n * Run command\r\n */\r\n async run(): Promise<void> {\r\n const codemods = await this.createCodemods()\r\n\r\n await codemods.makeUsingStub(stubsRoot, 'make/filter/main.stub', {\r\n name: this.name,\r\n })\r\n }\r\n}\r\n"],"mappings":";;;;;;;;AASA,SAAS,aAAa,YAAY;AAGlC,IAAqB,aAArB,cAAwC,YAAY;AAAA,EAClD,OAAO,cAAc;AAAA,EACrB,OAAO,cAAc;AAAA;AAAA;AAAA;AAAA,EAWrB,MAAM,MAAqB;AACzB,UAAM,WAAW,MAAM,KAAK,eAAe;AAE3C,UAAM,SAAS,cAAc,WAAW,yBAAyB;AAAA,MAC/D,MAAM,KAAK;AAAA,IACb,CAAC;AAAA,EACH;AACF;AAZU;AAAA,EADP,KAAK,OAAO,EAAE,aAAa,yBAAyB,CAAC;AAAA,GAPnC,WAQX;","names":[]}
@@ -0,0 +1,2 @@
1
+ import type Configure from '@adonisjs/core/commands/configure';
2
+ export declare function configure(command: Configure): Promise<void>;
@@ -0,0 +1,4 @@
1
+ export { configure } from './configure.js';
2
+ export { stubsRoot } from './stubs/main.js';
3
+ export { BaseModelFilter } from './src/base_model.js';
4
+ export { Filterable } from './src/mixin.js';
package/build/index.js ADDED
@@ -0,0 +1,111 @@
1
+ import {
2
+ stubsRoot
3
+ } from "./chunk-NBGNVIUM.js";
4
+ import {
5
+ __decorateClass,
6
+ __publicField
7
+ } from "./chunk-XUS63JTZ.js";
8
+
9
+ // configure.ts
10
+ async function configure(command) {
11
+ const codemods = await command.createCodemods();
12
+ await codemods.updateRcFile((rcFile) => {
13
+ rcFile.addProvider("adonis-lucid-filter/provider");
14
+ rcFile.addCommand("adonis-lucid-filter/commands");
15
+ });
16
+ }
17
+
18
+ // src/base_model.ts
19
+ import camelCase from "lodash/camelCase.js";
20
+ function StaticImplements() {
21
+ return (_t) => {
22
+ };
23
+ }
24
+ var BaseModelFilter = class {
25
+ constructor($query, $input) {
26
+ this.$query = $query;
27
+ this.$input = $input;
28
+ this.$input = BaseModelFilter.removeEmptyInput(this.$input);
29
+ this.$blacklist = this.constructor.blacklist;
30
+ }
31
+ handle() {
32
+ if (this.setup && typeof this.setup === "function") {
33
+ this.setup(this.$query);
34
+ }
35
+ this.$filterByInput();
36
+ return this.$query;
37
+ }
38
+ whitelistMethod(method) {
39
+ const index = this.$blacklist.indexOf(method);
40
+ const isBlacklisted = index !== -1;
41
+ if (isBlacklisted) this.$blacklist.splice(index, 1);
42
+ return isBlacklisted;
43
+ }
44
+ $filterByInput() {
45
+ for (const key in this.$input) {
46
+ const method = this.$getFilterMethod(key);
47
+ const keyName = key;
48
+ const value = this.$input[keyName];
49
+ if (this.$methodIsCallable(method)) {
50
+ ;
51
+ this[method](value);
52
+ }
53
+ }
54
+ }
55
+ $getFilterMethod(key) {
56
+ const methodName = this.constructor.dropId ? key.replace(/^(.*)(_id|Id)$/, "$1") : key;
57
+ return this.constructor.camelCase ? camelCase(methodName) : methodName;
58
+ }
59
+ static removeEmptyInput(input) {
60
+ const filteredInput = {};
61
+ for (const key in input) {
62
+ const keyName = key;
63
+ const value = input[keyName];
64
+ if (value !== "" && value !== null && value !== void 0) {
65
+ filteredInput[keyName] = value;
66
+ }
67
+ }
68
+ return filteredInput;
69
+ }
70
+ $methodIsCallable(method) {
71
+ const methodKey = method;
72
+ return !!this[methodKey] && typeof this[methodKey] === "function" && !this.$methodIsBlacklisted(method);
73
+ }
74
+ $methodIsBlacklisted(method) {
75
+ return this.$blacklist.includes(method);
76
+ }
77
+ };
78
+ __publicField(BaseModelFilter, "blacklist", []);
79
+ __publicField(BaseModelFilter, "dropId", true);
80
+ __publicField(BaseModelFilter, "camelCase", true);
81
+ BaseModelFilter = __decorateClass([
82
+ StaticImplements()
83
+ ], BaseModelFilter);
84
+
85
+ // src/mixin.ts
86
+ var Filterable = (superclass) => {
87
+ class FilterableModel extends superclass {
88
+ /**
89
+ * Filter method of filterable model
90
+ */
91
+ static filter(input, filter) {
92
+ const Filter = filter || this.$filter();
93
+ return new Filter(this.query(), input).handle();
94
+ }
95
+ /**
96
+ * Filtration scope of filterable model
97
+ */
98
+ static filtration = function(query, input, filter) {
99
+ const Filter = filter || this.$filter();
100
+ return new Filter(query, input).handle();
101
+ };
102
+ }
103
+ return FilterableModel;
104
+ };
105
+ export {
106
+ BaseModelFilter,
107
+ Filterable,
108
+ configure,
109
+ stubsRoot
110
+ };
111
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../configure.ts","../src/base_model.ts","../src/mixin.ts"],"sourcesContent":["/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\nimport type Configure from '@adonisjs/core/commands/configure'\r\n\r\nexport async function configure(command: Configure) {\r\n const codemods = await command.createCodemods()\r\n\r\n await codemods.updateRcFile((rcFile) => {\r\n rcFile.addProvider('adonis-lucid-filter/provider')\r\n rcFile.addCommand('adonis-lucid-filter/commands')\r\n })\r\n}\r\n","/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\nimport camelCase from 'lodash/camelCase.js'\r\nimport type { LucidFilter, LucidFilterContract } from './types/filter.js'\r\n\r\nfunction StaticImplements<T>() {\r\n return (_t: T) => {}\r\n}\r\n\r\n/**\r\n * Class to filtering AdonisJS Lucid ORM\r\n *\r\n * @class BaseModelFilter\r\n * @constructor\r\n */\r\n@StaticImplements<LucidFilterContract>()\r\nexport class BaseModelFilter implements LucidFilter {\r\n declare ['constructor']: typeof BaseModelFilter\r\n declare $blacklist: string[]\r\n\r\n static blacklist: string[] = []\r\n static dropId: boolean = true\r\n static camelCase: boolean = true\r\n\r\n setup?($query: any): void\r\n\r\n constructor(\r\n public $query: any,\r\n public $input: object\r\n ) {\r\n this.$input = BaseModelFilter.removeEmptyInput(this.$input)\r\n this.$blacklist = this.constructor.blacklist\r\n }\r\n\r\n handle(): any {\r\n if (this.setup && typeof this.setup === 'function') {\r\n this.setup(this.$query)\r\n }\r\n this.$filterByInput()\r\n\r\n return this.$query\r\n }\r\n\r\n whitelistMethod(method: string): boolean {\r\n const index = this.$blacklist.indexOf(method)\r\n\r\n const isBlacklisted = index !== -1\r\n if (isBlacklisted) this.$blacklist.splice(index, 1)\r\n\r\n return isBlacklisted\r\n }\r\n\r\n $filterByInput(): void {\r\n for (const key in this.$input) {\r\n const method = this.$getFilterMethod(key)\r\n\r\n const keyName = key as keyof typeof this.$input\r\n const value: unknown = this.$input[keyName]\r\n\r\n if (this.$methodIsCallable(method)) {\r\n ;(this[method as keyof this] as Function)(value)\r\n }\r\n }\r\n }\r\n\r\n $getFilterMethod(key: string): string {\r\n const methodName = this.constructor.dropId ? key.replace(/^(.*)(_id|Id)$/, '$1') : key\r\n return this.constructor.camelCase ? camelCase(methodName) : methodName\r\n }\r\n\r\n static removeEmptyInput(input: object): object {\r\n const filteredInput = {}\r\n\r\n for (const key in input) {\r\n const keyName = key as keyof typeof input\r\n const value = input[keyName]\r\n\r\n if (value !== '' && value !== null && value !== undefined) {\r\n filteredInput[keyName] = value\r\n }\r\n }\r\n return filteredInput\r\n }\r\n\r\n $methodIsCallable(method: string): boolean {\r\n const methodKey = method as keyof this\r\n\r\n return (\r\n !!this[methodKey] &&\r\n typeof this[methodKey] === 'function' &&\r\n !this.$methodIsBlacklisted(method)\r\n )\r\n }\r\n\r\n $methodIsBlacklisted(method: string): boolean {\r\n return this.$blacklist.includes(method)\r\n }\r\n}\r\nexport default BaseModelFilter\r\n","/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\nimport type { NormalizeConstructor } from '@adonisjs/core/types/helpers'\r\nimport type { BaseModel } from '@adonisjs/lucid/orm'\r\nimport type {\r\n InputObject,\r\n LucidFilterContract,\r\n} from '@codenameryuu/adonis-lucid-filter/types/filter'\r\nimport type {\r\n ModelQueryBuilderContract,\r\n QueryScope,\r\n QueryScopeCallback,\r\n} from '@adonisjs/lucid/types/model'\r\n\r\nexport const Filterable = <Model extends NormalizeConstructor<typeof BaseModel>>(\r\n superclass: Model\r\n) => {\r\n class FilterableModel extends superclass {\r\n declare static $filter: () => LucidFilterContract\r\n\r\n /**\r\n * Filter method of filterable model\r\n */\r\n static filter<\r\n T extends typeof FilterableModel,\r\n Filter extends LucidFilterContract = ReturnType<T['$filter']>,\r\n >(\r\n this: T,\r\n input: InputObject<InstanceType<Filter>>,\r\n filter?: Filter\r\n ): ModelQueryBuilderContract<T> {\r\n const Filter = filter || this.$filter()\r\n return new Filter(this.query(), input).handle()\r\n }\r\n\r\n /**\r\n * Filtration scope of filterable model\r\n */\r\n static filtration = function (\r\n this: typeof FilterableModel,\r\n query,\r\n input,\r\n filter?: LucidFilterContract\r\n ) {\r\n const Filter = filter || this.$filter()\r\n return new Filter(query, input).handle()\r\n } as QueryScope<Model, QueryScopeCallback>\r\n }\r\n return FilterableModel\r\n}\r\n"],"mappings":";;;;;;;;;AAWA,eAAsB,UAAU,SAAoB;AAClD,QAAM,WAAW,MAAM,QAAQ,eAAe;AAE9C,QAAM,SAAS,aAAa,CAAC,WAAW;AACtC,WAAO,YAAY,8BAA8B;AACjD,WAAO,WAAW,8BAA8B;AAAA,EAClD,CAAC;AACH;;;ACTA,OAAO,eAAe;AAGtB,SAAS,mBAAsB;AAC7B,SAAO,CAAC,OAAU;AAAA,EAAC;AACrB;AASO,IAAM,kBAAN,MAA6C;AAAA,EAUlD,YACS,QACA,QACP;AAFO;AACA;AAEP,SAAK,SAAS,gBAAgB,iBAAiB,KAAK,MAAM;AAC1D,SAAK,aAAa,KAAK,YAAY;AAAA,EACrC;AAAA,EAEA,SAAc;AACZ,QAAI,KAAK,SAAS,OAAO,KAAK,UAAU,YAAY;AAClD,WAAK,MAAM,KAAK,MAAM;AAAA,IACxB;AACA,SAAK,eAAe;AAEpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,gBAAgB,QAAyB;AACvC,UAAM,QAAQ,KAAK,WAAW,QAAQ,MAAM;AAE5C,UAAM,gBAAgB,UAAU;AAChC,QAAI,cAAe,MAAK,WAAW,OAAO,OAAO,CAAC;AAElD,WAAO;AAAA,EACT;AAAA,EAEA,iBAAuB;AACrB,eAAW,OAAO,KAAK,QAAQ;AAC7B,YAAM,SAAS,KAAK,iBAAiB,GAAG;AAExC,YAAM,UAAU;AAChB,YAAM,QAAiB,KAAK,OAAO,OAAO;AAE1C,UAAI,KAAK,kBAAkB,MAAM,GAAG;AAClC;AAAC,QAAC,KAAK,MAAoB,EAAe,KAAK;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB,KAAqB;AACpC,UAAM,aAAa,KAAK,YAAY,SAAS,IAAI,QAAQ,kBAAkB,IAAI,IAAI;AACnF,WAAO,KAAK,YAAY,YAAY,UAAU,UAAU,IAAI;AAAA,EAC9D;AAAA,EAEA,OAAO,iBAAiB,OAAuB;AAC7C,UAAM,gBAAgB,CAAC;AAEvB,eAAW,OAAO,OAAO;AACvB,YAAM,UAAU;AAChB,YAAM,QAAQ,MAAM,OAAO;AAE3B,UAAI,UAAU,MAAM,UAAU,QAAQ,UAAU,QAAW;AACzD,sBAAc,OAAO,IAAI;AAAA,MAC3B;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,kBAAkB,QAAyB;AACzC,UAAM,YAAY;AAElB,WACE,CAAC,CAAC,KAAK,SAAS,KAChB,OAAO,KAAK,SAAS,MAAM,cAC3B,CAAC,KAAK,qBAAqB,MAAM;AAAA,EAErC;AAAA,EAEA,qBAAqB,QAAyB;AAC5C,WAAO,KAAK,WAAW,SAAS,MAAM;AAAA,EACxC;AACF;AA7EE,cAJW,iBAIJ,aAAsB,CAAC;AAC9B,cALW,iBAKJ,UAAkB;AACzB,cANW,iBAMJ,aAAqB;AANjB,kBAAN;AAAA,EADN,iBAAsC;AAAA,GAC1B;;;ACFN,IAAM,aAAa,CACxB,eACG;AAAA,EACH,MAAM,wBAAwB,WAAW;AAAA;AAAA;AAAA;AAAA,IAMvC,OAAO,OAKL,OACA,QAC8B;AAC9B,YAAM,SAAS,UAAU,KAAK,QAAQ;AACtC,aAAO,IAAI,OAAO,KAAK,MAAM,GAAG,KAAK,EAAE,OAAO;AAAA,IAChD;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,aAAa,SAElB,OACA,OACA,QACA;AACA,YAAM,SAAS,UAAU,KAAK,QAAQ;AACtC,aAAO,IAAI,OAAO,OAAO,KAAK,EAAE,OAAO;AAAA,IACzC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ import type { ApplicationService } from '@adonisjs/core/types';
2
+ export default class LucidFilterProvider {
3
+ protected app: ApplicationService;
4
+ constructor(app: ApplicationService);
5
+ boot(): Promise<void>;
6
+ }
@@ -0,0 +1,19 @@
1
+ import {
2
+ extendModelQueryBuilder
3
+ } from "../chunk-FZT5JNRL.js";
4
+ import "../chunk-XUS63JTZ.js";
5
+
6
+ // providers/lucid_filter_provider.ts
7
+ var LucidFilterProvider = class {
8
+ constructor(app) {
9
+ this.app = app;
10
+ }
11
+ async boot() {
12
+ const { ModelQueryBuilder } = await this.app.import("@adonisjs/lucid/orm");
13
+ extendModelQueryBuilder(ModelQueryBuilder);
14
+ }
15
+ };
16
+ export {
17
+ LucidFilterProvider as default
18
+ };
19
+ //# sourceMappingURL=lucid_filter_provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../providers/lucid_filter_provider.ts"],"sourcesContent":["/*\r\n * adonis-lucid-filter\r\n *\r\n * (c) Lookin Anton <alf@lookinlab.ru>\r\n *\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n */\r\n\r\n/// <reference path=\"../src/types/querybuilder.ts\" />\r\n\r\nimport type { ApplicationService } from '@adonisjs/core/types'\r\nimport { extendModelQueryBuilder } from '../src/bindings/model_query_builder.js'\r\n\r\nexport default class LucidFilterProvider {\r\n constructor(protected app: ApplicationService) {}\r\n\r\n async boot() {\r\n const { ModelQueryBuilder } = await this.app.import('@adonisjs/lucid/orm')\r\n extendModelQueryBuilder(ModelQueryBuilder)\r\n }\r\n}\r\n"],"mappings":";;;;;;AAcA,IAAqB,sBAArB,MAAyC;AAAA,EACvC,YAAsB,KAAyB;AAAzB;AAAA,EAA0B;AAAA,EAEhD,MAAM,OAAO;AACX,UAAM,EAAE,kBAAkB,IAAI,MAAM,KAAK,IAAI,OAAO,qBAAqB;AACzE,4BAAwB,iBAAiB;AAAA,EAC3C;AACF;","names":[]}
@@ -0,0 +1,26 @@
1
+ import type { LucidFilter } from './types/filter.js';
2
+ /**
3
+ * Class to filtering AdonisJS Lucid ORM
4
+ *
5
+ * @class BaseModelFilter
6
+ * @constructor
7
+ */
8
+ export declare class BaseModelFilter implements LucidFilter {
9
+ $query: any;
10
+ $input: object;
11
+ ['constructor']: typeof BaseModelFilter;
12
+ $blacklist: string[];
13
+ static blacklist: string[];
14
+ static dropId: boolean;
15
+ static camelCase: boolean;
16
+ setup?($query: any): void;
17
+ constructor($query: any, $input: object);
18
+ handle(): any;
19
+ whitelistMethod(method: string): boolean;
20
+ $filterByInput(): void;
21
+ $getFilterMethod(key: string): string;
22
+ static removeEmptyInput(input: object): object;
23
+ $methodIsCallable(method: string): boolean;
24
+ $methodIsBlacklisted(method: string): boolean;
25
+ }
26
+ export default BaseModelFilter;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Define filter method to ModelQueryBuilder
3
+ */
4
+ export declare function extendModelQueryBuilder(builder: any): void;
@@ -0,0 +1,8 @@
1
+ import {
2
+ extendModelQueryBuilder
3
+ } from "../../chunk-FZT5JNRL.js";
4
+ import "../../chunk-XUS63JTZ.js";
5
+ export {
6
+ extendModelQueryBuilder
7
+ };
8
+ //# sourceMappingURL=model_query_builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,154 @@
1
+ import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
+ import type { BaseModel } from '@adonisjs/lucid/orm';
3
+ import type { InputObject, LucidFilterContract } from '@codenameryuu/adonis-lucid-filter/types/filter';
4
+ import type { ModelQueryBuilderContract, QueryScope, QueryScopeCallback } from '@adonisjs/lucid/types/model';
5
+ export declare const Filterable: <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => {
6
+ new (...args: any[]): {
7
+ $attributes: import("@adonisjs/lucid/types/model").ModelObject;
8
+ $extras: import("@adonisjs/lucid/types/model").ModelObject;
9
+ $original: import("@adonisjs/lucid/types/model").ModelObject;
10
+ $preloaded: {
11
+ [relation: string]: import("@adonisjs/lucid/types/model").LucidRow | import("@adonisjs/lucid/types/model").LucidRow[];
12
+ };
13
+ $sideloaded: import("@adonisjs/lucid/types/model").ModelObject;
14
+ $primaryKeyValue?: number | string;
15
+ $isPersisted: boolean;
16
+ $isNew: boolean;
17
+ $isLocal: boolean;
18
+ $dirty: import("@adonisjs/lucid/types/model").ModelObject;
19
+ $isDirty: boolean;
20
+ $isDeleted: boolean;
21
+ $options?: import("@adonisjs/lucid/types/model").ModelOptions;
22
+ $trx?: import("@adonisjs/lucid/types/database").TransactionClientContract;
23
+ $setOptionsAndTrx(options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): void;
24
+ useTransaction(trx: import("@adonisjs/lucid/types/database").TransactionClientContract): /*elided*/ any;
25
+ useConnection(connection: string): /*elided*/ any;
26
+ $getQueryFor(action: "insert", client: import("@adonisjs/lucid/types/database").QueryClientContract): ReturnType<import("@adonisjs/lucid/types/database").QueryClientContract["insertQuery"]>;
27
+ $getQueryFor(action: "update" | "delete" | "refresh", client: import("@adonisjs/lucid/types/database").QueryClientContract): ModelQueryBuilderContract<import("@adonisjs/lucid/types/model").LucidModel>;
28
+ $setAttribute(key: string, value: any): void;
29
+ $getAttribute(key: string): any;
30
+ $getAttributeFromCache(key: string, callback: import("@adonisjs/lucid/types/model").CacheNode["getter"]): any;
31
+ $hasRelated(key: string): boolean;
32
+ $setRelated(key: string, result: import("@adonisjs/lucid/types/querybuilder").OneOrMany<import("@adonisjs/lucid/types/model").LucidRow> | null): void;
33
+ $pushRelated(key: string, result: import("@adonisjs/lucid/types/querybuilder").OneOrMany<import("@adonisjs/lucid/types/model").LucidRow> | null): void;
34
+ $getRelated(key: string, defaultValue?: any): import("@adonisjs/lucid/types/querybuilder").OneOrMany<import("@adonisjs/lucid/types/model").LucidRow> | undefined | null;
35
+ $consumeAdapterResult(adapterResult: import("@adonisjs/lucid/types/model").ModelObject, sideloadAttributes?: import("@adonisjs/lucid/types/model").ModelObject): void;
36
+ $hydrateOriginals(): void;
37
+ fill(value: Partial<import("@adonisjs/lucid/types/model").ModelAttributes</*elided*/ any>>, allowExtraProperties?: boolean): /*elided*/ any;
38
+ merge(value: Partial<import("@adonisjs/lucid/types/model").ModelAttributes</*elided*/ any>>, allowExtraProperties?: boolean): /*elided*/ any;
39
+ isDirty(fields?: undefined[] | undefined): boolean;
40
+ enableForceUpdate(): /*elided*/ any;
41
+ save(): Promise</*elided*/ any>;
42
+ saveQuietly(): Promise</*elided*/ any>;
43
+ lockForUpdate<T>(callback: (user: /*elided*/ any) => T | Promise<T>): Promise<T>;
44
+ delete(): Promise<void>;
45
+ deleteQuietly(): Promise<void>;
46
+ refresh(): Promise</*elided*/ any>;
47
+ load: import("@adonisjs/lucid/types/model").LucidRowPreload</*elided*/ any>;
48
+ loadOnce: import("@adonisjs/lucid/types/model").LucidRowPreloadOnce</*elided*/ any>;
49
+ preload: import("@adonisjs/lucid/types/model").LucidRowPreload</*elided*/ any>;
50
+ loadAggregate: <Self extends /*elided*/ any, Name extends import("@adonisjs/lucid/types/relations").ExtractModelRelations<Self>, RelatedBuilder = NonNullable<Self[Name]> extends import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> & Self[Name] & {})["subQuery"] : never>(name: Name, callback: (builder: RelatedBuilder) => void) => import("@adonisjs/lucid/types/model").LazyLoadAggregatesContract<Self>;
51
+ loadCount: <Self extends /*elided*/ any, Name_1 extends import("@adonisjs/lucid/types/relations").ExtractModelRelations<Self>, RelatedBuilder_1 = NonNullable<Self[Name_1]> extends import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> & Self[Name_1] & {})["subQuery"] : never>(name: Name_1, callback?: ((builder: RelatedBuilder_1) => void) | undefined) => import("@adonisjs/lucid/types/model").LazyLoadAggregatesContract<Self>;
52
+ serializeAttributes(fields?: import("@adonisjs/lucid/types/model").CherryPickFields, raw?: boolean): import("@adonisjs/lucid/types/model").ModelObject;
53
+ serializeComputed(fields?: import("@adonisjs/lucid/types/model").CherryPickFields): import("@adonisjs/lucid/types/model").ModelObject;
54
+ serializeRelations(fields: undefined, raw: true): {
55
+ [key: string]: import("@adonisjs/lucid/types/model").LucidRow | import("@adonisjs/lucid/types/model").LucidRow[];
56
+ };
57
+ serializeRelations(cherryPick: import("@adonisjs/lucid/types/model").CherryPick["relations"] | undefined, raw: false | undefined): import("@adonisjs/lucid/types/model").ModelObject;
58
+ serializeRelations(cherryPick?: import("@adonisjs/lucid/types/model").CherryPick["relations"], raw?: boolean): import("@adonisjs/lucid/types/model").ModelObject;
59
+ serialize(cherryPick?: import("@adonisjs/lucid/types/model").CherryPick): import("@adonisjs/lucid/types/model").ModelObject;
60
+ toObject(): import("@adonisjs/lucid/types/model").ModelObject;
61
+ toJSON(): import("@adonisjs/lucid/types/model").ModelObject;
62
+ toAttributes(): Record<string, any>;
63
+ related<Name_2 extends undefined>(relation: Name_2): NonNullable</*elided*/ any[Name_2]> extends import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> & /*elided*/ any[Name_2] & {})["client"] : never;
64
+ };
65
+ $filter: () => LucidFilterContract;
66
+ /**
67
+ * Filter method of filterable model
68
+ */
69
+ filter<T extends /*elided*/ any & Model, Filter extends LucidFilterContract = ReturnType<T["$filter"]>>(this: T, input: InputObject<InstanceType<Filter>>, filter?: Filter): ModelQueryBuilderContract<T>;
70
+ /**
71
+ * Filtration scope of filterable model
72
+ */
73
+ filtration: QueryScope<Model, QueryScopeCallback>;
74
+ find: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<null | InstanceType<T>>;
75
+ readonly booted: boolean;
76
+ $columnsDefinitions: Map<string, import("@adonisjs/lucid/types/model").ModelColumnOptions>;
77
+ $relationsDefinitions: Map<string, import("@adonisjs/lucid/types/relations").RelationshipsContract>;
78
+ $computedDefinitions: Map<string, import("@adonisjs/lucid/types/model").ComputedOptions>;
79
+ primaryKey: string;
80
+ connection?: string | undefined;
81
+ namingStrategy: import("@adonisjs/lucid/types/model").NamingStrategyContract;
82
+ table: string;
83
+ selfAssignPrimaryKey: boolean;
84
+ $adapter: import("@adonisjs/lucid/types/model").AdapterContract;
85
+ useAdapter: (adapter: import("@adonisjs/lucid/types/model").AdapterContract) => void;
86
+ $hooks: import("@poppinss/hooks").default<any>;
87
+ $keys: {
88
+ attributesToColumns: import("@adonisjs/lucid/types/model").ModelKeysContract;
89
+ attributesToSerialized: import("@adonisjs/lucid/types/model").ModelKeysContract;
90
+ columnsToAttributes: import("@adonisjs/lucid/types/model").ModelKeysContract;
91
+ columnsToSerialized: import("@adonisjs/lucid/types/model").ModelKeysContract;
92
+ serializedToColumns: import("@adonisjs/lucid/types/model").ModelKeysContract;
93
+ serializedToAttributes: import("@adonisjs/lucid/types/model").ModelKeysContract;
94
+ columnAliasesToAttributes: import("@adonisjs/lucid/types/model").ModelKeysContract;
95
+ };
96
+ $createFromAdapterResult: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, result?: import("@adonisjs/lucid/types/model").ModelObject, sideloadAttributes?: import("@adonisjs/lucid/types/model").ModelObject, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => null | InstanceType<T>;
97
+ $createMultipleFromAdapterResult: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, results: import("@adonisjs/lucid/types/model").ModelObject[], sideloadAttributes?: import("@adonisjs/lucid/types/model").ModelObject, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => InstanceType<T>[];
98
+ $addColumn: (name: string, options: Partial<import("@adonisjs/lucid/types/model").ColumnOptions>) => import("@adonisjs/lucid/types/model").ColumnOptions;
99
+ $hasColumn: (name: string) => boolean;
100
+ $getColumn: (name: string) => import("@adonisjs/lucid/types/model").ModelColumnOptions | undefined;
101
+ $getColumnAlias: (columnName: string) => string;
102
+ columnsForSelect: () => Record<string, string>;
103
+ $addComputed: (name: string, options: Partial<import("@adonisjs/lucid/types/model").ComputedOptions>) => import("@adonisjs/lucid/types/model").ComputedOptions;
104
+ $hasComputed: (name: string) => boolean;
105
+ $getComputed: (name: string) => import("@adonisjs/lucid/types/model").ComputedOptions | undefined;
106
+ $addRelation: (name: string, type: import("@adonisjs/lucid/types/relations").ModelRelationTypes["__opaque_type"], relatedModel: () => import("@adonisjs/lucid/types/model").LucidModel, options: import("@adonisjs/lucid/types/model").ModelRelationOptions) => void;
107
+ $hasRelation: (name: string) => boolean;
108
+ $getRelation: {
109
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel, Name_2 extends import("@adonisjs/lucid/types/relations").ExtractModelRelations<InstanceType<Model_1>>>(this: Model_1, name: Name_2): NonNullable<InstanceType<Model_1>[Name_2]> extends import("@adonisjs/lucid/types/relations").ModelRelations<import("@adonisjs/lucid/types/model").LucidModel, import("@adonisjs/lucid/types/model").LucidModel> ? NonNullable<InstanceType<Model_1>[Name_2]>["client"]["relation"] : import("@adonisjs/lucid/types/relations").RelationshipsContract;
110
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel>(this: Model_1, name: string): import("@adonisjs/lucid/types/relations").RelationshipsContract;
111
+ };
112
+ $defineProperty: <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel, Prop extends keyof Model_1>(this: Model_1, propertyName: Prop, defaultValue: Model_1[Prop], strategy: "inherit" | "define" | ((value: Model_1[Prop]) => Model_1[Prop])) => void;
113
+ boot: () => void;
114
+ before: {
115
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel, Event extends "find" | "fetch">(this: Model_1, event: Event, handler: import("@adonisjs/lucid/types/model").HooksHandler<ModelQueryBuilderContract<Model_1>, Event>): void;
116
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel>(this: Model_1, event: "paginate", handler: import("@adonisjs/lucid/types/model").HooksHandler<[ModelQueryBuilderContract<Model_1>, ModelQueryBuilderContract<Model_1>], "paginate">): void;
117
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel, Event_1 extends import("@adonisjs/lucid/types/model").EventsList>(this: Model_1, event: Event_1, handler: import("@adonisjs/lucid/types/model").HooksHandler<InstanceType<Model_1>, Event_1>): void;
118
+ };
119
+ after: {
120
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel>(this: Model_1, event: "fetch", handler: import("@adonisjs/lucid/types/model").HooksHandler<InstanceType<Model_1>[], "fetch">): void;
121
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel>(this: Model_1, event: "paginate", handler: import("@adonisjs/lucid/types/model").HooksHandler<import("@adonisjs/lucid/types/model").ModelPaginatorContract<InstanceType<Model_1>>, "paginate">): void;
122
+ <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel, Event_2 extends import("@adonisjs/lucid/types/model").EventsList>(this: Model_1, event: Event_2, handler: import("@adonisjs/lucid/types/model").HooksHandler<InstanceType<Model_1>, Event_2>): void;
123
+ };
124
+ create: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>>;
125
+ createQuietly: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>>;
126
+ createMany: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>[]>;
127
+ createManyQuietly: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>[]>;
128
+ findOrFail: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T>>;
129
+ findBy: {
130
+ <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, clause: Record<string, unknown>, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<null | InstanceType<T>>;
131
+ <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, key: string, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<null | InstanceType<T>>;
132
+ };
133
+ findByOrFail: {
134
+ <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, clause: Record<string, unknown>, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T>>;
135
+ <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, key: string, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T>>;
136
+ };
137
+ findManyBy: {
138
+ <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, clause: Record<string, unknown>, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T>[]>;
139
+ <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, key: string, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T>[]>;
140
+ };
141
+ first: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<null | InstanceType<T>>;
142
+ firstOrFail: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T>>;
143
+ findMany: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, value: any[], options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T>[]>;
144
+ firstOrNew: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, searchPayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, savePayload?: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>>;
145
+ firstOrCreate: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, searchPayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, savePayload?: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>>;
146
+ updateOrCreate: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, searchPayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, updatePayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>>;
147
+ fetchOrNewUpMany: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, predicate: keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>> | (keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>)[], payload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>[]>;
148
+ fetchOrCreateMany: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, predicate: keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>> | (keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>)[], payload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>[]>;
149
+ updateOrCreateMany: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, predicate: keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>> | (keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>)[], payload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T>[]>;
150
+ all: <T extends import("@adonisjs/lucid/types/model").LucidModel>(this: T, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T>[]>;
151
+ query: <Model_1 extends import("@adonisjs/lucid/types/model").LucidModel, Result = InstanceType<Model_1>>(this: Model_1, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => ModelQueryBuilderContract<Model_1, Result>;
152
+ transaction: import("@adonisjs/lucid/types/database").TransactionFn;
153
+ truncate: (cascade?: boolean) => Promise<void>;
154
+ } & Model;
@@ -0,0 +1,47 @@
1
+ import type { CamelCase, SnakeCase, Split } from 'type-fest';
2
+ import type { LucidModel, LucidRow, ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
3
+ /**
4
+ * Lucid filter instance
5
+ */
6
+ export interface LucidFilter {
7
+ setup?($query: any): void;
8
+ whitelistMethod(method: string): boolean;
9
+ handle(): any;
10
+ $filterByInput(): void;
11
+ $getFilterMethod(key: string): string;
12
+ $methodIsCallable(method: string): boolean;
13
+ $methodIsBlacklisted(method: string): boolean;
14
+ }
15
+ /**
16
+ * Lucid filter static contract
17
+ */
18
+ export interface LucidFilterContract {
19
+ blacklist: string[];
20
+ dropId: boolean;
21
+ camelCase: boolean;
22
+ removeEmptyInput(input: object): object;
23
+ new ($query: ModelQueryBuilderContract<LucidModel, LucidRow>, $input: object): LucidFilter;
24
+ }
25
+ /**
26
+ * Pick keys from methods of filter with a type of first value
27
+ */
28
+ type PickKeys<Filter> = {
29
+ [Key in keyof Filter as SnakeCase<Exclude<Key, keyof LucidFilter | 'constructor'>>]: Filter[Key] extends (value: infer V, ...args: any) => any ? V : never;
30
+ };
31
+ /**
32
+ * Add `_id` to end of SnakeCase keys with number type
33
+ */
34
+ type KeysWithIds<SCKeys> = {
35
+ [Key in keyof SCKeys as Key extends string ? 'id' extends Split<Key, '_'>[number] ? never : SCKeys[Key] extends number ? `${string & Key}_id` : never : never]?: SCKeys[Key];
36
+ };
37
+ /**
38
+ * Convert all keys to CamelCase
39
+ */
40
+ type CamelCased<Keys> = {
41
+ [Key in keyof Keys as CamelCase<`${string & Key}`>]?: Keys[Key];
42
+ };
43
+ /**
44
+ * Input object of filter model
45
+ */
46
+ export type InputObject<Instance extends InstanceType<LucidFilterContract>> = Partial<PickKeys<Instance>> & KeysWithIds<PickKeys<Instance>> & CamelCased<PickKeys<Instance>> & CamelCased<KeysWithIds<PickKeys<Instance>>>;
47
+ export {};
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,15 @@
1
+ import type { LucidFilterContract, InputObject } from '@codenameryuu/adonis-lucid-filter/types/filter';
2
+ declare module '@adonisjs/lucid/types/model' {
3
+ type FilterableModel = LucidModel & {
4
+ $filter: () => LucidFilterContract;
5
+ filtration: QueryScope<LucidModel, QueryScopeCallback>;
6
+ };
7
+ type ExcludeFilterableMethods<Methods, Model> = {
8
+ [Method in keyof Methods]: Model extends FilterableModel ? Methods[Method] : never;
9
+ };
10
+ type FilterableMethods<Model extends LucidModel> = {
11
+ filter<Filter extends LucidFilterContract = ReturnType<(FilterableModel & Model)['$filter']>>(input: InputObject<InstanceType<Filter>>, filter?: Filter): ModelQueryBuilderContract<Model, InstanceType<Model>>;
12
+ };
13
+ interface ModelQueryBuilderContract<Model extends LucidModel, Result = InstanceType<Model>> extends ExcludeFilterableMethods<FilterableMethods<Model>, Model> {
14
+ }
15
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=querybuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
1
+ export declare const stubsRoot: string;
package/package.json ADDED
@@ -0,0 +1,134 @@
1
+ {
2
+ "name": "@codenameryuu/adonis-lucid-filter",
3
+ "description": "Addon for filtering AdonisJS Lucid ORM",
4
+ "version": "2.0.0",
5
+ "engines": {
6
+ "node": ">=20.6.0"
7
+ },
8
+ "main": "./build/index.js",
9
+ "type": "module",
10
+ "files": [
11
+ "build",
12
+ "!build/bin",
13
+ "!build/tests"
14
+ ],
15
+ "exports": {
16
+ ".": "./build/index.js",
17
+ "./commands": "./build/commands/main.js",
18
+ "./types/*": "./build/src/types/*.js",
19
+ "./bindings": "./build/src/bindings/model_query_builder.js",
20
+ "./provider": "./build/providers/lucid_filter_provider.js"
21
+ },
22
+ "scripts": {
23
+ "lint": "eslint .",
24
+ "clean": "del-cli build",
25
+ "precompile": "npm run lint && npm run clean",
26
+ "postcompile": "npm run copy:stubs && npm run index:commands",
27
+ "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
28
+ "build": "npm run compile",
29
+ "copy:stubs": "copyfiles \"stubs/**/**/*.stub\" --up=\"1\" build",
30
+ "index:commands": "adonis-kit index build/commands",
31
+ "quick:test": "NODE_DEBUG=\"adonis-lucid-filter\" node --enable-source-maps --loader=ts-node/esm bin/test.ts",
32
+ "pretest": "npm run lint",
33
+ "test": "c8 npm run quick:test",
34
+ "typecheck": "tsc --noEmit",
35
+ "version": "npm run build",
36
+ "prepublishOnly": "npm run build",
37
+ "release": "np"
38
+ },
39
+ "devDependencies": {
40
+ "@adonisjs/assembler": "^7.7.0",
41
+ "@adonisjs/core": "^7.0.0",
42
+ "@adonisjs/eslint-config": "^1.3.0",
43
+ "@adonisjs/lucid": "^22.0.0",
44
+ "@adonisjs/prettier-config": "^1.3.0",
45
+ "@adonisjs/tsconfig": "^1.3.0",
46
+ "@japa/assert": "^2.1.0",
47
+ "@japa/expect-type": "^2.0.2",
48
+ "@japa/file-system": "^2.3.0",
49
+ "@japa/runner": "^3.1.4",
50
+ "@japa/snapshot": "^2.0.5",
51
+ "@swc/core": "^1.6.7",
52
+ "@types/lodash": "^4.17.6",
53
+ "c8": "^9.1.0",
54
+ "copyfiles": "^2.4.1",
55
+ "del-cli": "^5.1.0",
56
+ "eslint": "^8.57.0",
57
+ "knex": "^3.1.0",
58
+ "lodash": "^4.17.21",
59
+ "luxon": "^3.4.4",
60
+ "np": "^9.2.0",
61
+ "reflect-metadata": "^0.2.2",
62
+ "sqlite3": "^5.1.7",
63
+ "ts-node": "^10.9.2",
64
+ "tsup": "^8.1.0",
65
+ "typescript": "^5.5.3"
66
+ },
67
+ "dependencies": {
68
+ "type-fest": "^4.21.0"
69
+ },
70
+ "peerDependencies": {
71
+ "@adonisjs/core": "^6.2.3",
72
+ "@adonisjs/lucid": "^21.1.0",
73
+ "lodash": "^4.17.21"
74
+ },
75
+ "author": "LookinGit",
76
+ "license": "MIT",
77
+ "homepage": "https://github.com/lookinlab/adonis-lucid-filter#readme",
78
+ "repository": {
79
+ "type": "git",
80
+ "url": "git+ssh://git@github.com/lookinlab/adonis-lucid-filter.git"
81
+ },
82
+ "bugs": {
83
+ "url": "https://github.com/lookinlab/adonis-lucid-filter/issues"
84
+ },
85
+ "keywords": [
86
+ "adonisjs",
87
+ "adonisjs-filter",
88
+ "adonisjs-lucid",
89
+ "adonisjs-lucid-filter",
90
+ "adonis",
91
+ "adonis-lucid",
92
+ "adonis-filter",
93
+ "adonis-lucid-filter"
94
+ ],
95
+ "eslintConfig": {
96
+ "extends": "@adonisjs/eslint-config/package"
97
+ },
98
+ "prettier": "@adonisjs/prettier-config",
99
+ "publishConfig": {
100
+ "access": "public",
101
+ "tag": "latest"
102
+ },
103
+ "np": {
104
+ "message": "chore(release): %s",
105
+ "tag": "latest",
106
+ "branch": "master",
107
+ "anyBranch": false
108
+ },
109
+ "c8": {
110
+ "reporter": [
111
+ "text",
112
+ "html"
113
+ ],
114
+ "exclude": [
115
+ "tests/**",
116
+ "bin/**"
117
+ ]
118
+ },
119
+ "tsup": {
120
+ "entry": [
121
+ "./index.ts",
122
+ "./src/types/*.ts",
123
+ "./src/bindings/model_query_builder.ts",
124
+ "./commands/make_filter.ts",
125
+ "./providers/lucid_filter_provider.ts"
126
+ ],
127
+ "outDir": "./build",
128
+ "clean": true,
129
+ "format": "esm",
130
+ "dts": false,
131
+ "sourcemap": true,
132
+ "target": "esnext"
133
+ }
134
+ }