UNPKG

@clickup/ent-framework

Version:

A PostgreSQL graph-database-alike library with microsharding and row-level security

67 lines 2.89 kB
import type { Client } from "../../abstract/Client"; import type { Cluster } from "../../abstract/Cluster"; import type { Schema } from "../../abstract/Schema"; import type { FieldOfIDType, Table, UniqueKey } from "../../types"; import { Configuration } from "../Configuration"; import { Inverse } from "../Inverse"; import { type ShardAffinity } from "../ShardAffinity"; import { ShardLocator } from "../ShardLocator"; import { Triggers } from "../Triggers"; import { Validation } from "../Validation"; export interface ConfigInstance { } export interface ConfigClass<TTable extends Table, TUniqueKey extends UniqueKey<TTable>, TClient extends Client> { /** * Some Ent parameters need to be configured lazily, on the 1st access, * because there could be cyclic references between Ent classes (e.g. in their * privacy rules). So configure() is called on some later stage, at the moment * of actual Ent operations (like loading, creation etc.). There is no static * abstract methods in TS yet, so making it non-abstract. */ configure(): Configuration<TTable>; /** * A helper class to work-around TS weakness in return value type inference: * https://github.com/Microsoft/TypeScript/issues/31273. It could've been just * a function, but having a class is a little more natural. */ readonly Configuration: new (cfg: Configuration<TTable>) => Configuration<TTable>; /** * A Cluster where this Ent lives. */ readonly CLUSTER: Cluster<TClient>; /** * A schema which represents this Ent. */ readonly SCHEMA: Schema<TTable, TUniqueKey>; /** * Defines how to find the right Shard during Ent insertion. */ readonly SHARD_AFFINITY: ShardAffinity<FieldOfIDType<TTable>>; /** * Shard locator for this Ent, responsible for resolving IDs into Shard objects. */ readonly SHARD_LOCATOR: ShardLocator<TClient, TTable, FieldOfIDType<TTable>>; /** * Privacy rules for this Ent class. */ readonly VALIDATION: Validation<TTable>; /** * Triggers for this Ent class. */ readonly TRIGGERS: Triggers<TTable>; /** * Inverse assoc managers for fields. */ readonly INVERSES: Array<Inverse<TClient, TTable>>; /** * TS requires us to have a public constructor to infer instance types in * various places. We make this constructor throw if it's called. */ new (): ConfigInstance; } /** * Modifies the passed class adding support for Ent configuration (such as: * Cluster, table schema, privacy rules, triggers etc.). */ export declare function ConfigMixin<TTable extends Table, TUniqueKey extends UniqueKey<TTable>, TClient extends Client>(Base: new () => {}, cluster: Cluster<TClient>, schema: Schema<TTable, TUniqueKey>): ConfigClass<TTable, TUniqueKey, TClient>; //# sourceMappingURL=ConfigMixin.d.ts.map