bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
42 lines (41 loc) • 2.94 kB
TypeScript
import type { EntityManager } from "../../data/entities";
import { Field, type TActionContext, type TRenderContext } from "./Field";
import type { TFieldTSType } from "../../data/entities/EntityTypescript";
import { s } from "bknd/utils";
export declare const jsonFieldConfigSchema: s.ObjectSchema<{
readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly required: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
readonly label: s.Schema<s.ISchemaOptions, string | undefined, string | 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>;
}, s.Merge<s.IObjectOptions & {
additionalProperties: false;
}>>;
export type JsonFieldConfig = s.Static<typeof jsonFieldConfigSchema>;
export declare class JsonField<Required extends true | false = false, TypeOverride = object> extends Field<JsonFieldConfig, TypeOverride, Required> {
readonly type = "json";
protected getSchema(): s.ObjectSchema<{
readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>;
readonly required: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
readonly label: s.Schema<s.ISchemaOptions, string | undefined, string | 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>;
}, s.Merge<s.IObjectOptions & {
additionalProperties: false;
}>>;
/**
* Transform value after retrieving from database
* @param value
*/
transformRetrieve(value: any): any;
isSerializable(value: any): boolean;
isSerialized(value: any): boolean;
isValid(value: any): boolean;
getValue(value: any, context: TRenderContext): any;
transformPersist(_value: any, em: EntityManager<any>, context: TActionContext): Promise<string | undefined>;
toType(): TFieldTSType;
}