import { LucidModel, ColumnOptions, ComputedOptions } from '@adonisjs/lucid/types/model'; import type { HasOne, ManyToMany, HasManyThrough, ManyToManyRelationOptions, RelationOptions, ThroughRelationOptions } from '@adonisjs/lucid/types/relations'; import type { ResourcefulColumnDefinition, ResourcefulComputedAccessorDefinition, ResourcefulRelationshipDefinition, AnySchema, StringSchema, DateSchema, BinarySchema, NumberSchema, BooleanSchema, ObjectSchema, ArraySchema, ResourcefulPropertySchema } from "../types"; /** * Options for date columns including autoCreate and autoUpdate flags. * * @example * ```ts * { * autoCreate: true, * autoUpdate: false, * nullable: false, * } * ``` */ export type DateColumnOptions = DataTypeColumnOptions & { autoCreate: boolean; autoUpdate: boolean; }; /** * Options for relation decorators on related models. * * @example * ```ts * import { resourcefulBelongsTo } from '@nhtio/lucid-resourceful' * * class Post { * @resourcefulBelongsTo(() => User, { foreignKey: 'user_id' }) * public user: User * } * ``` */ export type RelatedModelRelationOptions = RelationOptions> | ManyToManyRelationOptions> | Omit>, 'throughModel'>; /** * Options for hasManyThrough relation decorators. * * @example * ```ts * import { resourcefulHasManyThrough } from '@nhtio/lucid-resourceful' * * class User { * @resourcefulHasManyThrough([ * () => Role, * () => UserRolePivot * ], { foreignKey: 'user_id' }) * public roles: HasManyThrough * } * ``` */ export type HasManyThroughRelationOptions = Omit>, 'throughModel'>; export type DataTypeColumnOptions = ColumnOptions; export type DataTypeComputedOptions = Omit; /** * Decorator to define a resourceful column on a Lucid model property. * Applies validation, metadata, and Lucid column options. * * @example * ```ts * import { resourcefulColumn, ResourcefulStringType } from '@nhtio/lucid-resourceful' * * class User { * @resourcefulColumn({ type: ResourcefulStringType({ minLength: 1, maxLength: 100 }), nullable: false }) * public name: string * } * ``` * * @param options - Resourceful column options and Lucid column options. * @returns Property decorator function. */ export declare function resourcefulColumn(options?: Partial & Partial>): (target: any, propertyKey: string) => void; export declare namespace resourcefulColumn { var string: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var date: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var dateTime: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var binary: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var number: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var integer: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var bigint: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var unsignedint: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var boolean: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var object: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var array: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; } /** * Decorator to define a resourceful computed accessor on a Lucid model property. * Applies validation, metadata, and Lucid computed options. * * @example * ```ts * import { resourcefulComputed, ResourcefulStringType } from '@nhtio/lucid-resourceful' * * class User { * @resourcefulComputed({ type: ResourcefulStringType({ minLength: 1, maxLength: 100 }) }) * public get fullName() { * return `${this.firstName} ${this.lastName}` * } * } * ``` * * @param options - Resourceful computed accessor options and Lucid computed options. * @returns Property decorator function. */ export declare function resourcefulComputed(options?: Partial & Partial>): (target: any, propertyKey: string) => void; export declare namespace resourcefulComputed { var string: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var date: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var dateTime: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var binary: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var number: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var integer: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var bigint: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var unsignedint: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var boolean: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var object: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; var array: (options?: Partial & Partial>) => (target: any, propertyKey: string) => void; } /** * Decorator to define a resourceful belongsTo relationship on a Lucid model property. * * @example * ```ts * import { resourcefulBelongsTo } from '@nhtio/lucid-resourceful' * * class Post { * @resourcefulBelongsTo(() => User, { foreignKey: 'user_id' }) * public user: User * } * ``` * * @param model - Function returning the related model class. * @param options - Relationship options and resourceful relationship definition. * @returns Property decorator function. */ export declare function resourcefulBelongsTo(model: () => RelatedModel, options?: Partial>> & Partial): (target: any, propertyKey: string) => void; /** * Decorator to define a resourceful hasOne relationship on a Lucid model property. * * @example * ```ts * import { resourcefulHasOne } from '@nhtio/lucid-resourceful' * * class UserProfile { * @resourcefulHasOne(() => User, { foreignKey: 'user_id' }) * public user: UserProfile * } * ``` * * @param model - Function returning the related model class. * @param options - Relationship options and resourceful relationship definition. * @returns Property decorator function. */ export declare function resourcefulHasOne(model: () => RelatedModel, options?: Partial>> & Partial): (target: any, propertyKey: string) => void; /** * Decorator to define a resourceful hasMany relationship on a Lucid model property. * * @example * ```ts * import { resourcefulHasMany } from '@nhtio/lucid-resourceful' * * class User { * @resourcefulHasMany(() => Post, { foreignKey: 'user_id' }) * public posts: HasMany * } * ``` * * @param model - Function returning the related model class. * @param options - Relationship options and resourceful relationship definition. * @returns Property decorator function. */ export declare function resourcefulHasMany(model: () => RelatedModel, options?: Partial>> & Partial): (target: any, propertyKey: string) => void; /** * Decorator to define a resourceful manyToMany relationship on a Lucid model property. * * @example * ```ts * import { resourcefulManyToMany } from '@nhtio/lucid-resourceful' * * class User { * @resourcefulManyToMany(() => Role, { pivotTable: 'role_user' }) * public roles: ManyToMany * } * ``` * * @param model - Function returning the related model class. * @param options - ManyToMany relationship options and resourceful relationship definition. * @returns Property decorator function. */ export declare function resourcefulManyToMany(model: () => RelatedModel, options?: Partial>> & Partial): (target: any, propertyKey: string) => void; /** * Decorator to define a resourceful hasManyThrough relationship on a Lucid model property. * * @example * ```ts * import { resourcefulHasManyThrough } from '@nhtio/lucid-resourceful' * * class User { * @resourcefulHasManyThrough([ * () => Role, * () => UserRolePivot * ], { foreignKey: 'user_id' }) * public roles: HasManyThrough * } * ``` * * @param model - Tuple of functions returning the related model and through model classes. * @param options - HasManyThrough relationship options and resourceful relationship definition. * @returns Property decorator function. */ export declare function resourcefulHasManyThrough(model: [ () => RelatedModel, () => LucidModel ], options?: Partial> & Partial): (target: any, propertyKey: string) => void;