UNPKG

@adonis-agora/filter

Version:

Server-side query filtering/sorting/pagination for AdonisJS — Spatie-style input, a Lucid adapter, and field allow-listing. Part of the Agora ecosystem.

32 lines 1.71 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { args, BaseCommand } from '@adonisjs/core/ace'; import { stubsRoot } from '../stubs/main.js'; /** * `node ace make:filter <name>` — scaffold a filter class under `app/filters/`. * * The generated class extends `BaseModelFilter`: allow-lists as statics for the plain columns, a * `setup()` for the scope the client cannot relax, and a method per key that needs SQL of its own. * It is `@inject()`ed, so a constructor dependency resolves through the container exactly as a * controller's does. */ export default class MakeFilter extends BaseCommand { static commandName = 'make:filter'; static description = 'Create a new filter class'; static options = { allowUnknownFlags: true }; async run() { const codemods = await this.createCodemods(); await codemods.makeUsingStub(stubsRoot, 'make/filter/main.stub', { flags: this.parsed.flags, entity: this.app.generators.createEntity(this.name), }); } } __decorate([ args.string({ description: 'Name of the filter (e.g. user)' }) ], MakeFilter.prototype, "name", void 0); //# sourceMappingURL=make_filter.js.map