UNPKG

bknd

Version:

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

56 lines (55 loc) 3.42 kB
import { s } from "bknd/utils"; import { Field } from "./Field"; import type { TFieldTSType } from "../../data/entities/EntityTypescript"; export declare const primaryFieldTypes: readonly ["integer", "uuid"]; export type TPrimaryFieldFormat = (typeof primaryFieldTypes)[number]; export declare const primaryFieldConfigSchema: s.ObjectSchema<{ readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; readonly default_value: s.Schema<s.ISchemaOptions, any, any>; 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 format: s.Schema<s.ISchemaOptions, "integer" | "uuid" | undefined, "integer" | "uuid" | undefined>; readonly required: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>; }, s.Merge<s.IObjectOptions & { additionalProperties: false; }>>; export type PrimaryFieldConfig = s.Static<typeof primaryFieldConfigSchema>; export declare class PrimaryField<Required extends true | false = false> extends Field<PrimaryFieldConfig, string, Required> { readonly type = "primary"; constructor(name?: string, cfg?: PrimaryFieldConfig); isRequired(): boolean; protected getSchema(): s.ObjectSchema<{ readonly description: s.Schema<s.ISchemaOptions, string | undefined, string | undefined>; readonly default_value: s.Schema<s.ISchemaOptions, any, any>; 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 format: s.Schema<s.ISchemaOptions, "integer" | "uuid" | undefined, "integer" | "uuid" | undefined>; readonly required: s.Schema<s.ISchemaOptions, boolean | undefined, boolean | undefined>; }, s.Merge<s.IObjectOptions & { additionalProperties: false; }>>; get format(): "integer" | "uuid"; get fieldType(): "integer" | "text"; schema(): Readonly<{ type: "text" | "integer"; name: string; primary: true; nullable: false; }>; getNewValue(): any; transformPersist(value: any): Promise<number>; toJsonSchema(): (s.Schema<{ readonly writeOnly: undefined; }, number, number> & { readonly writeOnly: undefined; }) | (s.StringSchema<{ readonly writeOnly: undefined; }> & { readonly writeOnly: undefined; }); toType(): TFieldTSType; }