From 4ed835873832e528dea0274d60c13ba6b39fee6f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 11 Oct 2026 19:30:38 +1100 Subject: [PATCH] feat: create model --- bun.lock | 1 + docker-compose.yml | 2 +- .../20261011T0821_init_schema/migration.json | 7 + .../20261011T0821_init_schema/migration.ts | 268 +++ .../app/20261011T0821_init_schema/ops.json | 862 +++++++++ .../contract.d.ts | 1609 +++++++++++++++++ .../contract.json | 1 + packages/database/src/index.ts | 2 + packages/database/src/prisma/contract.d.ts | 1220 +++++++++++-- packages/database/src/prisma/contract.json | 1208 +++++++++++-- packages/database/src/prisma/contract.prisma | 113 +- packages/database/src/prisma/db.ts | 10 +- server/package.json | 1 + server/src/index.ts | 2 + 14 files changed, 5033 insertions(+), 273 deletions(-) create mode 100644 packages/database/migrations/app/20261011T0821_init_schema/migration.json create mode 100755 packages/database/migrations/app/20261011T0821_init_schema/migration.ts create mode 100644 packages/database/migrations/app/20261011T0821_init_schema/ops.json create mode 100644 packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.d.ts create mode 100644 packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.json diff --git a/bun.lock b/bun.lock index 83ef79e..15d8208 100644 --- a/bun.lock +++ b/bun.lock @@ -123,6 +123,7 @@ "version": "0.0.0", "dependencies": { "@odyssey/constants": "workspace:*", + "@odyssey/database": "workspace:*", "@odyssey/game": "workspace:*", "@odyssey/models": "workspace:*", "@odyssey/utils": "workspace:*", diff --git a/docker-compose.yml b/docker-compose.yml index edcffa7..97a1900 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,7 @@ services: networks: - internal ports: - - 5173:5173 + - 5432:5432 volumes: - ./postgres-data:/var/lib/postgresql environment: diff --git a/packages/database/migrations/app/20261011T0821_init_schema/migration.json b/packages/database/migrations/app/20261011T0821_init_schema/migration.json new file mode 100644 index 0000000..b4feb7a --- /dev/null +++ b/packages/database/migrations/app/20261011T0821_init_schema/migration.json @@ -0,0 +1,7 @@ +{ + "from": null, + "to": "6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04", + "providedInvariants": [], + "createdAt": "2026-10-11T08:21:15.726Z", + "migrationHash": "99b3a1febb9f739bf258c99ebe1dbfe692b86792e8eb511fc7eef8e985e8e8cd" +} \ No newline at end of file diff --git a/packages/database/migrations/app/20261011T0821_init_schema/migration.ts b/packages/database/migrations/app/20261011T0821_init_schema/migration.ts new file mode 100755 index 0000000..a39cb73 --- /dev/null +++ b/packages/database/migrations/app/20261011T0821_init_schema/migration.ts @@ -0,0 +1,268 @@ +#!/usr/bin/env -S node +import type { Contract as End } from '../../snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract'; +import endContract from '../../snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.json' with { type: 'json' }; +import { + Migration, + MigrationCLI, + checkExpression, + col, + primaryKey, +} from '@prisma/orm-postgres/migration'; + +export default class M extends Migration { + override readonly endContractJson = endContract; + + override get operations() { + return [ + this.createSchema({ schema: 'public' }), + this.createTable({ + schema: 'public', + table: 'Command', + columns: [ + col('command', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('error', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('id', 'BIGSERIAL', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + col('output', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('pwd', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('sessionId', 'int8', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + col('stage', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('timestamp', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + ], + constraints: [primaryKey(['id'])], + }), + this.createTable({ + schema: 'public', + table: 'LoginAttempt', + columns: [ + col('id', 'BIGSERIAL', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + col('ip', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('loginMethod', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('message', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('success', 'bool', { notNull: true, codecRef: { codecId: 'pg/bool@1' } }), + col('time', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('userAgent', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('userId', 'int8', { codecRef: { codecId: 'pg/int8@1' } }), + col('username', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + ], + constraints: [ + primaryKey(['id']), + checkExpression( + 'LoginAttempt_loginMethod_check_f8485f11', + `"loginMethod" IN ('password', 'google', 'github')`, + ), + ], + }), + this.createTable({ + schema: 'public', + table: 'Session', + columns: [ + col('completedEvents', 'text[]', { + notNull: true, + codecRef: { codecId: 'pg/text@1', many: true }, + }), + col('containerId', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('containerName', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('createdAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('finishedAt', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-temporal@1' } }), + col('graph', 'jsonb', { notNull: true, codecRef: { codecId: 'pg/jsonb@1' } }), + col('id', 'BIGSERIAL', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + col('lastActivityAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('locale', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('quest', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('status', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('userId', 'int8', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + ], + constraints: [ + primaryKey(['id']), + checkExpression( + 'Session_completedEvents_elem_not_null_b55d23f4', + 'array_position("completedEvents", NULL) IS NULL', + ), + checkExpression( + 'Session_status_check_8fa5bbc6', + `"status" IN ('active', 'finished', 'inactive')`, + ), + ], + }), + this.createTable({ + schema: 'public', + table: 'User', + columns: [ + col('createdAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('email', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('id', 'BIGSERIAL', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + col('isGuest', 'bool', { notNull: true, codecRef: { codecId: 'pg/bool@1' } }), + col('name', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('updatedAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('username', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + ], + constraints: [primaryKey(['id'])], + }), + this.createTable({ + schema: 'public', + table: 'UserLoginMethod', + columns: [ + col('createdAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('displayName', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('hashedPassword', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('oauthId', 'text', { codecRef: { codecId: 'pg/text@1' } }), + col('type', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('updatedAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('userId', 'int8', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + ], + constraints: [ + primaryKey(['userId', 'type']), + checkExpression( + 'UserLoginMethod_type_check_6814314f', + `"type" IN ('password', 'google', 'github')`, + ), + ], + }), + this.createTable({ + schema: 'public', + table: 'UserProgress', + columns: [ + col('finishedAt', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-temporal@1' } }), + col('quest', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }), + col('startedAt', 'timestamptz', { + notNull: true, + codecRef: { codecId: 'pg/timestamptz-temporal@1' }, + }), + col('userId', 'int8', { notNull: true, codecRef: { codecId: 'pg/int8@1' } }), + ], + constraints: [primaryKey(['userId', 'quest'])], + }), + this.addUnique({ + schema: 'public', + table: 'User', + constraint: 'User_email_key', + columns: ['email'], + }), + this.addUnique({ + schema: 'public', + table: 'User', + constraint: 'User_username_key', + columns: ['username'], + }), + this.addUnique({ + schema: 'public', + table: 'UserLoginMethod', + constraint: 'UserLoginMethod_type_oauthId_key', + columns: ['type', 'oauthId'], + }), + this.createIndex({ + schema: 'public', + table: 'Command', + index: 'Command_sessionId_idx_29f415d4', + columns: ['sessionId'], + }), + this.createIndex({ + schema: 'public', + table: 'LoginAttempt', + index: 'LoginAttempt_userId_idx_a489d58a', + columns: ['userId'], + }), + this.createIndex({ + schema: 'public', + table: 'Session', + index: 'Session_userId_idx_a489d58a', + columns: ['userId'], + }), + this.createIndex({ + schema: 'public', + table: 'Session', + index: 'Session_userId_quest_idx_b13626bf', + columns: ['userId', 'quest'], + }), + this.createIndex({ + schema: 'public', + table: 'Session', + index: 'Session_userId_status_idx_e4a128ba', + columns: ['userId', 'status'], + }), + this.createIndex({ + schema: 'public', + table: 'UserLoginMethod', + index: 'UserLoginMethod_userId_idx_a489d58a', + columns: ['userId'], + }), + this.createIndex({ + schema: 'public', + table: 'UserProgress', + index: 'UserProgress_userId_idx_a489d58a', + columns: ['userId'], + }), + this.addForeignKey({ + schema: 'public', + table: 'Command', + foreignKey: { + name: 'Command_sessionId_fkey', + columns: ['sessionId'], + references: { schema: 'public', table: 'Session', columns: ['id'] }, + }, + }), + this.addForeignKey({ + schema: 'public', + table: 'LoginAttempt', + foreignKey: { + name: 'LoginAttempt_userId_fkey', + columns: ['userId'], + references: { schema: 'public', table: 'User', columns: ['id'] }, + }, + }), + this.addForeignKey({ + schema: 'public', + table: 'Session', + foreignKey: { + name: 'Session_userId_fkey', + columns: ['userId'], + references: { schema: 'public', table: 'User', columns: ['id'] }, + }, + }), + this.addForeignKey({ + schema: 'public', + table: 'UserLoginMethod', + foreignKey: { + name: 'UserLoginMethod_userId_fkey', + columns: ['userId'], + references: { schema: 'public', table: 'User', columns: ['id'] }, + }, + }), + this.addForeignKey({ + schema: 'public', + table: 'UserProgress', + foreignKey: { + name: 'UserProgress_userId_fkey', + columns: ['userId'], + references: { schema: 'public', table: 'User', columns: ['id'] }, + }, + }), + ]; + } +} + +MigrationCLI.run(import.meta.url, M); diff --git a/packages/database/migrations/app/20261011T0821_init_schema/ops.json b/packages/database/migrations/app/20261011T0821_init_schema/ops.json new file mode 100644 index 0000000..7981efb --- /dev/null +++ b/packages/database/migrations/app/20261011T0821_init_schema/ops.json @@ -0,0 +1,862 @@ +[ + { + "id": "schema.public", + "label": "Create schema \"public\"", + "operationClass": "additive", + "target": { + "id": "postgres" + }, + "precheck": [], + "execute": [ + { + "description": "Create schema \"public\"", + "sql": "CREATE SCHEMA IF NOT EXISTS \"public\"", + "params": [] + } + ], + "postcheck": [] + }, + { + "id": "table.Command", + "label": "Create table \"Command\"", + "summary": "Creates table \"Command\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "table", + "name": "Command" + } + }, + "precheck": [ + { + "description": "ensure table \"Command\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"Command\"" + ] + } + ], + "execute": [ + { + "description": "create table \"Command\"", + "sql": "CREATE TABLE \"public\".\"Command\" (\n \"command\" text NOT NULL,\n \"error\" text,\n \"id\" BIGSERIAL NOT NULL,\n \"output\" text,\n \"pwd\" text NOT NULL,\n \"sessionId\" int8 NOT NULL,\n \"stage\" text,\n \"timestamp\" timestamptz NOT NULL,\n PRIMARY KEY (\"id\")\n)", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify table \"Command\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"Command\"" + ] + } + ] + }, + { + "id": "table.LoginAttempt", + "label": "Create table \"LoginAttempt\"", + "summary": "Creates table \"LoginAttempt\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "table", + "name": "LoginAttempt" + } + }, + "precheck": [ + { + "description": "ensure table \"LoginAttempt\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"LoginAttempt\"" + ] + } + ], + "execute": [ + { + "description": "create table \"LoginAttempt\"", + "sql": "CREATE TABLE \"public\".\"LoginAttempt\" (\n \"id\" BIGSERIAL NOT NULL,\n \"ip\" text NOT NULL,\n \"loginMethod\" text NOT NULL,\n \"message\" text,\n \"success\" bool NOT NULL,\n \"time\" timestamptz NOT NULL,\n \"userAgent\" text NOT NULL,\n \"userId\" int8,\n \"username\" text NOT NULL,\n PRIMARY KEY (\"id\"),\n CONSTRAINT \"LoginAttempt_loginMethod_check_f8485f11\" CHECK (\"loginMethod\" IN ('password', 'google', 'github'))\n)", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify table \"LoginAttempt\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"LoginAttempt\"" + ] + } + ] + }, + { + "id": "table.Session", + "label": "Create table \"Session\"", + "summary": "Creates table \"Session\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "table", + "name": "Session" + } + }, + "precheck": [ + { + "description": "ensure table \"Session\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"Session\"" + ] + } + ], + "execute": [ + { + "description": "create table \"Session\"", + "sql": "CREATE TABLE \"public\".\"Session\" (\n \"completedEvents\" text[] NOT NULL,\n \"containerId\" text,\n \"containerName\" text,\n \"createdAt\" timestamptz NOT NULL,\n \"finishedAt\" timestamptz,\n \"graph\" jsonb NOT NULL,\n \"id\" BIGSERIAL NOT NULL,\n \"lastActivityAt\" timestamptz NOT NULL,\n \"locale\" text NOT NULL,\n \"quest\" text NOT NULL,\n \"status\" text NOT NULL,\n \"userId\" int8 NOT NULL,\n PRIMARY KEY (\"id\"),\n CONSTRAINT \"Session_completedEvents_elem_not_null_b55d23f4\" CHECK (array_position(\"completedEvents\", NULL) IS NULL),\n CONSTRAINT \"Session_status_check_8fa5bbc6\" CHECK (\"status\" IN ('active', 'finished', 'inactive'))\n)", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify table \"Session\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"Session\"" + ] + } + ] + }, + { + "id": "table.User", + "label": "Create table \"User\"", + "summary": "Creates table \"User\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "table", + "name": "User" + } + }, + "precheck": [ + { + "description": "ensure table \"User\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"User\"" + ] + } + ], + "execute": [ + { + "description": "create table \"User\"", + "sql": "CREATE TABLE \"public\".\"User\" (\n \"createdAt\" timestamptz NOT NULL,\n \"email\" text NOT NULL,\n \"id\" BIGSERIAL NOT NULL,\n \"isGuest\" bool NOT NULL,\n \"name\" text,\n \"updatedAt\" timestamptz NOT NULL,\n \"username\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify table \"User\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"User\"" + ] + } + ] + }, + { + "id": "table.UserLoginMethod", + "label": "Create table \"UserLoginMethod\"", + "summary": "Creates table \"UserLoginMethod\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "table", + "name": "UserLoginMethod" + } + }, + "precheck": [ + { + "description": "ensure table \"UserLoginMethod\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"UserLoginMethod\"" + ] + } + ], + "execute": [ + { + "description": "create table \"UserLoginMethod\"", + "sql": "CREATE TABLE \"public\".\"UserLoginMethod\" (\n \"createdAt\" timestamptz NOT NULL,\n \"displayName\" text,\n \"hashedPassword\" text,\n \"oauthId\" text,\n \"type\" text NOT NULL,\n \"updatedAt\" timestamptz NOT NULL,\n \"userId\" int8 NOT NULL,\n PRIMARY KEY (\"userId\", \"type\"),\n CONSTRAINT \"UserLoginMethod_type_check_6814314f\" CHECK (\"type\" IN ('password', 'google', 'github'))\n)", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify table \"UserLoginMethod\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"UserLoginMethod\"" + ] + } + ] + }, + { + "id": "table.UserProgress", + "label": "Create table \"UserProgress\"", + "summary": "Creates table \"UserProgress\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "table", + "name": "UserProgress" + } + }, + "precheck": [ + { + "description": "ensure table \"UserProgress\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"UserProgress\"" + ] + } + ], + "execute": [ + { + "description": "create table \"UserProgress\"", + "sql": "CREATE TABLE \"public\".\"UserProgress\" (\n \"finishedAt\" timestamptz,\n \"quest\" text NOT NULL,\n \"startedAt\" timestamptz NOT NULL,\n \"userId\" int8 NOT NULL,\n PRIMARY KEY (\"userId\", \"quest\")\n)", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify table \"UserProgress\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"UserProgress\"" + ] + } + ] + }, + { + "id": "unique.User.User_email_key", + "label": "Add unique constraint on \"User\" (email)", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "unique", + "name": "User_email_key", + "table": "User" + } + }, + "precheck": [ + { + "description": "ensure constraint \"User_email_key\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "User_email_key", + "public", + "\"public\".\"User\"" + ] + } + ], + "execute": [ + { + "description": "add unique constraint \"User_email_key\"", + "sql": "ALTER TABLE \"public\".\"User\" ADD CONSTRAINT \"User_email_key\" UNIQUE (\"email\")" + } + ], + "postcheck": [ + { + "description": "verify constraint \"User_email_key\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "User_email_key", + "public", + "\"public\".\"User\"" + ] + } + ] + }, + { + "id": "unique.User.User_username_key", + "label": "Add unique constraint on \"User\" (username)", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "unique", + "name": "User_username_key", + "table": "User" + } + }, + "precheck": [ + { + "description": "ensure constraint \"User_username_key\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "User_username_key", + "public", + "\"public\".\"User\"" + ] + } + ], + "execute": [ + { + "description": "add unique constraint \"User_username_key\"", + "sql": "ALTER TABLE \"public\".\"User\" ADD CONSTRAINT \"User_username_key\" UNIQUE (\"username\")" + } + ], + "postcheck": [ + { + "description": "verify constraint \"User_username_key\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "User_username_key", + "public", + "\"public\".\"User\"" + ] + } + ] + }, + { + "id": "unique.UserLoginMethod.UserLoginMethod_type_oauthId_key", + "label": "Add unique constraint on \"UserLoginMethod\" (type, oauthId)", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "unique", + "name": "UserLoginMethod_type_oauthId_key", + "table": "UserLoginMethod" + } + }, + "precheck": [ + { + "description": "ensure constraint \"UserLoginMethod_type_oauthId_key\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "UserLoginMethod_type_oauthId_key", + "public", + "\"public\".\"UserLoginMethod\"" + ] + } + ], + "execute": [ + { + "description": "add unique constraint \"UserLoginMethod_type_oauthId_key\"", + "sql": "ALTER TABLE \"public\".\"UserLoginMethod\" ADD CONSTRAINT \"UserLoginMethod_type_oauthId_key\" UNIQUE (\"type\", \"oauthId\")" + } + ], + "postcheck": [ + { + "description": "verify constraint \"UserLoginMethod_type_oauthId_key\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "UserLoginMethod_type_oauthId_key", + "public", + "\"public\".\"UserLoginMethod\"" + ] + } + ] + }, + { + "id": "index.Command.Command_sessionId_idx_29f415d4", + "label": "Create index \"Command_sessionId_idx_29f415d4\" on \"Command\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "Command_sessionId_idx_29f415d4", + "table": "Command" + } + }, + "precheck": [ + { + "description": "ensure index \"Command_sessionId_idx_29f415d4\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"Command_sessionId_idx_29f415d4\"" + ] + } + ], + "execute": [ + { + "description": "create index \"Command_sessionId_idx_29f415d4\"", + "sql": "CREATE INDEX \"Command_sessionId_idx_29f415d4\" ON \"public\".\"Command\" (\"sessionId\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"Command_sessionId_idx_29f415d4\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"Command_sessionId_idx_29f415d4\"" + ] + } + ] + }, + { + "id": "index.LoginAttempt.LoginAttempt_userId_idx_a489d58a", + "label": "Create index \"LoginAttempt_userId_idx_a489d58a\" on \"LoginAttempt\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "LoginAttempt_userId_idx_a489d58a", + "table": "LoginAttempt" + } + }, + "precheck": [ + { + "description": "ensure index \"LoginAttempt_userId_idx_a489d58a\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"LoginAttempt_userId_idx_a489d58a\"" + ] + } + ], + "execute": [ + { + "description": "create index \"LoginAttempt_userId_idx_a489d58a\"", + "sql": "CREATE INDEX \"LoginAttempt_userId_idx_a489d58a\" ON \"public\".\"LoginAttempt\" (\"userId\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"LoginAttempt_userId_idx_a489d58a\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"LoginAttempt_userId_idx_a489d58a\"" + ] + } + ] + }, + { + "id": "index.Session.Session_userId_idx_a489d58a", + "label": "Create index \"Session_userId_idx_a489d58a\" on \"Session\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "Session_userId_idx_a489d58a", + "table": "Session" + } + }, + "precheck": [ + { + "description": "ensure index \"Session_userId_idx_a489d58a\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"Session_userId_idx_a489d58a\"" + ] + } + ], + "execute": [ + { + "description": "create index \"Session_userId_idx_a489d58a\"", + "sql": "CREATE INDEX \"Session_userId_idx_a489d58a\" ON \"public\".\"Session\" (\"userId\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"Session_userId_idx_a489d58a\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"Session_userId_idx_a489d58a\"" + ] + } + ] + }, + { + "id": "index.Session.Session_userId_quest_idx_b13626bf", + "label": "Create index \"Session_userId_quest_idx_b13626bf\" on \"Session\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "Session_userId_quest_idx_b13626bf", + "table": "Session" + } + }, + "precheck": [ + { + "description": "ensure index \"Session_userId_quest_idx_b13626bf\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"Session_userId_quest_idx_b13626bf\"" + ] + } + ], + "execute": [ + { + "description": "create index \"Session_userId_quest_idx_b13626bf\"", + "sql": "CREATE INDEX \"Session_userId_quest_idx_b13626bf\" ON \"public\".\"Session\" (\"userId\", \"quest\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"Session_userId_quest_idx_b13626bf\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"Session_userId_quest_idx_b13626bf\"" + ] + } + ] + }, + { + "id": "index.Session.Session_userId_status_idx_e4a128ba", + "label": "Create index \"Session_userId_status_idx_e4a128ba\" on \"Session\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "Session_userId_status_idx_e4a128ba", + "table": "Session" + } + }, + "precheck": [ + { + "description": "ensure index \"Session_userId_status_idx_e4a128ba\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"Session_userId_status_idx_e4a128ba\"" + ] + } + ], + "execute": [ + { + "description": "create index \"Session_userId_status_idx_e4a128ba\"", + "sql": "CREATE INDEX \"Session_userId_status_idx_e4a128ba\" ON \"public\".\"Session\" (\"userId\", \"status\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"Session_userId_status_idx_e4a128ba\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"Session_userId_status_idx_e4a128ba\"" + ] + } + ] + }, + { + "id": "index.UserLoginMethod.UserLoginMethod_userId_idx_a489d58a", + "label": "Create index \"UserLoginMethod_userId_idx_a489d58a\" on \"UserLoginMethod\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "UserLoginMethod_userId_idx_a489d58a", + "table": "UserLoginMethod" + } + }, + "precheck": [ + { + "description": "ensure index \"UserLoginMethod_userId_idx_a489d58a\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"UserLoginMethod_userId_idx_a489d58a\"" + ] + } + ], + "execute": [ + { + "description": "create index \"UserLoginMethod_userId_idx_a489d58a\"", + "sql": "CREATE INDEX \"UserLoginMethod_userId_idx_a489d58a\" ON \"public\".\"UserLoginMethod\" (\"userId\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"UserLoginMethod_userId_idx_a489d58a\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"UserLoginMethod_userId_idx_a489d58a\"" + ] + } + ] + }, + { + "id": "index.UserProgress.UserProgress_userId_idx_a489d58a", + "label": "Create index \"UserProgress_userId_idx_a489d58a\" on \"UserProgress\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "index", + "name": "UserProgress_userId_idx_a489d58a", + "table": "UserProgress" + } + }, + "precheck": [ + { + "description": "ensure index \"UserProgress_userId_idx_a489d58a\" does not exist", + "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"", + "params": [ + "\"public\".\"UserProgress_userId_idx_a489d58a\"" + ] + } + ], + "execute": [ + { + "description": "create index \"UserProgress_userId_idx_a489d58a\"", + "sql": "CREATE INDEX \"UserProgress_userId_idx_a489d58a\" ON \"public\".\"UserProgress\" (\"userId\")", + "params": [] + } + ], + "postcheck": [ + { + "description": "verify index \"UserProgress_userId_idx_a489d58a\" exists", + "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"", + "params": [ + "\"public\".\"UserProgress_userId_idx_a489d58a\"" + ] + } + ] + }, + { + "id": "foreignKey.Command.Command_sessionId_fkey", + "label": "Add foreign key \"Command_sessionId_fkey\" on \"Command\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "foreignKey", + "name": "Command_sessionId_fkey", + "table": "Command" + } + }, + "precheck": [ + { + "description": "ensure FK \"Command_sessionId_fkey\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "Command_sessionId_fkey", + "public", + "\"public\".\"Command\"" + ] + } + ], + "execute": [ + { + "description": "add FK \"Command_sessionId_fkey\"", + "sql": "ALTER TABLE \"public\".\"Command\"\nADD CONSTRAINT \"Command_sessionId_fkey\"\nFOREIGN KEY (\"sessionId\")\nREFERENCES \"public\".\"Session\" (\"id\")" + } + ], + "postcheck": [ + { + "description": "verify FK \"Command_sessionId_fkey\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "Command_sessionId_fkey", + "public", + "\"public\".\"Command\"" + ] + } + ] + }, + { + "id": "foreignKey.LoginAttempt.LoginAttempt_userId_fkey", + "label": "Add foreign key \"LoginAttempt_userId_fkey\" on \"LoginAttempt\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "foreignKey", + "name": "LoginAttempt_userId_fkey", + "table": "LoginAttempt" + } + }, + "precheck": [ + { + "description": "ensure FK \"LoginAttempt_userId_fkey\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "LoginAttempt_userId_fkey", + "public", + "\"public\".\"LoginAttempt\"" + ] + } + ], + "execute": [ + { + "description": "add FK \"LoginAttempt_userId_fkey\"", + "sql": "ALTER TABLE \"public\".\"LoginAttempt\"\nADD CONSTRAINT \"LoginAttempt_userId_fkey\"\nFOREIGN KEY (\"userId\")\nREFERENCES \"public\".\"User\" (\"id\")" + } + ], + "postcheck": [ + { + "description": "verify FK \"LoginAttempt_userId_fkey\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "LoginAttempt_userId_fkey", + "public", + "\"public\".\"LoginAttempt\"" + ] + } + ] + }, + { + "id": "foreignKey.Session.Session_userId_fkey", + "label": "Add foreign key \"Session_userId_fkey\" on \"Session\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "foreignKey", + "name": "Session_userId_fkey", + "table": "Session" + } + }, + "precheck": [ + { + "description": "ensure FK \"Session_userId_fkey\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "Session_userId_fkey", + "public", + "\"public\".\"Session\"" + ] + } + ], + "execute": [ + { + "description": "add FK \"Session_userId_fkey\"", + "sql": "ALTER TABLE \"public\".\"Session\"\nADD CONSTRAINT \"Session_userId_fkey\"\nFOREIGN KEY (\"userId\")\nREFERENCES \"public\".\"User\" (\"id\")" + } + ], + "postcheck": [ + { + "description": "verify FK \"Session_userId_fkey\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "Session_userId_fkey", + "public", + "\"public\".\"Session\"" + ] + } + ] + }, + { + "id": "foreignKey.UserLoginMethod.UserLoginMethod_userId_fkey", + "label": "Add foreign key \"UserLoginMethod_userId_fkey\" on \"UserLoginMethod\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "foreignKey", + "name": "UserLoginMethod_userId_fkey", + "table": "UserLoginMethod" + } + }, + "precheck": [ + { + "description": "ensure FK \"UserLoginMethod_userId_fkey\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "UserLoginMethod_userId_fkey", + "public", + "\"public\".\"UserLoginMethod\"" + ] + } + ], + "execute": [ + { + "description": "add FK \"UserLoginMethod_userId_fkey\"", + "sql": "ALTER TABLE \"public\".\"UserLoginMethod\"\nADD CONSTRAINT \"UserLoginMethod_userId_fkey\"\nFOREIGN KEY (\"userId\")\nREFERENCES \"public\".\"User\" (\"id\")" + } + ], + "postcheck": [ + { + "description": "verify FK \"UserLoginMethod_userId_fkey\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "UserLoginMethod_userId_fkey", + "public", + "\"public\".\"UserLoginMethod\"" + ] + } + ] + }, + { + "id": "foreignKey.UserProgress.UserProgress_userId_fkey", + "label": "Add foreign key \"UserProgress_userId_fkey\" on \"UserProgress\"", + "operationClass": "additive", + "target": { + "id": "postgres", + "details": { + "schema": "public", + "objectType": "foreignKey", + "name": "UserProgress_userId_fkey", + "table": "UserProgress" + } + }, + "precheck": [ + { + "description": "ensure FK \"UserProgress_userId_fkey\" does not exist", + "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "UserProgress_userId_fkey", + "public", + "\"public\".\"UserProgress\"" + ] + } + ], + "execute": [ + { + "description": "add FK \"UserProgress_userId_fkey\"", + "sql": "ALTER TABLE \"public\".\"UserProgress\"\nADD CONSTRAINT \"UserProgress_userId_fkey\"\nFOREIGN KEY (\"userId\")\nREFERENCES \"public\".\"User\" (\"id\")" + } + ], + "postcheck": [ + { + "description": "verify FK \"UserProgress_userId_fkey\" exists", + "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"", + "params": [ + "UserProgress_userId_fkey", + "public", + "\"public\".\"UserProgress\"" + ] + } + ] + } +] \ No newline at end of file diff --git a/packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.d.ts b/packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.d.ts new file mode 100644 index 0000000..12d6618 --- /dev/null +++ b/packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.d.ts @@ -0,0 +1,1609 @@ +// ⚠️ GENERATED FILE - DO NOT EDIT +// This file is automatically generated by 'prisma contract emit'. +// To regenerate, run: prisma contract emit +import type { CodecTypes as PgTypes } from '@prisma/orm-postgres/target/codec-types'; +import type { QueryOperationTypes as PgTargetQueryOps } from '@prisma/orm-postgres/target/operation-types'; + +import type { + ContractWithTypeMaps, + RelationKeys, + TypeMaps as TypeMapsType, +} from '@prisma/orm-postgres/family-contract/types'; +import type { + Contract as ContractType, + ExecutionHashBase, + NamespaceId, + ProfileHashBase, + StorageHashBase, +} from '@prisma/orm-postgres/contract/types'; + +export type StorageHash = + StorageHashBase<'6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04'>; +export type ExecutionHash = ExecutionHashBase; +export type ProfileHash = + ProfileHashBase<'3916f444a8a17ad749191acf9e08dad97d1a327b88c2f1d45d12f240296aa8b2'>; + +export type CodecTypes = PgTypes; +export type LaneCodecTypes = CodecTypes; +export type QueryOperationTypes = PgTargetQueryOps; +export type AggregateTypes = { + readonly avg: { + readonly byCodec: { + readonly 'pg/float@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/float4@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/float8@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/int@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/int2@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/int4@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/int8@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/int8number@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/interval@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/numeric@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/time-string@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/time-temporal@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/unboundedint@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'sql/float@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'sql/int@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + }; + }; + readonly avgDecimal: { + readonly byCodec: { + readonly 'pg/int@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/int2@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/int4@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/int8@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/int8number@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/numeric@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/unboundedint@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'sql/int@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + }; + }; + readonly count: { + readonly byCodec: {}; + readonly withoutInput: { readonly output: 'pg/int8number@1'; readonly nullable: false }; + readonly anyInput: { readonly output: 'pg/int8number@1'; readonly nullable: false }; + }; + readonly countBigInt: { + readonly byCodec: {}; + readonly withoutInput: { readonly output: 'pg/int8@1'; readonly nullable: false }; + readonly anyInput: { readonly output: 'pg/int8@1'; readonly nullable: false }; + }; + readonly max: { + readonly byCodec: { + readonly 'pg/char@1': { readonly output: 'pg/char@1'; readonly nullable: true }; + readonly 'pg/date-string@1': { readonly output: 'pg/date-string@1'; readonly nullable: true }; + readonly 'pg/date-temporal@1': { + readonly output: 'pg/date-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/enum@1': { readonly output: 'pg/enum@1'; readonly nullable: true }; + readonly 'pg/float@1': { readonly output: 'pg/float@1'; readonly nullable: true }; + readonly 'pg/float4@1': { readonly output: 'pg/float4@1'; readonly nullable: true }; + readonly 'pg/float8@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/inet@1': { readonly output: 'pg/inet@1'; readonly nullable: true }; + readonly 'pg/int@1': { readonly output: 'pg/int@1'; readonly nullable: true }; + readonly 'pg/int2@1': { readonly output: 'pg/int2@1'; readonly nullable: true }; + readonly 'pg/int4@1': { readonly output: 'pg/int4@1'; readonly nullable: true }; + readonly 'pg/int8@1': { readonly output: 'pg/int8@1'; readonly nullable: true }; + readonly 'pg/int8number@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/interval@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/numeric@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/text-array@1': { readonly output: 'pg/text-array@1'; readonly nullable: true }; + readonly 'pg/text@1': { readonly output: 'pg/text@1'; readonly nullable: true }; + readonly 'pg/time-string@1': { readonly output: 'pg/time-string@1'; readonly nullable: true }; + readonly 'pg/time-temporal@1': { + readonly output: 'pg/time-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/timestamp-string@1': { + readonly output: 'pg/timestamp-string@1'; + readonly nullable: true; + }; + readonly 'pg/timestamp-temporal@1': { + readonly output: 'pg/timestamp-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/timestamptz-date@1': { + readonly output: 'pg/timestamptz-date@1'; + readonly nullable: true; + }; + readonly 'pg/timestamptz-string@1': { + readonly output: 'pg/timestamptz-string@1'; + readonly nullable: true; + }; + readonly 'pg/timestamptz-temporal@1': { + readonly output: 'pg/timestamptz-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/timetz@1': { readonly output: 'pg/timetz@1'; readonly nullable: true }; + readonly 'pg/unboundedint@1': { + readonly output: 'pg/unboundedint@1'; + readonly nullable: true; + }; + readonly 'pg/varchar@1': { readonly output: 'pg/text@1'; readonly nullable: true }; + readonly 'sql/char@1': { readonly output: 'sql/char@1'; readonly nullable: true }; + readonly 'sql/float@1': { readonly output: 'sql/float@1'; readonly nullable: true }; + readonly 'sql/int@1': { readonly output: 'sql/int@1'; readonly nullable: true }; + readonly 'sql/text@1': { readonly output: 'sql/text@1'; readonly nullable: true }; + readonly 'sql/varchar@1': { readonly output: 'pg/text@1'; readonly nullable: true }; + }; + }; + readonly min: { + readonly byCodec: { + readonly 'pg/char@1': { readonly output: 'pg/char@1'; readonly nullable: true }; + readonly 'pg/date-string@1': { readonly output: 'pg/date-string@1'; readonly nullable: true }; + readonly 'pg/date-temporal@1': { + readonly output: 'pg/date-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/enum@1': { readonly output: 'pg/enum@1'; readonly nullable: true }; + readonly 'pg/float@1': { readonly output: 'pg/float@1'; readonly nullable: true }; + readonly 'pg/float4@1': { readonly output: 'pg/float4@1'; readonly nullable: true }; + readonly 'pg/float8@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/inet@1': { readonly output: 'pg/inet@1'; readonly nullable: true }; + readonly 'pg/int@1': { readonly output: 'pg/int@1'; readonly nullable: true }; + readonly 'pg/int2@1': { readonly output: 'pg/int2@1'; readonly nullable: true }; + readonly 'pg/int4@1': { readonly output: 'pg/int4@1'; readonly nullable: true }; + readonly 'pg/int8@1': { readonly output: 'pg/int8@1'; readonly nullable: true }; + readonly 'pg/int8number@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/interval@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/numeric@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/text-array@1': { readonly output: 'pg/text-array@1'; readonly nullable: true }; + readonly 'pg/text@1': { readonly output: 'pg/text@1'; readonly nullable: true }; + readonly 'pg/time-string@1': { readonly output: 'pg/time-string@1'; readonly nullable: true }; + readonly 'pg/time-temporal@1': { + readonly output: 'pg/time-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/timestamp-string@1': { + readonly output: 'pg/timestamp-string@1'; + readonly nullable: true; + }; + readonly 'pg/timestamp-temporal@1': { + readonly output: 'pg/timestamp-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/timestamptz-date@1': { + readonly output: 'pg/timestamptz-date@1'; + readonly nullable: true; + }; + readonly 'pg/timestamptz-string@1': { + readonly output: 'pg/timestamptz-string@1'; + readonly nullable: true; + }; + readonly 'pg/timestamptz-temporal@1': { + readonly output: 'pg/timestamptz-temporal@1'; + readonly nullable: true; + }; + readonly 'pg/timetz@1': { readonly output: 'pg/timetz@1'; readonly nullable: true }; + readonly 'pg/unboundedint@1': { + readonly output: 'pg/unboundedint@1'; + readonly nullable: true; + }; + readonly 'pg/varchar@1': { readonly output: 'pg/text@1'; readonly nullable: true }; + readonly 'sql/char@1': { readonly output: 'sql/char@1'; readonly nullable: true }; + readonly 'sql/float@1': { readonly output: 'sql/float@1'; readonly nullable: true }; + readonly 'sql/int@1': { readonly output: 'sql/int@1'; readonly nullable: true }; + readonly 'sql/text@1': { readonly output: 'sql/text@1'; readonly nullable: true }; + readonly 'sql/varchar@1': { readonly output: 'pg/text@1'; readonly nullable: true }; + }; + }; + readonly sum: { + readonly byCodec: { + readonly 'pg/float@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/float4@1': { readonly output: 'pg/float4@1'; readonly nullable: true }; + readonly 'pg/float8@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'pg/int@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/int2@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/int4@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/int8@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/int8number@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + readonly 'pg/interval@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/numeric@1': { readonly output: 'pg/numeric@1'; readonly nullable: true }; + readonly 'pg/time-string@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/time-temporal@1': { readonly output: 'pg/interval@1'; readonly nullable: true }; + readonly 'pg/unboundedint@1': { + readonly output: 'pg/unboundedint@1'; + readonly nullable: true; + }; + readonly 'sql/float@1': { readonly output: 'pg/float8@1'; readonly nullable: true }; + readonly 'sql/int@1': { readonly output: 'pg/int8number@1'; readonly nullable: true }; + }; + }; + readonly sumBigInt: { + readonly byCodec: { + readonly 'pg/int@1': { readonly output: 'pg/int8@1'; readonly nullable: true }; + readonly 'pg/int2@1': { readonly output: 'pg/int8@1'; readonly nullable: true }; + readonly 'pg/int4@1': { readonly output: 'pg/int8@1'; readonly nullable: true }; + readonly 'pg/int8@1': { readonly output: 'pg/unboundedint@1'; readonly nullable: true }; + readonly 'pg/int8number@1': { readonly output: 'pg/unboundedint@1'; readonly nullable: true }; + readonly 'pg/unboundedint@1': { + readonly output: 'pg/unboundedint@1'; + readonly nullable: true; + }; + readonly 'sql/int@1': { readonly output: 'pg/int8@1'; readonly nullable: true }; + }; + }; +}; +type DefaultLiteralValue = CodecId extends keyof CodecTypes + ? Encoded extends CodecTypes[CodecId]['json'] + ? Encoded + : CodecTypes[CodecId]['json'] + : Encoded; + +export type FieldOutputTypes = { + readonly public: { + readonly Command: { + readonly command: CodecTypes['pg/text@1']['output']; + readonly error: CodecTypes['pg/text@1']['output'] | null; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly output: CodecTypes['pg/text@1']['output'] | null; + readonly pwd: CodecTypes['pg/text@1']['output']; + readonly sessionId: CodecTypes['pg/int8@1']['output']; + readonly stage: CodecTypes['pg/text@1']['output'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['output']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['output']; + readonly ip: CodecTypes['pg/text@1']['output']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['output'] | null; + readonly success: CodecTypes['pg/bool@1']['output']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userAgent: CodecTypes['pg/text@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output'] | null; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['output'] | null; + readonly containerName: CodecTypes['pg/text@1']['output'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly locale: CodecTypes['pg/text@1']['output']; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + readonly User: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly email: CodecTypes['pg/text@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly isGuest: CodecTypes['pg/bool@1']['output']; + readonly name: CodecTypes['pg/text@1']['output'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly displayName: CodecTypes['pg/text@1']['output'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['output'] | null; + readonly oauthId: CodecTypes['pg/text@1']['output'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + }; +}; +export type FieldInputTypes = { + readonly public: { + readonly Command: { + readonly command: CodecTypes['pg/text@1']['input']; + readonly error: CodecTypes['pg/text@1']['input'] | null; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly output: CodecTypes['pg/text@1']['input'] | null; + readonly pwd: CodecTypes['pg/text@1']['input']; + readonly sessionId: CodecTypes['pg/int8@1']['input']; + readonly stage: CodecTypes['pg/text@1']['input'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['input']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['input']; + readonly ip: CodecTypes['pg/text@1']['input']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['input'] | null; + readonly success: CodecTypes['pg/bool@1']['input']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userAgent: CodecTypes['pg/text@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input'] | null; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['input'] | null; + readonly containerName: CodecTypes['pg/text@1']['input'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly locale: CodecTypes['pg/text@1']['input']; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + readonly User: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly email: CodecTypes['pg/text@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly isGuest: CodecTypes['pg/bool@1']['input']; + readonly name: CodecTypes['pg/text@1']['input'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly displayName: CodecTypes['pg/text@1']['input'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['input'] | null; + readonly oauthId: CodecTypes['pg/text@1']['input'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + }; +}; +export type StorageColumnTypes = { + readonly public: { + readonly Command: { + readonly command: CodecTypes['pg/text@1']['output']; + readonly error: CodecTypes['pg/text@1']['output'] | null; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly output: CodecTypes['pg/text@1']['output'] | null; + readonly pwd: CodecTypes['pg/text@1']['output']; + readonly sessionId: CodecTypes['pg/int8@1']['output']; + readonly stage: CodecTypes['pg/text@1']['output'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['output']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['output']; + readonly ip: CodecTypes['pg/text@1']['output']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['output'] | null; + readonly success: CodecTypes['pg/bool@1']['output']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userAgent: CodecTypes['pg/text@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output'] | null; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['output'] | null; + readonly containerName: CodecTypes['pg/text@1']['output'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly locale: CodecTypes['pg/text@1']['output']; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + readonly User: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly email: CodecTypes['pg/text@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly isGuest: CodecTypes['pg/bool@1']['output']; + readonly name: CodecTypes['pg/text@1']['output'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly displayName: CodecTypes['pg/text@1']['output'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['output'] | null; + readonly oauthId: CodecTypes['pg/text@1']['output'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + }; +}; +export type StorageColumnInputTypes = { + readonly public: { + readonly Command: { + readonly command: CodecTypes['pg/text@1']['input']; + readonly error: CodecTypes['pg/text@1']['input'] | null; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly output: CodecTypes['pg/text@1']['input'] | null; + readonly pwd: CodecTypes['pg/text@1']['input']; + readonly sessionId: CodecTypes['pg/int8@1']['input']; + readonly stage: CodecTypes['pg/text@1']['input'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['input']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['input']; + readonly ip: CodecTypes['pg/text@1']['input']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['input'] | null; + readonly success: CodecTypes['pg/bool@1']['input']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userAgent: CodecTypes['pg/text@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input'] | null; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['input'] | null; + readonly containerName: CodecTypes['pg/text@1']['input'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly locale: CodecTypes['pg/text@1']['input']; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + readonly User: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly email: CodecTypes['pg/text@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly isGuest: CodecTypes['pg/bool@1']['input']; + readonly name: CodecTypes['pg/text@1']['input'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly displayName: CodecTypes['pg/text@1']['input'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['input'] | null; + readonly oauthId: CodecTypes['pg/text@1']['input'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + }; +}; + +export namespace Models { + export type public_Command = { + command: CodecTypes['pg/text@1']['output']; + error: CodecTypes['pg/text@1']['output'] | null; + id: CodecTypes['pg/int8@1']['output']; + output: CodecTypes['pg/text@1']['output'] | null; + pwd: CodecTypes['pg/text@1']['output']; + sessionId: CodecTypes['pg/int8@1']['output']; + stage: CodecTypes['pg/text@1']['output'] | null; + timestamp: CodecTypes['pg/timestamptz-temporal@1']['output']; + session: public_Session; + readonly [RelationKeys]?: 'session'; + }; + export type public_LoginAttempt = { + id: CodecTypes['pg/int8@1']['output']; + ip: CodecTypes['pg/text@1']['output']; + loginMethod: 'password' | 'google' | 'github'; + message: CodecTypes['pg/text@1']['output'] | null; + success: CodecTypes['pg/bool@1']['output']; + time: CodecTypes['pg/timestamptz-temporal@1']['output']; + userAgent: CodecTypes['pg/text@1']['output']; + userId: CodecTypes['pg/int8@1']['output'] | null; + username: CodecTypes['pg/text@1']['output']; + user: public_User | null; + readonly [RelationKeys]?: 'user'; + }; + export type public_Session = { + completedEvents: ReadonlyArray; + containerId: CodecTypes['pg/text@1']['output'] | null; + containerName: CodecTypes['pg/text@1']['output'] | null; + createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + graph: CodecTypes['pg/jsonb@1']['output']; + id: CodecTypes['pg/int8@1']['output']; + lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + locale: CodecTypes['pg/text@1']['output']; + quest: CodecTypes['pg/text@1']['output']; + status: 'active' | 'finished' | 'inactive'; + userId: CodecTypes['pg/int8@1']['output']; + commands: public_Command[]; + user: public_User; + readonly [RelationKeys]?: 'commands' | 'user'; + }; + export type public_User = { + createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + email: CodecTypes['pg/text@1']['output']; + id: CodecTypes['pg/int8@1']['output']; + isGuest: CodecTypes['pg/bool@1']['output']; + name: CodecTypes['pg/text@1']['output'] | null; + updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + username: CodecTypes['pg/text@1']['output']; + loginAttempts: public_LoginAttempt[]; + loginMethods: public_UserLoginMethod[]; + progress: public_UserProgress[]; + sessions: public_Session[]; + readonly [RelationKeys]?: 'loginAttempts' | 'loginMethods' | 'progress' | 'sessions'; + }; + export type public_UserLoginMethod = { + createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + displayName: CodecTypes['pg/text@1']['output'] | null; + hashedPassword: CodecTypes['pg/text@1']['output'] | null; + oauthId: CodecTypes['pg/text@1']['output'] | null; + type: 'password' | 'google' | 'github'; + updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + userId: CodecTypes['pg/int8@1']['output']; + user: public_User; + readonly [RelationKeys]?: 'user'; + }; + export type public_UserProgress = { + finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + quest: CodecTypes['pg/text@1']['output']; + startedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + userId: CodecTypes['pg/int8@1']['output']; + user: public_User; + readonly [RelationKeys]?: 'user'; + }; +} + +export declare const models: { + public: { + Command: Models.public_Command; + LoginAttempt: Models.public_LoginAttempt; + Session: Models.public_Session; + User: Models.public_User; + UserLoginMethod: Models.public_UserLoginMethod; + UserProgress: Models.public_UserProgress; + }; +}; + +export type TypeMaps = TypeMapsType< + CodecTypes, + QueryOperationTypes, + FieldOutputTypes, + FieldInputTypes, + StorageColumnTypes, + StorageColumnInputTypes, + AggregateTypes +>; + +type ContractBase = Omit< + ContractType<{ + readonly namespaces: { + readonly public: { + readonly id: 'public'; + readonly kind: 'postgres-schema'; + readonly entries: { + readonly table: { + readonly Command: { + columns: { + readonly command: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly error: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly id: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly default: { + readonly kind: 'function'; + readonly expression: 'autoincrement()'; + }; + readonly many: false; + }; + readonly output: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly pwd: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly sessionId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + readonly stage: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly timestamp: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['id'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'Command_sessionId_idx_29f415d4'; + readonly prefix: 'Command_sessionId_idx'; + readonly columns: readonly ['sessionId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'Command'; + readonly columns: readonly ['sessionId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'Session'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly LoginAttempt: { + columns: { + readonly id: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly default: { + readonly kind: 'function'; + readonly expression: 'autoincrement()'; + }; + readonly many: false; + }; + readonly ip: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly loginMethod: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly message: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly success: { + readonly dataType: 'pg/bool'; + readonly codecId: 'pg/bool@1'; + readonly nullable: false; + readonly many: false; + }; + readonly time: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userAgent: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: true; + readonly many: false; + }; + readonly username: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['id'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'LoginAttempt_userId_idx_a489d58a'; + readonly prefix: 'LoginAttempt_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'LoginAttempt'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly Session: { + columns: { + readonly completedEvents: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: { readonly elementNullable: false }; + }; + readonly containerId: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly containerName: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly createdAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly finishedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: true; + readonly many: false; + }; + readonly graph: { + readonly dataType: 'pg/jsonb'; + readonly codecId: 'pg/jsonb@1'; + readonly nullable: false; + readonly many: false; + }; + readonly id: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly default: { + readonly kind: 'function'; + readonly expression: 'autoincrement()'; + }; + readonly many: false; + }; + readonly lastActivityAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly locale: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly quest: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly status: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['id'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'Session_userId_idx_a489d58a'; + readonly prefix: 'Session_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + { + readonly name: 'Session_userId_quest_idx_b13626bf'; + readonly prefix: 'Session_userId_quest_idx'; + readonly columns: readonly ['userId', 'quest']; + readonly unique: false; + }, + { + readonly name: 'Session_userId_status_idx_e4a128ba'; + readonly prefix: 'Session_userId_status_idx'; + readonly columns: readonly ['userId', 'status']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'Session'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly User: { + columns: { + readonly createdAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly email: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly id: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly default: { + readonly kind: 'function'; + readonly expression: 'autoincrement()'; + }; + readonly many: false; + }; + readonly isGuest: { + readonly dataType: 'pg/bool'; + readonly codecId: 'pg/bool@1'; + readonly nullable: false; + readonly many: false; + }; + readonly name: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly updatedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly username: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['id'] }; + uniques: readonly [ + { readonly columns: readonly ['email'] }, + { readonly columns: readonly ['username'] }, + ]; + indexes: readonly []; + foreignKeys: readonly []; + }; + readonly UserLoginMethod: { + columns: { + readonly createdAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly displayName: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly hashedPassword: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly oauthId: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly type: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly updatedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['userId', 'type'] }; + uniques: readonly [{ readonly columns: readonly ['type', 'oauthId'] }]; + indexes: readonly [ + { + readonly name: 'UserLoginMethod_userId_idx_a489d58a'; + readonly prefix: 'UserLoginMethod_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'UserLoginMethod'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly UserProgress: { + columns: { + readonly finishedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: true; + readonly many: false; + }; + readonly quest: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly startedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['userId', 'quest'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'UserProgress_userId_idx_a489d58a'; + readonly prefix: 'UserProgress_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'UserProgress'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + }; + readonly valueSet: { + readonly LoginMethod: { + readonly kind: 'valueSet'; + readonly values: readonly ['password', 'google', 'github']; + }; + readonly SessionStatus: { + readonly kind: 'valueSet'; + readonly values: readonly ['active', 'finished', 'inactive']; + }; + }; + }; + }; + }; + readonly storageHash: StorageHash; + }>, + 'roots' | 'domain' +> & { + readonly target: 'postgres'; + readonly targetFamily: 'sql'; + readonly roots: { + readonly Command: { readonly namespace: 'public' & NamespaceId; readonly model: 'Command' }; + readonly LoginAttempt: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'LoginAttempt'; + }; + readonly Session: { readonly namespace: 'public' & NamespaceId; readonly model: 'Session' }; + readonly User: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly UserLoginMethod: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserLoginMethod'; + }; + readonly UserProgress: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserProgress'; + }; + }; + readonly domain: { + readonly namespaces: { + readonly public: { + readonly models: { + readonly Command: { + readonly fields: { + readonly command: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly error: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly id: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly output: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly pwd: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly sessionId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly stage: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly timestamp: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + }; + readonly relations: { + readonly session: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'Session'; + }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['sessionId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'Command'; + readonly namespaceId: 'public'; + readonly fields: { + readonly command: { readonly column: 'command' }; + readonly error: { readonly column: 'error' }; + readonly id: { readonly column: 'id' }; + readonly output: { readonly column: 'output' }; + readonly pwd: { readonly column: 'pwd' }; + readonly sessionId: { readonly column: 'sessionId' }; + readonly stage: { readonly column: 'stage' }; + readonly timestamp: { readonly column: 'timestamp' }; + }; + }; + }; + readonly LoginAttempt: { + readonly fields: { + readonly id: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly ip: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly loginMethod: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly message: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly success: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/bool@1' }; + }; + readonly time: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly userAgent: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly userId: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly username: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + }; + readonly relations: { + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: true; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'LoginAttempt'; + readonly namespaceId: 'public'; + readonly fields: { + readonly id: { readonly column: 'id' }; + readonly ip: { readonly column: 'ip' }; + readonly loginMethod: { readonly column: 'loginMethod' }; + readonly message: { readonly column: 'message' }; + readonly success: { readonly column: 'success' }; + readonly time: { readonly column: 'time' }; + readonly userAgent: { readonly column: 'userAgent' }; + readonly userId: { readonly column: 'userId' }; + readonly username: { readonly column: 'username' }; + }; + }; + }; + readonly Session: { + readonly fields: { + readonly completedEvents: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + readonly many: { readonly elementNullable: false }; + }; + readonly containerId: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly containerName: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly createdAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly finishedAt: { + readonly nullable: true; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly graph: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/jsonb@1' }; + }; + readonly id: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly lastActivityAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly locale: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly quest: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly status: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly userId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + }; + readonly relations: { + readonly commands: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'Command'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['sessionId']; + }; + }; + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'Session'; + readonly namespaceId: 'public'; + readonly fields: { + readonly completedEvents: { readonly column: 'completedEvents' }; + readonly containerId: { readonly column: 'containerId' }; + readonly containerName: { readonly column: 'containerName' }; + readonly createdAt: { readonly column: 'createdAt' }; + readonly finishedAt: { readonly column: 'finishedAt' }; + readonly graph: { readonly column: 'graph' }; + readonly id: { readonly column: 'id' }; + readonly lastActivityAt: { readonly column: 'lastActivityAt' }; + readonly locale: { readonly column: 'locale' }; + readonly quest: { readonly column: 'quest' }; + readonly status: { readonly column: 'status' }; + readonly userId: { readonly column: 'userId' }; + }; + }; + }; + readonly User: { + readonly fields: { + readonly createdAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly email: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly id: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly isGuest: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/bool@1' }; + }; + readonly name: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly updatedAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly username: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + }; + readonly relations: { + readonly loginAttempts: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'LoginAttempt'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; + }; + }; + readonly loginMethods: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserLoginMethod'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; + }; + }; + readonly progress: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserProgress'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; + }; + }; + readonly sessions: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'Session'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; + }; + }; + }; + readonly storage: { + readonly table: 'User'; + readonly namespaceId: 'public'; + readonly fields: { + readonly createdAt: { readonly column: 'createdAt' }; + readonly email: { readonly column: 'email' }; + readonly id: { readonly column: 'id' }; + readonly isGuest: { readonly column: 'isGuest' }; + readonly name: { readonly column: 'name' }; + readonly updatedAt: { readonly column: 'updatedAt' }; + readonly username: { readonly column: 'username' }; + }; + }; + }; + readonly UserLoginMethod: { + readonly fields: { + readonly createdAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly displayName: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly hashedPassword: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly oauthId: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly type: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly updatedAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly userId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + }; + readonly relations: { + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'UserLoginMethod'; + readonly namespaceId: 'public'; + readonly fields: { + readonly createdAt: { readonly column: 'createdAt' }; + readonly displayName: { readonly column: 'displayName' }; + readonly hashedPassword: { readonly column: 'hashedPassword' }; + readonly oauthId: { readonly column: 'oauthId' }; + readonly type: { readonly column: 'type' }; + readonly updatedAt: { readonly column: 'updatedAt' }; + readonly userId: { readonly column: 'userId' }; + }; + }; + }; + readonly UserProgress: { + readonly fields: { + readonly finishedAt: { + readonly nullable: true; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly quest: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly startedAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly userId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + }; + readonly relations: { + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'UserProgress'; + readonly namespaceId: 'public'; + readonly fields: { + readonly finishedAt: { readonly column: 'finishedAt' }; + readonly quest: { readonly column: 'quest' }; + readonly startedAt: { readonly column: 'startedAt' }; + readonly userId: { readonly column: 'userId' }; + }; + }; + }; + }; + readonly enum: { + readonly LoginMethod: { + readonly codecId: 'pg/text@1'; + readonly members: readonly [ + { readonly name: 'Password'; readonly value: 'password' }, + { readonly name: 'Google'; readonly value: 'google' }, + { readonly name: 'GitHub'; readonly value: 'github' }, + ]; + }; + readonly SessionStatus: { + readonly codecId: 'pg/text@1'; + readonly members: readonly [ + { readonly name: 'Active'; readonly value: 'active' }, + { readonly name: 'Finished'; readonly value: 'finished' }, + { readonly name: 'Inactive'; readonly value: 'inactive' }, + ]; + }; + }; + readonly enumMemberTypes?: { + readonly LoginMethod: readonly [ + { readonly name: 'Password'; readonly value: 'password' }, + { readonly name: 'Google'; readonly value: 'google' }, + { readonly name: 'GitHub'; readonly value: 'github' }, + ]; + readonly SessionStatus: readonly [ + { readonly name: 'Active'; readonly value: 'active' }, + { readonly name: 'Finished'; readonly value: 'finished' }, + { readonly name: 'Inactive'; readonly value: 'inactive' }, + ]; + }; + }; + }; + }; + readonly capabilities: { + readonly postgres: { + readonly distinctOn: true; + readonly forKeyShare: true; + readonly forNoKeyUpdate: true; + readonly jsonAgg: true; + readonly lateral: true; + readonly limit: true; + readonly orderBy: true; + readonly returning: true; + }; + readonly sql: { + readonly checkConstraint: true; + readonly defaultInInsert: true; + readonly enums: true; + readonly forShare: true; + readonly forUpdate: true; + readonly insertOnConflictSkip: true; + readonly insertOnConflictWithoutTarget: true; + readonly lateral: true; + readonly lockNowait: true; + readonly lockOf: true; + readonly lockSkipLocked: true; + readonly returning: true; + readonly scalarList: true; + }; + }; + readonly extensions: {}; + readonly meta: {}; + + readonly profileHash: ProfileHash; +}; + +export type Contract = ContractWithTypeMaps; + +export type Namespaces = Contract['storage']['namespaces']; diff --git a/packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.json b/packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.json new file mode 100644 index 0000000..5df6fe0 --- /dev/null +++ b/packages/database/migrations/snapshots/6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04/contract.json @@ -0,0 +1 @@ +{"_generated":{"message":"This file is automatically generated by \"prisma contract emit\".","regenerate":"To regenerate, run: prisma contract emit","warning":"⚠️ GENERATED FILE - DO NOT EDIT"},"capabilities":{"postgres":{"distinctOn":true,"forKeyShare":true,"forNoKeyUpdate":true,"jsonAgg":true,"lateral":true,"limit":true,"orderBy":true,"returning":true},"sql":{"checkConstraint":true,"defaultInInsert":true,"enums":true,"forShare":true,"forUpdate":true,"insertOnConflictSkip":true,"insertOnConflictWithoutTarget":true,"lateral":true,"lockNowait":true,"lockOf":true,"lockSkipLocked":true,"returning":true,"scalarList":true}},"domain":{"namespaces":{"public":{"enum":{"LoginMethod":{"codecId":"pg/text@1","members":[{"name":"Password","value":"password"},{"name":"Google","value":"google"},{"name":"GitHub","value":"github"}]},"SessionStatus":{"codecId":"pg/text@1","members":[{"name":"Active","value":"active"},{"name":"Finished","value":"finished"},{"name":"Inactive","value":"inactive"}]}},"models":{"Command":{"fields":{"command":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"error":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"id":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}},"output":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"pwd":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"sessionId":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}},"stage":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"timestamp":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}}},"relations":{"session":{"cardinality":"N:1","nullable":false,"on":{"localFields":["sessionId"],"targetFields":["id"]},"to":{"model":"Session","namespace":"public"}}},"storage":{"fields":{"command":{"column":"command"},"error":{"column":"error"},"id":{"column":"id"},"output":{"column":"output"},"pwd":{"column":"pwd"},"sessionId":{"column":"sessionId"},"stage":{"column":"stage"},"timestamp":{"column":"timestamp"}},"namespaceId":"public","table":"Command"}},"LoginAttempt":{"fields":{"id":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}},"ip":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"loginMethod":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"},"valueSet":{"entityKind":"enum","entityName":"LoginMethod","namespaceId":"public","plane":"domain"}},"message":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"success":{"nullable":false,"type":{"codecId":"pg/bool@1","kind":"scalar"}},"time":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"userAgent":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"userId":{"nullable":true,"type":{"codecId":"pg/int8@1","kind":"scalar"}},"username":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}}},"relations":{"user":{"cardinality":"N:1","nullable":true,"on":{"localFields":["userId"],"targetFields":["id"]},"to":{"model":"User","namespace":"public"}}},"storage":{"fields":{"id":{"column":"id"},"ip":{"column":"ip"},"loginMethod":{"column":"loginMethod"},"message":{"column":"message"},"success":{"column":"success"},"time":{"column":"time"},"userAgent":{"column":"userAgent"},"userId":{"column":"userId"},"username":{"column":"username"}},"namespaceId":"public","table":"LoginAttempt"}},"Session":{"fields":{"completedEvents":{"many":{"elementNullable":false},"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"containerId":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"containerName":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"createdAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"finishedAt":{"nullable":true,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"graph":{"nullable":false,"type":{"codecId":"pg/jsonb@1","kind":"scalar"}},"id":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}},"lastActivityAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"locale":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"quest":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"status":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"},"valueSet":{"entityKind":"enum","entityName":"SessionStatus","namespaceId":"public","plane":"domain"}},"userId":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}}},"relations":{"commands":{"cardinality":"1:N","on":{"localFields":["id"],"targetFields":["sessionId"]},"to":{"model":"Command","namespace":"public"}},"user":{"cardinality":"N:1","nullable":false,"on":{"localFields":["userId"],"targetFields":["id"]},"to":{"model":"User","namespace":"public"}}},"storage":{"fields":{"completedEvents":{"column":"completedEvents"},"containerId":{"column":"containerId"},"containerName":{"column":"containerName"},"createdAt":{"column":"createdAt"},"finishedAt":{"column":"finishedAt"},"graph":{"column":"graph"},"id":{"column":"id"},"lastActivityAt":{"column":"lastActivityAt"},"locale":{"column":"locale"},"quest":{"column":"quest"},"status":{"column":"status"},"userId":{"column":"userId"}},"namespaceId":"public","table":"Session"}},"User":{"fields":{"createdAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"email":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"id":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}},"isGuest":{"nullable":false,"type":{"codecId":"pg/bool@1","kind":"scalar"}},"name":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"updatedAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"username":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}}},"relations":{"loginAttempts":{"cardinality":"1:N","on":{"localFields":["id"],"targetFields":["userId"]},"to":{"model":"LoginAttempt","namespace":"public"}},"loginMethods":{"cardinality":"1:N","on":{"localFields":["id"],"targetFields":["userId"]},"to":{"model":"UserLoginMethod","namespace":"public"}},"progress":{"cardinality":"1:N","on":{"localFields":["id"],"targetFields":["userId"]},"to":{"model":"UserProgress","namespace":"public"}},"sessions":{"cardinality":"1:N","on":{"localFields":["id"],"targetFields":["userId"]},"to":{"model":"Session","namespace":"public"}}},"storage":{"fields":{"createdAt":{"column":"createdAt"},"email":{"column":"email"},"id":{"column":"id"},"isGuest":{"column":"isGuest"},"name":{"column":"name"},"updatedAt":{"column":"updatedAt"},"username":{"column":"username"}},"namespaceId":"public","table":"User"}},"UserLoginMethod":{"fields":{"createdAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"displayName":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"hashedPassword":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"oauthId":{"nullable":true,"type":{"codecId":"pg/text@1","kind":"scalar"}},"type":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"},"valueSet":{"entityKind":"enum","entityName":"LoginMethod","namespaceId":"public","plane":"domain"}},"updatedAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"userId":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}}},"relations":{"user":{"cardinality":"N:1","nullable":false,"on":{"localFields":["userId"],"targetFields":["id"]},"to":{"model":"User","namespace":"public"}}},"storage":{"fields":{"createdAt":{"column":"createdAt"},"displayName":{"column":"displayName"},"hashedPassword":{"column":"hashedPassword"},"oauthId":{"column":"oauthId"},"type":{"column":"type"},"updatedAt":{"column":"updatedAt"},"userId":{"column":"userId"}},"namespaceId":"public","table":"UserLoginMethod"}},"UserProgress":{"fields":{"finishedAt":{"nullable":true,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"quest":{"nullable":false,"type":{"codecId":"pg/text@1","kind":"scalar"}},"startedAt":{"nullable":false,"type":{"codecId":"pg/timestamptz-temporal@1","kind":"scalar"}},"userId":{"nullable":false,"type":{"codecId":"pg/int8@1","kind":"scalar"}}},"relations":{"user":{"cardinality":"N:1","nullable":false,"on":{"localFields":["userId"],"targetFields":["id"]},"to":{"model":"User","namespace":"public"}}},"storage":{"fields":{"finishedAt":{"column":"finishedAt"},"quest":{"column":"quest"},"startedAt":{"column":"startedAt"},"userId":{"column":"userId"}},"namespaceId":"public","table":"UserProgress"}}}}}},"extensions":{},"meta":{},"profileHash":"3916f444a8a17ad749191acf9e08dad97d1a327b88c2f1d45d12f240296aa8b2","roots":{"Command":{"model":"Command","namespace":"public"},"LoginAttempt":{"model":"LoginAttempt","namespace":"public"},"Session":{"model":"Session","namespace":"public"},"User":{"model":"User","namespace":"public"},"UserLoginMethod":{"model":"UserLoginMethod","namespace":"public"},"UserProgress":{"model":"UserProgress","namespace":"public"}},"schemaVersion":"1","storage":{"namespaces":{"public":{"entries":{"table":{"Command":{"columns":{"command":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"error":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"id":{"codecId":"pg/int8@1","dataType":"pg/int8","default":{"expression":"autoincrement()","kind":"function"},"nullable":false},"output":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"pwd":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"sessionId":{"codecId":"pg/int8@1","dataType":"pg/int8","nullable":false},"stage":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"timestamp":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false}},"foreignKeys":[{"index":{"name":"Command_sessionId_idx_29f415d4"},"source":{"columns":["sessionId"],"namespaceId":"public","tableName":"Command"},"target":{"columns":["id"],"namespaceId":"public","tableName":"Session"}}],"indexes":[{"columns":["sessionId"],"name":"Command_sessionId_idx_29f415d4","prefix":"Command_sessionId_idx","unique":false}],"primaryKey":{"columns":["id"]},"uniques":[]},"LoginAttempt":{"checks":[{"expression":"\"loginMethod\" IN ('password', 'google', 'github')","name":"LoginAttempt_loginMethod_check_f8485f11","prefix":"LoginAttempt_loginMethod_check"}],"columns":{"id":{"codecId":"pg/int8@1","dataType":"pg/int8","default":{"expression":"autoincrement()","kind":"function"},"nullable":false},"ip":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"loginMethod":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false,"valueSet":{"entityKind":"valueSet","entityName":"LoginMethod","namespaceId":"public","plane":"storage"}},"message":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"success":{"codecId":"pg/bool@1","dataType":"pg/bool","nullable":false},"time":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"userAgent":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"userId":{"codecId":"pg/int8@1","dataType":"pg/int8","nullable":true},"username":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false}},"foreignKeys":[{"index":{"name":"LoginAttempt_userId_idx_a489d58a"},"source":{"columns":["userId"],"namespaceId":"public","tableName":"LoginAttempt"},"target":{"columns":["id"],"namespaceId":"public","tableName":"User"}}],"indexes":[{"columns":["userId"],"name":"LoginAttempt_userId_idx_a489d58a","prefix":"LoginAttempt_userId_idx","unique":false}],"primaryKey":{"columns":["id"]},"uniques":[]},"Session":{"checks":[{"expression":"array_position(\"completedEvents\", NULL) IS NULL","name":"Session_completedEvents_elem_not_null_b55d23f4","prefix":"Session_completedEvents_elem_not_null"},{"expression":"\"status\" IN ('active', 'finished', 'inactive')","name":"Session_status_check_8fa5bbc6","prefix":"Session_status_check"}],"columns":{"completedEvents":{"codecId":"pg/text@1","dataType":"pg/text","many":{"elementNullable":false},"nullable":false},"containerId":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"containerName":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"createdAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"finishedAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":true},"graph":{"codecId":"pg/jsonb@1","dataType":"pg/jsonb","nullable":false},"id":{"codecId":"pg/int8@1","dataType":"pg/int8","default":{"expression":"autoincrement()","kind":"function"},"nullable":false},"lastActivityAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"locale":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"quest":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"status":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false,"valueSet":{"entityKind":"valueSet","entityName":"SessionStatus","namespaceId":"public","plane":"storage"}},"userId":{"codecId":"pg/int8@1","dataType":"pg/int8","nullable":false}},"foreignKeys":[{"index":{"name":"Session_userId_idx_a489d58a"},"source":{"columns":["userId"],"namespaceId":"public","tableName":"Session"},"target":{"columns":["id"],"namespaceId":"public","tableName":"User"}}],"indexes":[{"columns":["userId"],"name":"Session_userId_idx_a489d58a","prefix":"Session_userId_idx","unique":false},{"columns":["userId","quest"],"name":"Session_userId_quest_idx_b13626bf","prefix":"Session_userId_quest_idx","unique":false},{"columns":["userId","status"],"name":"Session_userId_status_idx_e4a128ba","prefix":"Session_userId_status_idx","unique":false}],"primaryKey":{"columns":["id"]},"uniques":[]},"User":{"columns":{"createdAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"email":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"id":{"codecId":"pg/int8@1","dataType":"pg/int8","default":{"expression":"autoincrement()","kind":"function"},"nullable":false},"isGuest":{"codecId":"pg/bool@1","dataType":"pg/bool","nullable":false},"name":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"updatedAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"username":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false}},"foreignKeys":[],"indexes":[],"primaryKey":{"columns":["id"]},"uniques":[{"columns":["email"]},{"columns":["username"]}]},"UserLoginMethod":{"checks":[{"expression":"\"type\" IN ('password', 'google', 'github')","name":"UserLoginMethod_type_check_6814314f","prefix":"UserLoginMethod_type_check"}],"columns":{"createdAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"displayName":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"hashedPassword":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"oauthId":{"codecId":"pg/text@1","dataType":"pg/text","nullable":true},"type":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false,"valueSet":{"entityKind":"valueSet","entityName":"LoginMethod","namespaceId":"public","plane":"storage"}},"updatedAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"userId":{"codecId":"pg/int8@1","dataType":"pg/int8","nullable":false}},"foreignKeys":[{"index":{"name":"UserLoginMethod_userId_idx_a489d58a"},"source":{"columns":["userId"],"namespaceId":"public","tableName":"UserLoginMethod"},"target":{"columns":["id"],"namespaceId":"public","tableName":"User"}}],"indexes":[{"columns":["userId"],"name":"UserLoginMethod_userId_idx_a489d58a","prefix":"UserLoginMethod_userId_idx","unique":false}],"primaryKey":{"columns":["userId","type"]},"uniques":[{"columns":["type","oauthId"]}]},"UserProgress":{"columns":{"finishedAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":true},"quest":{"codecId":"pg/text@1","dataType":"pg/text","nullable":false},"startedAt":{"codecId":"pg/timestamptz-temporal@1","dataType":"pg/timestamptz","nullable":false},"userId":{"codecId":"pg/int8@1","dataType":"pg/int8","nullable":false}},"foreignKeys":[{"index":{"name":"UserProgress_userId_idx_a489d58a"},"source":{"columns":["userId"],"namespaceId":"public","tableName":"UserProgress"},"target":{"columns":["id"],"namespaceId":"public","tableName":"User"}}],"indexes":[{"columns":["userId"],"name":"UserProgress_userId_idx_a489d58a","prefix":"UserProgress_userId_idx","unique":false}],"primaryKey":{"columns":["userId","quest"]},"uniques":[]}},"valueSet":{"LoginMethod":{"kind":"valueSet","values":["password","google","github"]},"SessionStatus":{"kind":"valueSet","values":["active","finished","inactive"]}}},"id":"public","kind":"postgres-schema"}},"storageHash":"6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04"},"target":"postgres","targetFamily":"sql"} diff --git a/packages/database/src/index.ts b/packages/database/src/index.ts index 6cbd97c..1843c9b 100644 --- a/packages/database/src/index.ts +++ b/packages/database/src/index.ts @@ -1 +1,3 @@ +export { db } from './prisma/db' + console.log('Hello via Bun!') diff --git a/packages/database/src/prisma/contract.d.ts b/packages/database/src/prisma/contract.d.ts index a2c1b30..12d6618 100644 --- a/packages/database/src/prisma/contract.d.ts +++ b/packages/database/src/prisma/contract.d.ts @@ -18,9 +18,8 @@ import type { } from '@prisma/orm-postgres/contract/types'; export type StorageHash = - StorageHashBase<'a51b4833fdaffe730572670ccc27dd89af7e0726ab3de7f428d21702d687cc15'>; -export type ExecutionHash = - ExecutionHashBase<'4e88564095b5e0ba7904ffdba3c563ef916d87688c8c483c67055f71a9194f0f'>; + StorageHashBase<'6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04'>; +export type ExecutionHash = ExecutionHashBase; export type ProfileHash = ProfileHashBase<'3916f444a8a17ad749191acf9e08dad97d1a327b88c2f1d45d12f240296aa8b2'>; @@ -234,112 +233,343 @@ type DefaultLiteralValue = CodecId extends keyo export type FieldOutputTypes = { readonly public: { - readonly Post: { - readonly authorId: CodecTypes['pg/int4@1']['output']; - readonly content: CodecTypes['pg/text@1']['output'] | null; - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['output']; - readonly id: CodecTypes['pg/int4@1']['output']; - readonly title: CodecTypes['pg/text@1']['output']; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['output']; + readonly Command: { + readonly command: CodecTypes['pg/text@1']['output']; + readonly error: CodecTypes['pg/text@1']['output'] | null; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly output: CodecTypes['pg/text@1']['output'] | null; + readonly pwd: CodecTypes['pg/text@1']['output']; + readonly sessionId: CodecTypes['pg/int8@1']['output']; + readonly stage: CodecTypes['pg/text@1']['output'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['output']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['output']; + readonly ip: CodecTypes['pg/text@1']['output']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['output'] | null; + readonly success: CodecTypes['pg/bool@1']['output']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userAgent: CodecTypes['pg/text@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output'] | null; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['output'] | null; + readonly containerName: CodecTypes['pg/text@1']['output'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly locale: CodecTypes['pg/text@1']['output']; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['output']; }; readonly User: { - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['output']; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; readonly email: CodecTypes['pg/text@1']['output']; - readonly id: CodecTypes['pg/int4@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly isGuest: CodecTypes['pg/bool@1']['output']; readonly name: CodecTypes['pg/text@1']['output'] | null; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['output']; - readonly username: CodecTypes['pg/text@1']['output'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly displayName: CodecTypes['pg/text@1']['output'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['output'] | null; + readonly oauthId: CodecTypes['pg/text@1']['output'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; }; }; }; export type FieldInputTypes = { readonly public: { - readonly Post: { - readonly authorId: CodecTypes['pg/int4@1']['input']; - readonly content: CodecTypes['pg/text@1']['input'] | null; - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['input']; - readonly id: CodecTypes['pg/int4@1']['input']; - readonly title: CodecTypes['pg/text@1']['input']; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['input']; + readonly Command: { + readonly command: CodecTypes['pg/text@1']['input']; + readonly error: CodecTypes['pg/text@1']['input'] | null; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly output: CodecTypes['pg/text@1']['input'] | null; + readonly pwd: CodecTypes['pg/text@1']['input']; + readonly sessionId: CodecTypes['pg/int8@1']['input']; + readonly stage: CodecTypes['pg/text@1']['input'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['input']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['input']; + readonly ip: CodecTypes['pg/text@1']['input']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['input'] | null; + readonly success: CodecTypes['pg/bool@1']['input']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userAgent: CodecTypes['pg/text@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input'] | null; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['input'] | null; + readonly containerName: CodecTypes['pg/text@1']['input'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly locale: CodecTypes['pg/text@1']['input']; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['input']; }; readonly User: { - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['input']; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; readonly email: CodecTypes['pg/text@1']['input']; - readonly id: CodecTypes['pg/int4@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly isGuest: CodecTypes['pg/bool@1']['input']; readonly name: CodecTypes['pg/text@1']['input'] | null; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['input']; - readonly username: CodecTypes['pg/text@1']['input'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly displayName: CodecTypes['pg/text@1']['input'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['input'] | null; + readonly oauthId: CodecTypes['pg/text@1']['input'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; }; }; }; export type StorageColumnTypes = { readonly public: { - readonly Post: { - readonly authorId: CodecTypes['pg/int4@1']['output']; - readonly content: CodecTypes['pg/text@1']['output'] | null; - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['output']; - readonly id: CodecTypes['pg/int4@1']['output']; - readonly title: CodecTypes['pg/text@1']['output']; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['output']; + readonly Command: { + readonly command: CodecTypes['pg/text@1']['output']; + readonly error: CodecTypes['pg/text@1']['output'] | null; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly output: CodecTypes['pg/text@1']['output'] | null; + readonly pwd: CodecTypes['pg/text@1']['output']; + readonly sessionId: CodecTypes['pg/int8@1']['output']; + readonly stage: CodecTypes['pg/text@1']['output'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['output']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['output']; + readonly ip: CodecTypes['pg/text@1']['output']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['output'] | null; + readonly success: CodecTypes['pg/bool@1']['output']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userAgent: CodecTypes['pg/text@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output'] | null; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['output'] | null; + readonly containerName: CodecTypes['pg/text@1']['output'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly locale: CodecTypes['pg/text@1']['output']; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['output']; }; readonly User: { - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['output']; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; readonly email: CodecTypes['pg/text@1']['output']; - readonly id: CodecTypes['pg/int4@1']['output']; + readonly id: CodecTypes['pg/int8@1']['output']; + readonly isGuest: CodecTypes['pg/bool@1']['output']; readonly name: CodecTypes['pg/text@1']['output'] | null; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['output']; - readonly username: CodecTypes['pg/text@1']['output'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly username: CodecTypes['pg/text@1']['output']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly displayName: CodecTypes['pg/text@1']['output'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['output'] | null; + readonly oauthId: CodecTypes['pg/text@1']['output'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + readonly quest: CodecTypes['pg/text@1']['output']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + readonly userId: CodecTypes['pg/int8@1']['output']; }; }; }; export type StorageColumnInputTypes = { readonly public: { - readonly Post: { - readonly authorId: CodecTypes['pg/int4@1']['input']; - readonly content: CodecTypes['pg/text@1']['input'] | null; - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['input']; - readonly id: CodecTypes['pg/int4@1']['input']; - readonly title: CodecTypes['pg/text@1']['input']; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['input']; + readonly Command: { + readonly command: CodecTypes['pg/text@1']['input']; + readonly error: CodecTypes['pg/text@1']['input'] | null; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly output: CodecTypes['pg/text@1']['input'] | null; + readonly pwd: CodecTypes['pg/text@1']['input']; + readonly sessionId: CodecTypes['pg/int8@1']['input']; + readonly stage: CodecTypes['pg/text@1']['input'] | null; + readonly timestamp: CodecTypes['pg/timestamptz-temporal@1']['input']; + }; + readonly LoginAttempt: { + readonly id: CodecTypes['pg/int8@1']['input']; + readonly ip: CodecTypes['pg/text@1']['input']; + readonly loginMethod: 'password' | 'google' | 'github'; + readonly message: CodecTypes['pg/text@1']['input'] | null; + readonly success: CodecTypes['pg/bool@1']['input']; + readonly time: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userAgent: CodecTypes['pg/text@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input'] | null; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly Session: { + readonly completedEvents: ReadonlyArray; + readonly containerId: CodecTypes['pg/text@1']['input'] | null; + readonly containerName: CodecTypes['pg/text@1']['input'] | null; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly graph: CodecTypes['pg/jsonb@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly locale: CodecTypes['pg/text@1']['input']; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly status: 'active' | 'finished' | 'inactive'; + readonly userId: CodecTypes['pg/int8@1']['input']; }; readonly User: { - readonly createdAt: CodecTypes['pg/timestamptz-string@1']['input']; + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; readonly email: CodecTypes['pg/text@1']['input']; - readonly id: CodecTypes['pg/int4@1']['input']; + readonly id: CodecTypes['pg/int8@1']['input']; + readonly isGuest: CodecTypes['pg/bool@1']['input']; readonly name: CodecTypes['pg/text@1']['input'] | null; - readonly updatedAt: CodecTypes['pg/timestamptz-string@1']['input']; - readonly username: CodecTypes['pg/text@1']['input'] | null; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly username: CodecTypes['pg/text@1']['input']; + }; + readonly UserLoginMethod: { + readonly createdAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly displayName: CodecTypes['pg/text@1']['input'] | null; + readonly hashedPassword: CodecTypes['pg/text@1']['input'] | null; + readonly oauthId: CodecTypes['pg/text@1']['input'] | null; + readonly type: 'password' | 'google' | 'github'; + readonly updatedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; + }; + readonly UserProgress: { + readonly finishedAt: CodecTypes['pg/timestamptz-temporal@1']['input'] | null; + readonly quest: CodecTypes['pg/text@1']['input']; + readonly startedAt: CodecTypes['pg/timestamptz-temporal@1']['input']; + readonly userId: CodecTypes['pg/int8@1']['input']; }; }; }; export namespace Models { - export type public_Post = { - authorId: CodecTypes['pg/int4@1']['output']; - content: CodecTypes['pg/text@1']['output'] | null; - createdAt: CodecTypes['pg/timestamptz-string@1']['output']; - id: CodecTypes['pg/int4@1']['output']; - title: CodecTypes['pg/text@1']['output']; - updatedAt: CodecTypes['pg/timestamptz-string@1']['output']; - author: public_User; - readonly [RelationKeys]?: 'author'; + export type public_Command = { + command: CodecTypes['pg/text@1']['output']; + error: CodecTypes['pg/text@1']['output'] | null; + id: CodecTypes['pg/int8@1']['output']; + output: CodecTypes['pg/text@1']['output'] | null; + pwd: CodecTypes['pg/text@1']['output']; + sessionId: CodecTypes['pg/int8@1']['output']; + stage: CodecTypes['pg/text@1']['output'] | null; + timestamp: CodecTypes['pg/timestamptz-temporal@1']['output']; + session: public_Session; + readonly [RelationKeys]?: 'session'; + }; + export type public_LoginAttempt = { + id: CodecTypes['pg/int8@1']['output']; + ip: CodecTypes['pg/text@1']['output']; + loginMethod: 'password' | 'google' | 'github'; + message: CodecTypes['pg/text@1']['output'] | null; + success: CodecTypes['pg/bool@1']['output']; + time: CodecTypes['pg/timestamptz-temporal@1']['output']; + userAgent: CodecTypes['pg/text@1']['output']; + userId: CodecTypes['pg/int8@1']['output'] | null; + username: CodecTypes['pg/text@1']['output']; + user: public_User | null; + readonly [RelationKeys]?: 'user'; + }; + export type public_Session = { + completedEvents: ReadonlyArray; + containerId: CodecTypes['pg/text@1']['output'] | null; + containerName: CodecTypes['pg/text@1']['output'] | null; + createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + graph: CodecTypes['pg/jsonb@1']['output']; + id: CodecTypes['pg/int8@1']['output']; + lastActivityAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + locale: CodecTypes['pg/text@1']['output']; + quest: CodecTypes['pg/text@1']['output']; + status: 'active' | 'finished' | 'inactive'; + userId: CodecTypes['pg/int8@1']['output']; + commands: public_Command[]; + user: public_User; + readonly [RelationKeys]?: 'commands' | 'user'; }; export type public_User = { - createdAt: CodecTypes['pg/timestamptz-string@1']['output']; + createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; email: CodecTypes['pg/text@1']['output']; - id: CodecTypes['pg/int4@1']['output']; + id: CodecTypes['pg/int8@1']['output']; + isGuest: CodecTypes['pg/bool@1']['output']; name: CodecTypes['pg/text@1']['output'] | null; - updatedAt: CodecTypes['pg/timestamptz-string@1']['output']; - username: CodecTypes['pg/text@1']['output'] | null; - posts: public_Post[]; - readonly [RelationKeys]?: 'posts'; + updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + username: CodecTypes['pg/text@1']['output']; + loginAttempts: public_LoginAttempt[]; + loginMethods: public_UserLoginMethod[]; + progress: public_UserProgress[]; + sessions: public_Session[]; + readonly [RelationKeys]?: 'loginAttempts' | 'loginMethods' | 'progress' | 'sessions'; + }; + export type public_UserLoginMethod = { + createdAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + displayName: CodecTypes['pg/text@1']['output'] | null; + hashedPassword: CodecTypes['pg/text@1']['output'] | null; + oauthId: CodecTypes['pg/text@1']['output'] | null; + type: 'password' | 'google' | 'github'; + updatedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + userId: CodecTypes['pg/int8@1']['output']; + user: public_User; + readonly [RelationKeys]?: 'user'; + }; + export type public_UserProgress = { + finishedAt: CodecTypes['pg/timestamptz-temporal@1']['output'] | null; + quest: CodecTypes['pg/text@1']['output']; + startedAt: CodecTypes['pg/timestamptz-temporal@1']['output']; + userId: CodecTypes['pg/int8@1']['output']; + user: public_User; + readonly [RelationKeys]?: 'user'; }; } export declare const models: { public: { - Post: Models.public_Post; + Command: Models.public_Command; + LoginAttempt: Models.public_LoginAttempt; + Session: Models.public_Session; User: Models.public_User; + UserLoginMethod: Models.public_UserLoginMethod; + UserProgress: Models.public_UserProgress; }; }; @@ -361,30 +591,23 @@ type ContractBase = Omit< readonly kind: 'postgres-schema'; readonly entries: { readonly table: { - readonly Post: { + readonly Command: { columns: { - readonly authorId: { - readonly dataType: 'pg/int4'; - readonly codecId: 'pg/int4@1'; + readonly command: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; readonly nullable: false; readonly many: false; }; - readonly content: { + readonly error: { readonly dataType: 'pg/text'; readonly codecId: 'pg/text@1'; readonly nullable: true; readonly many: false; }; - readonly createdAt: { - readonly dataType: 'pg/timestamptz'; - readonly codecId: 'pg/timestamptz-string@1'; - readonly nullable: false; - readonly default: { readonly kind: 'function'; readonly expression: 'now()' }; - readonly many: false; - }; readonly id: { - readonly dataType: 'pg/int4'; - readonly codecId: 'pg/int4@1'; + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; readonly nullable: false; readonly default: { readonly kind: 'function'; @@ -392,15 +615,33 @@ type ContractBase = Omit< }; readonly many: false; }; - readonly title: { + readonly output: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly pwd: { readonly dataType: 'pg/text'; readonly codecId: 'pg/text@1'; readonly nullable: false; readonly many: false; }; - readonly updatedAt: { + readonly sessionId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + readonly stage: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly timestamp: { readonly dataType: 'pg/timestamptz'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; readonly nullable: false; readonly many: false; }; @@ -409,9 +650,9 @@ type ContractBase = Omit< uniques: readonly []; indexes: readonly [ { - readonly name: 'Post_authorId_idx_e47547ed'; - readonly prefix: 'Post_authorId_idx'; - readonly columns: readonly ['authorId']; + readonly name: 'Command_sessionId_idx_29f415d4'; + readonly prefix: 'Command_sessionId_idx'; + readonly columns: readonly ['sessionId']; readonly unique: false; }, ]; @@ -419,8 +660,210 @@ type ContractBase = Omit< { readonly source: { readonly namespaceId: 'public' & NamespaceId; - readonly tableName: 'Post'; - readonly columns: readonly ['authorId']; + readonly tableName: 'Command'; + readonly columns: readonly ['sessionId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'Session'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly LoginAttempt: { + columns: { + readonly id: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly default: { + readonly kind: 'function'; + readonly expression: 'autoincrement()'; + }; + readonly many: false; + }; + readonly ip: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly loginMethod: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly message: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly success: { + readonly dataType: 'pg/bool'; + readonly codecId: 'pg/bool@1'; + readonly nullable: false; + readonly many: false; + }; + readonly time: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userAgent: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: true; + readonly many: false; + }; + readonly username: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['id'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'LoginAttempt_userId_idx_a489d58a'; + readonly prefix: 'LoginAttempt_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'LoginAttempt'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly Session: { + columns: { + readonly completedEvents: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: { readonly elementNullable: false }; + }; + readonly containerId: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly containerName: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly createdAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly finishedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: true; + readonly many: false; + }; + readonly graph: { + readonly dataType: 'pg/jsonb'; + readonly codecId: 'pg/jsonb@1'; + readonly nullable: false; + readonly many: false; + }; + readonly id: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly default: { + readonly kind: 'function'; + readonly expression: 'autoincrement()'; + }; + readonly many: false; + }; + readonly lastActivityAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly locale: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly quest: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly status: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['id'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'Session_userId_idx_a489d58a'; + readonly prefix: 'Session_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + { + readonly name: 'Session_userId_quest_idx_b13626bf'; + readonly prefix: 'Session_userId_quest_idx'; + readonly columns: readonly ['userId', 'quest']; + readonly unique: false; + }, + { + readonly name: 'Session_userId_status_idx_e4a128ba'; + readonly prefix: 'Session_userId_status_idx'; + readonly columns: readonly ['userId', 'status']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'Session'; + readonly columns: readonly ['userId']; }; readonly target: { readonly namespaceId: 'public' & NamespaceId; @@ -434,9 +877,8 @@ type ContractBase = Omit< columns: { readonly createdAt: { readonly dataType: 'pg/timestamptz'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; readonly nullable: false; - readonly default: { readonly kind: 'function'; readonly expression: 'now()' }; readonly many: false; }; readonly email: { @@ -446,8 +888,8 @@ type ContractBase = Omit< readonly many: false; }; readonly id: { - readonly dataType: 'pg/int4'; - readonly codecId: 'pg/int4@1'; + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; readonly nullable: false; readonly default: { readonly kind: 'function'; @@ -455,6 +897,12 @@ type ContractBase = Omit< }; readonly many: false; }; + readonly isGuest: { + readonly dataType: 'pg/bool'; + readonly codecId: 'pg/bool@1'; + readonly nullable: false; + readonly many: false; + }; readonly name: { readonly dataType: 'pg/text'; readonly codecId: 'pg/text@1'; @@ -463,22 +911,157 @@ type ContractBase = Omit< }; readonly updatedAt: { readonly dataType: 'pg/timestamptz'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; readonly nullable: false; readonly many: false; }; readonly username: { readonly dataType: 'pg/text'; readonly codecId: 'pg/text@1'; - readonly nullable: true; + readonly nullable: false; readonly many: false; }; }; primaryKey: { readonly columns: readonly ['id'] }; - uniques: readonly [{ readonly columns: readonly ['email'] }]; + uniques: readonly [ + { readonly columns: readonly ['email'] }, + { readonly columns: readonly ['username'] }, + ]; indexes: readonly []; foreignKeys: readonly []; }; + readonly UserLoginMethod: { + columns: { + readonly createdAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly displayName: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly hashedPassword: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly oauthId: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: true; + readonly many: false; + }; + readonly type: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly updatedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['userId', 'type'] }; + uniques: readonly [{ readonly columns: readonly ['type', 'oauthId'] }]; + indexes: readonly [ + { + readonly name: 'UserLoginMethod_userId_idx_a489d58a'; + readonly prefix: 'UserLoginMethod_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'UserLoginMethod'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + readonly UserProgress: { + columns: { + readonly finishedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: true; + readonly many: false; + }; + readonly quest: { + readonly dataType: 'pg/text'; + readonly codecId: 'pg/text@1'; + readonly nullable: false; + readonly many: false; + }; + readonly startedAt: { + readonly dataType: 'pg/timestamptz'; + readonly codecId: 'pg/timestamptz-temporal@1'; + readonly nullable: false; + readonly many: false; + }; + readonly userId: { + readonly dataType: 'pg/int8'; + readonly codecId: 'pg/int8@1'; + readonly nullable: false; + readonly many: false; + }; + }; + primaryKey: { readonly columns: readonly ['userId', 'quest'] }; + uniques: readonly []; + indexes: readonly [ + { + readonly name: 'UserProgress_userId_idx_a489d58a'; + readonly prefix: 'UserProgress_userId_idx'; + readonly columns: readonly ['userId']; + readonly unique: false; + }, + ]; + foreignKeys: readonly [ + { + readonly source: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'UserProgress'; + readonly columns: readonly ['userId']; + }; + readonly target: { + readonly namespaceId: 'public' & NamespaceId; + readonly tableName: 'User'; + readonly columns: readonly ['id']; + }; + }, + ]; + }; + }; + readonly valueSet: { + readonly LoginMethod: { + readonly kind: 'valueSet'; + readonly values: readonly ['password', 'google', 'github']; + }; + readonly SessionStatus: { + readonly kind: 'valueSet'; + readonly values: readonly ['active', 'finished', 'inactive']; + }; }; }; }; @@ -490,20 +1073,174 @@ type ContractBase = Omit< readonly target: 'postgres'; readonly targetFamily: 'sql'; readonly roots: { - readonly Post: { readonly namespace: 'public' & NamespaceId; readonly model: 'Post' }; + readonly Command: { readonly namespace: 'public' & NamespaceId; readonly model: 'Command' }; + readonly LoginAttempt: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'LoginAttempt'; + }; + readonly Session: { readonly namespace: 'public' & NamespaceId; readonly model: 'Session' }; readonly User: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly UserLoginMethod: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserLoginMethod'; + }; + readonly UserProgress: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserProgress'; + }; }; readonly domain: { readonly namespaces: { readonly public: { readonly models: { - readonly Post: { + readonly Command: { readonly fields: { - readonly authorId: { + readonly command: { readonly nullable: false; - readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int4@1' }; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; }; - readonly content: { + readonly error: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly id: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly output: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly pwd: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly sessionId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly stage: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly timestamp: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + }; + readonly relations: { + readonly session: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'Session'; + }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['sessionId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'Command'; + readonly namespaceId: 'public'; + readonly fields: { + readonly command: { readonly column: 'command' }; + readonly error: { readonly column: 'error' }; + readonly id: { readonly column: 'id' }; + readonly output: { readonly column: 'output' }; + readonly pwd: { readonly column: 'pwd' }; + readonly sessionId: { readonly column: 'sessionId' }; + readonly stage: { readonly column: 'stage' }; + readonly timestamp: { readonly column: 'timestamp' }; + }; + }; + }; + readonly LoginAttempt: { + readonly fields: { + readonly id: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly ip: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly loginMethod: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly message: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly success: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/bool@1' }; + }; + readonly time: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly userAgent: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly userId: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly username: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + }; + readonly relations: { + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: true; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'LoginAttempt'; + readonly namespaceId: 'public'; + readonly fields: { + readonly id: { readonly column: 'id' }; + readonly ip: { readonly column: 'ip' }; + readonly loginMethod: { readonly column: 'loginMethod' }; + readonly message: { readonly column: 'message' }; + readonly success: { readonly column: 'success' }; + readonly time: { readonly column: 'time' }; + readonly userAgent: { readonly column: 'userAgent' }; + readonly userId: { readonly column: 'userId' }; + readonly username: { readonly column: 'username' }; + }; + }; + }; + readonly Session: { + readonly fields: { + readonly completedEvents: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + readonly many: { readonly elementNullable: false }; + }; + readonly containerId: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly containerName: { readonly nullable: true; readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; }; @@ -511,46 +1248,86 @@ type ContractBase = Omit< readonly nullable: false; readonly type: { readonly kind: 'scalar'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; }; }; + readonly finishedAt: { + readonly nullable: true; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly graph: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/jsonb@1' }; + }; readonly id: { readonly nullable: false; - readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int4@1' }; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; }; - readonly title: { - readonly nullable: false; - readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; - }; - readonly updatedAt: { + readonly lastActivityAt: { readonly nullable: false; readonly type: { readonly kind: 'scalar'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; }; }; + readonly locale: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly quest: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly status: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly userId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; }; readonly relations: { - readonly author: { + readonly commands: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'Command'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['sessionId']; + }; + }; + readonly user: { readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; readonly cardinality: 'N:1'; readonly nullable: false; readonly on: { - readonly localFields: readonly ['authorId']; + readonly localFields: readonly ['userId']; readonly targetFields: readonly ['id']; }; }; }; readonly storage: { - readonly table: 'Post'; + readonly table: 'Session'; readonly namespaceId: 'public'; readonly fields: { - readonly authorId: { readonly column: 'authorId' }; - readonly content: { readonly column: 'content' }; + readonly completedEvents: { readonly column: 'completedEvents' }; + readonly containerId: { readonly column: 'containerId' }; + readonly containerName: { readonly column: 'containerName' }; readonly createdAt: { readonly column: 'createdAt' }; + readonly finishedAt: { readonly column: 'finishedAt' }; + readonly graph: { readonly column: 'graph' }; readonly id: { readonly column: 'id' }; - readonly title: { readonly column: 'title' }; - readonly updatedAt: { readonly column: 'updatedAt' }; + readonly lastActivityAt: { readonly column: 'lastActivityAt' }; + readonly locale: { readonly column: 'locale' }; + readonly quest: { readonly column: 'quest' }; + readonly status: { readonly column: 'status' }; + readonly userId: { readonly column: 'userId' }; }; }; }; @@ -560,7 +1337,7 @@ type ContractBase = Omit< readonly nullable: false; readonly type: { readonly kind: 'scalar'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; }; }; readonly email: { @@ -569,7 +1346,11 @@ type ContractBase = Omit< }; readonly id: { readonly nullable: false; - readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int4@1' }; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + readonly isGuest: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/bool@1' }; }; readonly name: { readonly nullable: true; @@ -579,21 +1360,57 @@ type ContractBase = Omit< readonly nullable: false; readonly type: { readonly kind: 'scalar'; - readonly codecId: 'pg/timestamptz-string@1'; + readonly codecId: 'pg/timestamptz-temporal@1'; }; }; readonly username: { - readonly nullable: true; + readonly nullable: false; readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; }; }; readonly relations: { - readonly posts: { - readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'Post' }; + readonly loginAttempts: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'LoginAttempt'; + }; readonly cardinality: '1:N'; readonly on: { readonly localFields: readonly ['id']; - readonly targetFields: readonly ['authorId']; + readonly targetFields: readonly ['userId']; + }; + }; + readonly loginMethods: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserLoginMethod'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; + }; + }; + readonly progress: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'UserProgress'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; + }; + }; + readonly sessions: { + readonly to: { + readonly namespace: 'public' & NamespaceId; + readonly model: 'Session'; + }; + readonly cardinality: '1:N'; + readonly on: { + readonly localFields: readonly ['id']; + readonly targetFields: readonly ['userId']; }; }; }; @@ -604,12 +1421,152 @@ type ContractBase = Omit< readonly createdAt: { readonly column: 'createdAt' }; readonly email: { readonly column: 'email' }; readonly id: { readonly column: 'id' }; + readonly isGuest: { readonly column: 'isGuest' }; readonly name: { readonly column: 'name' }; readonly updatedAt: { readonly column: 'updatedAt' }; readonly username: { readonly column: 'username' }; }; }; }; + readonly UserLoginMethod: { + readonly fields: { + readonly createdAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly displayName: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly hashedPassword: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly oauthId: { + readonly nullable: true; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly type: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly updatedAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly userId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + }; + readonly relations: { + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'UserLoginMethod'; + readonly namespaceId: 'public'; + readonly fields: { + readonly createdAt: { readonly column: 'createdAt' }; + readonly displayName: { readonly column: 'displayName' }; + readonly hashedPassword: { readonly column: 'hashedPassword' }; + readonly oauthId: { readonly column: 'oauthId' }; + readonly type: { readonly column: 'type' }; + readonly updatedAt: { readonly column: 'updatedAt' }; + readonly userId: { readonly column: 'userId' }; + }; + }; + }; + readonly UserProgress: { + readonly fields: { + readonly finishedAt: { + readonly nullable: true; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly quest: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/text@1' }; + }; + readonly startedAt: { + readonly nullable: false; + readonly type: { + readonly kind: 'scalar'; + readonly codecId: 'pg/timestamptz-temporal@1'; + }; + }; + readonly userId: { + readonly nullable: false; + readonly type: { readonly kind: 'scalar'; readonly codecId: 'pg/int8@1' }; + }; + }; + readonly relations: { + readonly user: { + readonly to: { readonly namespace: 'public' & NamespaceId; readonly model: 'User' }; + readonly cardinality: 'N:1'; + readonly nullable: false; + readonly on: { + readonly localFields: readonly ['userId']; + readonly targetFields: readonly ['id']; + }; + }; + }; + readonly storage: { + readonly table: 'UserProgress'; + readonly namespaceId: 'public'; + readonly fields: { + readonly finishedAt: { readonly column: 'finishedAt' }; + readonly quest: { readonly column: 'quest' }; + readonly startedAt: { readonly column: 'startedAt' }; + readonly userId: { readonly column: 'userId' }; + }; + }; + }; + }; + readonly enum: { + readonly LoginMethod: { + readonly codecId: 'pg/text@1'; + readonly members: readonly [ + { readonly name: 'Password'; readonly value: 'password' }, + { readonly name: 'Google'; readonly value: 'google' }, + { readonly name: 'GitHub'; readonly value: 'github' }, + ]; + }; + readonly SessionStatus: { + readonly codecId: 'pg/text@1'; + readonly members: readonly [ + { readonly name: 'Active'; readonly value: 'active' }, + { readonly name: 'Finished'; readonly value: 'finished' }, + { readonly name: 'Inactive'; readonly value: 'inactive' }, + ]; + }; + }; + readonly enumMemberTypes?: { + readonly LoginMethod: readonly [ + { readonly name: 'Password'; readonly value: 'password' }, + { readonly name: 'Google'; readonly value: 'google' }, + { readonly name: 'GitHub'; readonly value: 'github' }, + ]; + readonly SessionStatus: readonly [ + { readonly name: 'Active'; readonly value: 'active' }, + { readonly name: 'Finished'; readonly value: 'finished' }, + { readonly name: 'Inactive'; readonly value: 'inactive' }, + ]; }; }; }; @@ -642,31 +1599,6 @@ type ContractBase = Omit< }; }; readonly extensions: {}; - readonly execution: { - readonly executionHash: ExecutionHash; - readonly mutations: { - readonly defaults: readonly [ - { - readonly onCreate: { readonly id: 'timestampNow'; readonly kind: 'generator' }; - readonly onUpdate: { readonly id: 'timestampNow'; readonly kind: 'generator' }; - readonly ref: { - readonly entry: 'Post'; - readonly field: 'updatedAt'; - readonly namespace: 'public'; - }; - }, - { - readonly onCreate: { readonly id: 'timestampNow'; readonly kind: 'generator' }; - readonly onUpdate: { readonly id: 'timestampNow'; readonly kind: 'generator' }; - readonly ref: { - readonly entry: 'User'; - readonly field: 'updatedAt'; - readonly namespace: 'public'; - }; - }, - ]; - }; - }; readonly meta: {}; readonly profileHash: ProfileHash; diff --git a/packages/database/src/prisma/contract.json b/packages/database/src/prisma/contract.json index a6f6ca7..389a7bb 100644 --- a/packages/database/src/prisma/contract.json +++ b/packages/database/src/prisma/contract.json @@ -4,71 +4,258 @@ "target": "postgres", "profileHash": "3916f444a8a17ad749191acf9e08dad97d1a327b88c2f1d45d12f240296aa8b2", "roots": { - "Post": { - "model": "Post", + "Command": { + "model": "Command", + "namespace": "public" + }, + "LoginAttempt": { + "model": "LoginAttempt", + "namespace": "public" + }, + "Session": { + "model": "Session", "namespace": "public" }, "User": { "model": "User", "namespace": "public" + }, + "UserLoginMethod": { + "model": "UserLoginMethod", + "namespace": "public" + }, + "UserProgress": { + "model": "UserProgress", + "namespace": "public" } }, "domain": { "namespaces": { "public": { + "enum": { + "LoginMethod": { + "codecId": "pg/text@1", + "members": [ + { + "name": "Password", + "value": "password" + }, + { + "name": "Google", + "value": "google" + }, + { + "name": "GitHub", + "value": "github" + } + ] + }, + "SessionStatus": { + "codecId": "pg/text@1", + "members": [ + { + "name": "Active", + "value": "active" + }, + { + "name": "Finished", + "value": "finished" + }, + { + "name": "Inactive", + "value": "inactive" + } + ] + } + }, "models": { - "Post": { + "Command": { "fields": { - "authorId": { + "command": { "nullable": false, "type": { - "codecId": "pg/int4@1", + "codecId": "pg/text@1", "kind": "scalar" } }, - "content": { + "error": { "nullable": true, "type": { "codecId": "pg/text@1", "kind": "scalar" } }, - "createdAt": { - "nullable": false, - "type": { - "codecId": "pg/timestamptz-string@1", - "kind": "scalar" - } - }, "id": { "nullable": false, "type": { - "codecId": "pg/int4@1", + "codecId": "pg/int8@1", "kind": "scalar" } }, - "title": { + "output": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "pwd": { "nullable": false, "type": { "codecId": "pg/text@1", "kind": "scalar" } }, - "updatedAt": { + "sessionId": { "nullable": false, "type": { - "codecId": "pg/timestamptz-string@1", + "codecId": "pg/int8@1", + "kind": "scalar" + } + }, + "stage": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "timestamp": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", "kind": "scalar" } } }, "relations": { - "author": { + "session": { "cardinality": "N:1", "nullable": false, "on": { "localFields": [ - "authorId" + "sessionId" + ], + "targetFields": [ + "id" + ] + }, + "to": { + "model": "Session", + "namespace": "public" + } + } + }, + "storage": { + "fields": { + "command": { + "column": "command" + }, + "error": { + "column": "error" + }, + "id": { + "column": "id" + }, + "output": { + "column": "output" + }, + "pwd": { + "column": "pwd" + }, + "sessionId": { + "column": "sessionId" + }, + "stage": { + "column": "stage" + }, + "timestamp": { + "column": "timestamp" + } + }, + "namespaceId": "public", + "table": "Command" + } + }, + "LoginAttempt": { + "fields": { + "id": { + "nullable": false, + "type": { + "codecId": "pg/int8@1", + "kind": "scalar" + } + }, + "ip": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "loginMethod": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + }, + "valueSet": { + "entityKind": "enum", + "entityName": "LoginMethod", + "namespaceId": "public", + "plane": "domain" + } + }, + "message": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "success": { + "nullable": false, + "type": { + "codecId": "pg/bool@1", + "kind": "scalar" + } + }, + "time": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "userAgent": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "userId": { + "nullable": true, + "type": { + "codecId": "pg/int8@1", + "kind": "scalar" + } + }, + "username": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + } + }, + "relations": { + "user": { + "cardinality": "N:1", + "nullable": true, + "on": { + "localFields": [ + "userId" ], "targetFields": [ "id" @@ -82,27 +269,208 @@ }, "storage": { "fields": { - "authorId": { - "column": "authorId" + "id": { + "column": "id" }, - "content": { - "column": "content" + "ip": { + "column": "ip" + }, + "loginMethod": { + "column": "loginMethod" + }, + "message": { + "column": "message" + }, + "success": { + "column": "success" + }, + "time": { + "column": "time" + }, + "userAgent": { + "column": "userAgent" + }, + "userId": { + "column": "userId" + }, + "username": { + "column": "username" + } + }, + "namespaceId": "public", + "table": "LoginAttempt" + } + }, + "Session": { + "fields": { + "completedEvents": { + "many": { + "elementNullable": false + }, + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "containerId": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "containerName": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "createdAt": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "finishedAt": { + "nullable": true, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "graph": { + "nullable": false, + "type": { + "codecId": "pg/jsonb@1", + "kind": "scalar" + } + }, + "id": { + "nullable": false, + "type": { + "codecId": "pg/int8@1", + "kind": "scalar" + } + }, + "lastActivityAt": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "locale": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "quest": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "status": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + }, + "valueSet": { + "entityKind": "enum", + "entityName": "SessionStatus", + "namespaceId": "public", + "plane": "domain" + } + }, + "userId": { + "nullable": false, + "type": { + "codecId": "pg/int8@1", + "kind": "scalar" + } + } + }, + "relations": { + "commands": { + "cardinality": "1:N", + "on": { + "localFields": [ + "id" + ], + "targetFields": [ + "sessionId" + ] + }, + "to": { + "model": "Command", + "namespace": "public" + } + }, + "user": { + "cardinality": "N:1", + "nullable": false, + "on": { + "localFields": [ + "userId" + ], + "targetFields": [ + "id" + ] + }, + "to": { + "model": "User", + "namespace": "public" + } + } + }, + "storage": { + "fields": { + "completedEvents": { + "column": "completedEvents" + }, + "containerId": { + "column": "containerId" + }, + "containerName": { + "column": "containerName" }, "createdAt": { "column": "createdAt" }, + "finishedAt": { + "column": "finishedAt" + }, + "graph": { + "column": "graph" + }, "id": { "column": "id" }, - "title": { - "column": "title" + "lastActivityAt": { + "column": "lastActivityAt" }, - "updatedAt": { - "column": "updatedAt" + "locale": { + "column": "locale" + }, + "quest": { + "column": "quest" + }, + "status": { + "column": "status" + }, + "userId": { + "column": "userId" } }, "namespaceId": "public", - "table": "Post" + "table": "Session" } }, "User": { @@ -110,7 +478,7 @@ "createdAt": { "nullable": false, "type": { - "codecId": "pg/timestamptz-string@1", + "codecId": "pg/timestamptz-temporal@1", "kind": "scalar" } }, @@ -124,7 +492,14 @@ "id": { "nullable": false, "type": { - "codecId": "pg/int4@1", + "codecId": "pg/int8@1", + "kind": "scalar" + } + }, + "isGuest": { + "nullable": false, + "type": { + "codecId": "pg/bool@1", "kind": "scalar" } }, @@ -138,12 +513,12 @@ "updatedAt": { "nullable": false, "type": { - "codecId": "pg/timestamptz-string@1", + "codecId": "pg/timestamptz-temporal@1", "kind": "scalar" } }, "username": { - "nullable": true, + "nullable": false, "type": { "codecId": "pg/text@1", "kind": "scalar" @@ -151,18 +526,63 @@ } }, "relations": { - "posts": { + "loginAttempts": { "cardinality": "1:N", "on": { "localFields": [ "id" ], "targetFields": [ - "authorId" + "userId" ] }, "to": { - "model": "Post", + "model": "LoginAttempt", + "namespace": "public" + } + }, + "loginMethods": { + "cardinality": "1:N", + "on": { + "localFields": [ + "id" + ], + "targetFields": [ + "userId" + ] + }, + "to": { + "model": "UserLoginMethod", + "namespace": "public" + } + }, + "progress": { + "cardinality": "1:N", + "on": { + "localFields": [ + "id" + ], + "targetFields": [ + "userId" + ] + }, + "to": { + "model": "UserProgress", + "namespace": "public" + } + }, + "sessions": { + "cardinality": "1:N", + "on": { + "localFields": [ + "id" + ], + "targetFields": [ + "userId" + ] + }, + "to": { + "model": "Session", "namespace": "public" } } @@ -178,6 +598,9 @@ "id": { "column": "id" }, + "isGuest": { + "column": "isGuest" + }, "name": { "column": "name" }, @@ -191,6 +614,178 @@ "namespaceId": "public", "table": "User" } + }, + "UserLoginMethod": { + "fields": { + "createdAt": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "displayName": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "hashedPassword": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "oauthId": { + "nullable": true, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "type": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + }, + "valueSet": { + "entityKind": "enum", + "entityName": "LoginMethod", + "namespaceId": "public", + "plane": "domain" + } + }, + "updatedAt": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "userId": { + "nullable": false, + "type": { + "codecId": "pg/int8@1", + "kind": "scalar" + } + } + }, + "relations": { + "user": { + "cardinality": "N:1", + "nullable": false, + "on": { + "localFields": [ + "userId" + ], + "targetFields": [ + "id" + ] + }, + "to": { + "model": "User", + "namespace": "public" + } + } + }, + "storage": { + "fields": { + "createdAt": { + "column": "createdAt" + }, + "displayName": { + "column": "displayName" + }, + "hashedPassword": { + "column": "hashedPassword" + }, + "oauthId": { + "column": "oauthId" + }, + "type": { + "column": "type" + }, + "updatedAt": { + "column": "updatedAt" + }, + "userId": { + "column": "userId" + } + }, + "namespaceId": "public", + "table": "UserLoginMethod" + } + }, + "UserProgress": { + "fields": { + "finishedAt": { + "nullable": true, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "quest": { + "nullable": false, + "type": { + "codecId": "pg/text@1", + "kind": "scalar" + } + }, + "startedAt": { + "nullable": false, + "type": { + "codecId": "pg/timestamptz-temporal@1", + "kind": "scalar" + } + }, + "userId": { + "nullable": false, + "type": { + "codecId": "pg/int8@1", + "kind": "scalar" + } + } + }, + "relations": { + "user": { + "cardinality": "N:1", + "nullable": false, + "on": { + "localFields": [ + "userId" + ], + "targetFields": [ + "id" + ] + }, + "to": { + "model": "User", + "namespace": "public" + } + } + }, + "storage": { + "fields": { + "finishedAt": { + "column": "finishedAt" + }, + "quest": { + "column": "quest" + }, + "startedAt": { + "column": "startedAt" + }, + "userId": { + "column": "userId" + } + }, + "namespaceId": "public", + "table": "UserProgress" + } } } } @@ -201,43 +796,49 @@ "public": { "entries": { "table": { - "Post": { + "Command": { "columns": { - "authorId": { - "codecId": "pg/int4@1", - "dataType": "pg/int4", + "command": { + "codecId": "pg/text@1", + "dataType": "pg/text", "nullable": false }, - "content": { + "error": { "codecId": "pg/text@1", "dataType": "pg/text", "nullable": true }, - "createdAt": { - "codecId": "pg/timestamptz-string@1", - "dataType": "pg/timestamptz", - "default": { - "expression": "now()", - "kind": "function" - }, - "nullable": false - }, "id": { - "codecId": "pg/int4@1", - "dataType": "pg/int4", + "codecId": "pg/int8@1", + "dataType": "pg/int8", "default": { "expression": "autoincrement()", "kind": "function" }, "nullable": false }, - "title": { + "output": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "pwd": { "codecId": "pg/text@1", "dataType": "pg/text", "nullable": false }, - "updatedAt": { - "codecId": "pg/timestamptz-string@1", + "sessionId": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "nullable": false + }, + "stage": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "timestamp": { + "codecId": "pg/timestamptz-temporal@1", "dataType": "pg/timestamptz", "nullable": false } @@ -245,14 +846,117 @@ "foreignKeys": [ { "index": { - "name": "Post_authorId_idx_e47547ed" + "name": "Command_sessionId_idx_29f415d4" }, "source": { "columns": [ - "authorId" + "sessionId" ], "namespaceId": "public", - "tableName": "Post" + "tableName": "Command" + }, + "target": { + "columns": [ + "id" + ], + "namespaceId": "public", + "tableName": "Session" + } + } + ], + "indexes": [ + { + "columns": [ + "sessionId" + ], + "name": "Command_sessionId_idx_29f415d4", + "prefix": "Command_sessionId_idx", + "unique": false + } + ], + "primaryKey": { + "columns": [ + "id" + ] + }, + "uniques": [] + }, + "LoginAttempt": { + "checks": [ + { + "expression": "\"loginMethod\" IN ('password', 'google', 'github')", + "name": "LoginAttempt_loginMethod_check_f8485f11", + "prefix": "LoginAttempt_loginMethod_check" + } + ], + "columns": { + "id": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "default": { + "expression": "autoincrement()", + "kind": "function" + }, + "nullable": false + }, + "ip": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false + }, + "loginMethod": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false, + "valueSet": { + "entityKind": "valueSet", + "entityName": "LoginMethod", + "namespaceId": "public", + "plane": "storage" + } + }, + "message": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "success": { + "codecId": "pg/bool@1", + "dataType": "pg/bool", + "nullable": false + }, + "time": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": false + }, + "userAgent": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false + }, + "userId": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "nullable": true + }, + "username": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false + } + }, + "foreignKeys": [ + { + "index": { + "name": "LoginAttempt_userId_idx_a489d58a" + }, + "source": { + "columns": [ + "userId" + ], + "namespaceId": "public", + "tableName": "LoginAttempt" }, "target": { "columns": [ @@ -266,10 +970,154 @@ "indexes": [ { "columns": [ - "authorId" + "userId" ], - "name": "Post_authorId_idx_e47547ed", - "prefix": "Post_authorId_idx", + "name": "LoginAttempt_userId_idx_a489d58a", + "prefix": "LoginAttempt_userId_idx", + "unique": false + } + ], + "primaryKey": { + "columns": [ + "id" + ] + }, + "uniques": [] + }, + "Session": { + "checks": [ + { + "expression": "array_position(\"completedEvents\", NULL) IS NULL", + "name": "Session_completedEvents_elem_not_null_b55d23f4", + "prefix": "Session_completedEvents_elem_not_null" + }, + { + "expression": "\"status\" IN ('active', 'finished', 'inactive')", + "name": "Session_status_check_8fa5bbc6", + "prefix": "Session_status_check" + } + ], + "columns": { + "completedEvents": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "many": { + "elementNullable": false + }, + "nullable": false + }, + "containerId": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "containerName": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "createdAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": false + }, + "finishedAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": true + }, + "graph": { + "codecId": "pg/jsonb@1", + "dataType": "pg/jsonb", + "nullable": false + }, + "id": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "default": { + "expression": "autoincrement()", + "kind": "function" + }, + "nullable": false + }, + "lastActivityAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": false + }, + "locale": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false + }, + "quest": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false + }, + "status": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false, + "valueSet": { + "entityKind": "valueSet", + "entityName": "SessionStatus", + "namespaceId": "public", + "plane": "storage" + } + }, + "userId": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "nullable": false + } + }, + "foreignKeys": [ + { + "index": { + "name": "Session_userId_idx_a489d58a" + }, + "source": { + "columns": [ + "userId" + ], + "namespaceId": "public", + "tableName": "Session" + }, + "target": { + "columns": [ + "id" + ], + "namespaceId": "public", + "tableName": "User" + } + } + ], + "indexes": [ + { + "columns": [ + "userId" + ], + "name": "Session_userId_idx_a489d58a", + "prefix": "Session_userId_idx", + "unique": false + }, + { + "columns": [ + "userId", + "quest" + ], + "name": "Session_userId_quest_idx_b13626bf", + "prefix": "Session_userId_quest_idx", + "unique": false + }, + { + "columns": [ + "userId", + "status" + ], + "name": "Session_userId_status_idx_e4a128ba", + "prefix": "Session_userId_status_idx", "unique": false } ], @@ -283,12 +1131,8 @@ "User": { "columns": { "createdAt": { - "codecId": "pg/timestamptz-string@1", + "codecId": "pg/timestamptz-temporal@1", "dataType": "pg/timestamptz", - "default": { - "expression": "now()", - "kind": "function" - }, "nullable": false }, "email": { @@ -297,28 +1141,33 @@ "nullable": false }, "id": { - "codecId": "pg/int4@1", - "dataType": "pg/int4", + "codecId": "pg/int8@1", + "dataType": "pg/int8", "default": { "expression": "autoincrement()", "kind": "function" }, "nullable": false }, + "isGuest": { + "codecId": "pg/bool@1", + "dataType": "pg/bool", + "nullable": false + }, "name": { "codecId": "pg/text@1", "dataType": "pg/text", "nullable": true }, "updatedAt": { - "codecId": "pg/timestamptz-string@1", + "codecId": "pg/timestamptz-temporal@1", "dataType": "pg/timestamptz", "nullable": false }, "username": { "codecId": "pg/text@1", "dataType": "pg/text", - "nullable": true + "nullable": false } }, "foreignKeys": [], @@ -333,8 +1182,190 @@ "columns": [ "email" ] + }, + { + "columns": [ + "username" + ] } ] + }, + "UserLoginMethod": { + "checks": [ + { + "expression": "\"type\" IN ('password', 'google', 'github')", + "name": "UserLoginMethod_type_check_6814314f", + "prefix": "UserLoginMethod_type_check" + } + ], + "columns": { + "createdAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": false + }, + "displayName": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "hashedPassword": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "oauthId": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": true + }, + "type": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false, + "valueSet": { + "entityKind": "valueSet", + "entityName": "LoginMethod", + "namespaceId": "public", + "plane": "storage" + } + }, + "updatedAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": false + }, + "userId": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "nullable": false + } + }, + "foreignKeys": [ + { + "index": { + "name": "UserLoginMethod_userId_idx_a489d58a" + }, + "source": { + "columns": [ + "userId" + ], + "namespaceId": "public", + "tableName": "UserLoginMethod" + }, + "target": { + "columns": [ + "id" + ], + "namespaceId": "public", + "tableName": "User" + } + } + ], + "indexes": [ + { + "columns": [ + "userId" + ], + "name": "UserLoginMethod_userId_idx_a489d58a", + "prefix": "UserLoginMethod_userId_idx", + "unique": false + } + ], + "primaryKey": { + "columns": [ + "userId", + "type" + ] + }, + "uniques": [ + { + "columns": [ + "type", + "oauthId" + ] + } + ] + }, + "UserProgress": { + "columns": { + "finishedAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": true + }, + "quest": { + "codecId": "pg/text@1", + "dataType": "pg/text", + "nullable": false + }, + "startedAt": { + "codecId": "pg/timestamptz-temporal@1", + "dataType": "pg/timestamptz", + "nullable": false + }, + "userId": { + "codecId": "pg/int8@1", + "dataType": "pg/int8", + "nullable": false + } + }, + "foreignKeys": [ + { + "index": { + "name": "UserProgress_userId_idx_a489d58a" + }, + "source": { + "columns": [ + "userId" + ], + "namespaceId": "public", + "tableName": "UserProgress" + }, + "target": { + "columns": [ + "id" + ], + "namespaceId": "public", + "tableName": "User" + } + } + ], + "indexes": [ + { + "columns": [ + "userId" + ], + "name": "UserProgress_userId_idx_a489d58a", + "prefix": "UserProgress_userId_idx", + "unique": false + } + ], + "primaryKey": { + "columns": [ + "userId", + "quest" + ] + }, + "uniques": [] + } + }, + "valueSet": { + "LoginMethod": { + "kind": "valueSet", + "values": [ + "password", + "google", + "github" + ] + }, + "SessionStatus": { + "kind": "valueSet", + "values": [ + "active", + "finished", + "inactive" + ] } } }, @@ -342,44 +1373,7 @@ "kind": "postgres-schema" } }, - "storageHash": "a51b4833fdaffe730572670ccc27dd89af7e0726ab3de7f428d21702d687cc15" - }, - "execution": { - "executionHash": "4e88564095b5e0ba7904ffdba3c563ef916d87688c8c483c67055f71a9194f0f", - "mutations": { - "defaults": [ - { - "onCreate": { - "id": "timestampNow", - "kind": "generator" - }, - "onUpdate": { - "id": "timestampNow", - "kind": "generator" - }, - "ref": { - "entry": "Post", - "field": "updatedAt", - "namespace": "public" - } - }, - { - "onCreate": { - "id": "timestampNow", - "kind": "generator" - }, - "onUpdate": { - "id": "timestampNow", - "kind": "generator" - }, - "ref": { - "entry": "User", - "field": "updatedAt", - "namespace": "public" - } - } - ] - } + "storageHash": "6fecb00f7a40489f8c1a9a4dad506cc6d4b95789cbb32519634132f006530c04" }, "capabilities": { "postgres": { diff --git a/packages/database/src/prisma/contract.prisma b/packages/database/src/prisma/contract.prisma index 2d11c7b..8477ad0 100644 --- a/packages/database/src/prisma/contract.prisma +++ b/packages/database/src/prisma/contract.prisma @@ -1,21 +1,102 @@ // use prisma-8 - model User { - id Int @id @default(autoincrement()) - email String @unique - username String? - name String? - posts Post[] - createdAt TimestamptzString @default(now()) - updatedAt temporal.updatedAtString() + id BigInt @id @default(autoincrement()) + email String @unique + username String @unique + name String? + createdAt DateTime + updatedAt DateTime + isGuest Boolean + + loginMethods UserLoginMethod[] + progress UserProgress[] + sessions Session[] + loginAttempts LoginAttempt[] } -model Post { - id Int @id @default(autoincrement()) - title String - content String? - author User @relation(fields: [authorId], references: [id]) - authorId Int - createdAt TimestamptzString @default(now()) - updatedAt temporal.updatedAtString() +enum LoginMethod { + @@type("pg/text@1") + Password = "password" + Google = "google" + GitHub = "github" +} + +// User login using one of the login method +model UserLoginMethod { + type LoginMethod + userId BigInt + createdAt DateTime + updatedAt DateTime + hashedPassword String? + oauthId String? + displayName String? + + @@id([userId, type]) + @@unique([type, oauthId]) + user User @relation(fields: [userId], references: [id]) +} + +// Store what quest a user has completed +model UserProgress { + userId BigInt + quest String + startedAt DateTime + finishedAt DateTime? + user User @relation(fields: [userId], references: [id]) + + @@id([userId, quest]) +} + +enum SessionStatus { + @@type("pg/text@1") + Active = "active" + Finished = "finished" + Inactive = "inactive" +} + +model Session { + id BigInt @id @default(autoincrement()) + userId BigInt + quest String + locale String + containerId String? + containerName String? + status SessionStatus + createdAt DateTime + lastActivityAt DateTime + finishedAt DateTime? + completedEvents String[] + graph Jsonb + user User @relation(fields: [userId], references: [id]) + commands Command[] + + @@index([userId, quest]) + @@index([userId, status]) +} + +model Command { + id BigInt @id @default(autoincrement()) + sessionId BigInt + timestamp DateTime + pwd String + command String + output String? + error String? + stage String? + session Session @relation(fields: [sessionId], references: [id]) + + @@index([sessionId]) +} + +model LoginAttempt { + id BigInt @id @default(autoincrement()) + username String + userId BigInt? + ip String + loginMethod LoginMethod + userAgent String + time DateTime + success Boolean + message String? + user User? @relation(fields: [userId], references: [id]) } diff --git a/packages/database/src/prisma/db.ts b/packages/database/src/prisma/db.ts index a3cd91d..0fe7d3e 100644 --- a/packages/database/src/prisma/db.ts +++ b/packages/database/src/prisma/db.ts @@ -1,9 +1,9 @@ -import 'dotenv/config'; -import postgres from '@prisma/orm-postgres/runtime'; -import type { Contract } from './contract.d'; -import contractJson from './contract.json' with { type: 'json' }; +import 'dotenv/config' +import postgres from '@prisma/orm-postgres/runtime' +import type { Contract } from './contract.d' +import contractJson from './contract.json' with { type: 'json' } export const db = postgres({ contractJson, url: process.env['DATABASE_URL']!, -}); +}) diff --git a/server/package.json b/server/package.json index b42e9bc..9254750 100644 --- a/server/package.json +++ b/server/package.json @@ -15,6 +15,7 @@ "@odyssey/game": "workspace:*", "@odyssey/models": "workspace:*", "@odyssey/utils": "workspace:*", + "@odyssey/database": "workspace:*", "@trpc/server": "^11.8.0", "bcrypt": "^5.1.1", "commander": "^11.0.0", diff --git a/server/src/index.ts b/server/src/index.ts index 68a6531..f6ee8ac 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -6,6 +6,7 @@ import swaggerUI from 'swagger-ui-express' import passport from 'passport' import * as trpcExpress from '@trpc/server/adapters/express' import { connectDB } from '@odyssey/models' +import { db } from '@odyssey/database' import './auth/passport.js' import socketServer from './api/socket.js' @@ -22,6 +23,7 @@ import { appRouter } from './routers/index.js' import { createContext } from './trpc.js' async function main() { + console.log(db) if (!config.secret) { logger.error( 'No SECRET_KEY found in .env! To set up a persistent key, please run `bun run setup`:'