import { type RequestEvent } from '@sveltejs/kit'; import type { CombiTableColumn, ColumnType } from './combitabletypes'; import { PartialDateType } from './types'; import { DateTime } from 'luxon'; export interface AutoCompleteOptions { insensitive?: boolean; maxItems?: number; prefilter?: { [key: string]: { [key: string]: any; }; }; } /** * Provides autocomplete functionality with Prisma * * This is designed to use inside a `+server.ts` file in a route which * has parameters `table` and `col` * (for example `routes/autocomplete/[table][col]`). It returns * an array of matches starting with the text in the `t` query parameter. * The maximum number returned can be customised in the * `PUBLIC_COMBITABLE_AUTOCOMPLETE_TAKE` variable with a default of 10. * * ```ts * const prisma = new PrismaClient(); * return await autocomplete(prisma, event, {god: ["**"]}); * ``` * * The third parameter is the tables and columns to arrow (we wouldn't want, * for example, someone to call it with a table of user). * * The format of the this parameter is an object whose keys are names of * tables (Prisma lowercase version) and whose valoues is an array of * allowed columns. If that array is a single item and it is * then all * columns are allowed. If it is ** then all columns on related tables * are allowed as well (eg "god.father.name"). * * @param client prisma client * @param event the Sveltelkit request event * @param cols tables and columns to allow (see description) * @returns a JSON array of results */ export declare function autocomplete(client: any, event: RequestEvent, cols?: { [key: string]: string[]; }, options?: AutoCompleteOptions): Promise; export declare function stringIsDate(val: string, dateFormat?: string): boolean; export declare function stringIsDateMonth(val: string, dateFormat?: string): boolean; export declare function stringIsDateYear(val: string, dateFormat?: string): boolean; export declare function stringIsPartialDate(val: string, dateFormat?: string): boolean; export declare function validateField(col: CombiTableColumn, value: string | number | Date | null | boolean | undefined, dateFormat?: string): string | undefined; export declare function asBoolean(val: string | number | boolean | undefined): boolean; export declare function asBooleanOrUndefined(val: string | number | boolean | undefined): boolean | undefined; export declare function asNumber(val: string | number | boolean | undefined): number; export declare function asNumberOrUndefined(val: string | number | boolean | undefined): number | undefined; export declare function asString(val: string | number | boolean | undefined | Date, type?: ColumnType | undefined, dateFormat?: string, dateType?: PartialDateType): string; export declare function asStringOrUndefined(val: string | number | boolean | undefined, type?: ColumnType | undefined): string | undefined; export declare function printDate(date: Date | undefined | null | string, dateFormat: string, nullValue?: string): string; export declare function printPartialDate(date: Date | undefined | null, type: PartialDateType, dateFormat?: string): string; export declare function parseDate(val: string, dateFormat?: string): Date; export declare function parseLuxonDateTime(date: string, { dateFormat, tz }: { dateFormat?: string; tz?: string | undefined; }): DateTime | DateTime; export declare function parseLuxonTime(date: string, { dateFormat, tz }: { dateFormat?: string; tz?: string | undefined; }): DateTime | DateTime; export declare function parseLuxonDate(date: string, { dateFormat, tz }: { dateFormat?: string; tz?: string | undefined; }): DateTime | DateTime; export declare function splitPartialDate(val: string, dateFormat?: string): { year: number; month: number | null; day: number | null; }; export declare function joinPartialDate(year: number, month: number | null, day: number | null, dateFormat?: string): string; export declare function yearFromPartialDate(val: string, dateFormat?: string): number; export declare function monthFromPartialDate(val: string, dateFormat?: string): number | null; export declare function dayFromPartialDate(val: string, dateFormat?: string): number | null; export declare function getToday(): Date; export declare function firstOfMonth(year: number, month: number | null, day: number | null): Date; export declare function addDays(date: Date, days: number): Date; export declare function lastOfMonth(year: number, month: number | null, day: number | null): Date; export declare function numDaysBetween(date1: Date, date2: Date): number; export declare const PartialDateYear_Month = 7; export declare const PartialDateYear_Day = 1; export declare const PartialDateMonth_Day = 15; export declare function parsePartialDateOrNull(val: string | undefined | null, dateFormat: string): { date: Date | null; type: PartialDateType | null; }; export declare function parsePartialDate(val: string, dateFormat: string): { date: Date; type: PartialDateType; };