From be28754d12d0ab9e7bf5bc03657cd0aec51b0420 Mon Sep 17 00:00:00 2001 From: Vincent Shuali <100994924+canjalal@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:07:11 -0800 Subject: [PATCH 1/3] [#479] Fix import statements in database scripts Following the updating of dependencies in PR #472 the database scripts in src/backend/db/lib stopped working. This PR fixes these scripts through updating the import statements for the pg package. Co-authored-by: Nick Visutsithiwong <2823112+nickvisut@users.noreply.github.com> Co-authored-by: Francis Li --- src/backend/db/lib/get-db.ts | 35 +- src/backend/db/lib/migrate.ts | 3 +- src/backend/db/lib/reset.ts | 6 +- src/backend/db/zapatos/schema.d.ts | 1970 ++++++++++++++-------------- 4 files changed, 1014 insertions(+), 1000 deletions(-) diff --git a/src/backend/db/lib/get-db.ts b/src/backend/db/lib/get-db.ts index 047a6089..985596c9 100644 --- a/src/backend/db/lib/get-db.ts +++ b/src/backend/db/lib/get-db.ts @@ -1,35 +1,43 @@ import { Kysely, PostgresDialect } from "kysely"; import { KyselyDatabaseInstance, KyselySchema } from "@/backend/lib"; -import { Pool } from "pg"; +import pg from "pg"; -type DatabaseInstanceAndPool = { db: KyselyDatabaseInstance; pool: Pool }; +const { Pool } = pg; + +type DatabaseInstanceAndPool = { + db: KyselyDatabaseInstance; + pool: typeof Pool; +}; const databaseUrlToSingleton = new Map(); -const poolToSingleton = new WeakMap(); +const poolToSingleton = new WeakMap(); type GetDb = { (databaseUrl: string): DatabaseInstanceAndPool; - (pool: Pool): DatabaseInstanceAndPool; + (pool: typeof Pool): DatabaseInstanceAndPool; }; export const getDb: GetDb = (databaseUrlOrPool) => { if (databaseUrlOrPool instanceof Pool) { - if (!poolToSingleton.has(databaseUrlOrPool)) { + if (!poolToSingleton.has(databaseUrlOrPool as typeof Pool)) { const db = new Kysely({ dialect: new PostgresDialect({ pool: databaseUrlOrPool, }), }); - const dbAndPool = { db, pool: databaseUrlOrPool }; - poolToSingleton.set(databaseUrlOrPool, dbAndPool); + const dbAndPool = { + db, + pool: databaseUrlOrPool, + } as DatabaseInstanceAndPool; + poolToSingleton.set(databaseUrlOrPool as typeof Pool, dbAndPool); } - return poolToSingleton.get(databaseUrlOrPool)!; + return poolToSingleton.get(databaseUrlOrPool as typeof Pool)!; } - if (!databaseUrlToSingleton.has(databaseUrlOrPool)) { + if (!databaseUrlToSingleton.has(databaseUrlOrPool as string)) { const pool = new Pool({ - connectionString: databaseUrlOrPool, + connectionString: databaseUrlOrPool as string, }); const db = new Kysely({ @@ -38,8 +46,11 @@ export const getDb: GetDb = (databaseUrlOrPool) => { }), }); - databaseUrlToSingleton.set(databaseUrlOrPool, { db, pool }); + databaseUrlToSingleton.set(databaseUrlOrPool as string, { + db, + pool: Pool as unknown as typeof Pool, + }); } - return databaseUrlToSingleton.get(databaseUrlOrPool)!; + return databaseUrlToSingleton.get(databaseUrlOrPool as string)!; }; diff --git a/src/backend/db/lib/migrate.ts b/src/backend/db/lib/migrate.ts index 2e806b04..f95443ed 100644 --- a/src/backend/db/lib/migrate.ts +++ b/src/backend/db/lib/migrate.ts @@ -1,9 +1,10 @@ -import { parse } from "pg-connection-string"; +import pgConnectionString from "pg-connection-string"; import * as postgresMigrations from "postgres-migrations"; import * as zg from "zapatos/generate"; import path from "node:path"; import { logger } from "@/backend/lib"; +const { parse } = pgConnectionString; interface MigrateOptions { silent?: boolean; shouldGenerateTypes?: boolean; diff --git a/src/backend/db/lib/reset.ts b/src/backend/db/lib/reset.ts index 90082168..4171c866 100644 --- a/src/backend/db/lib/reset.ts +++ b/src/backend/db/lib/reset.ts @@ -1,8 +1,10 @@ -import { Client } from "pg"; -import { parse } from "pg-connection-string"; +import client from "pg"; +import pgConnectionString from "pg-connection-string"; import { logger } from "@/backend/lib"; import { migrate } from "./migrate"; +const { Client } = client; +const { parse } = pgConnectionString; export const reset = async (databaseUrl: string) => { const connectionConfig = parse(databaseUrl); diff --git a/src/backend/db/zapatos/schema.d.ts b/src/backend/db/zapatos/schema.d.ts index d3bbac37..0d734ec7 100644 --- a/src/backend/db/zapatos/schema.d.ts +++ b/src/backend/db/zapatos/schema.d.ts @@ -3,7 +3,7 @@ It's been generated by Zapatos, and is liable to be overwritten Zapatos: https://jawj.github.io/zapatos/ -Copyright (C) 2020 - 2022 George MacKerron +Copyright (C) 2020 - 2023 George MacKerron Released under the MIT licence: see LICENCE file */ @@ -29,6 +29,12 @@ declare module 'zapatos/schema' { export namespace account { export type Table = 'account'; export interface Selectable { + /** + * **account.access_token** + * - `text` in database + * - Nullable, no default + */ + access_token: string | null; /** * **account.account_id** * - `uuid` in database @@ -36,17 +42,17 @@ declare module 'zapatos/schema' { */ account_id: string; /** - * **account.user_id** - * - `uuid` in database + * **account.expires_at** + * - `int4` in database * - Nullable, no default */ - user_id: string | null; + expires_at: number | null; /** - * **account.provider_name** + * **account.id_token** * - `text` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - provider_name: string; + id_token: string | null; /** * **account.provider_account_id** * - `text` in database @@ -54,11 +60,11 @@ declare module 'zapatos/schema' { */ provider_account_id: string; /** - * **account.access_token** + * **account.provider_name** * - `text` in database - * - Nullable, no default + * - `NOT NULL`, no default */ - access_token: string | null; + provider_name: string; /** * **account.refresh_token** * - `text` in database @@ -66,37 +72,37 @@ declare module 'zapatos/schema' { */ refresh_token: string | null; /** - * **account.expires_at** - * - `int4` in database + * **account.scope** + * - `text` in database * - Nullable, no default */ - expires_at: number | null; + scope: string | null; /** - * **account.token_type** + * **account.session_state** * - `text` in database * - Nullable, no default */ - token_type: string | null; + session_state: string | null; /** - * **account.scope** + * **account.token_type** * - `text` in database * - Nullable, no default */ - scope: string | null; + token_type: string | null; /** - * **account.id_token** - * - `text` in database + * **account.user_id** + * - `uuid` in database * - Nullable, no default */ - id_token: string | null; + user_id: string | null; + } + export interface JSONSelectable { /** - * **account.session_state** + * **account.access_token** * - `text` in database * - Nullable, no default */ - session_state: string | null; - } - export interface JSONSelectable { + access_token: string | null; /** * **account.account_id** * - `uuid` in database @@ -104,17 +110,17 @@ declare module 'zapatos/schema' { */ account_id: string; /** - * **account.user_id** - * - `uuid` in database + * **account.expires_at** + * - `int4` in database * - Nullable, no default */ - user_id: string | null; + expires_at: number | null; /** - * **account.provider_name** + * **account.id_token** * - `text` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - provider_name: string; + id_token: string | null; /** * **account.provider_account_id** * - `text` in database @@ -122,11 +128,11 @@ declare module 'zapatos/schema' { */ provider_account_id: string; /** - * **account.access_token** + * **account.provider_name** * - `text` in database - * - Nullable, no default + * - `NOT NULL`, no default */ - access_token: string | null; + provider_name: string; /** * **account.refresh_token** * - `text` in database @@ -134,37 +140,37 @@ declare module 'zapatos/schema' { */ refresh_token: string | null; /** - * **account.expires_at** - * - `int4` in database + * **account.scope** + * - `text` in database * - Nullable, no default */ - expires_at: number | null; + scope: string | null; /** - * **account.token_type** + * **account.session_state** * - `text` in database * - Nullable, no default */ - token_type: string | null; + session_state: string | null; /** - * **account.scope** + * **account.token_type** * - `text` in database * - Nullable, no default */ - scope: string | null; + token_type: string | null; /** - * **account.id_token** - * - `text` in database + * **account.user_id** + * - `uuid` in database * - Nullable, no default */ - id_token: string | null; + user_id: string | null; + } + export interface Whereable { /** - * **account.session_state** + * **account.access_token** * - `text` in database * - Nullable, no default */ - session_state: string | null; - } - export interface Whereable { + access_token?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **account.account_id** * - `uuid` in database @@ -172,17 +178,17 @@ declare module 'zapatos/schema' { */ account_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.user_id** - * - `uuid` in database + * **account.expires_at** + * - `int4` in database * - Nullable, no default */ - user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + expires_at?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.provider_name** + * **account.id_token** * - `text` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - provider_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + id_token?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **account.provider_account_id** * - `text` in database @@ -190,11 +196,11 @@ declare module 'zapatos/schema' { */ provider_account_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.access_token** + * **account.provider_name** * - `text` in database - * - Nullable, no default + * - `NOT NULL`, no default */ - access_token?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + provider_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **account.refresh_token** * - `text` in database @@ -202,37 +208,37 @@ declare module 'zapatos/schema' { */ refresh_token?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.expires_at** - * - `int4` in database + * **account.scope** + * - `text` in database * - Nullable, no default */ - expires_at?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + scope?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.token_type** + * **account.session_state** * - `text` in database * - Nullable, no default */ - token_type?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + session_state?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.scope** + * **account.token_type** * - `text` in database * - Nullable, no default */ - scope?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + token_type?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **account.id_token** - * - `text` in database + * **account.user_id** + * - `uuid` in database * - Nullable, no default */ - id_token?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** - * **account.session_state** + * **account.access_token** * - `text` in database * - Nullable, no default */ - session_state?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + access_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** * **account.account_id** * - `uuid` in database @@ -240,17 +246,17 @@ declare module 'zapatos/schema' { */ account_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** - * **account.user_id** - * - `uuid` in database + * **account.expires_at** + * - `int4` in database * - Nullable, no default */ - user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + expires_at?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **account.provider_name** + * **account.id_token** * - `text` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - provider_name: string | db.Parameter | db.SQLFragment; + id_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** * **account.provider_account_id** * - `text` in database @@ -258,11 +264,11 @@ declare module 'zapatos/schema' { */ provider_account_id: string | db.Parameter | db.SQLFragment; /** - * **account.access_token** + * **account.provider_name** * - `text` in database - * - Nullable, no default + * - `NOT NULL`, no default */ - access_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + provider_name: string | db.Parameter | db.SQLFragment; /** * **account.refresh_token** * - `text` in database @@ -270,37 +276,37 @@ declare module 'zapatos/schema' { */ refresh_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **account.expires_at** - * - `int4` in database + * **account.scope** + * - `text` in database * - Nullable, no default */ - expires_at?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; + scope?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **account.token_type** + * **account.session_state** * - `text` in database * - Nullable, no default */ - token_type?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + session_state?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **account.scope** + * **account.token_type** * - `text` in database * - Nullable, no default */ - scope?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + token_type?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **account.id_token** - * - `text` in database + * **account.user_id** + * - `uuid` in database * - Nullable, no default */ - id_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + } + export interface Updatable { /** - * **account.session_state** + * **account.access_token** * - `text` in database * - Nullable, no default */ - session_state?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + access_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **account.account_id** * - `uuid` in database @@ -308,17 +314,17 @@ declare module 'zapatos/schema' { */ account_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **account.user_id** - * - `uuid` in database + * **account.expires_at** + * - `int4` in database * - Nullable, no default */ - user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + expires_at?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **account.provider_name** + * **account.id_token** * - `text` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - provider_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + id_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **account.provider_account_id** * - `text` in database @@ -326,11 +332,11 @@ declare module 'zapatos/schema' { */ provider_account_id?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **account.access_token** + * **account.provider_name** * - `text` in database - * - Nullable, no default + * - `NOT NULL`, no default */ - access_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + provider_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **account.refresh_token** * - `text` in database @@ -338,35 +344,29 @@ declare module 'zapatos/schema' { */ refresh_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **account.expires_at** - * - `int4` in database - * - Nullable, no default - */ - expires_at?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **account.token_type** + * **account.scope** * - `text` in database * - Nullable, no default */ - token_type?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + scope?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **account.scope** + * **account.session_state** * - `text` in database * - Nullable, no default */ - scope?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + session_state?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **account.id_token** + * **account.token_type** * - `text` in database * - Nullable, no default */ - id_token?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + token_type?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **account.session_state** - * - `text` in database + * **account.user_id** + * - `uuid` in database * - Nullable, no default */ - session_state?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'account_pkey' | 'account_provider_name_provider_account_id_key'; export type Column = keyof Selectable; @@ -382,6 +382,18 @@ declare module 'zapatos/schema' { export namespace benchmark { export type Table = 'benchmark'; export interface Selectable { + /** + * **benchmark.attempts_per_trial** + * - `int2` in database + * - Nullable, no default + */ + attempts_per_trial: number | null; + /** + * **benchmark.baseline_level** + * - `int2` in database + * - `NOT NULL`, no default + */ + baseline_level: number; /** * **benchmark.benchmark_id** * - `uuid` in database @@ -389,17 +401,17 @@ declare module 'zapatos/schema' { */ benchmark_id: string; /** - * **benchmark.goal_id** - * - `uuid` in database + * **benchmark.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at: Date; + /** + * **benchmark.current_level** + * - `int2` in database * - Nullable, no default */ - goal_id: string | null; - /** - * **benchmark.status** - * - `text` in database - * - `NOT NULL`, default: `'In Progress'::text` - */ - status: string; + current_level: number | null; /** * **benchmark.description** * - `text` in database @@ -407,11 +419,17 @@ declare module 'zapatos/schema' { */ description: string; /** - * **benchmark.setup** + * **benchmark.frequency** * - `text` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `''::text` */ - setup: string; + frequency: string; + /** + * **benchmark.goal_id** + * - `uuid` in database + * - Nullable, no default + */ + goal_id: string | null; /** * **benchmark.instructions** * - `text` in database @@ -425,35 +443,37 @@ declare module 'zapatos/schema' { */ materials: string; /** - * **benchmark.frequency** + * **benchmark.metric_name** * - `text` in database - * - `NOT NULL`, default: `''::text` + * - `NOT NULL`, no default */ - frequency: string; + metric_name: string; /** - * **benchmark.target_level** + * **benchmark.number_of_trials** * - `int2` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - target_level: number; + number_of_trials: number | null; /** - * **benchmark.baseline_level** - * - `int2` in database + * **benchmark.setup** + * - `text` in database * - `NOT NULL`, no default */ - baseline_level: number; + setup: string; /** - * **benchmark.current_level** - * - `int2` in database - * - Nullable, no default + * **benchmark.status** + * - `text` in database + * - `NOT NULL`, default: `'In Progress'::text` */ - current_level: number | null; + status: string; /** - * **benchmark.metric_name** - * - `text` in database + * **benchmark.target_level** + * - `int2` in database * - `NOT NULL`, no default */ - metric_name: string; + target_level: number; + } + export interface JSONSelectable { /** * **benchmark.attempts_per_trial** * - `int2` in database @@ -461,19 +481,11 @@ declare module 'zapatos/schema' { */ attempts_per_trial: number | null; /** - * **benchmark.number_of_trials** + * **benchmark.baseline_level** * - `int2` in database - * - Nullable, no default - */ - number_of_trials: number | null; - /** - * **benchmark.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * - `NOT NULL`, no default */ - created_at: Date; - } - export interface JSONSelectable { + baseline_level: number; /** * **benchmark.benchmark_id** * - `uuid` in database @@ -481,17 +493,17 @@ declare module 'zapatos/schema' { */ benchmark_id: string; /** - * **benchmark.goal_id** - * - `uuid` in database - * - Nullable, no default + * **benchmark.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - goal_id: string | null; + created_at: db.TimestampTzString; /** - * **benchmark.status** - * - `text` in database - * - `NOT NULL`, default: `'In Progress'::text` + * **benchmark.current_level** + * - `int2` in database + * - Nullable, no default */ - status: string; + current_level: number | null; /** * **benchmark.description** * - `text` in database @@ -499,11 +511,17 @@ declare module 'zapatos/schema' { */ description: string; /** - * **benchmark.setup** + * **benchmark.frequency** * - `text` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `''::text` */ - setup: string; + frequency: string; + /** + * **benchmark.goal_id** + * - `uuid` in database + * - Nullable, no default + */ + goal_id: string | null; /** * **benchmark.instructions** * - `text` in database @@ -517,55 +535,49 @@ declare module 'zapatos/schema' { */ materials: string; /** - * **benchmark.frequency** + * **benchmark.metric_name** * - `text` in database - * - `NOT NULL`, default: `''::text` + * - `NOT NULL`, no default */ - frequency: string; + metric_name: string; /** - * **benchmark.target_level** + * **benchmark.number_of_trials** * - `int2` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - target_level: number; + number_of_trials: number | null; /** - * **benchmark.baseline_level** - * - `int2` in database + * **benchmark.setup** + * - `text` in database * - `NOT NULL`, no default */ - baseline_level: number; + setup: string; /** - * **benchmark.current_level** - * - `int2` in database - * - Nullable, no default + * **benchmark.status** + * - `text` in database + * - `NOT NULL`, default: `'In Progress'::text` */ - current_level: number | null; + status: string; /** - * **benchmark.metric_name** - * - `text` in database + * **benchmark.target_level** + * - `int2` in database * - `NOT NULL`, no default */ - metric_name: string; + target_level: number; + } + export interface Whereable { /** * **benchmark.attempts_per_trial** * - `int2` in database * - Nullable, no default */ - attempts_per_trial: number | null; + attempts_per_trial?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.number_of_trials** + * **benchmark.baseline_level** * - `int2` in database - * - Nullable, no default - */ - number_of_trials: number | null; - /** - * **benchmark.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * - `NOT NULL`, no default */ - created_at: db.TimestampTzString; - } - export interface Whereable { + baseline_level?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **benchmark.benchmark_id** * - `uuid` in database @@ -573,17 +585,17 @@ declare module 'zapatos/schema' { */ benchmark_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.goal_id** - * - `uuid` in database - * - Nullable, no default + * **benchmark.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - goal_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.status** - * - `text` in database - * - `NOT NULL`, default: `'In Progress'::text` + * **benchmark.current_level** + * - `int2` in database + * - Nullable, no default */ - status?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + current_level?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **benchmark.description** * - `text` in database @@ -591,11 +603,17 @@ declare module 'zapatos/schema' { */ description?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.setup** + * **benchmark.frequency** * - `text` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `''::text` */ - setup?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + frequency?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** + * **benchmark.goal_id** + * - `uuid` in database + * - Nullable, no default + */ + goal_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **benchmark.instructions** * - `text` in database @@ -609,55 +627,49 @@ declare module 'zapatos/schema' { */ materials?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.frequency** + * **benchmark.metric_name** * - `text` in database - * - `NOT NULL`, default: `''::text` + * - `NOT NULL`, no default */ - frequency?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + metric_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.target_level** + * **benchmark.number_of_trials** * - `int2` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - target_level?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + number_of_trials?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.baseline_level** - * - `int2` in database + * **benchmark.setup** + * - `text` in database * - `NOT NULL`, no default */ - baseline_level?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + setup?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.current_level** - * - `int2` in database - * - Nullable, no default + * **benchmark.status** + * - `text` in database + * - `NOT NULL`, default: `'In Progress'::text` */ - current_level?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + status?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **benchmark.metric_name** - * - `text` in database + * **benchmark.target_level** + * - `int2` in database * - `NOT NULL`, no default */ - metric_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + target_level?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **benchmark.attempts_per_trial** * - `int2` in database * - Nullable, no default */ - attempts_per_trial?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + attempts_per_trial?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **benchmark.number_of_trials** + * **benchmark.baseline_level** * - `int2` in database - * - Nullable, no default - */ - number_of_trials?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **benchmark.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * - `NOT NULL`, no default */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + baseline_level: number | db.Parameter | db.SQLFragment; /** * **benchmark.benchmark_id** * - `uuid` in database @@ -665,17 +677,17 @@ declare module 'zapatos/schema' { */ benchmark_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** - * **benchmark.goal_id** - * - `uuid` in database - * - Nullable, no default + * **benchmark.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - goal_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; /** - * **benchmark.status** - * - `text` in database - * - `NOT NULL`, default: `'In Progress'::text` + * **benchmark.current_level** + * - `int2` in database + * - Nullable, no default */ - status?: string | db.Parameter | db.DefaultType | db.SQLFragment; + current_level?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; /** * **benchmark.description** * - `text` in database @@ -683,11 +695,17 @@ declare module 'zapatos/schema' { */ description: string | db.Parameter | db.SQLFragment; /** - * **benchmark.setup** + * **benchmark.frequency** * - `text` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `''::text` */ - setup: string | db.Parameter | db.SQLFragment; + frequency?: string | db.Parameter | db.DefaultType | db.SQLFragment; + /** + * **benchmark.goal_id** + * - `uuid` in database + * - Nullable, no default + */ + goal_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** * **benchmark.instructions** * - `text` in database @@ -701,55 +719,49 @@ declare module 'zapatos/schema' { */ materials?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** - * **benchmark.frequency** + * **benchmark.metric_name** * - `text` in database - * - `NOT NULL`, default: `''::text` + * - `NOT NULL`, no default */ - frequency?: string | db.Parameter | db.DefaultType | db.SQLFragment; + metric_name: string | db.Parameter | db.SQLFragment; /** - * **benchmark.target_level** + * **benchmark.number_of_trials** * - `int2` in database - * - `NOT NULL`, no default + * - Nullable, no default */ - target_level: number | db.Parameter | db.SQLFragment; + number_of_trials?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **benchmark.baseline_level** - * - `int2` in database + * **benchmark.setup** + * - `text` in database * - `NOT NULL`, no default */ - baseline_level: number | db.Parameter | db.SQLFragment; + setup: string | db.Parameter | db.SQLFragment; /** - * **benchmark.current_level** - * - `int2` in database - * - Nullable, no default + * **benchmark.status** + * - `text` in database + * - `NOT NULL`, default: `'In Progress'::text` */ - current_level?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; + status?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** - * **benchmark.metric_name** - * - `text` in database + * **benchmark.target_level** + * - `int2` in database * - `NOT NULL`, no default */ - metric_name: string | db.Parameter | db.SQLFragment; + target_level: number | db.Parameter | db.SQLFragment; + } + export interface Updatable { /** * **benchmark.attempts_per_trial** * - `int2` in database * - Nullable, no default */ - attempts_per_trial?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; + attempts_per_trial?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **benchmark.number_of_trials** + * **benchmark.baseline_level** * - `int2` in database - * - Nullable, no default - */ - number_of_trials?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; - /** - * **benchmark.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * - `NOT NULL`, no default */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + baseline_level?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **benchmark.benchmark_id** * - `uuid` in database @@ -757,17 +769,17 @@ declare module 'zapatos/schema' { */ benchmark_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **benchmark.goal_id** - * - `uuid` in database - * - Nullable, no default + * **benchmark.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - goal_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **benchmark.status** - * - `text` in database - * - `NOT NULL`, default: `'In Progress'::text` + * **benchmark.current_level** + * - `int2` in database + * - Nullable, no default */ - status?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + current_level?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **benchmark.description** * - `text` in database @@ -775,11 +787,17 @@ declare module 'zapatos/schema' { */ description?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **benchmark.setup** + * **benchmark.frequency** * - `text` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `''::text` */ - setup?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + frequency?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **benchmark.goal_id** + * - `uuid` in database + * - Nullable, no default + */ + goal_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **benchmark.instructions** * - `text` in database @@ -793,53 +811,35 @@ declare module 'zapatos/schema' { */ materials?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **benchmark.frequency** + * **benchmark.metric_name** * - `text` in database - * - `NOT NULL`, default: `''::text` - */ - frequency?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; - /** - * **benchmark.target_level** - * - `int2` in database * - `NOT NULL`, no default */ - target_level?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **benchmark.baseline_level** - * - `int2` in database - * - `NOT NULL`, no default - */ - baseline_level?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + metric_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **benchmark.current_level** + * **benchmark.number_of_trials** * - `int2` in database * - Nullable, no default */ - current_level?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + number_of_trials?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **benchmark.metric_name** + * **benchmark.setup** * - `text` in database * - `NOT NULL`, no default */ - metric_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + setup?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **benchmark.attempts_per_trial** - * - `int2` in database - * - Nullable, no default + * **benchmark.status** + * - `text` in database + * - `NOT NULL`, default: `'In Progress'::text` */ - attempts_per_trial?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + status?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **benchmark.number_of_trials** + * **benchmark.target_level** * - `int2` in database - * - Nullable, no default - */ - number_of_trials?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **benchmark.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * - `NOT NULL`, no default */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + target_level?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; } export type UniqueIndex = 'benchmark_pkey'; export type Column = keyof Selectable; @@ -855,18 +855,6 @@ declare module 'zapatos/schema' { export namespace file { export type Table = 'file'; export interface Selectable { - /** - * **file.file_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - file_id: string; - /** - * **file.name** - * - `text` in database - * - `NOT NULL`, no default - */ - name: string; /** * **file.content_type** * - `text` in database @@ -874,25 +862,17 @@ declare module 'zapatos/schema' { */ content_type: string; /** - * **file.ext_s3_path** - * - `text` in database - * - `NOT NULL`, no default - */ - ext_s3_path: string; - /** - * **file.uploaded_by_user_id** - * - `uuid` in database - * - Nullable, no default - */ - uploaded_by_user_id: string | null; - /** * **file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ created_at: Date; - } - export interface JSONSelectable { + /** + * **file.ext_s3_path** + * - `text` in database + * - `NOT NULL`, no default + */ + ext_s3_path: string; /** * **file.file_id** * - `uuid` in database @@ -905,6 +885,14 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ name: string; + /** + * **file.uploaded_by_user_id** + * - `uuid` in database + * - Nullable, no default + */ + uploaded_by_user_id: string | null; + } + export interface JSONSelectable { /** * **file.content_type** * - `text` in database @@ -912,25 +900,55 @@ declare module 'zapatos/schema' { */ content_type: string; /** + * **file.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at: db.TimestampTzString; + /** * **file.ext_s3_path** * - `text` in database * - `NOT NULL`, no default */ ext_s3_path: string; /** + * **file.file_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + file_id: string; + /** + * **file.name** + * - `text` in database + * - `NOT NULL`, no default + */ + name: string; + /** * **file.uploaded_by_user_id** * - `uuid` in database * - Nullable, no default */ uploaded_by_user_id: string | null; + } + export interface Whereable { + /** + * **file.content_type** + * - `text` in database + * - `NOT NULL`, no default + */ + content_type?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at: db.TimestampTzString; - } - export interface Whereable { + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** + * **file.ext_s3_path** + * - `text` in database + * - `NOT NULL`, no default + */ + ext_s3_path?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **file.file_id** * - `uuid` in database @@ -944,31 +962,31 @@ declare module 'zapatos/schema' { */ name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **file.content_type** - * - `text` in database - * - `NOT NULL`, no default - */ - content_type?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **file.ext_s3_path** - * - `text` in database - * - `NOT NULL`, no default - */ - ext_s3_path?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** * **file.uploaded_by_user_id** * - `uuid` in database * - Nullable, no default */ uploaded_by_user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { + /** + * **file.content_type** + * - `text` in database + * - `NOT NULL`, no default + */ + content_type: string | db.Parameter | db.SQLFragment; /** * **file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; + /** + * **file.ext_s3_path** + * - `text` in database + * - `NOT NULL`, no default + */ + ext_s3_path: string | db.Parameter | db.SQLFragment; /** * **file.file_id** * - `uuid` in database @@ -982,31 +1000,31 @@ declare module 'zapatos/schema' { */ name: string | db.Parameter | db.SQLFragment; /** - * **file.content_type** - * - `text` in database - * - `NOT NULL`, no default - */ - content_type: string | db.Parameter | db.SQLFragment; - /** - * **file.ext_s3_path** - * - `text` in database - * - `NOT NULL`, no default - */ - ext_s3_path: string | db.Parameter | db.SQLFragment; - /** * **file.uploaded_by_user_id** * - `uuid` in database * - Nullable, no default */ uploaded_by_user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + } + export interface Updatable { + /** + * **file.content_type** + * - `text` in database + * - `NOT NULL`, no default + */ + content_type?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **file.ext_s3_path** + * - `text` in database + * - `NOT NULL`, no default + */ + ext_s3_path?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **file.file_id** * - `uuid` in database @@ -1020,29 +1038,11 @@ declare module 'zapatos/schema' { */ name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **file.content_type** - * - `text` in database - * - `NOT NULL`, no default - */ - content_type?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **file.ext_s3_path** - * - `text` in database - * - `NOT NULL`, no default - */ - ext_s3_path?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** * **file.uploaded_by_user_id** * - `uuid` in database * - Nullable, no default */ uploaded_by_user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **file.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` - */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'file_ext_s3_path_key' | 'file_pkey'; export type Column = keyof Selectable; @@ -1058,24 +1058,6 @@ declare module 'zapatos/schema' { export namespace goal { export type Table = 'goal'; export interface Selectable { - /** - * **goal.goal_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - goal_id: string; - /** - * **goal.iep_id** - * - `uuid` in database - * - Nullable, no default - */ - iep_id: string | null; - /** - * **goal.description** - * - `text` in database - * - `NOT NULL`, no default - */ - description: string; /** * **goal.category** * - `text` in database @@ -1088,8 +1070,12 @@ declare module 'zapatos/schema' { * - `NOT NULL`, default: `now()` */ created_at: Date; - } - export interface JSONSelectable { + /** + * **goal.description** + * - `text` in database + * - `NOT NULL`, no default + */ + description: string; /** * **goal.goal_id** * - `uuid` in database @@ -1102,12 +1088,8 @@ declare module 'zapatos/schema' { * - Nullable, no default */ iep_id: string | null; - /** - * **goal.description** - * - `text` in database - * - `NOT NULL`, no default - */ - description: string; + } + export interface JSONSelectable { /** * **goal.category** * - `text` in database @@ -1120,26 +1102,26 @@ declare module 'zapatos/schema' { * - `NOT NULL`, default: `now()` */ created_at: db.TimestampTzString; - } - export interface Whereable { + /** + * **goal.description** + * - `text` in database + * - `NOT NULL`, no default + */ + description: string; /** * **goal.goal_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - goal_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + goal_id: string; /** * **goal.iep_id** * - `uuid` in database * - Nullable, no default */ - iep_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **goal.description** - * - `text` in database - * - `NOT NULL`, no default - */ - description?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + iep_id: string | null; + } + export interface Whereable { /** * **goal.category** * - `text` in database @@ -1152,26 +1134,26 @@ declare module 'zapatos/schema' { * - `NOT NULL`, default: `now()` */ created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + /** + * **goal.description** + * - `text` in database + * - `NOT NULL`, no default + */ + description?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **goal.goal_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - goal_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + goal_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **goal.iep_id** * - `uuid` in database * - Nullable, no default */ - iep_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; - /** - * **goal.description** - * - `text` in database - * - `NOT NULL`, no default - */ - description: string | db.Parameter | db.SQLFragment; + iep_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **goal.category** * - `text` in database @@ -1184,26 +1166,26 @@ declare module 'zapatos/schema' { * - `NOT NULL`, default: `now()` */ created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + /** + * **goal.description** + * - `text` in database + * - `NOT NULL`, no default + */ + description: string | db.Parameter | db.SQLFragment; /** * **goal.goal_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - goal_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + goal_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** * **goal.iep_id** * - `uuid` in database * - Nullable, no default */ - iep_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **goal.description** - * - `text` in database - * - `NOT NULL`, no default - */ - description?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + iep_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + } + export interface Updatable { /** * **goal.category** * - `text` in database @@ -1216,6 +1198,24 @@ declare module 'zapatos/schema' { * - `NOT NULL`, default: `now()` */ created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **goal.description** + * - `text` in database + * - `NOT NULL`, no default + */ + description?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + /** + * **goal.goal_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + goal_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **goal.iep_id** + * - `uuid` in database + * - Nullable, no default + */ + iep_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'goal_pkey'; export type Column = keyof Selectable; @@ -1231,18 +1231,6 @@ declare module 'zapatos/schema' { export namespace iep { export type Table = 'iep'; export interface Selectable { - /** - * **iep.iep_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - iep_id: string; - /** - * **iep.student_id** - * - `uuid` in database - * - Nullable, no default - */ - student_id: string | null; /** * **iep.case_manager_id** * - `uuid` in database @@ -1250,25 +1238,17 @@ declare module 'zapatos/schema' { */ case_manager_id: string | null; /** - * **iep.start_date** - * - `date` in database - * - `NOT NULL`, no default + * **iep.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - start_date: Date; + created_at: Date; /** * **iep.end_date** * - `date` in database * - `NOT NULL`, no default */ end_date: Date; - /** - * **iep.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` - */ - created_at: Date; - } - export interface JSONSelectable { /** * **iep.iep_id** * - `uuid` in database @@ -1276,11 +1256,19 @@ declare module 'zapatos/schema' { */ iep_id: string; /** + * **iep.start_date** + * - `date` in database + * - `NOT NULL`, no default + */ + start_date: Date; + /** * **iep.student_id** * - `uuid` in database * - Nullable, no default */ student_id: string | null; + } + export interface JSONSelectable { /** * **iep.case_manager_id** * - `uuid` in database @@ -1288,37 +1276,37 @@ declare module 'zapatos/schema' { */ case_manager_id: string | null; /** - * **iep.start_date** - * - `date` in database - * - `NOT NULL`, no default + * **iep.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - start_date: db.DateString; + created_at: db.TimestampTzString; /** * **iep.end_date** * - `date` in database * - `NOT NULL`, no default */ end_date: db.DateString; - /** - * **iep.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` - */ - created_at: db.TimestampTzString; - } - export interface Whereable { /** * **iep.iep_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - iep_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + iep_id: string; + /** + * **iep.start_date** + * - `date` in database + * - `NOT NULL`, no default + */ + start_date: db.DateString; /** * **iep.student_id** * - `uuid` in database * - Nullable, no default */ - student_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + student_id: string | null; + } + export interface Whereable { /** * **iep.case_manager_id** * - `uuid` in database @@ -1326,37 +1314,37 @@ declare module 'zapatos/schema' { */ case_manager_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **iep.start_date** - * - `date` in database - * - `NOT NULL`, no default + * **iep.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - start_date?: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **iep.end_date** * - `date` in database * - `NOT NULL`, no default */ end_date?: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **iep.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` - */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { /** * **iep.iep_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - iep_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + iep_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** + * **iep.start_date** + * - `date` in database + * - `NOT NULL`, no default + */ + start_date?: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **iep.student_id** * - `uuid` in database * - Nullable, no default */ - student_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + student_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **iep.case_manager_id** * - `uuid` in database @@ -1364,37 +1352,37 @@ declare module 'zapatos/schema' { */ case_manager_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **iep.start_date** - * - `date` in database - * - `NOT NULL`, no default + * **iep.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - start_date: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; /** * **iep.end_date** * - `date` in database * - `NOT NULL`, no default */ end_date: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment; - /** - * **iep.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` - */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; - } - export interface Updatable { /** * **iep.iep_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - iep_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + iep_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + /** + * **iep.start_date** + * - `date` in database + * - `NOT NULL`, no default + */ + start_date: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment; /** * **iep.student_id** * - `uuid` in database * - Nullable, no default */ - student_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + student_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + } + export interface Updatable { /** * **iep.case_manager_id** * - `uuid` in database @@ -1402,11 +1390,11 @@ declare module 'zapatos/schema' { */ case_manager_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **iep.start_date** - * - `date` in database - * - `NOT NULL`, no default + * **iep.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - start_date?: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** * **iep.end_date** * - `date` in database @@ -1414,11 +1402,23 @@ declare module 'zapatos/schema' { */ end_date?: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **iep.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * **iep.iep_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + iep_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **iep.start_date** + * - `date` in database + * - `NOT NULL`, no default + */ + start_date?: (db.DateString | Date) | db.Parameter<(db.DateString | Date)> | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + /** + * **iep.student_id** + * - `uuid` in database + * - Nullable, no default + */ + student_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'iep_pkey'; export type Column = keyof Selectable; @@ -1434,6 +1434,18 @@ declare module 'zapatos/schema' { export namespace migrations { export type Table = 'migrations'; export interface Selectable { + /** + * **migrations.executed_at** + * - `timestamp` in database + * - Nullable, default: `CURRENT_TIMESTAMP` + */ + executed_at: Date | null; + /** + * **migrations.hash** + * - `varchar` in database + * - `NOT NULL`, no default + */ + hash: string; /** * **migrations.id** * - `int4` in database @@ -1446,20 +1458,20 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ name: string; + } + export interface JSONSelectable { + /** + * **migrations.executed_at** + * - `timestamp` in database + * - Nullable, default: `CURRENT_TIMESTAMP` + */ + executed_at: db.TimestampString | null; /** * **migrations.hash** * - `varchar` in database * - `NOT NULL`, no default */ hash: string; - /** - * **migrations.executed_at** - * - `timestamp` in database - * - Nullable, default: `CURRENT_TIMESTAMP` - */ - executed_at: Date | null; - } - export interface JSONSelectable { /** * **migrations.id** * - `int4` in database @@ -1472,20 +1484,20 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ name: string; - /** - * **migrations.hash** - * - `varchar` in database - * - `NOT NULL`, no default - */ - hash: string; + } + export interface Whereable { /** * **migrations.executed_at** * - `timestamp` in database * - Nullable, default: `CURRENT_TIMESTAMP` */ - executed_at: db.TimestampString | null; - } - export interface Whereable { + executed_at?: (db.TimestampString | Date) | db.Parameter<(db.TimestampString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** + * **migrations.hash** + * - `varchar` in database + * - `NOT NULL`, no default + */ + hash?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **migrations.id** * - `int4` in database @@ -1498,20 +1510,20 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **migrations.hash** - * - `varchar` in database - * - `NOT NULL`, no default - */ - hash?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **migrations.executed_at** * - `timestamp` in database * - Nullable, default: `CURRENT_TIMESTAMP` */ - executed_at?: (db.TimestampString | Date) | db.Parameter<(db.TimestampString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + executed_at?: (db.TimestampString | Date) | db.Parameter<(db.TimestampString | Date)> | null | db.DefaultType | db.SQLFragment; + /** + * **migrations.hash** + * - `varchar` in database + * - `NOT NULL`, no default + */ + hash: string | db.Parameter | db.SQLFragment; /** * **migrations.id** * - `int4` in database @@ -1524,20 +1536,20 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ name: string | db.Parameter | db.SQLFragment; - /** - * **migrations.hash** - * - `varchar` in database - * - `NOT NULL`, no default - */ - hash: string | db.Parameter | db.SQLFragment; + } + export interface Updatable { /** * **migrations.executed_at** * - `timestamp` in database * - Nullable, default: `CURRENT_TIMESTAMP` */ - executed_at?: (db.TimestampString | Date) | db.Parameter<(db.TimestampString | Date)> | null | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + executed_at?: (db.TimestampString | Date) | db.Parameter<(db.TimestampString | Date)> | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + /** + * **migrations.hash** + * - `varchar` in database + * - `NOT NULL`, no default + */ + hash?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **migrations.id** * - `int4` in database @@ -1550,18 +1562,6 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **migrations.hash** - * - `varchar` in database - * - `NOT NULL`, no default - */ - hash?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **migrations.executed_at** - * - `timestamp` in database - * - Nullable, default: `CURRENT_TIMESTAMP` - */ - executed_at?: (db.TimestampString | Date) | db.Parameter<(db.TimestampString | Date)> | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'migrations_name_key' | 'migrations_pkey'; export type Column = keyof Selectable; @@ -1660,6 +1660,12 @@ declare module 'zapatos/schema' { export namespace session { export type Table = 'session'; export interface Selectable { + /** + * **session.expires_at** + * - `timestamptz` in database + * - `NOT NULL`, no default + */ + expires_at: Date; /** * **session.session_id** * - `uuid` in database @@ -1678,14 +1684,14 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ user_id: string; + } + export interface JSONSelectable { /** * **session.expires_at** * - `timestamptz` in database * - `NOT NULL`, no default */ - expires_at: Date; - } - export interface JSONSelectable { + expires_at: db.TimestampTzString; /** * **session.session_id** * - `uuid` in database @@ -1704,14 +1710,14 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ user_id: string; + } + export interface Whereable { /** * **session.expires_at** * - `timestamptz` in database * - `NOT NULL`, no default */ - expires_at: db.TimestampTzString; - } - export interface Whereable { + expires_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **session.session_id** * - `uuid` in database @@ -1730,14 +1736,14 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **session.expires_at** * - `timestamptz` in database * - `NOT NULL`, no default */ - expires_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + expires_at: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment; /** * **session.session_id** * - `uuid` in database @@ -1756,14 +1762,14 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ user_id: string | db.Parameter | db.SQLFragment; + } + export interface Updatable { /** * **session.expires_at** * - `timestamptz` in database * - `NOT NULL`, no default */ - expires_at: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment; - } - export interface Updatable { + expires_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **session.session_id** * - `uuid` in database @@ -1782,12 +1788,6 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ user_id?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **session.expires_at** - * - `timestamptz` in database - * - `NOT NULL`, no default - */ - expires_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.SQLFragment | db.SQLFragment>; } export type UniqueIndex = 'session_pkey' | 'session_session_token_key'; export type Column = keyof Selectable; @@ -1804,11 +1804,17 @@ declare module 'zapatos/schema' { export type Table = 'student'; export interface Selectable { /** - * **student.student_id** + * **student.assigned_case_manager_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - student_id: string; + assigned_case_manager_id: string | null; + /** + * **student.email** + * - `text` in database + * - `NOT NULL`, no default + */ + email: string; /** * **student.first_name** * - `text` in database @@ -1816,17 +1822,25 @@ declare module 'zapatos/schema' { */ first_name: string; /** + * **student.grade** + * - `int2` in database + * - `NOT NULL`, no default + */ + grade: number; + /** * **student.last_name** * - `text` in database * - `NOT NULL`, no default */ last_name: string; /** - * **student.email** - * - `text` in database - * - `NOT NULL`, no default + * **student.student_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` */ - email: string; + student_id: string; + } + export interface JSONSelectable { /** * **student.assigned_case_manager_id** * - `uuid` in database @@ -1834,19 +1848,11 @@ declare module 'zapatos/schema' { */ assigned_case_manager_id: string | null; /** - * **student.grade** - * - `int2` in database + * **student.email** + * - `text` in database * - `NOT NULL`, no default */ - grade: number; - } - export interface JSONSelectable { - /** - * **student.student_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - student_id: string; + email: string; /** * **student.first_name** * - `text` in database @@ -1854,37 +1860,37 @@ declare module 'zapatos/schema' { */ first_name: string; /** + * **student.grade** + * - `int2` in database + * - `NOT NULL`, no default + */ + grade: number; + /** * **student.last_name** * - `text` in database * - `NOT NULL`, no default */ last_name: string; /** - * **student.email** - * - `text` in database - * - `NOT NULL`, no default + * **student.student_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` */ - email: string; + student_id: string; + } + export interface Whereable { /** * **student.assigned_case_manager_id** * - `uuid` in database * - Nullable, no default */ - assigned_case_manager_id: string | null; + assigned_case_manager_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **student.grade** - * - `int2` in database + * **student.email** + * - `text` in database * - `NOT NULL`, no default */ - grade: number; - } - export interface Whereable { - /** - * **student.student_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - student_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + email?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **student.first_name** * - `text` in database @@ -1892,75 +1898,75 @@ declare module 'zapatos/schema' { */ first_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **student.last_name** - * - `text` in database + * **student.grade** + * - `int2` in database * - `NOT NULL`, no default */ - last_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + grade?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **student.email** + * **student.last_name** * - `text` in database * - `NOT NULL`, no default */ - email?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + last_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **student.assigned_case_manager_id** + * **student.student_id** * - `uuid` in database - * - Nullable, no default - */ - assigned_case_manager_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **student.grade** - * - `int2` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - grade?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + student_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; } export interface Insertable { /** - * **student.student_id** + * **student.assigned_case_manager_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - student_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + assigned_case_manager_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **student.first_name** + * **student.email** * - `text` in database * - `NOT NULL`, no default */ - first_name: string | db.Parameter | db.SQLFragment; + email: string | db.Parameter | db.SQLFragment; /** - * **student.last_name** + * **student.first_name** * - `text` in database * - `NOT NULL`, no default */ - last_name: string | db.Parameter | db.SQLFragment; + first_name: string | db.Parameter | db.SQLFragment; /** - * **student.email** - * - `text` in database + * **student.grade** + * - `int2` in database * - `NOT NULL`, no default */ - email: string | db.Parameter | db.SQLFragment; + grade: number | db.Parameter | db.SQLFragment; /** - * **student.assigned_case_manager_id** - * - `uuid` in database - * - Nullable, no default + * **student.last_name** + * - `text` in database + * - `NOT NULL`, no default */ - assigned_case_manager_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + last_name: string | db.Parameter | db.SQLFragment; /** - * **student.grade** - * - `int2` in database - * - `NOT NULL`, no default + * **student.student_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` */ - grade: number | db.Parameter | db.SQLFragment; + student_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; } export interface Updatable { /** - * **student.student_id** + * **student.assigned_case_manager_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - student_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + assigned_case_manager_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + /** + * **student.email** + * - `text` in database + * - `NOT NULL`, no default + */ + email?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **student.first_name** * - `text` in database @@ -1968,29 +1974,23 @@ declare module 'zapatos/schema' { */ first_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **student.last_name** - * - `text` in database + * **student.grade** + * - `int2` in database * - `NOT NULL`, no default */ - last_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + grade?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **student.email** + * **student.last_name** * - `text` in database * - `NOT NULL`, no default */ - email?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + last_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **student.assigned_case_manager_id** + * **student.student_id** * - `uuid` in database - * - Nullable, no default - */ - assigned_case_manager_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **student.grade** - * - `int2` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - grade?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + student_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'student_email_key' | 'student_pkey'; export type Column = keyof Selectable; @@ -2007,11 +2007,11 @@ declare module 'zapatos/schema' { export type Table = 'task'; export interface Selectable { /** - * **task.task_id** + * **task.assignee_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - task_id: string; + assignee_id: string | null; /** * **task.benchmark_id** * - `uuid` in database @@ -2019,31 +2019,17 @@ declare module 'zapatos/schema' { */ benchmark_id: string | null; /** - * **task.assignee_id** - * - `uuid` in database - * - Nullable, no default - */ - assignee_id: string | null; - /** * **task.due_date** * - `timestamptz` in database * - Nullable, no default */ due_date: Date | null; /** - * **task.trial_count** - * - `int4` in database - * - Nullable, no default - */ - trial_count: number | null; - /** * **task.seen** * - `bool` in database * - `NOT NULL`, default: `false` */ seen: boolean; - } - export interface JSONSelectable { /** * **task.task_id** * - `uuid` in database @@ -2051,11 +2037,13 @@ declare module 'zapatos/schema' { */ task_id: string; /** - * **task.benchmark_id** - * - `uuid` in database + * **task.trial_count** + * - `int4` in database * - Nullable, no default */ - benchmark_id: string | null; + trial_count: number | null; + } + export interface JSONSelectable { /** * **task.assignee_id** * - `uuid` in database @@ -2063,37 +2051,37 @@ declare module 'zapatos/schema' { */ assignee_id: string | null; /** - * **task.due_date** - * - `timestamptz` in database + * **task.benchmark_id** + * - `uuid` in database * - Nullable, no default */ - due_date: db.TimestampTzString | null; + benchmark_id: string | null; /** - * **task.trial_count** - * - `int4` in database + * **task.due_date** + * - `timestamptz` in database * - Nullable, no default */ - trial_count: number | null; + due_date: db.TimestampTzString | null; /** * **task.seen** * - `bool` in database * - `NOT NULL`, default: `false` */ seen: boolean; - } - export interface Whereable { /** * **task.task_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - task_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + task_id: string; /** - * **task.benchmark_id** - * - `uuid` in database + * **task.trial_count** + * - `int4` in database * - Nullable, no default */ - benchmark_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + trial_count: number | null; + } + export interface Whereable { /** * **task.assignee_id** * - `uuid` in database @@ -2101,37 +2089,37 @@ declare module 'zapatos/schema' { */ assignee_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **task.due_date** - * - `timestamptz` in database + * **task.benchmark_id** + * - `uuid` in database * - Nullable, no default */ - due_date?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + benchmark_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **task.trial_count** - * - `int4` in database + * **task.due_date** + * - `timestamptz` in database * - Nullable, no default */ - trial_count?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + due_date?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **task.seen** * - `bool` in database * - `NOT NULL`, default: `false` */ seen?: boolean | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { /** * **task.task_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - task_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + task_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **task.benchmark_id** - * - `uuid` in database + * **task.trial_count** + * - `int4` in database * - Nullable, no default */ - benchmark_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + trial_count?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **task.assignee_id** * - `uuid` in database @@ -2139,37 +2127,37 @@ declare module 'zapatos/schema' { */ assignee_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **task.due_date** - * - `timestamptz` in database + * **task.benchmark_id** + * - `uuid` in database * - Nullable, no default */ - due_date?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment; + benchmark_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **task.trial_count** - * - `int4` in database + * **task.due_date** + * - `timestamptz` in database * - Nullable, no default */ - trial_count?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; + due_date?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment; /** * **task.seen** * - `bool` in database * - `NOT NULL`, default: `false` */ seen?: boolean | db.Parameter | db.DefaultType | db.SQLFragment; - } - export interface Updatable { /** * **task.task_id** * - `uuid` in database * - `NOT NULL`, default: `uuid_generate_v4()` */ - task_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + task_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** - * **task.benchmark_id** - * - `uuid` in database + * **task.trial_count** + * - `int4` in database * - Nullable, no default */ - benchmark_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + trial_count?: number | db.Parameter | null | db.DefaultType | db.SQLFragment; + } + export interface Updatable { /** * **task.assignee_id** * - `uuid` in database @@ -2177,23 +2165,35 @@ declare module 'zapatos/schema' { */ assignee_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **task.due_date** - * - `timestamptz` in database + * **task.benchmark_id** + * - `uuid` in database * - Nullable, no default */ - due_date?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + benchmark_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **task.trial_count** - * - `int4` in database + * **task.due_date** + * - `timestamptz` in database * - Nullable, no default */ - trial_count?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + due_date?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **task.seen** * - `bool` in database * - `NOT NULL`, default: `false` */ seen?: boolean | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **task.task_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + task_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **task.trial_count** + * - `int4` in database + * - Nullable, no default + */ + trial_count?: number | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'benchmark_assignee_unique' | 'task_pkey'; export type Column = keyof Selectable; @@ -2210,23 +2210,29 @@ declare module 'zapatos/schema' { export type Table = 'trial_data'; export interface Selectable { /** - * **trial_data.trial_data_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * **trial_data.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - trial_data_id: string; + created_at: Date; /** - * **trial_data.task_id** + * **trial_data.created_by_user_id** * - `uuid` in database * - Nullable, no default */ - task_id: string | null; + created_by_user_id: string | null; /** - * **trial_data.created_by_user_id** - * - `uuid` in database + * **trial_data.notes** + * - `text` in database * - Nullable, no default */ - created_by_user_id: string | null; + notes: string | null; + /** + * **trial_data.submitted** + * - `bool` in database + * - `NOT NULL`, default: `false` + */ + submitted: boolean; /** * **trial_data.success** * - `int4` in database @@ -2234,17 +2240,37 @@ declare module 'zapatos/schema' { */ success: number; /** + * **trial_data.task_id** + * - `uuid` in database + * - Nullable, no default + */ + task_id: string | null; + /** + * **trial_data.trial_data_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + trial_data_id: string; + /** * **trial_data.unsuccess** * - `int4` in database * - `NOT NULL`, no default */ unsuccess: number; + } + export interface JSONSelectable { /** - * **trial_data.submitted** - * - `bool` in database - * - `NOT NULL`, default: `false` + * **trial_data.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - submitted: boolean; + created_at: db.TimestampTzString; + /** + * **trial_data.created_by_user_id** + * - `uuid` in database + * - Nullable, no default + */ + created_by_user_id: string | null; /** * **trial_data.notes** * - `text` in database @@ -2252,19 +2278,17 @@ declare module 'zapatos/schema' { */ notes: string | null; /** - * **trial_data.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * **trial_data.submitted** + * - `bool` in database + * - `NOT NULL`, default: `false` */ - created_at: Date; - } - export interface JSONSelectable { + submitted: boolean; /** - * **trial_data.trial_data_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * **trial_data.success** + * - `int4` in database + * - `NOT NULL`, no default */ - trial_data_id: string; + success: number; /** * **trial_data.task_id** * - `uuid` in database @@ -2272,49 +2296,49 @@ declare module 'zapatos/schema' { */ task_id: string | null; /** - * **trial_data.created_by_user_id** + * **trial_data.trial_data_id** * - `uuid` in database - * - Nullable, no default - */ - created_by_user_id: string | null; - /** - * **trial_data.success** - * - `int4` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - success: number; + trial_data_id: string; /** * **trial_data.unsuccess** * - `int4` in database * - `NOT NULL`, no default */ unsuccess: number; + } + export interface Whereable { /** - * **trial_data.submitted** - * - `bool` in database - * - `NOT NULL`, default: `false` + * **trial_data.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - submitted: boolean; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** + * **trial_data.created_by_user_id** + * - `uuid` in database + * - Nullable, no default + */ + created_by_user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **trial_data.notes** * - `text` in database * - Nullable, no default */ - notes: string | null; + notes?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **trial_data.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * **trial_data.submitted** + * - `bool` in database + * - `NOT NULL`, default: `false` */ - created_at: db.TimestampTzString; - } - export interface Whereable { + submitted?: boolean | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **trial_data.trial_data_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * **trial_data.success** + * - `int4` in database + * - `NOT NULL`, no default */ - trial_data_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + success?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **trial_data.task_id** * - `uuid` in database @@ -2322,49 +2346,49 @@ declare module 'zapatos/schema' { */ task_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **trial_data.created_by_user_id** + * **trial_data.trial_data_id** * - `uuid` in database - * - Nullable, no default - */ - created_by_user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **trial_data.success** - * - `int4` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - success?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + trial_data_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **trial_data.unsuccess** * - `int4` in database * - `NOT NULL`, no default */ unsuccess?: number | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** - * **trial_data.submitted** - * - `bool` in database - * - `NOT NULL`, default: `false` + * **trial_data.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - submitted?: boolean | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; + /** + * **trial_data.created_by_user_id** + * - `uuid` in database + * - Nullable, no default + */ + created_by_user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** * **trial_data.notes** * - `text` in database * - Nullable, no default */ - notes?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + notes?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **trial_data.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * **trial_data.submitted** + * - `bool` in database + * - `NOT NULL`, default: `false` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + submitted?: boolean | db.Parameter | db.DefaultType | db.SQLFragment; /** - * **trial_data.trial_data_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * **trial_data.success** + * - `int4` in database + * - `NOT NULL`, no default */ - trial_data_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + success: number | db.Parameter | db.SQLFragment; /** * **trial_data.task_id** * - `uuid` in database @@ -2372,49 +2396,49 @@ declare module 'zapatos/schema' { */ task_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **trial_data.created_by_user_id** + * **trial_data.trial_data_id** * - `uuid` in database - * - Nullable, no default - */ - created_by_user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; - /** - * **trial_data.success** - * - `int4` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - success: number | db.Parameter | db.SQLFragment; + trial_data_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; /** * **trial_data.unsuccess** * - `int4` in database * - `NOT NULL`, no default */ unsuccess: number | db.Parameter | db.SQLFragment; + } + export interface Updatable { /** - * **trial_data.submitted** - * - `bool` in database - * - `NOT NULL`, default: `false` + * **trial_data.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` */ - submitted?: boolean | db.Parameter | db.DefaultType | db.SQLFragment; + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** + * **trial_data.created_by_user_id** + * - `uuid` in database + * - Nullable, no default + */ + created_by_user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **trial_data.notes** * - `text` in database * - Nullable, no default */ - notes?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + notes?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **trial_data.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * **trial_data.submitted** + * - `bool` in database + * - `NOT NULL`, default: `false` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + submitted?: boolean | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **trial_data.trial_data_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * **trial_data.success** + * - `int4` in database + * - `NOT NULL`, no default */ - trial_data_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + success?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **trial_data.task_id** * - `uuid` in database @@ -2422,41 +2446,17 @@ declare module 'zapatos/schema' { */ task_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **trial_data.created_by_user_id** + * **trial_data.trial_data_id** * - `uuid` in database - * - Nullable, no default - */ - created_by_user_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **trial_data.success** - * - `int4` in database - * - `NOT NULL`, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - success?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; + trial_data_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** * **trial_data.unsuccess** * - `int4` in database * - `NOT NULL`, no default */ unsuccess?: number | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **trial_data.submitted** - * - `bool` in database - * - `NOT NULL`, default: `false` - */ - submitted?: boolean | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; - /** - * **trial_data.notes** - * - `text` in database - * - Nullable, no default - */ - notes?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **trial_data.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` - */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'trial_data_pkey'; export type Column = keyof Selectable; @@ -2473,11 +2473,17 @@ declare module 'zapatos/schema' { export type Table = 'trial_data_file'; export interface Selectable { /** - * **trial_data_file.trial_file_id** + * **trial_data_file.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at: Date; + /** + * **trial_data_file.file_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - trial_file_id: string; + file_id: string | null; /** * **trial_data_file.trial_data_id** * - `uuid` in database @@ -2485,25 +2491,25 @@ declare module 'zapatos/schema' { */ trial_data_id: string | null; /** - * **trial_data_file.file_id** + * **trial_data_file.trial_file_id** * - `uuid` in database - * - Nullable, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - file_id: string | null; + trial_file_id: string; + } + export interface JSONSelectable { /** * **trial_data_file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at: Date; - } - export interface JSONSelectable { + created_at: db.TimestampTzString; /** - * **trial_data_file.trial_file_id** + * **trial_data_file.file_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - trial_file_id: string; + file_id: string | null; /** * **trial_data_file.trial_data_id** * - `uuid` in database @@ -2511,25 +2517,25 @@ declare module 'zapatos/schema' { */ trial_data_id: string | null; /** - * **trial_data_file.file_id** + * **trial_data_file.trial_file_id** * - `uuid` in database - * - Nullable, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - file_id: string | null; + trial_file_id: string; + } + export interface Whereable { /** * **trial_data_file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at: db.TimestampTzString; - } - export interface Whereable { + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **trial_data_file.trial_file_id** + * **trial_data_file.file_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - trial_file_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + file_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **trial_data_file.trial_data_id** * - `uuid` in database @@ -2537,25 +2543,25 @@ declare module 'zapatos/schema' { */ trial_data_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** - * **trial_data_file.file_id** + * **trial_data_file.trial_file_id** * - `uuid` in database - * - Nullable, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - file_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + trial_file_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **trial_data_file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; /** - * **trial_data_file.trial_file_id** + * **trial_data_file.file_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - trial_file_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + file_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** * **trial_data_file.trial_data_id** * - `uuid` in database @@ -2563,25 +2569,25 @@ declare module 'zapatos/schema' { */ trial_data_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** - * **trial_data_file.file_id** + * **trial_data_file.trial_file_id** * - `uuid` in database - * - Nullable, no default + * - `NOT NULL`, default: `uuid_generate_v4()` */ - file_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + trial_file_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + } + export interface Updatable { /** * **trial_data_file.created_at** * - `timestamptz` in database * - `NOT NULL`, default: `now()` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; - } - export interface Updatable { + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; /** - * **trial_data_file.trial_file_id** + * **trial_data_file.file_id** * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * - Nullable, no default */ - trial_file_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + file_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **trial_data_file.trial_data_id** * - `uuid` in database @@ -2589,17 +2595,11 @@ declare module 'zapatos/schema' { */ trial_data_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** - * **trial_data_file.file_id** + * **trial_data_file.trial_file_id** * - `uuid` in database - * - Nullable, no default - */ - file_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **trial_data_file.created_at** - * - `timestamptz` in database - * - `NOT NULL`, default: `now()` + * - `NOT NULL`, default: `uuid_generate_v4()` */ - created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + trial_file_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'trial_data_file_pkey' | 'trial_data_file_trial_data_id_file_id_key'; export type Column = keyof Selectable; @@ -2616,11 +2616,17 @@ declare module 'zapatos/schema' { export type Table = 'user'; export interface Selectable { /** - * **user.user_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` + * **user.email** + * - `text` in database + * - `NOT NULL`, no default */ - user_id: string; + email: string; + /** + * **user.email_verified_at** + * - `timestamptz` in database + * - Nullable, no default + */ + email_verified_at: Date | null; /** * **user.first_name** * - `text` in database @@ -2628,6 +2634,12 @@ declare module 'zapatos/schema' { */ first_name: string; /** + * **user.image_url** + * - `text` in database + * - Nullable, no default + */ + image_url: string | null; + /** * **user.last_name** * - `text` in database * - `NOT NULL`, no default @@ -2641,6 +2653,14 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ role: string; + /** + * **user.user_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + user_id: string; + } + export interface JSONSelectable { /** * **user.email** * - `text` in database @@ -2652,21 +2672,7 @@ declare module 'zapatos/schema' { * - `timestamptz` in database * - Nullable, no default */ - email_verified_at: Date | null; - /** - * **user.image_url** - * - `text` in database - * - Nullable, no default - */ - image_url: string | null; - } - export interface JSONSelectable { - /** - * **user.user_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - user_id: string; + email_verified_at: db.TimestampTzString | null; /** * **user.first_name** * - `text` in database @@ -2674,6 +2680,12 @@ declare module 'zapatos/schema' { */ first_name: string; /** + * **user.image_url** + * - `text` in database + * - Nullable, no default + */ + image_url: string | null; + /** * **user.last_name** * - `text` in database * - `NOT NULL`, no default @@ -2687,32 +2699,26 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ role: string; + /** + * **user.user_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + user_id: string; + } + export interface Whereable { /** * **user.email** * - `text` in database * - `NOT NULL`, no default */ - email: string; + email?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **user.email_verified_at** * - `timestamptz` in database * - Nullable, no default */ - email_verified_at: db.TimestampTzString | null; - /** - * **user.image_url** - * - `text` in database - * - Nullable, no default - */ - image_url: string | null; - } - export interface Whereable { - /** - * **user.user_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + email_verified_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** * **user.first_name** * - `text` in database @@ -2720,6 +2726,12 @@ declare module 'zapatos/schema' { */ first_name?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** + * **user.image_url** + * - `text` in database + * - Nullable, no default + */ + image_url?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** * **user.last_name** * - `text` in database * - `NOT NULL`, no default @@ -2733,32 +2745,26 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ role?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** + * **user.user_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + user_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + } + export interface Insertable { /** * **user.email** * - `text` in database * - `NOT NULL`, no default */ - email?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + email: string | db.Parameter | db.SQLFragment; /** * **user.email_verified_at** * - `timestamptz` in database * - Nullable, no default */ - email_verified_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - /** - * **user.image_url** - * - `text` in database - * - Nullable, no default - */ - image_url?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; - } - export interface Insertable { - /** - * **user.user_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - user_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + email_verified_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment; /** * **user.first_name** * - `text` in database @@ -2766,6 +2772,12 @@ declare module 'zapatos/schema' { */ first_name: string | db.Parameter | db.SQLFragment; /** + * **user.image_url** + * - `text` in database + * - Nullable, no default + */ + image_url?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; + /** * **user.last_name** * - `text` in database * - `NOT NULL`, no default @@ -2779,32 +2791,26 @@ declare module 'zapatos/schema' { * - `NOT NULL`, no default */ role: string | db.Parameter | db.SQLFragment; + /** + * **user.user_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` + */ + user_id?: string | db.Parameter | db.DefaultType | db.SQLFragment; + } + export interface Updatable { /** * **user.email** * - `text` in database * - `NOT NULL`, no default */ - email: string | db.Parameter | db.SQLFragment; + email?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** * **user.email_verified_at** * - `timestamptz` in database * - Nullable, no default */ - email_verified_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment; - /** - * **user.image_url** - * - `text` in database - * - Nullable, no default - */ - image_url?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; - } - export interface Updatable { - /** - * **user.user_id** - * - `uuid` in database - * - `NOT NULL`, default: `uuid_generate_v4()` - */ - user_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + email_verified_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** * **user.first_name** * - `text` in database @@ -2812,6 +2818,12 @@ declare module 'zapatos/schema' { */ first_name?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** + * **user.image_url** + * - `text` in database + * - Nullable, no default + */ + image_url?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + /** * **user.last_name** * - `text` in database * - `NOT NULL`, no default @@ -2826,23 +2838,11 @@ declare module 'zapatos/schema' { */ role?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; /** - * **user.email** - * - `text` in database - * - `NOT NULL`, no default - */ - email?: string | db.Parameter | db.SQLFragment | db.SQLFragment | db.SQLFragment>; - /** - * **user.email_verified_at** - * - `timestamptz` in database - * - Nullable, no default - */ - email_verified_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; - /** - * **user.image_url** - * - `text` in database - * - Nullable, no default + * **user.user_id** + * - `uuid` in database + * - `NOT NULL`, default: `uuid_generate_v4()` */ - image_url?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; + user_id?: string | db.Parameter | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; } export type UniqueIndex = 'user_email_key' | 'user_pkey'; export type Column = keyof Selectable; From 7f858b96fec019ca9761abce9c35d357224d4321 Mon Sep 17 00:00:00 2001 From: Thom Hickey Date: Tue, 10 Dec 2024 18:33:46 -0800 Subject: [PATCH 2/3] [Closes #451] Admin panel + new PaginatedTable component + some fixes (#474) * basic user table working with sort and search and pagination all handled back-end * feat: adding users * fix: types * feat: edit users * feat: edit user, role dropdown * fix: styling + search query counts/pagination * fix: styling * fix: role init + sharing types backend/frontend * fix: lint * feat: better error handling ux + toas fixes * fix: table2 refactor + breadcrumb + linting * fix: prettier * fix: prettier * fix: types * fix: some cleanup + user can't edit their own role * fix: rename new table * fix: code cleanup + case handling of roles cleaned up * fix: unused import * Fix lint errors --------- Co-authored-by: Francis Li Co-authored-by: Francis Li --- src/backend/routers/user.ts | 180 +++++++++++++++- src/components/CustomToast.tsx | 52 +++-- .../design_system/breadcrumbs/Breadcrumbs.tsx | 6 +- .../design_system/dropdown/Dropdown.tsx | 11 +- src/components/navbar/NavBar.tsx | 2 + src/components/styles/Toast.module.css | 1 + src/components/table/PaginatedTable.tsx | 195 ++++++++++++++++++ src/components/table/renderers.tsx | 63 ++++++ src/components/table/types.ts | 42 ++++ src/pages/_app.tsx | 50 +++-- src/pages/admin/[user_id].tsx | 188 +++++++++++++++++ src/pages/admin/index.tsx | 116 ++++++++++- src/theme.ts | 31 +++ src/types/auth.ts | 16 ++ 14 files changed, 899 insertions(+), 54 deletions(-) create mode 100644 src/components/table/PaginatedTable.tsx create mode 100644 src/components/table/renderers.tsx create mode 100644 src/components/table/types.ts create mode 100644 src/pages/admin/[user_id].tsx diff --git a/src/backend/routers/user.ts b/src/backend/routers/user.ts index 0c0bfdb3..16910d21 100644 --- a/src/backend/routers/user.ts +++ b/src/backend/routers/user.ts @@ -1,4 +1,29 @@ -import { hasAuthenticated, router } from "../trpc"; +import { hasAuthenticated, hasAdmin, router } from "../trpc"; +import { z } from "zod"; +import { UserType, ROLE_OPTIONS } from "@/types/auth"; +import { TRPCError } from "@trpc/server"; + +export const sortOrderSchema = z.enum(["asc", "desc"]).default("asc"); +export const sortBySchema = z + .enum(["first_name", "last_name", "email", "role"]) + .default("first_name"); + +const paginationInput = z.object({ + page: z.number().min(1).default(1), + pageSize: z.number().min(1).default(10), + sortBy: sortBySchema, + sortOrder: sortOrderSchema, + search: z.string().optional(), +}); + +const createUserSchema = z.object({ + first_name: z.string(), + last_name: z.string(), + email: z.string().email(), + role: z.string(), +}); + +const roleValues = ROLE_OPTIONS.map((r) => r.value) as [string, ...string[]]; export const user = router({ getMe: hasAuthenticated.query(async (req) => { @@ -20,6 +45,64 @@ export const user = router({ return user; }), + getUsers: hasAdmin.input(paginationInput).query(async (req) => { + const { page, pageSize, sortBy, sortOrder, search } = req.input; + const offset = (page - 1) * pageSize; + + let baseQuery = req.ctx.db + .selectFrom("user") + .select([ + "user_id", + "first_name", + "last_name", + "email", + "image_url", + "role", + ]); + + if (search) { + baseQuery = baseQuery.where((eb) => + eb.or([ + eb("first_name", "ilike", `%${search}%`), + eb("last_name", "ilike", `%${search}%`), + eb("email", "ilike", `%${search}%`), + eb("role", "ilike", `%${search}%`), + ]) + ); + } + + // Separate count query + let countQuery = req.ctx.db + .selectFrom("user") + .select(req.ctx.db.fn.countAll().as("count")); + + // Apply search filter to count query if exists + if (search) { + countQuery = countQuery.where((eb) => + eb.or([ + eb("first_name", "ilike", `%${search}%`), + eb("last_name", "ilike", `%${search}%`), + eb("email", "ilike", `%${search}%`), + eb("role", "ilike", `%${search}%`), + ]) + ); + } + + const [users, totalCount] = await Promise.all([ + baseQuery + .orderBy(sortBy, sortOrder) + .limit(pageSize) + .offset(offset) + .execute(), + countQuery.executeTakeFirst(), + ]); + + return { + users, + totalCount: Number(totalCount?.count ?? 0), + totalPages: Math.ceil(Number(totalCount?.count ?? 0) / pageSize), + }; + }), /** * @returns Whether the current user is a case manager */ @@ -34,4 +117,99 @@ export const user = router({ return result.length > 0; }), + + createUser: hasAdmin.input(createUserSchema).mutation(async (req) => { + const { first_name, last_name, email, role } = req.input; + + // Check if user already exists + const existingUser = await req.ctx.db + .selectFrom("user") + .where("email", "=", email) + .selectAll() + .executeTakeFirst(); + + if (existingUser) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "User with this email already exists", + }); + } + + const user = await req.ctx.db + .insertInto("user") + .values({ + first_name, + last_name, + email, + role, + }) + .returningAll() + .executeTakeFirstOrThrow(); + + return user; + }), + + getUserById: hasAdmin + .input(z.object({ user_id: z.string() })) + .query(async (req) => { + const { user_id } = req.input; + + return await req.ctx.db + .selectFrom("user") + .selectAll() + .where("user_id", "=", user_id) + .executeTakeFirstOrThrow(); + }), + + editUser: hasAdmin + .input( + z.object({ + user_id: z.string(), + first_name: z.string(), + last_name: z.string(), + email: z.string().email(), + role: z.enum(roleValues).transform((role) => { + switch (role) { + case "admin": + return UserType.Admin; + case "case_manager": + return UserType.CaseManager; + case "para": + return UserType.Para; + default: + return UserType.User; + } + }), + }) + ) + .mutation(async (req) => { + const { user_id, first_name, last_name, email, role } = req.input; + + const { userId } = req.ctx.auth; + + const dbUser = await req.ctx.db + .selectFrom("user") + .where("user_id", "=", user_id) + .selectAll() + .executeTakeFirstOrThrow(); + + if (userId === user_id && dbUser.role !== (role as string)) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "You cannot change your own role", + }); + } + + return await req.ctx.db + .updateTable("user") + .set({ + first_name, + last_name, + email: email.toLowerCase(), + role, + }) + .where("user_id", "=", user_id) + .returningAll() + .executeTakeFirstOrThrow(); + }), }); diff --git a/src/components/CustomToast.tsx b/src/components/CustomToast.tsx index fea3e8e2..31afc256 100644 --- a/src/components/CustomToast.tsx +++ b/src/components/CustomToast.tsx @@ -1,43 +1,37 @@ -import React, { useState } from "react"; +import React from "react"; import styles from "./styles/Toast.module.css"; import Image from "next/image"; interface CustomToastProps { errorMessage: string; + onClose: () => void; } -const CustomToast = ({ errorMessage }: CustomToastProps) => { - const [showToast, setShowToast] = useState(true); - +const CustomToast = ({ errorMessage, onClose }: CustomToastProps) => { const handleCloseToast = () => { - setShowToast(false); + onClose(); }; return ( - <> - {showToast && ( -
-
- Error Img -
{errorMessage ?? null}
- - -
-
- )} - +
+
+ Error Img +
{errorMessage}
+ +
+
); }; diff --git a/src/components/design_system/breadcrumbs/Breadcrumbs.tsx b/src/components/design_system/breadcrumbs/Breadcrumbs.tsx index 7c2cb884..0a447ddc 100644 --- a/src/components/design_system/breadcrumbs/Breadcrumbs.tsx +++ b/src/components/design_system/breadcrumbs/Breadcrumbs.tsx @@ -22,8 +22,12 @@ const BreadcrumbsNav = () => { { user_id: paths[2] }, { enabled: Boolean(paths[2] && paths[1] === "staff") } ); + const { data: user } = trpc.user.getUserById.useQuery( + { user_id: paths[2] }, + { enabled: Boolean(paths[2] && paths[1] === "admin") } + ); - const personData: Student | Para | undefined = student || para; + const personData: Student | Para | undefined = student || para || user; // An array of breadcrumbs fixed to students/staff as the first index. This will be modified depending on how the address bar will be displayed. const breadcrumbs = paths.map((path, index) => { diff --git a/src/components/design_system/dropdown/Dropdown.tsx b/src/components/design_system/dropdown/Dropdown.tsx index c4625605..69940c96 100644 --- a/src/components/design_system/dropdown/Dropdown.tsx +++ b/src/components/design_system/dropdown/Dropdown.tsx @@ -24,7 +24,7 @@ interface DropdownProps { optionDisabled?: string[]; } -const Dropdown = ({ +export const Dropdown = ({ itemList, selectedOption, setSelectedOption, @@ -38,7 +38,6 @@ const Dropdown = ({ }; return ( - // Minimum styles used. More can be defined in className. {label} @@ -48,8 +47,13 @@ const Dropdown = ({ value={selectedOption} label={label} onChange={handleChange} - // Allow disabling of form disabled={formDisabled} + MenuProps={{ + PaperProps: { + elevation: 1, + sx: { maxHeight: 300 }, + }, + }} > {itemList?.map((item) => ( {item.label} diff --git a/src/components/navbar/NavBar.tsx b/src/components/navbar/NavBar.tsx index 4bc04c20..5bd641d0 100644 --- a/src/components/navbar/NavBar.tsx +++ b/src/components/navbar/NavBar.tsx @@ -3,6 +3,7 @@ import PeopleOutline from "@mui/icons-material/PeopleOutline"; import Logout from "@mui/icons-material/Logout"; import MenuIcon from "@mui/icons-material/Menu"; import SchoolOutlined from "@mui/icons-material/SchoolOutlined"; +import AdminPanelSettings from "@mui/icons-material/AdminPanelSettings"; import ContentPaste from "@mui/icons-material/ContentPaste"; import SettingsOutlined from "@mui/icons-material/SettingsOutlined"; import AppBar from "@mui/material/AppBar"; @@ -112,6 +113,7 @@ export default function NavBar() { icon={} text="Settings" /> + } text="Admin" /> } text="Logout" diff --git a/src/components/styles/Toast.module.css b/src/components/styles/Toast.module.css index 33aa4e5a..2c12d370 100644 --- a/src/components/styles/Toast.module.css +++ b/src/components/styles/Toast.module.css @@ -3,6 +3,7 @@ bottom: 0; right: 0; width: 400px; + z-index: 9999; } .customToast { diff --git a/src/components/table/PaginatedTable.tsx b/src/components/table/PaginatedTable.tsx new file mode 100644 index 00000000..67f195a7 --- /dev/null +++ b/src/components/table/PaginatedTable.tsx @@ -0,0 +1,195 @@ +import React, { useState } from "react"; +import { + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Box, + Button, + TableSortLabel, + TextField, +} from "@mui/material"; +import { styled } from "@mui/material/styles"; +import { visuallyHidden } from "@mui/utils"; +import SearchIcon from "@mui/icons-material/Search"; +import { TableProps, UserBase } from "./types"; +import { renderTableInput, renderTableCell } from "./renderers"; +import $table from "./Table.module.css"; +import $button from "@/components/design_system/button/Button.module.css"; + +const StyledTableRow = styled(TableRow)(() => ({ + "&:nth-of-type(odd)": { + backgroundColor: "var(--grey-90)", + }, + "&:hover": { + backgroundColor: "lightgray", + cursor: "pointer", + }, +})); + +export function PaginatedTable({ + data, + columns, + type, + onRowClick, + page = 1, + totalPages = 1, + onPageChange, + sortBy, + sortOrder, + onSort, + onSearch, + searchTerm = "", + onAdd, + showAddRow = false, +}: TableProps) { + const [localSearchTerm, setLocalSearchTerm] = useState(searchTerm); + const [newRowData, setNewRowData] = useState>({}); + const [isAddingRow, setIsAddingRow] = useState(false); + + const handleKeyDown = (event: React.KeyboardEvent) => { + if (event.key === "Enter") { + event.preventDefault(); + onSearch?.(localSearchTerm); + } + }; + + const handleRequestSort = (property: keyof T) => { + const isAsc = sortBy === property && sortOrder === "asc"; + onSort(property, isAsc ? "desc" : "asc"); + }; + + const handleAddRow = async (e: React.FormEvent) => { + e.preventDefault(); + if (onAdd) { + await onAdd(newRowData as Omit); + setIsAddingRow(false); + setNewRowData({}); + } + }; + + return ( + + + setLocalSearchTerm(e.target.value)} + onKeyDown={handleKeyDown} + InputProps={{ + startAdornment: , + }} + /> + {showAddRow && !isAddingRow && ( + + )} + + + + + + + {columns.map((column) => ( + + handleRequestSort(column.id)} + className={$table.headerLabel} + > + {column.label} + {sortBy === column.id && ( + + {sortOrder === "desc" + ? "sorted descending" + : "sorted ascending"} + + )} + + + ))} + + + + {isAddingRow && ( + + +
+ + {columns.map((column) => ( + + {renderTableInput( + column, + newRowData[column.id], + (value) => + setNewRowData((prev) => ({ + ...prev, + [column.id]: value, + })) + )} + + ))} + + + + + + +
+
+ )} + {data.map((row) => ( + onRowClick?.(row)} + > + {columns.map((column) => ( + + {renderTableCell(column, row[column.id])} + + ))} + + ))} +
+
+
+ + {onPageChange && ( + + + + Page {page} of {totalPages} + + + + )} +
+ ); +} diff --git a/src/components/table/renderers.tsx b/src/components/table/renderers.tsx new file mode 100644 index 00000000..bd468017 --- /dev/null +++ b/src/components/table/renderers.tsx @@ -0,0 +1,63 @@ +import { TextField } from "@mui/material"; +import { Dropdown } from "@/components/design_system/dropdown/Dropdown"; +import { ColumnDefinition, UserBase, SelectOption } from "./types"; + +export function renderTableInput( + column: ColumnDefinition, + value: T[keyof T] | undefined, + onChange: (value: T[keyof T]) => void +): React.ReactNode { + switch (column.type) { + case "text": + return ( + onChange(e.target.value as T[keyof T])} + /> + ); + case "number": + return ( + onChange(Number(e.target.value) as T[keyof T])} + /> + ); + case "select": + return ( + onChange(newValue as T[keyof T])} + label={column.label} + /> + ); + default: + return String(value || ""); + } +} + +export function renderTableCell( + column: ColumnDefinition, + value: T[keyof T] +): React.ReactNode { + if (column.customRender) { + return column.customRender(value); + } + + switch (column.type) { + case "select": + return ( + column.options?.find((opt) => opt.value === value)?.label || + String(value) + ); + case "date": + return value instanceof Date ? value.toLocaleDateString() : String(value); + default: + return String(value || ""); + } +} diff --git a/src/components/table/types.ts b/src/components/table/types.ts new file mode 100644 index 00000000..e37b588b --- /dev/null +++ b/src/components/table/types.ts @@ -0,0 +1,42 @@ +import { Roles } from "@/types/auth"; + +export type ColumnType = "text" | "number" | "select" | "date"; + +export interface UserBase { + id?: string | number; + first_name: string; + last_name: string; + email: string; + role: Roles; +} + +export interface SelectOption { + value: string; + label: string; +} + +export interface ColumnDefinition { + id: keyof T; + label: string; + type: ColumnType; + options?: SelectOption[]; + validation?: (value: T[keyof T]) => boolean; + customRender?: (value: T[keyof T]) => React.ReactNode; +} + +export interface TableProps { + data: T[]; + columns: ColumnDefinition[]; + type: string; + onRowClick?: (row: T) => void; + page?: number; + totalPages?: number; + onPageChange?: (page: number) => void; + sortBy: keyof T; + sortOrder: "asc" | "desc"; + onSort: (sortBy: keyof T, sortOrder: "asc" | "desc") => void; + onSearch?: (search: string) => void; + searchTerm?: string; + onAdd?: (data: Omit) => Promise; + showAddRow?: boolean; +} diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 57a411e9..92c912e6 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -3,10 +3,10 @@ import { SessionProvider } from "next-auth/react"; import type { AppProps } from "next/app"; import { trpc } from "@/client/lib/trpc"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { httpBatchLink, loggerLink } from "@trpc/client"; +import { httpBatchLink, loggerLink, TRPCClientError } from "@trpc/client"; import { useState } from "react"; import "../styles/globals.css"; -import { QueryCache } from "@tanstack/react-query"; +import { QueryCache, MutationCache } from "@tanstack/react-query"; import toast from "react-hot-toast"; import Head from "next/head"; import superjson from "superjson"; @@ -17,6 +17,7 @@ import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns"; import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles"; import { compassTheme as theme } from "@/theme"; import { FontProvider } from "@/components/font-provider"; +import { AppRouter } from "@/backend/routers/_app"; interface CustomPageProps { session: Session; @@ -42,20 +43,21 @@ export default function App({ () => new QueryClient({ queryCache: new QueryCache({ - onError: (error) => { - if (error instanceof Error) { - const errorMessages: { [key: string]: string } = { - BAD_REQUEST: "400: Bad request, please try again", - UNAUTHORIZED: "401: Unauthorized Error", - NOT_FOUND: "404: Page not found", - }; - - const defaultMessage = "An error occured. Please try again"; - const msg = errorMessages[error.message] || defaultMessage; - setErrorMessage(msg); - } + onError: (error: unknown) => { + handleTRPCError(error); + }, + }), + mutationCache: new MutationCache({ + onError: (error: unknown) => { + handleTRPCError(error); }, }), + defaultOptions: { + queries: { + retry: false, + refetchOnWindowFocus: false, + }, + }, }) ); @@ -77,6 +79,21 @@ export default function App({ }) ); + const handleTRPCError = (error: unknown) => { + const trpcError = error as TRPCClientError; + const errorCode = trpcError.data?.code as keyof typeof errorMessages; + const errorMessage = trpcError.message; + + const errorMessages = { + BAD_REQUEST: errorMessage || "400: Bad request, please try again", + UNAUTHORIZED: "401: Unauthorized Error", + NOT_FOUND: "404: Page not found", + FORBIDDEN: "403: Access denied", + } as const; + + setErrorMessage(errorMessages[errorCode] ?? "An unexpected error occurred"); + }; + return ( <> @@ -92,7 +109,10 @@ export default function App({ {errorMessage && ( - + setErrorMessage("")} + /> )} diff --git a/src/pages/admin/[user_id].tsx b/src/pages/admin/[user_id].tsx new file mode 100644 index 00000000..d71fd1e8 --- /dev/null +++ b/src/pages/admin/[user_id].tsx @@ -0,0 +1,188 @@ +import { trpc } from "@/client/lib/trpc"; +import { Box, Button, Container, Modal, Stack, TextField } from "@mui/material"; +import Typography from "@mui/material/Typography"; +import { useRouter } from "next/router"; +import { useState, useEffect } from "react"; +import { UserType, ROLE_OPTIONS } from "@/types/auth"; +import $CompassModal from "@/components/design_system/modal/CompassModal.module.css"; +import $button from "@/components/design_system/button/Button.module.css"; +import { getRoleLabel } from "@/types/auth"; +import { Dropdown } from "@/components/design_system/dropdown/Dropdown"; + +interface UserFormData { + first_name: string; + last_name: string; + email: string; + role: UserType; +} + +const ViewUserPage = () => { + const [open, setOpen] = useState(false); + const handleOpen = () => setOpen(true); + const handleClose = () => setOpen(false); + + const utils = trpc.useContext(); + const router = useRouter(); + const { user_id } = router.query; + + const { data: user, isLoading } = trpc.user.getUserById.useQuery( + { user_id: user_id as string }, + { + enabled: Boolean(user_id), + retry: false, + onError: () => returnToUserList(), + } + ); + + const returnToUserList = async () => { + await router.push(`/admin`); + }; + + const editMutation = trpc.user.editUser.useMutation({ + onSuccess: () => utils.user.getUserById.invalidate(), + }); + + const [selectedRole, setSelectedRole] = useState(""); + + useEffect(() => { + if (user?.role) { + setSelectedRole(user.role); + } + }, [user?.role]); + + const handleEditUser = (e: React.FormEvent) => { + e.preventDefault(); + const formData = new FormData(e.currentTarget); + + if (!user) return; + + const userData: UserFormData = { + first_name: formData.get("firstName") as string, + last_name: formData.get("lastName") as string, + email: formData.get("email") as string, + role: selectedRole as UserType, + }; + + editMutation.mutate({ + user_id: user.user_id, + ...userData, + }); + + handleClose(); + }; + + if (isLoading) return
Loading...
; + if (!user) return null; + + return ( + + + +

+ {user.first_name} {user.last_name} +

+ +
+ + +
+ Email: {user.email} +
+
+ Role: {getRoleLabel(user.role)} +
+
+ + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + +
+
+
+
+
+
+ ); +}; + +export default ViewUserPage; diff --git a/src/pages/admin/index.tsx b/src/pages/admin/index.tsx index 31129bd1..195f49ff 100644 --- a/src/pages/admin/index.tsx +++ b/src/pages/admin/index.tsx @@ -1,11 +1,119 @@ import { requiresAdminAuth } from "@/client/lib/protected-page"; -import Link from "next/link"; +import { trpc } from "@/client/lib/trpc"; +import { PaginatedTable } from "@/components/table/PaginatedTable"; +import { ColumnDefinition, UserBase } from "@/components/table/types"; +import { useRouter } from "next/router"; +import { useState } from "react"; +import { ROLE_OPTIONS, Roles } from "@/types/auth"; +import { getRoleLabel } from "@/types/auth"; +import { sortBySchema, sortOrderSchema } from "@/backend/routers/user"; +import { z } from "zod"; + +interface User extends UserBase { + user_id: string; + first_name: string; + last_name: string; + email: string; + role: Roles; +} + +type SortBy = z.infer; +type SortOrder = z.infer; + +const AdminHome: React.FC = () => { + const utils = trpc.useContext(); + const router = useRouter(); + const [page, setPage] = useState(1); + const [sortBy, setSortBy] = + useState>("first_name"); + const [sortOrder, setSortOrder] = useState("asc"); + const [searchTerm, setSearchTerm] = useState(""); + const pageSize = 10; + + const { data, isLoading } = trpc.user.getUsers.useQuery({ + page, + pageSize, + sortBy: sortBy as SortBy, + sortOrder, + search: searchTerm, + }); + + const createUserMutation = trpc.user.createUser.useMutation({ + onSuccess: async () => { + await utils.user.getUsers.invalidate(); + }, + }); + + const handleAddUser = async (userData: Omit) => { + try { + await createUserMutation.mutateAsync({ + ...userData, + role: userData.role || "para", + }); + } catch (error) { + console.error(error); + } + }; + + const handleSort = (newSortBy: keyof User, newSortOrder: SortOrder) => { + setSortBy(newSortBy); + setSortOrder(newSortOrder); + }; + + const handleSearch = (search: string) => { + setSearchTerm(search); + setPage(1); + }; + + const handleRowClick = async (user: User) => { + await router.push(`/admin/${user.user_id}`); + }; + + const columns: ColumnDefinition[] = [ + { + id: "first_name", + label: "First Name", + type: "text", + }, + { + id: "last_name", + label: "Last Name", + type: "text", + }, + { + id: "email", + label: "Email", + type: "text", + }, + { + id: "role", + label: "Role", + type: "select", + options: [...ROLE_OPTIONS], + customRender: (value) => (value ? getRoleLabel(value as string) : ""), + }, + ]; + + if (isLoading) return
Loading...
; -const AdminHome = () => { return (
-

Admin Utilities

- Postgres info + + data={(data?.users as User[]) ?? []} + columns={columns} + type="Users" + onRowClick={handleRowClick} + page={page} + totalPages={data?.totalPages ?? 1} + onPageChange={setPage} + sortBy={sortBy as SortBy} + sortOrder={sortOrder} + onSort={handleSort} + onSearch={handleSearch} + searchTerm={searchTerm} + onAdd={handleAddUser} + showAddRow={true} + />
); }; diff --git a/src/theme.ts b/src/theme.ts index 5bbc2bfa..2be8399e 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -202,5 +202,36 @@ export const compassTheme = createTheme({ }), }, }, + MuiSelect: { + styleOverrides: { + root: { + "& .MuiOutlinedInput-notchedOutline": { + borderColor: "var(--primary)", + borderWidth: "1px", + }, + "&.Mui-focused": { + "& .MuiOutlinedInput-notchedOutline": { + borderColor: "var(--primary)", + borderWidth: "2px", + }, + }, + "&:hover:not(.Mui-focused)": { + "& .MuiOutlinedInput-notchedOutline": { + borderColor: "var(--grey-10)", + }, + }, + }, + }, + }, + MuiInputLabel: { + styleOverrides: { + root: { + color: "var(--grey-10)", + "&.Mui-focused": { + color: "var(--primary)", + }, + }, + }, + }, }, }); diff --git a/src/types/auth.ts b/src/types/auth.ts index 8d805845..05e9bc6c 100644 --- a/src/types/auth.ts +++ b/src/types/auth.ts @@ -25,3 +25,19 @@ export enum UserType { CaseManager = "case_manager", Admin = "admin", } + +export const ROLE_OPTIONS = [ + { label: "User", value: UserType.User }, + { label: "Para", value: UserType.Para }, + { label: "Case Manager", value: UserType.CaseManager }, + { label: "Admin", value: UserType.Admin }, +] as const; + +export type Roles = (typeof ROLE_OPTIONS)[number]["value"]; + +export function getRoleLabel(role: string): string { + const option = ROLE_OPTIONS.find( + (opt) => opt.value.toLowerCase() === role.toLowerCase() + ); + return option?.label || role; +} From f25a33302eaaff98083bf5710174b5b1c99dc923 Mon Sep 17 00:00:00 2001 From: NV <2823112+nickvisut@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:52:28 -0800 Subject: [PATCH 3/3] [#424] Feature/add sort date to assigned (#462) * add created_at timestamp to task table Co-authored-by: Vincent Shuali * add created_at timestamp to task table Co-authored-by: Vincent Shuali * add sort by date button * add missing field to task data type * update schema * rerun db reset after package update * clean up comments --------- Co-authored-by: Vincent Shuali Co-authored-by: Francis Li --- .../migrations/4_add-created-at-on-tasks.sql | 7 +++++ src/backend/db/zapatos/schema.d.ts | 30 +++++++++++++++++++ src/backend/routers/para.ts | 1 + src/pages/benchmarks/index.tsx | 16 ++++------ src/types/global.ts | 3 +- 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 src/backend/db/migrations/4_add-created-at-on-tasks.sql diff --git a/src/backend/db/migrations/4_add-created-at-on-tasks.sql b/src/backend/db/migrations/4_add-created-at-on-tasks.sql new file mode 100644 index 00000000..56f93d86 --- /dev/null +++ b/src/backend/db/migrations/4_add-created-at-on-tasks.sql @@ -0,0 +1,7 @@ +-- Each task should have a created_at date so that we can sort by assigned date +-- NOTE: This relies on the assigned date never changing; if the app allows changes, we will likely want create a dedicated assigned_on date in addition to (or instead of) this column +ALTER TABLE task +ADD COLUMN created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(); + +-- Add index to allow easy queries of tasks by date +CREATE INDEX idx_created_at ON task(created_at); diff --git a/src/backend/db/zapatos/schema.d.ts b/src/backend/db/zapatos/schema.d.ts index 0d734ec7..b49ab1f6 100644 --- a/src/backend/db/zapatos/schema.d.ts +++ b/src/backend/db/zapatos/schema.d.ts @@ -2019,6 +2019,12 @@ declare module 'zapatos/schema' { */ benchmark_id: string | null; /** + * **task.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at: Date; + /** * **task.due_date** * - `timestamptz` in database * - Nullable, no default @@ -2057,6 +2063,12 @@ declare module 'zapatos/schema' { */ benchmark_id: string | null; /** + * **task.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at: db.TimestampTzString; + /** * **task.due_date** * - `timestamptz` in database * - Nullable, no default @@ -2095,6 +2107,12 @@ declare module 'zapatos/schema' { */ benchmark_id?: string | db.Parameter | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; /** + * **task.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.SQLFragment | db.ParentColumn | db.SQLFragment | db.SQLFragment | db.ParentColumn>; + /** * **task.due_date** * - `timestamptz` in database * - Nullable, no default @@ -2133,6 +2151,12 @@ declare module 'zapatos/schema' { */ benchmark_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment; /** + * **task.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment; + /** * **task.due_date** * - `timestamptz` in database * - Nullable, no default @@ -2171,6 +2195,12 @@ declare module 'zapatos/schema' { */ benchmark_id?: string | db.Parameter | null | db.DefaultType | db.SQLFragment | db.SQLFragment | null | db.DefaultType | db.SQLFragment>; /** + * **task.created_at** + * - `timestamptz` in database + * - `NOT NULL`, default: `now()` + */ + created_at?: (db.TimestampTzString | Date) | db.Parameter<(db.TimestampTzString | Date)> | db.DefaultType | db.SQLFragment | db.SQLFragment | db.DefaultType | db.SQLFragment>; + /** * **task.due_date** * - `timestamptz` in database * - Nullable, no default diff --git a/src/backend/routers/para.ts b/src/backend/routers/para.ts index 4f331d96..78661095 100644 --- a/src/backend/routers/para.ts +++ b/src/backend/routers/para.ts @@ -83,6 +83,7 @@ export const para = router({ "task.due_date", "task.seen", "task.trial_count", + "task.created_at", eb .selectFrom("trial_data") diff --git a/src/pages/benchmarks/index.tsx b/src/pages/benchmarks/index.tsx index 79842d30..2bd3750d 100644 --- a/src/pages/benchmarks/index.tsx +++ b/src/pages/benchmarks/index.tsx @@ -122,13 +122,9 @@ function Benchmarks() { Filter - { - // TODO: replace simple sort pill w/this sort pill placeholder - /* - TODO: replace simple sort pill w/this sort pill placeholder - - Sort Pill Placeholder - ` if dropdown needed) */} + {/* simple sort pill POC (see TODO above) */}