bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
69 lines (68 loc) • 2.17 kB
TypeScript
import type { Entity, EntityManager, TEntityType } from "../../data/entities";
import type { EntityRelation } from "../../data/relations";
export type TEntityTSType = {
name: string;
type: TEntityType;
comment?: string;
fields: Record<string, TFieldTSType>;
};
type TFieldContextType = boolean | [boolean, boolean, boolean];
export type TFieldTSType = {
required?: TFieldContextType;
fillable?: TFieldContextType;
type: "PrimaryFieldType" | string;
comment?: string;
import?: {
package: string;
name: string;
}[];
};
export type EntityTypescriptOptions = {
indentWidth?: number;
indentChar?: string;
entityCommentMultiline?: boolean;
fieldCommentMultiline?: boolean;
};
export declare class EntityTypescript {
protected em: EntityManager<any>;
protected _options: EntityTypescriptOptions;
constructor(em: EntityManager<any>, _options?: EntityTypescriptOptions);
get options(): {
indentWidth: number;
indentChar: string;
entityCommentMultiline: boolean;
fieldCommentMultiline: boolean;
};
toTypes(): {
name: string;
type: "regular" | "system" | "generated";
comment: string | undefined;
fields: {
[k: string]: TFieldTSType;
};
}[];
getTab(count?: number): string;
collectImports(type: TEntityTSType, imports?: Record<string, string[]>): Record<string, string[]>;
typeName(name: string): string;
fieldTypesToString(type: TEntityTSType, opts?: {
ignore_fields?: string[];
indent?: number;
}): string;
relationToFieldType(relation: EntityRelation, entity: Entity): {
fields: {
[x: string]: {
required: boolean;
type: string;
};
};
};
importsToString(imports: Record<string, string[]>): string[];
commentString(comment?: string, indents?: number, multiline?: boolean): string;
entityToTypeString(entity: Entity, opts?: {
ignore_fields?: string[];
indent?: number;
export?: boolean;
}): string;
toString(): string;
}
export {};