import { AsyncLocalStorage } from 'node:async_hooks'; import { RecordId, Serializable } from '../types.js'; import { Field } from '../fields/field.js'; import { ApiIndexInputParams } from '../routes/handlers/api/index.js'; import { SimplePaginatorContract } from '@adonisjs/lucid/types/querybuilder'; import { Action } from '../actions/action.js'; export declare abstract class BaseResource implements Serializable { static storage: AsyncLocalStorage>; /** * The fields configuration for this resource. */ abstract fields(): Field[]; /** * The name used to identify this resource. * * @example "user" */ abstract name(): string; /** * The label of the resource. * * @example "User" */ label(): string; /** * The plural name of the resource. * * @example "Users" */ labelPlural(): string; /** * The id key of this model. * * @example "id" * @default this.model.primaryKey */ abstract idKey(): string; /** * The icon of the resource. * * @example "pi pi-user" */ icon?(): string; /** * Title key of this resource. * Defaults to the idKey. * * @example "email" */ titleKey(): string; route(action: 'show' | 'delete' | 'edit', id: string): string; route(action: 'index' | 'create'): string; /** * Operation for creating a record. */ abstract create(data: any): Promise; /** * Operation for querying the resource records. */ abstract list(params: ApiIndexInputParams): Promise>; /** * Operation for retrieving a single record of the model. */ abstract retrieve(id: RecordId): Promise; /** * Operation for updating a record. */ abstract update(id: RecordId, data: any): Promise; /** * Operation for deleting records by ids. */ abstract delete(...ids: RecordId[]): Promise; /** * Validate the given data over this Resource. */ abstract validate(data: any): Promise; /** * The list of available actions. */ abstract actions(): Action[]; /** * Serialize this resource for the frontend. * Skip fields omit the fields to avoid infinite loop. */ toJSON(skipFields?: boolean): { name: string; label: string; labelPlural: string; icon: string | undefined; slug: string; idKey: string; titleKey: string; actions: { id: string; label: string; severity: string; icon: string; confirmation: any; }[]; routes: { create: string; index: string; }; fields: { type: "field" | "panel"; fieldComponent: string | undefined; indexComponent: string | undefined; detailComponent: string | undefined; attributes: globalThis.Record; visibility: import("../fields/field.js").FieldVisibility; sortable: boolean; name: string; label: string; initialValue: any; }[]; }; }