UNPKG

bknd

Version:

Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.

62 lines (61 loc) 3.24 kB
import { type Static } from "../../core/utils"; import type { EntityManager } from "../entities"; import { Field } from "../fields"; import type { EntityRelation } from "./EntityRelation"; import type { EntityRelationAnchor } from "./EntityRelationAnchor"; import * as tbbox from "@sinclair/typebox"; import type { TFieldTSType } from "../../data/entities/EntityTypescript"; export declare const relationFieldConfigSchema: tbbox.TObject<{ default_value: tbbox.TOptional<tbbox.TAny>; required: tbbox.TOptional<tbbox.TBoolean>; description: tbbox.TOptional<tbbox.TString>; label: tbbox.TOptional<tbbox.TString>; fillable: tbbox.TOptional<tbbox.TUnion<[tbbox.TBoolean, tbbox.TArray<tbbox.TUnsafe<"create" | "read" | "update" | "delete">>]>>; hidden: tbbox.TOptional<tbbox.TUnion<[tbbox.TBoolean, tbbox.TArray<tbbox.TUnsafe<"form" | "table" | "create" | "read" | "update" | "delete" | "submit">>]>>; virtual: tbbox.TOptional<tbbox.TBoolean>; reference: tbbox.TString; target: tbbox.TString; target_field: tbbox.TOptional<tbbox.TString>; target_field_type: tbbox.TOptional<tbbox.TUnsafe<"text" | "integer">>; on_delete: tbbox.TOptional<tbbox.TUnsafe<"no action" | "restrict" | "cascade" | "set null" | "set default">>; }>; export type RelationFieldConfig = Static<typeof relationFieldConfigSchema>; export type RelationFieldBaseConfig = { label?: string; }; export declare class RelationField extends Field<RelationFieldConfig> { readonly type = "relation"; protected getSchema(): tbbox.TObject<{ default_value: tbbox.TOptional<tbbox.TAny>; required: tbbox.TOptional<tbbox.TBoolean>; description: tbbox.TOptional<tbbox.TString>; label: tbbox.TOptional<tbbox.TString>; fillable: tbbox.TOptional<tbbox.TUnion<[tbbox.TBoolean, tbbox.TArray<tbbox.TUnsafe<"create" | "read" | "update" | "delete">>]>>; hidden: tbbox.TOptional<tbbox.TUnion<[tbbox.TBoolean, tbbox.TArray<tbbox.TUnsafe<"form" | "table" | "create" | "read" | "update" | "delete" | "submit">>]>>; virtual: tbbox.TOptional<tbbox.TBoolean>; reference: tbbox.TString; target: tbbox.TString; target_field: tbbox.TOptional<tbbox.TString>; target_field_type: tbbox.TOptional<tbbox.TUnsafe<"text" | "integer">>; on_delete: tbbox.TOptional<tbbox.TUnsafe<"no action" | "restrict" | "cascade" | "set null" | "set default">>; }>; static create(relation: EntityRelation, target: EntityRelationAnchor, config?: RelationFieldBaseConfig): RelationField; reference(): string; target(): string; targetField(): string; schema(): Readonly<{ type: "text" | "integer"; references: `${string}.${string}` | `${string}.undefined`; onDelete: "no action" | "restrict" | "cascade" | "set null" | "set default"; name: string; nullable?: boolean; dflt?: any; unique?: boolean; primary?: boolean; onUpdate?: import("kysely").OnModifyForeignAction; }>; transformRetrieve(value: any): any; transformPersist(value: any, em: EntityManager<any>): Promise<any>; toJsonSchema(): tbbox.TNumber | tbbox.TOptional<tbbox.TNumber>; toType(): TFieldTSType; }