- Deleted contact router and its associated mail functionality. - Removed addEvent mutation from event_queue router. - Cleaned up fatture router by removing createClient and getListClienti procedures. - Commented out deletePrezziario mutation in prezziario router. - Removed unused procedures in servizio router, including getServizioOrdini and getPreOnboardData. - Cleaned up stats router by removing commented-out code. - Updated stripe router to restrict health check to admin users and changed several public procedures to protected. - Commented out sync router procedures and related types. - Removed unused client-related functions in fic controller. - Cleaned up servizio controller by removing getServizioOrdini and commented-out code. - Refactored auth service to inline pwResetTokenFromMailHandler logic. - Commented out deletePrezziario function in prezziario service. - Cleaned up zod types by commenting out unused types. - Commented out getMessagesArray function in kysely helper.
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import { isValid } from "date-fns";
|
|
import { expressionBuilder } from "kysely";
|
|
import { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/postgres";
|
|
import type Database from "~/schemas/Database";
|
|
import type { UsersId } from "~/schemas/public/Users";
|
|
// export function getMessagesArray() {
|
|
// const eb = expressionBuilder<Database, "chats">();
|
|
// return jsonArrayFrom(
|
|
// eb
|
|
// .selectFrom("messages")
|
|
// .selectAll("messages")
|
|
// .whereRef("messages.chatid", "=", "chats.chatid")
|
|
// .leftJoin("users", "users.id", "messages.sender")
|
|
// .select(["users.nome as sender_nome", "users.isAdmin as sender_isAdmin"])
|
|
// .orderBy("messages.time", "asc"),
|
|
// ).as("messagesArray");
|
|
// }
|
|
export type UserInfoQueryType = {
|
|
id: UsersId;
|
|
username: string;
|
|
email: string;
|
|
nome: string | null;
|
|
};
|
|
|
|
export function getUserInfo() {
|
|
const eb = expressionBuilder<Database, "chats">();
|
|
return jsonObjectFrom(
|
|
eb
|
|
.selectFrom("users")
|
|
.select(["id", "username", "email", "nome"])
|
|
.whereRef("users.id", "=", "chats.user_ref"),
|
|
).as("userinfo");
|
|
}
|
|
|
|
export function withImages() {
|
|
const eb = expressionBuilder<Database, "annunci">();
|
|
return jsonArrayFrom(
|
|
eb
|
|
.selectFrom("images_refs")
|
|
.select(["img", "thumb"])
|
|
.whereRef("images_refs.codice", "=", "annunci.codice")
|
|
.orderBy("images_refs.ordine", "asc"),
|
|
).as("images");
|
|
}
|
|
|
|
export function withVideos() {
|
|
const eb = expressionBuilder<Database, "annunci">();
|
|
return jsonArrayFrom(
|
|
eb
|
|
.selectFrom("videos_refs")
|
|
.select(["video", "thumb"])
|
|
.whereRef("videos_refs.codice", "=", "annunci.codice")
|
|
.orderBy("videos_refs.ordine", "asc"),
|
|
).as("videos");
|
|
}
|
|
|
|
export function parseNullableDateString(str: string | null): Date | null {
|
|
if (str === null) {
|
|
return null;
|
|
}
|
|
const date = new Date(str);
|
|
return isValid(date) ? date : null;
|
|
}
|