oak-domain/lib/types/EntityDesc.d.ts

33 lines
1.4 KiB
TypeScript

import { LocaleDef } from './Locale';
import { Index } from './Storage';
import { EntityShape, Configuration, EntityDict } from './Entity';
import { EntityDict as BaseEntityDict } from '../base-app-domain';
import { StyleDesc } from './Style';
import { AsyncContext } from '../store/AsyncRowStore';
import { SyncContext } from '../store/SyncRowStore';
import { SyncOrAsync } from './Polyfill';
export type EntityDesc<Schema extends EntityShape, Action extends string = '', Relation extends string = '', V extends Record<string, string> = {
['##oak_illegal##']: '';
}> = {
locales: LocaleDef<Schema, Action, Relation, keyof V extends '##oak_illegal##' ? {} : V>;
indexes?: Index<Schema>[];
configuration?: Configuration;
recursiveDepth?: number;
} & (Action extends '' ? (keyof V extends '##oak_illegal##' ? {} : {
style: StyleDesc<Action, V>;
}) : {
style: StyleDesc<Action, V>;
});
export type AttrUpdateMatrix<ED extends EntityDict & BaseEntityDict> = {
[T in keyof ED]?: {
[A in keyof ED[T]['Update']['data']]?: {
actions?: ED[T]['Action'][];
filter?: (NonNullable<ED[T]['Filter']>) | ((option: {
action: ED[T]['Action'];
data: ED[T]['Update']['data'];
filter?: ED[T]['Update']['filter'];
}, context: AsyncContext<ED> | SyncContext<ED>) => SyncOrAsync<ED[T]['Filter'] | undefined>);
};
};
};