import { Config, FieldContract, FieldProperty, SerializedField, FieldHookFunction, AuthorizeFunction, SanitizationRules, DataPayload } from '@tensei/common'; export declare class Field implements FieldContract { showHideField: { /** * * If this is true, the field will be shown on the * index page * */ showOnIndex: boolean; /** * * If this is true, the field will be updatable. It will * show up on the update page * */ showOnUpdate: boolean; /** * * If this is true, the field will show up on the detail page */ showOnDetail: boolean; /** * * If this is true, the field will be shown on the creation * form */ showOnCreation: boolean; }; graphqlType: string; showHideFieldFromApi: { hideOnCreateApi: boolean; hideOnUpdateApi: boolean; hideOnDeleteApi: boolean; hideOnFetchApi: boolean; }; component: { form: string; index: string; detail: string; }; showOnPanel: boolean; sidebar: boolean; formComponent(component: string): this; indexComponent(component: string): this; detailComponent(component: string): this; property: FieldProperty; relatedProperty: FieldProperty; tenseiConfig: Config | null; authorizeCallbacks: { authorizedToSee: AuthorizeFunction; authorizedToCreate: AuthorizeFunction; authorizedToUpdate: AuthorizeFunction; authorizedToDelete: AuthorizeFunction; }; onFieldUpdate: any; hooks: { beforeCreate: FieldHookFunction; beforeUpdate: FieldHookFunction; afterCreate: FieldHookFunction; afterUpdate: FieldHookFunction; onUpdate: FieldHookFunction; }; afterConfigSet(): void; onUpdate(this: T, onUpdate: () => any): T; required(this: T): T; requiredOnCreate(this: T): T; requiredOnUpdate(this: T): T; /** * * The name of the field. Will be used to display table columns, * field labels etc */ name: string; /** * * Define validation rules to be used to validate * this field on forms */ validationRules: Array; /** * * Validation rules for fields that are in array format */ arrayValidationRules: Array; /** * * Rules for sanitizing data for a field */ sanitizeRules: Array; /** * * Define validation rules to be used to validate * this field on creation forms */ creationValidationRules: Array; /** * * Define validation rules to be used to validate * this field on update forms */ updateValidationRules: Array; /** * * This is a set of all html attributes to be passed * to this component * */ attributes: {}; /** * * This value set to true will hide this field completely * from all query results. */ isHidden: boolean; isRelationshipField: boolean; /** * * The database field associated with this field. * By default, this will be the camel case * version of the name * */ databaseField: string; camelCaseName: string; camelCaseNamePlural: string; pascalCaseName: string; snakeCaseName: string; snakeCaseNamePlural: string; capsDatabasefieldName: string; /** * * The */ helpText: string; isNullable: boolean; isUnique: boolean; /** * * Adds database sorting by this field. Will show up * on the index page, on the table headers. * */ isSortable: boolean; /** * Adds database filtering by this field. Will show up * on the index page, on the table headers. * * Will also expose filtering on the frontend for this * field. * */ isFilterable: boolean; isSearchable: boolean; /** * * Set the default value of this * field * */ defaultValue: any; /** * Instantiate a new field. Requires the name, * and optionally the corresponding database * field. This field if not provided will * default to the camel case version of * the name. */ constructor(name: string, databaseField?: string); /** * * Show this field on the index page */ showOnIndex(): this; /** * * Show this field on the detail page */ showOnDetail(): this; /** * * Show this field on the creation page */ showOnCreate(): this; /** * * Show this field on the update page */ showOnUpdate(): this; /** * * Hide this field on the index page */ hideOnIndex(): this; type(type: string): this; serializer(serializeFn: (value: any) => any): this; /** * * Hide this field from the detail page */ hideOnDetail(): this; /** * * Hide this field from the create form */ hideOnCreate(): this; /** * * Hide this field from the update form */ hideOnUpdate(): this; /** * * Hide this field everywhere, except the index page */ onlyOnIndex(): this; /** * * Hide this field everuwhere, except the * create and update forms */ onlyOnForms(): this; /** * * Show this field only on the detail and, * index pages. hidden on create and * update forms. */ exceptOnForms(): this; hideOnApi(): this; hideOnCreateApi(): this; hideOnUpdateApi(): this; hideOnDeleteApi(): this; hideOnFetchApi(): this; /** * * Make this field sortable * */ sortable(this: T): T; /** * * Make this field filterable * */ filterable(this: T): T; /** * * Turn off filtering for this field. * */ notFilterable(this: T): T; /** * * Make this field searchable. will also index * this field in the database. * * This method optionally takes in the name of the index. * */ searchable(this: T, index?: string | boolean): T; onCreate(this: T, onCreate: () => any): T; /** * * Make this field unique * */ unique(this: T): T; /** * * Make this field unsigned * */ unsigned(this: T): T; shadow(): this; /** * Make this field a primary field * */ primary(this: T): T; /** * * Make this field signed * */ signed(this: T): T; notUnique(this: T): T; dockToSidebarOnForms(): this; removeFromSidebarOnForms(): this; /** * * Make this field nullable * */ notNullable(this: T): T; virtual(this: T, compute: (value: any) => any): T; /** * * Make this field nullable * */ nullable(this: T): T; getValueFromPayload(payload: DataPayload, request: Express.Request): any; /** * * Define the description. This would be a help text * that provides more information to the user * about this field on forms. */ description(this: T, description: string): T; /** * * Set the default value for this field. * Will save to the database as default. * */ default(this: T, value: any): T; /** * * Set the default value for this field. * Will show up on create forms as * default * */ defaultFormValue(this: T, value: any): T; /** * * Set the default value for this field. * Will show up on create forms as * default * */ defaultRaw(this: T, value: string): T; /** * * Set html attributes for this component */ htmlAttributes(this: T, attributes: {}): T; /** * * Set validation rules. These rules will be applied on both create * and update * * @param this */ rules(this: T, ...rules: Array): T; /** * * Set validation rules. These rules will be applied on both create * and update * * @param this */ arrayRules(this: T, ...rules: Array): T; /** * Define a sanitization rule to be used when saving data for this field. * * @param this * @param sanitize string */ sanitize(this: T, sanitizeRule: SanitizationRules): T; /** * Set the validation rules to be used when * creating this field to the database */ creationRules(this: T, ...rules: Array): T; /** * Set the validation rules to be used when updating * this field */ updateRules(this: T, ...rules: Array): T; /** * Set this field to be a hidden field. It won't show up * in query results. */ hidden(this: T): T; canSee(authorizeFunction: AuthorizeFunction): this; canCreate(authorizeFunction: AuthorizeFunction): this; canUpdate(authorizeFunction: AuthorizeFunction): this; canDelete(authorizeFunction: AuthorizeFunction): this; isHiddenOnApi(): boolean; /** * * Serializes the field for data to be sent * to the frontend * */ serialize(): SerializedField; } export default Field;