import { GenericFunction, IdType, NonNullEntity } from "@agrejus/db-framework-core"; export type QueryResult = (value: T, error?: any) => void; export type EntityMap = GenericFunction; export type EntitySelector = GenericFunction, boolean>; export type EntityParamsSelector = (payload: [NonNullEntity, P]) => boolean; export type EntityCallbackMany = (entities: NonNullEntity[], error?: any) => void; export type ChangeTrackedEntity = T & { __tracking__?: { isDirty: boolean; changes: { [K in keyof T]: T[K] }, original: { [K in keyof T]: T[K] }, isPaused: boolean }, __isProxy__: true } export type Enricher = GenericFunction; export type IdGetter = GenericFunction; export type DeepKeyOf = T extends object ? { [Key in keyof T & (string | number)]: T[Key] extends object ? `${Key & string}` | `${Key & string}.${DeepKeyOf}` : `${Key & string}` }[keyof T & (string | number)] : never; export type NonOverlappingKeys = Exclude; export type DeepNonOverlappingKeys< T, U, Path extends string = "" > = { [K in keyof T]: K extends string | number | bigint | boolean // Restrict K to valid key types ? K extends keyof U ? T[K] extends Array // Check if T[K] is an array ? U[K] extends Array // Check if U[K] is also an array ? [TItem] extends [UItem] // Compare array item types ? [UItem] extends [TItem] ? never // Exclude if array item types match : `${Path}${K}` : `${Path}${K}` : `${Path}${K}` // Include if U[K] is not an array : T[K] extends Record // If T[K] is an object ? U[K] extends Record // If U[K] is also an object ? DeepNonOverlappingKeys extends never ? never // If no unique nested keys, exclude this key : `${Path}${K}` // Include this key if nested keys are unique : `${Path}${K}` // Include if U[K] is not an object : never // Exclude if T[K] exists in U and is not an object : `${Path}${K}` // Include full path if key does not exist in U : never; // Exclude invalid keys }[keyof T]; export type DeepOptional = { [K in keyof T]?: T[K] extends Record ? T[K] extends Array // Check if T[K] is an array ? Array> // Recursively make array elements optional : DeepOptional // Recursively make object properties optional : T[K]; // Keep non-object types as they are }; export type DbSetOptions = { stateful: boolean; }