export declare const SCHEMA: DBSchema; export declare function Table({ name, rules, fields, }: { name: string; fields?: F; rules: PartialSchema; }): void; export interface DBSchema { [key: string]: TableSchema; } interface Fields { [key: string]: boolean | { type: "uuid" | "timestamp" | "string" | "boolean" | "map" | "array" | "integer" | "number" | "Buffer"; desc?: string; pg_type?: string; unique?: boolean; }; } interface UserOrProjectQuery { get?: { fields: { [key in keyof Partial]: any; }; throttle_changes?: number; pg_where?: string[] | { [key: string]: string; }[] | { [key: string]: string[]; }[]; pg_where_load?: string[] | { [key: string]: string; }[]; pg_changefeed?: string; remove_from_query?: string[]; admin?: boolean; options?: any; options_load?: any; instead_of_query?: (database: any, opts: { account_id?: string; project_id?: string; query: any; multi: boolean; options: any[]; }, cb: (err?: string | Error, result?: any) => void) => void; check_hook?: (database: any, query: any, account_id: string, project_id: string, cb: (err?: string | Error) => void) => void; }; set?: { fields: { [key in keyof Partial]: any; }; required_fields?: { [key in keyof Partial]: any; }; admin?: boolean; delete?: boolean; /** * 0. CHECK: Runs before doing any further processing; has callback, so this * provides a generic way to quickly check whether or not this query is allowed * for things that can't be done declaratively. The check_hook can also * mutate the obj (the user query), e.g., to enforce limits on input size. */ check_hook?: (database: any, query: any, account_id: string, project_id: string, cb: (err?: string | Error) => void) => void; /** * 1. BEFORE: If before_change is set, it is called with input * (database, old_val, query, account_id, cb) * before the actual change to the database is made. */ before_change?: (database: any, old_val: any, query: any, account_id: string, cb: (err?: string | Error) => void) => void; /** * 2. INSTEAD OF: If instead_of_change is set, then it is called with input * (database, old_val, query, account_id, cb) * *instead* of actually doing the update/insert to * the database. This makes it possible to run arbitrary * code whenever the user does a certain type of set query. * Obviously, if that code doesn't set the query in the * database, then query won't be the new val. */ instead_of_change?: (database: any, old_val: any, query: any, account_id: string, cb: (err?: string | Error, result?: any) => void) => void; /** * 3. AFTER: If set, the on_change is called with * (database, old_val, query, account_id, cb) * after everything the database has been modified. */ on_change?: (database: any, old_val: any, query: any, account_id: string, cb: (err?: string | Error) => void) => void; instead_of_query?: (database: any, opts: { query: any; options: any[]; }, cb: (err?: string | Error) => void) => void; }; } interface TableSchema { desc?: string; primary_key?: keyof F | (keyof F)[]; fields?: F; db_standby?: "unsafe" | "safer"; pg_nestloop?: boolean; pg_indexscan?: boolean; durability?: "soft" | "hard" | "ephemeral"; unique_writes?: boolean; anonymous?: boolean; virtual?: string | true; pg_indexes?: any[]; user_query?: UserOrProjectQuery; project_query?: UserOrProjectQuery; } declare type Omit = Pick>; declare type PartialSchema = Omit, "fields">; import { SiteSettings } from "./site-defaults"; import { SettingsExtras } from "./site-settings-extras"; export declare type AllSiteSettings = { [key in keyof SiteSettings | keyof SettingsExtras]?: any; }; export declare type AllSiteSettingsCached = AllSiteSettings & { _timestamp?: number; }; export declare type RegistrationTokenSetFields = "token" | "descr" | "expires" | "limit" | "disabled"; export declare type RegistrationTokenGetFields = RegistrationTokenSetFields | "counter"; export {};