bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
48 lines (47 loc) • 3.54 kB
TypeScript
import { type Schema as JsonSchema } from "@cfworker/json-schema";
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 jsonSchemaFieldConfigSchema: 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 schema: s.Schema<s.ISchemaOptions, any, any>;
readonly ui_schema: s.Schema<s.ISchemaOptions, any, any>;
readonly default_from_schema: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
}, s.Merge<s.IObjectOptions & {
additionalProperties: false;
}>>;
export type JsonSchemaFieldConfig = s.Static<typeof jsonSchemaFieldConfigSchema>;
export declare class JsonSchemaField<Required extends true | false = false, TypeOverride = object> extends Field<JsonSchemaFieldConfig, TypeOverride, Required> {
readonly type = "jsonschema";
private validator;
constructor(name: string, config: Partial<JsonSchemaFieldConfig>);
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 schema: s.Schema<s.ISchemaOptions, any, any>;
readonly ui_schema: s.Schema<s.ISchemaOptions, any, any>;
readonly default_from_schema: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>;
}, s.Merge<s.IObjectOptions & {
additionalProperties: false;
}>>;
getJsonSchema(): JsonSchema;
getJsonUiSchema(): any;
isValid(value: any, context?: TActionContext): boolean;
getValue(value: any, context: TRenderContext): any;
transformRetrieve(value: any): any;
transformPersist(_value: any, em: EntityManager<any>, context: TActionContext): Promise<string | undefined>;
toJsonSchema(): any;
toType(): TFieldTSType;
}