bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
45 lines (44 loc) • 2.37 kB
TypeScript
import { type Static } from "../../core/utils";
import { Field } from "./Field";
import * as tbbox from "@sinclair/typebox";
import type { TFieldTSType } from "../../data/entities/EntityTypescript";
export declare const primaryFieldTypes: readonly ["integer", "uuid"];
export type TPrimaryFieldFormat = (typeof primaryFieldTypes)[number];
export declare const primaryFieldConfigSchema: tbbox.TObject<{
default_value: tbbox.TOptional<tbbox.TAny>;
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>;
required: tbbox.TOptional<tbbox.TLiteral<false>>;
format: tbbox.TOptional<tbbox.TUnsafe<"uuid" | "integer">>;
}>;
export type PrimaryFieldConfig = 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(): tbbox.TObject<{
default_value: tbbox.TOptional<tbbox.TAny>;
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>;
required: tbbox.TOptional<tbbox.TLiteral<false>>;
format: tbbox.TOptional<tbbox.TUnsafe<"uuid" | "integer">>;
}>;
get format(): "uuid" | "integer";
get fieldType(): "text" | "integer";
schema(): Readonly<{
type: "text" | "integer";
name: string;
primary: true;
nullable: false;
}>;
getNewValue(): any;
transformPersist(value: any): Promise<number>;
toJsonSchema(): tbbox.TString | tbbox.TNumber;
toType(): TFieldTSType;
}