bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
67 lines (66 loc) • 4.2 kB
TypeScript
import { s } from "bknd/utils";
import type { EntityManager } from "../entities";
import { Field, type TActionContext, type TRenderContext } from "./Field";
import type { TFieldTSType } from "../../data/entities/EntityTypescript";
export declare const dateFieldConfigSchema: s.ObjectSchema<{
readonly label: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly required: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
readonly fillable: s.Schema<s.ISchemaOptions, boolean | ("create" | "read" | "update" | "delete")[] | undefined, boolean | ("create" | "read" | "update" | "delete")[] | undefined>;
readonly hidden: s.Schema<s.ISchemaOptions, boolean | ("table" | "create" | "read" | "update" | "delete" | "form" | "submit")[] | undefined, boolean | ("table" | "create" | "read" | "update" | "delete" | "form" | "submit")[] | undefined>;
readonly virtual: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
readonly default_value: s.Schema<s.ISchemaOptions, any, any>;
readonly type: s.Schema<s.ISchemaOptions, "date" | "week" | "datetime" | undefined, "date" | "week" | "datetime" | undefined>;
readonly timezone: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly min_date: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly max_date: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
}, s.Merge<s.IObjectOptions & {
additionalProperties: false;
}>>;
export type DateFieldConfig = s.Static<typeof dateFieldConfigSchema>;
export declare class DateField<Required extends true | false = false> extends Field<DateFieldConfig, Date, Required> {
readonly type = "date";
protected getSchema(): s.ObjectSchema<{
readonly label: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly required: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
readonly fillable: s.Schema<s.ISchemaOptions, boolean | ("create" | "read" | "update" | "delete")[] | undefined, boolean | ("create" | "read" | "update" | "delete")[] | undefined>;
readonly hidden: s.Schema<s.ISchemaOptions, boolean | ("table" | "create" | "read" | "update" | "delete" | "form" | "submit")[] | undefined, boolean | ("table" | "create" | "read" | "update" | "delete" | "form" | "submit")[] | undefined>;
readonly virtual: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
readonly default_value: s.Schema<s.ISchemaOptions, any, any>;
readonly type: s.Schema<s.ISchemaOptions, "date" | "week" | "datetime" | undefined, "date" | "week" | "datetime" | undefined>;
readonly timezone: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly min_date: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly max_date: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
}, s.Merge<s.IObjectOptions & {
additionalProperties: false;
}>>;
schema(): Readonly<{
type: "date" | "datetime";
name: string;
nullable?: boolean;
dflt?: any;
unique?: boolean;
primary?: boolean;
references?: string;
onDelete?: import("kysely").OnModifyForeignAction;
onUpdate?: import("kysely").OnModifyForeignAction;
}>;
getHtmlConfig(): {
element: string;
props: {
type: string | undefined;
};
};
private parseDateFromString;
getValue(value: string, context?: TRenderContext): string | undefined;
formatDate(_date: Date): string;
transformRetrieve(_value: string): Date | null;
transformPersist(_value: any, em: EntityManager<any>, context: TActionContext): Promise<string | undefined>;
toJsonSchema(): s.StringSchema<{
readonly default: any;
}> & {
readonly default: any;
};
toType(): TFieldTSType;
}