strengthened schema ensuring for system entities

This commit is contained in:
dswbx
2025-01-18 12:39:34 +01:00
parent 145b47e942
commit db10188945
12 changed files with 118 additions and 36 deletions

View File

@@ -111,13 +111,13 @@ export class EntityManager<TBD extends object = DefaultDB> {
// caused issues because this.entity() was using a reference (for when initial config was given)
}
entity(e: Entity | keyof TBD | string): Entity {
entity(e: Entity | keyof TBD | string, silent?: boolean): Entity {
// make sure to always retrieve by name
const entity = this.entities.find((entity) =>
e instanceof Entity ? entity.name === e.name : entity.name === e
);
if (!entity) {
if (!entity && !silent) {
// @ts-ignore
throw new EntityNotDefinedException(e instanceof Entity ? e.name : e);
}

View File

@@ -12,6 +12,9 @@ import type { HTMLInputTypeAttribute, InputHTMLAttributes } from "react";
import type { EntityManager } from "../entities";
import { InvalidFieldConfigException, TransformPersistFailedException } from "../errors";
// @todo: contexts need to be reworked
// e.g. "table" is irrelevant, because if read is not given, it fails
export const ActionContext = ["create", "read", "update", "delete"] as const;
export type TActionContext = (typeof ActionContext)[number];