import type { output } from "@tailor-platform/sdk";
import type { Kysely, Selectable, Insertable, Updateable } from "@tailor-platform/sdk/kysely";

export type InferSchema<T> = T extends Kysely<infer S> ? S : never;
export type { Selectable, Insertable, Updateable };

// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/consistent-type-definitions
export type EmptyFields = {};

// TODO: Ideally use Kysely Insertable-equivalent type from SDK instead of inferring from output<T>
export type FieldsToInsertable<F> = {
  [K in keyof F as null extends output<F[K]> ? never : K]: output<F[K]>;
} & {
  [K in keyof F as null extends output<F[K]> ? K : never]?: output<F[K]>;
};
