@lambda-group/charydbis
Version:
๐ NodeJS ScyllaDB ORM. ๐งช๐ง
21 lines (19 loc) โข 1.1 kB
TypeScript
declare const PrimaryKeyProp: unique symbol;
type AnyArray = any[];
type Primary<T> = T extends {
[PrimaryKeyProp]?: infer PK;
} ? PK : unknown;
type Flatten<T> = T extends [infer F, ...infer R] ? [...(F extends AnyArray ? F : [F]), ...Flatten<R>] : [];
type UnionCombinations<T, Keys extends Array<keyof T>, AccumulatedKeys extends Array<keyof T> = []> = Keys extends [infer First, ...infer Rest] ? First extends keyof T ? Rest extends Array<keyof T> ? StrictPick<T, First | AccumulatedKeys[number]> | UnionCombinations<T, Rest, [First, ...AccumulatedKeys]> : never : never : never;
type StrictPick<T, K extends keyof T> = Pick<T, K> & {
[P in keyof T as P extends K ? never : P]?: never;
};
type NonFilteredQuery<T extends {
[PrimaryKeyProp]?: AnyArray;
}> = UnionCombinations<T, Flatten<Primary<T>>>;
type FilterQuery<T extends {
[PrimaryKeyProp]?: AnyArray;
}> = NonFilteredQuery<T> | ({
allowFiltering: true;
} & Partial<T>);
export { type AnyArray, type FilterQuery, type Flatten, type NonFilteredQuery, type Primary, PrimaryKeyProp, type StrictPick, type UnionCombinations };