feat: add Zod schemas for various entities and update API routes
- Introduced Zod schemas for validation in the following entities: - Provincie - Ratelimiter - Rinnovi - Servizio - ServizioAnnunci - ServizioInteressi - TestiEStringhe - Users - UserEtichette - UserInvites - UsersAnagrafica - UsersStorage - VideosRefs - StatusConfermaEnum - TipologiaPosizioneEnum - Updated API routes in `catasto.ts` to include CRUD operations for Comuni, Nazioni, and Provincie with appropriate input validation. - Enhanced controller methods in `catasto.controller.ts` to handle create, edit, and delete operations for Comuni and Nazioni. - Added new utility Zod types for ComuniId, NazioniId, and ProvincieId. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
8f28b7bba3
commit
d17ac87917
47 changed files with 2644 additions and 97 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const { makeKyselyHook } = require("kanel-kysely");
|
||||
const { makePgTsGenerator } = require("kanel");
|
||||
const { generateZodSchemas, makeGenerateZodSchemas } = require("kanel-zod");
|
||||
const ignoredTables = ["schema_migrations"];
|
||||
|
||||
/**
|
||||
|
|
@ -42,6 +43,62 @@ const specificTypes = (mappings) => {
|
|||
};
|
||||
}
|
||||
|
||||
const kanelZodCastRegex = /as unknown as z.Schema<(.*?)(Mutator|Initializer)>/;
|
||||
const zodItemInitializer = /^export const \w+ = z\.object/
|
||||
|
||||
/**
|
||||
* @type {import("kanel").PostRenderHook}
|
||||
*
|
||||
* Renames the type of the `as unknown as z.Schema` casts from `kanel-zod` to
|
||||
* to be compatible with `kanel-kysely`, turning
|
||||
* 1. `as unknown as z.Schema<TableMutator>` into `as unknown as z.Schema<TableUpdate>`
|
||||
* 2. `as unknown as z.Schema<TableInitializer>` into `as unknown as z.Schema<NewTable>`
|
||||
*/
|
||||
function kanelKyselyZodCompatibilityHook(path, lines) {
|
||||
|
||||
return lines.map((line) => {
|
||||
if (zodItemInitializer.test(line)) {
|
||||
const parts = line.split(" ");
|
||||
if (parts[2].includes("Initializer")) {
|
||||
const nome = parts[2].replace("Initializer", "");
|
||||
parts[2] = "New" + nome[0].toUpperCase() + nome.slice(1) + "Schema";
|
||||
return parts.join(" ");
|
||||
}
|
||||
if (parts[2].includes("Mutator")) {
|
||||
const nome = parts[2].replace("Mutator", "");
|
||||
parts[2] = nome[0].toUpperCase() + nome.slice(1) + "UpdateSchema";
|
||||
return parts.join(" ");
|
||||
}
|
||||
const nome = parts[2];
|
||||
parts[2] = nome[0].toUpperCase() + nome.slice(1) + "Schema";
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
if (line.includes("as unknown as z.Schema")) {
|
||||
const replacedLine = line.replace(
|
||||
kanelZodCastRegex,
|
||||
(_, typeName, mutatorOrInitializer) => {
|
||||
|
||||
if (!mutatorOrInitializer) {
|
||||
return `as unknown as z.Schema<${typeName}>`;
|
||||
}
|
||||
|
||||
if (mutatorOrInitializer === "Mutator") {
|
||||
return `as unknown as z.Schema<${typeName}Update>`;
|
||||
}
|
||||
|
||||
return `as unknown as z.Schema<New${typeName}>`;
|
||||
}
|
||||
);
|
||||
return replacedLine;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return line;
|
||||
});
|
||||
}
|
||||
|
||||
/** @type {import('kanel').Config} */
|
||||
module.exports = {
|
||||
connection: {
|
||||
|
|
@ -53,27 +110,32 @@ module.exports = {
|
|||
},
|
||||
filter: (pgTable) => !ignoredTables.includes(pgTable.name),
|
||||
outputPath: "./src/schemas",
|
||||
generators: [makePgTsGenerator({
|
||||
customTypeMap: {
|
||||
"pg_catalog.tsvector": "string",
|
||||
"pg_catalog.bpchar": "string",
|
||||
'pg_catalog.numeric': 'number',
|
||||
//"pg_catalog.json": "string",
|
||||
generators: [
|
||||
makePgTsGenerator({
|
||||
customTypeMap: {
|
||||
"pg_catalog.tsvector": "string",
|
||||
"pg_catalog.bpchar": "string",
|
||||
'pg_catalog.numeric': 'number',
|
||||
//"pg_catalog.json": "string",
|
||||
|
||||
},
|
||||
preRenderHooks: [
|
||||
},
|
||||
preRenderHooks: [
|
||||
|
||||
specificTypes({
|
||||
"Annunci.caratteristiche": {
|
||||
name: "Caratteristiche",
|
||||
typeImports: [{ name: "Caratteristiche", path: "src/utils/kanel-types.ts", importAsType: true, isAbsolute: false, isDefault: false }],
|
||||
},
|
||||
}),
|
||||
makeKyselyHook(),
|
||||
],
|
||||
specificTypes({
|
||||
"Annunci.caratteristiche": {
|
||||
name: "Caratteristiche",
|
||||
typeImports: [{ name: "Caratteristiche", path: "src/utils/kanel-types.ts", importAsType: true, isAbsolute: false, isDefault: false }],
|
||||
},
|
||||
}),
|
||||
makeKyselyHook(),
|
||||
makeGenerateZodSchemas({
|
||||
castToSchema: false
|
||||
}),
|
||||
],
|
||||
|
||||
}),
|
||||
}),
|
||||
],
|
||||
postRenderHooks: [kanelKyselyZodCompatibilityHook],
|
||||
|
||||
preDeleteOutputFolder: true,
|
||||
|
||||
|
|
|
|||
11
apps/infoalloggi/package-lock.json
generated
11
apps/infoalloggi/package-lock.json
generated
|
|
@ -116,6 +116,7 @@
|
|||
"jsdom": "^29.0.2",
|
||||
"kanel": "^4.0.1",
|
||||
"kanel-kysely": "^4.0.0",
|
||||
"kanel-zod": "^4.0.0",
|
||||
"knip": "^6.4.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"react-email": "^5.2.10",
|
||||
|
|
@ -9089,6 +9090,16 @@
|
|||
"@kristiandupont/recase": "^1.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/kanel-zod": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/kanel-zod/-/kanel-zod-4.0.0.tgz",
|
||||
"integrity": "sha512-F2rLVeNDuoccjRtR5xW3iMJSwjdhyxVcmmoc7H5AXF8QB0uT+syMIrsrrKeN/x4+BLS39myYF0nRpUvOiahs9Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@kristiandupont/recase": "^1.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/kleur": {
|
||||
"version": "3.0.3",
|
||||
"dev": true,
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@
|
|||
"jsdom": "^29.0.2",
|
||||
"kanel": "^4.0.1",
|
||||
"kanel-kysely": "^4.0.0",
|
||||
"kanel-zod": "^4.0.0",
|
||||
"knip": "^6.4.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"react-email": "^5.2.10",
|
||||
|
|
|
|||
|
|
@ -675,6 +675,7 @@ export const en: LangDict = {
|
|||
items: [
|
||||
{ href: "/area-riservata/admin/etichette", title: "Labels" },
|
||||
{ href: "/area-riservata/admin/flags", title: "Flags" },
|
||||
{ href: "/area-riservata/admin/catasto", title: "Catasto" },
|
||||
{ href: "/area-riservata/admin/banners", title: "Banners" },
|
||||
{
|
||||
href: "/area-riservata/admin/testi-stringhe",
|
||||
|
|
|
|||
|
|
@ -680,6 +680,7 @@ export const it: LangDict = {
|
|||
items: [
|
||||
{ href: "/area-riservata/admin/etichette", title: "Etichette" },
|
||||
{ href: "/area-riservata/admin/flags", title: "Flags" },
|
||||
{ href: "/area-riservata/admin/catasto", title: "Catasto" },
|
||||
{ href: "/area-riservata/admin/banners", title: "Banners" },
|
||||
{
|
||||
href: "/area-riservata/admin/testi-stringhe",
|
||||
|
|
|
|||
1022
apps/infoalloggi/src/pages/area-riservata/admin/catasto.tsx
Normal file
1022
apps/infoalloggi/src/pages/area-riservata/admin/catasto.tsx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -50,7 +50,7 @@ const AdminFlags: NextPageWithLayout = () => {
|
|||
<div className="mx-3 items-start justify-between md:flex">
|
||||
<div className="flex max-w-lg items-center gap-3">
|
||||
<h3 className="font-bold text-accent-foreground text-xl sm:text-2xl">
|
||||
Impostazioni
|
||||
Flags
|
||||
</h3>
|
||||
<button
|
||||
className="cursor-pointer"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import type { Caratteristiche } from '../../utils/kanel-types.ts';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.annunci */
|
||||
export type AnnunciId = number & { __brand: 'public.annunci' };
|
||||
|
|
@ -115,4 +116,171 @@ export type Annunci = Selectable<AnnunciTable>;
|
|||
|
||||
export type NewAnnunci = Insertable<AnnunciTable>;
|
||||
|
||||
export type AnnunciUpdate = Updateable<AnnunciTable>;
|
||||
export type AnnunciUpdate = Updateable<AnnunciTable>;
|
||||
|
||||
export const annunciId = z.number().transform(value => value as AnnunciId);
|
||||
|
||||
export const AnnunciSchema = z.object({
|
||||
id: annunciId,
|
||||
codice: z.string(),
|
||||
locatore: z.string().nullable(),
|
||||
numero: z.string().nullable(),
|
||||
idlocatore: z.string().nullable(),
|
||||
indirizzo: z.string().nullable(),
|
||||
civico: z.string().nullable(),
|
||||
comune: z.string().nullable(),
|
||||
cap: z.string().nullable(),
|
||||
provincia: z.string().nullable(),
|
||||
regione: z.string().nullable(),
|
||||
lat: z.string().nullable(),
|
||||
lon: z.string().nullable(),
|
||||
indirizzo_secondario: z.string().nullable(),
|
||||
civico_secondario: z.string().nullable(),
|
||||
lat_secondario: z.string().nullable(),
|
||||
lon_secondario: z.string().nullable(),
|
||||
tipo: z.string().nullable(),
|
||||
categorie: z.string().array().nullable(),
|
||||
prezzo: z.number(),
|
||||
anno: z.string().nullable(),
|
||||
classe: z.string().nullable(),
|
||||
mq: z.string().nullable(),
|
||||
piano: z.string().nullable(),
|
||||
piano_palazzo: z.number().nullable(),
|
||||
unita_condominio: z.number().nullable(),
|
||||
numero_vani: z.number().nullable(),
|
||||
numero_camere: z.number().nullable(),
|
||||
numero_bagni: z.number().nullable(),
|
||||
numero_balconi: z.number().nullable(),
|
||||
numero_terrazzi: z.number().nullable(),
|
||||
numero_box: z.number().nullable(),
|
||||
numero_postiauto: z.number().nullable(),
|
||||
accessori: z.string().array().nullable(),
|
||||
titolo_it: z.string().nullable(),
|
||||
desc_it: z.string().nullable(),
|
||||
titolo_en: z.string().nullable(),
|
||||
desc_en: z.string().nullable(),
|
||||
stato: z.string().nullable(),
|
||||
web: z.boolean().nullable(),
|
||||
caratteristiche: z.unknown().nullable(),
|
||||
homepage: z.boolean().nullable(),
|
||||
external_videos: z.string().array().nullable(),
|
||||
email: z.string().nullable(),
|
||||
creato_il: z.date().nullable(),
|
||||
modificato_il: z.date().nullable(),
|
||||
consegna: z.number().nullable(),
|
||||
disponibile_da: z.date().nullable(),
|
||||
permanenza: z.number().array().nullable(),
|
||||
persone: z.string().array().nullable(),
|
||||
media_updated_at: z.date().nullable(),
|
||||
tipo_locatore: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const NewAnnunciSchema = z.object({
|
||||
id: annunciId.optional(),
|
||||
codice: z.string(),
|
||||
locatore: z.string().optional().nullable(),
|
||||
numero: z.string().optional().nullable(),
|
||||
idlocatore: z.string().optional().nullable(),
|
||||
indirizzo: z.string().optional().nullable(),
|
||||
civico: z.string().optional().nullable(),
|
||||
comune: z.string().optional().nullable(),
|
||||
cap: z.string().optional().nullable(),
|
||||
provincia: z.string().optional().nullable(),
|
||||
regione: z.string().optional().nullable(),
|
||||
lat: z.string().optional().nullable(),
|
||||
lon: z.string().optional().nullable(),
|
||||
indirizzo_secondario: z.string().optional().nullable(),
|
||||
civico_secondario: z.string().optional().nullable(),
|
||||
lat_secondario: z.string().optional().nullable(),
|
||||
lon_secondario: z.string().optional().nullable(),
|
||||
tipo: z.string().optional().nullable(),
|
||||
categorie: z.string().array().optional().nullable(),
|
||||
prezzo: z.number().optional(),
|
||||
anno: z.string().optional().nullable(),
|
||||
classe: z.string().optional().nullable(),
|
||||
mq: z.string().optional().nullable(),
|
||||
piano: z.string().optional().nullable(),
|
||||
piano_palazzo: z.number().optional().nullable(),
|
||||
unita_condominio: z.number().optional().nullable(),
|
||||
numero_vani: z.number().optional().nullable(),
|
||||
numero_camere: z.number().optional().nullable(),
|
||||
numero_bagni: z.number().optional().nullable(),
|
||||
numero_balconi: z.number().optional().nullable(),
|
||||
numero_terrazzi: z.number().optional().nullable(),
|
||||
numero_box: z.number().optional().nullable(),
|
||||
numero_postiauto: z.number().optional().nullable(),
|
||||
accessori: z.string().array().optional().nullable(),
|
||||
titolo_it: z.string().optional().nullable(),
|
||||
desc_it: z.string().optional().nullable(),
|
||||
titolo_en: z.string().optional().nullable(),
|
||||
desc_en: z.string().optional().nullable(),
|
||||
stato: z.string().optional().nullable(),
|
||||
web: z.boolean().optional().nullable(),
|
||||
caratteristiche: z.unknown().optional().nullable(),
|
||||
homepage: z.boolean().optional().nullable(),
|
||||
external_videos: z.string().array().optional().nullable(),
|
||||
email: z.string().optional().nullable(),
|
||||
creato_il: z.date().optional().nullable(),
|
||||
modificato_il: z.date().optional().nullable(),
|
||||
consegna: z.number().optional().nullable(),
|
||||
disponibile_da: z.date().optional().nullable(),
|
||||
permanenza: z.number().array().optional().nullable(),
|
||||
persone: z.string().array().optional().nullable(),
|
||||
media_updated_at: z.date().optional().nullable(),
|
||||
tipo_locatore: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export const AnnunciUpdateSchema = z.object({
|
||||
id: annunciId.optional(),
|
||||
codice: z.string().optional(),
|
||||
locatore: z.string().optional().nullable(),
|
||||
numero: z.string().optional().nullable(),
|
||||
idlocatore: z.string().optional().nullable(),
|
||||
indirizzo: z.string().optional().nullable(),
|
||||
civico: z.string().optional().nullable(),
|
||||
comune: z.string().optional().nullable(),
|
||||
cap: z.string().optional().nullable(),
|
||||
provincia: z.string().optional().nullable(),
|
||||
regione: z.string().optional().nullable(),
|
||||
lat: z.string().optional().nullable(),
|
||||
lon: z.string().optional().nullable(),
|
||||
indirizzo_secondario: z.string().optional().nullable(),
|
||||
civico_secondario: z.string().optional().nullable(),
|
||||
lat_secondario: z.string().optional().nullable(),
|
||||
lon_secondario: z.string().optional().nullable(),
|
||||
tipo: z.string().optional().nullable(),
|
||||
categorie: z.string().array().optional().nullable(),
|
||||
prezzo: z.number().optional(),
|
||||
anno: z.string().optional().nullable(),
|
||||
classe: z.string().optional().nullable(),
|
||||
mq: z.string().optional().nullable(),
|
||||
piano: z.string().optional().nullable(),
|
||||
piano_palazzo: z.number().optional().nullable(),
|
||||
unita_condominio: z.number().optional().nullable(),
|
||||
numero_vani: z.number().optional().nullable(),
|
||||
numero_camere: z.number().optional().nullable(),
|
||||
numero_bagni: z.number().optional().nullable(),
|
||||
numero_balconi: z.number().optional().nullable(),
|
||||
numero_terrazzi: z.number().optional().nullable(),
|
||||
numero_box: z.number().optional().nullable(),
|
||||
numero_postiauto: z.number().optional().nullable(),
|
||||
accessori: z.string().array().optional().nullable(),
|
||||
titolo_it: z.string().optional().nullable(),
|
||||
desc_it: z.string().optional().nullable(),
|
||||
titolo_en: z.string().optional().nullable(),
|
||||
desc_en: z.string().optional().nullable(),
|
||||
stato: z.string().optional().nullable(),
|
||||
web: z.boolean().optional().nullable(),
|
||||
caratteristiche: z.unknown().optional().nullable(),
|
||||
homepage: z.boolean().optional().nullable(),
|
||||
external_videos: z.string().array().optional().nullable(),
|
||||
email: z.string().optional().nullable(),
|
||||
creato_il: z.date().optional().nullable(),
|
||||
modificato_il: z.date().optional().nullable(),
|
||||
consegna: z.number().optional().nullable(),
|
||||
disponibile_da: z.date().optional().nullable(),
|
||||
permanenza: z.number().array().optional().nullable(),
|
||||
persone: z.string().array().optional().nullable(),
|
||||
media_updated_at: z.date().optional().nullable(),
|
||||
tipo_locatore: z.string().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
/** Represents the enum public.BanType */
|
||||
enum BanType {
|
||||
ip = 'ip',
|
||||
|
|
@ -6,4 +8,12 @@ enum BanType {
|
|||
cf = 'cf',
|
||||
};
|
||||
|
||||
export default BanType;
|
||||
export default BanType;
|
||||
|
||||
/** Zod schema for BanType */
|
||||
export const banType = z.enum([
|
||||
'ip',
|
||||
'email',
|
||||
'phone',
|
||||
'cf',
|
||||
]);
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import type { default as BanType } from './BanType';
|
||||
import { banType, type default as BanType } from './BanType';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.banlist */
|
||||
export type BanlistId = number & { __brand: 'public.banlist' };
|
||||
|
|
@ -17,4 +18,24 @@ export type Banlist = Selectable<BanlistTable>;
|
|||
|
||||
export type NewBanlist = Insertable<BanlistTable>;
|
||||
|
||||
export type BanlistUpdate = Updateable<BanlistTable>;
|
||||
export type BanlistUpdate = Updateable<BanlistTable>;
|
||||
|
||||
export const banlistId = z.number().transform(value => value as BanlistId);
|
||||
|
||||
export const BanlistSchema = z.object({
|
||||
id: banlistId,
|
||||
value: z.string(),
|
||||
type: banType,
|
||||
});
|
||||
|
||||
export const NewBanlistSchema = z.object({
|
||||
id: banlistId.optional(),
|
||||
value: z.string(),
|
||||
type: banType,
|
||||
});
|
||||
|
||||
export const BanlistUpdateSchema = z.object({
|
||||
id: banlistId.optional(),
|
||||
value: z.string().optional(),
|
||||
type: banType.optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.banners */
|
||||
export type BannersIdbanner = string & { __brand: 'public.banners' };
|
||||
|
|
@ -36,4 +37,54 @@ export type Banners = Selectable<BannersTable>;
|
|||
|
||||
export type NewBanners = Insertable<BannersTable>;
|
||||
|
||||
export type BannersUpdate = Updateable<BannersTable>;
|
||||
export type BannersUpdate = Updateable<BannersTable>;
|
||||
|
||||
export const bannersIdbanner = z.string().transform(value => value as BannersIdbanner);
|
||||
|
||||
export const BannersSchema = z.object({
|
||||
idbanner: bannersIdbanner,
|
||||
titolo: z.string().nullable(),
|
||||
testo: z.string().nullable(),
|
||||
is_unskippable: z.boolean(),
|
||||
has_cta: z.boolean(),
|
||||
cta_href: z.string().nullable(),
|
||||
cta_icon: z.string().nullable(),
|
||||
cta_text: z.string().nullable(),
|
||||
color: z.string().nullable(),
|
||||
is_active: z.boolean(),
|
||||
show_public: z.boolean(),
|
||||
show_private: z.boolean(),
|
||||
hide_duration: z.number().nullable(),
|
||||
});
|
||||
|
||||
export const NewBannersSchema = z.object({
|
||||
idbanner: bannersIdbanner,
|
||||
titolo: z.string().optional().nullable(),
|
||||
testo: z.string().optional().nullable(),
|
||||
is_unskippable: z.boolean(),
|
||||
has_cta: z.boolean(),
|
||||
cta_href: z.string().optional().nullable(),
|
||||
cta_icon: z.string().optional().nullable(),
|
||||
cta_text: z.string().optional().nullable(),
|
||||
color: z.string().optional().nullable(),
|
||||
is_active: z.boolean(),
|
||||
show_public: z.boolean(),
|
||||
show_private: z.boolean(),
|
||||
hide_duration: z.number().optional().nullable(),
|
||||
});
|
||||
|
||||
export const BannersUpdateSchema = z.object({
|
||||
idbanner: bannersIdbanner.optional(),
|
||||
titolo: z.string().optional().nullable(),
|
||||
testo: z.string().optional().nullable(),
|
||||
is_unskippable: z.boolean().optional(),
|
||||
has_cta: z.boolean().optional(),
|
||||
cta_href: z.string().optional().nullable(),
|
||||
cta_icon: z.string().optional().nullable(),
|
||||
cta_text: z.string().optional().nullable(),
|
||||
color: z.string().optional().nullable(),
|
||||
is_active: z.boolean().optional(),
|
||||
show_public: z.boolean().optional(),
|
||||
show_private: z.boolean().optional(),
|
||||
hide_duration: z.number().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import type { UsersId } from './Users';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.chats */
|
||||
export type ChatsChatid = string & { __brand: 'public.chats' };
|
||||
|
|
@ -19,4 +20,27 @@ export type Chats = Selectable<ChatsTable>;
|
|||
|
||||
export type NewChats = Insertable<ChatsTable>;
|
||||
|
||||
export type ChatsUpdate = Updateable<ChatsTable>;
|
||||
export type ChatsUpdate = Updateable<ChatsTable>;
|
||||
|
||||
export const chatsChatid = z.uuid().transform(value => value as ChatsChatid);
|
||||
|
||||
export const ChatsSchema = z.object({
|
||||
chatid: chatsChatid,
|
||||
created_at: z.date(),
|
||||
user_ref: usersId,
|
||||
tags: z.string().array().nullable(),
|
||||
});
|
||||
|
||||
export const NewChatsSchema = z.object({
|
||||
chatid: chatsChatid.optional(),
|
||||
created_at: z.date(),
|
||||
user_ref: usersId,
|
||||
tags: z.string().array().optional().nullable(),
|
||||
});
|
||||
|
||||
export const ChatsUpdateSchema = z.object({
|
||||
chatid: chatsChatid.optional(),
|
||||
created_at: z.date().optional(),
|
||||
user_ref: usersId.optional(),
|
||||
tags: z.string().array().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { ChatsChatid } from './Chats';
|
||||
import type { EtichetteIdEtichetta } from './Etichette';
|
||||
import { chatsChatid, type ChatsChatid } from './Chats';
|
||||
import { etichetteIdEtichetta, type EtichetteIdEtichetta } from './Etichette';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.chats_etichette */
|
||||
export default interface ChatsEtichetteTable {
|
||||
|
|
@ -13,4 +14,19 @@ export type ChatsEtichette = Selectable<ChatsEtichetteTable>;
|
|||
|
||||
export type NewChatsEtichette = Insertable<ChatsEtichetteTable>;
|
||||
|
||||
export type ChatsEtichetteUpdate = Updateable<ChatsEtichetteTable>;
|
||||
export type ChatsEtichetteUpdate = Updateable<ChatsEtichetteTable>;
|
||||
|
||||
export const ChatsEtichetteSchema = z.object({
|
||||
chatid: chatsChatid,
|
||||
etichettaid: etichetteIdEtichetta,
|
||||
});
|
||||
|
||||
export const NewChatsEtichetteSchema = z.object({
|
||||
chatid: chatsChatid,
|
||||
etichettaid: etichetteIdEtichetta,
|
||||
});
|
||||
|
||||
export const ChatsEtichetteUpdateSchema = z.object({
|
||||
chatid: chatsChatid.optional(),
|
||||
etichettaid: etichetteIdEtichetta.optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.comuni */
|
||||
export type ComuniId = number & { __brand: 'public.comuni' };
|
||||
|
|
@ -20,4 +21,30 @@ export type Comuni = Selectable<ComuniTable>;
|
|||
|
||||
export type NewComuni = Insertable<ComuniTable>;
|
||||
|
||||
export type ComuniUpdate = Updateable<ComuniTable>;
|
||||
export type ComuniUpdate = Updateable<ComuniTable>;
|
||||
|
||||
export const comuniId = z.number().transform(value => value as ComuniId);
|
||||
|
||||
export const ComuniSchema = z.object({
|
||||
id: comuniId,
|
||||
nome: z.string(),
|
||||
sigla: z.string(),
|
||||
catasto: z.string(),
|
||||
cap: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const NewComuniSchema = z.object({
|
||||
id: comuniId.optional(),
|
||||
nome: z.string(),
|
||||
sigla: z.string(),
|
||||
catasto: z.string(),
|
||||
cap: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export const ComuniUpdateSchema = z.object({
|
||||
id: comuniId.optional(),
|
||||
nome: z.string().optional(),
|
||||
sigla: z.string().optional(),
|
||||
catasto: z.string().optional(),
|
||||
cap: z.string().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import type { UsersId } from './Users';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.emails */
|
||||
export type EmailsIdEmail = number & { __brand: 'public.emails' };
|
||||
|
|
@ -19,4 +20,27 @@ export type Emails = Selectable<EmailsTable>;
|
|||
|
||||
export type NewEmails = Insertable<EmailsTable>;
|
||||
|
||||
export type EmailsUpdate = Updateable<EmailsTable>;
|
||||
export type EmailsUpdate = Updateable<EmailsTable>;
|
||||
|
||||
export const emailsIdEmail = z.number().transform(value => value as EmailsIdEmail);
|
||||
|
||||
export const EmailsSchema = z.object({
|
||||
id_email: emailsIdEmail,
|
||||
user_id: usersId,
|
||||
created_at: z.date(),
|
||||
data: z.unknown(),
|
||||
});
|
||||
|
||||
export const NewEmailsSchema = z.object({
|
||||
id_email: emailsIdEmail.optional(),
|
||||
user_id: usersId,
|
||||
created_at: z.date().optional(),
|
||||
data: z.unknown(),
|
||||
});
|
||||
|
||||
export const EmailsUpdateSchema = z.object({
|
||||
id_email: emailsIdEmail.optional(),
|
||||
user_id: usersId.optional(),
|
||||
created_at: z.date().optional(),
|
||||
data: z.unknown().optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.etichette */
|
||||
export type EtichetteIdEtichetta = number & { __brand: 'public.etichette' };
|
||||
|
|
@ -16,4 +17,24 @@ export type Etichette = Selectable<EtichetteTable>;
|
|||
|
||||
export type NewEtichette = Insertable<EtichetteTable>;
|
||||
|
||||
export type EtichetteUpdate = Updateable<EtichetteTable>;
|
||||
export type EtichetteUpdate = Updateable<EtichetteTable>;
|
||||
|
||||
export const etichetteIdEtichetta = z.number().transform(value => value as EtichetteIdEtichetta);
|
||||
|
||||
export const EtichetteSchema = z.object({
|
||||
id_etichetta: etichetteIdEtichetta,
|
||||
title: z.string(),
|
||||
color_hex: z.string(),
|
||||
});
|
||||
|
||||
export const NewEtichetteSchema = z.object({
|
||||
id_etichetta: etichetteIdEtichetta.optional(),
|
||||
title: z.string(),
|
||||
color_hex: z.string(),
|
||||
});
|
||||
|
||||
export const EtichetteUpdateSchema = z.object({
|
||||
id_etichetta: etichetteIdEtichetta.optional(),
|
||||
title: z.string().optional(),
|
||||
color_hex: z.string().optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.event_queue */
|
||||
export type EventQueueEventId = number & { __brand: 'public.event_queue' };
|
||||
|
|
@ -18,4 +19,27 @@ export type EventQueue = Selectable<EventQueueTable>;
|
|||
|
||||
export type NewEventQueue = Insertable<EventQueueTable>;
|
||||
|
||||
export type EventQueueUpdate = Updateable<EventQueueTable>;
|
||||
export type EventQueueUpdate = Updateable<EventQueueTable>;
|
||||
|
||||
export const eventQueueEventId = z.number().transform(value => value as EventQueueEventId);
|
||||
|
||||
export const EventQueueSchema = z.object({
|
||||
event_id: eventQueueEventId,
|
||||
lock_expires: z.date(),
|
||||
data: z.unknown().nullable(),
|
||||
status: z.string(),
|
||||
});
|
||||
|
||||
export const NewEventQueueSchema = z.object({
|
||||
event_id: eventQueueEventId.optional(),
|
||||
lock_expires: z.date(),
|
||||
data: z.unknown().optional().nullable(),
|
||||
status: z.string().optional(),
|
||||
});
|
||||
|
||||
export const EventQueueUpdateSchema = z.object({
|
||||
event_id: eventQueueEventId.optional(),
|
||||
lock_expires: z.date().optional(),
|
||||
data: z.unknown().optional().nullable(),
|
||||
status: z.string().optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.flags */
|
||||
export type FlagsId = string & { __brand: 'public.flags' };
|
||||
|
|
@ -14,4 +15,21 @@ export type Flags = Selectable<FlagsTable>;
|
|||
|
||||
export type NewFlags = Insertable<FlagsTable>;
|
||||
|
||||
export type FlagsUpdate = Updateable<FlagsTable>;
|
||||
export type FlagsUpdate = Updateable<FlagsTable>;
|
||||
|
||||
export const flagsId = z.string().transform(value => value as FlagsId);
|
||||
|
||||
export const FlagsSchema = z.object({
|
||||
id: flagsId,
|
||||
value: z.boolean(),
|
||||
});
|
||||
|
||||
export const NewFlagsSchema = z.object({
|
||||
id: flagsId,
|
||||
value: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const FlagsUpdateSchema = z.object({
|
||||
id: flagsId.optional(),
|
||||
value: z.boolean().optional(),
|
||||
});
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
/** Represents the enum public.GenericStatusEnum */
|
||||
enum GenericStatusEnum {
|
||||
pending = 'pending',
|
||||
|
|
@ -5,4 +7,11 @@ enum GenericStatusEnum {
|
|||
failed = 'failed',
|
||||
};
|
||||
|
||||
export default GenericStatusEnum;
|
||||
export default GenericStatusEnum;
|
||||
|
||||
/** Zod schema for GenericStatusEnum */
|
||||
export const genericStatusEnum = z.enum([
|
||||
'pending',
|
||||
'success',
|
||||
'failed',
|
||||
]);
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.images_refs */
|
||||
export default interface ImagesRefsTable {
|
||||
|
|
@ -17,4 +18,28 @@ export type ImagesRefs = Selectable<ImagesRefsTable>;
|
|||
|
||||
export type NewImagesRefs = Insertable<ImagesRefsTable>;
|
||||
|
||||
export type ImagesRefsUpdate = Updateable<ImagesRefsTable>;
|
||||
export type ImagesRefsUpdate = Updateable<ImagesRefsTable>;
|
||||
|
||||
export const ImagesRefsSchema = z.object({
|
||||
codice: z.string(),
|
||||
ordine: z.number(),
|
||||
img: z.string(),
|
||||
thumb: z.string(),
|
||||
og_url: z.string(),
|
||||
});
|
||||
|
||||
export const NewImagesRefsSchema = z.object({
|
||||
codice: z.string(),
|
||||
ordine: z.number(),
|
||||
img: z.string(),
|
||||
thumb: z.string(),
|
||||
og_url: z.string(),
|
||||
});
|
||||
|
||||
export const ImagesRefsUpdateSchema = z.object({
|
||||
codice: z.string().optional(),
|
||||
ordine: z.number().optional(),
|
||||
img: z.string().optional(),
|
||||
thumb: z.string().optional(),
|
||||
og_url: z.string().optional(),
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { ChatsChatid } from './Chats';
|
||||
import type { UsersId } from './Users';
|
||||
import { chatsChatid, type ChatsChatid } from './Chats';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.messages */
|
||||
export type MessagesMessageid = string & { __brand: 'public.messages' };
|
||||
|
|
@ -28,4 +29,39 @@ export type Messages = Selectable<MessagesTable>;
|
|||
|
||||
export type NewMessages = Insertable<MessagesTable>;
|
||||
|
||||
export type MessagesUpdate = Updateable<MessagesTable>;
|
||||
export type MessagesUpdate = Updateable<MessagesTable>;
|
||||
|
||||
export const messagesMessageid = z.uuid().transform(value => value as MessagesMessageid);
|
||||
|
||||
export const MessagesSchema = z.object({
|
||||
messageid: messagesMessageid,
|
||||
chatid: chatsChatid,
|
||||
message: z.string(),
|
||||
time: z.date(),
|
||||
isread: z.boolean(),
|
||||
sender: usersId,
|
||||
reply_to_id: messagesMessageid.nullable(),
|
||||
is_forwarded: z.boolean(),
|
||||
});
|
||||
|
||||
export const NewMessagesSchema = z.object({
|
||||
messageid: messagesMessageid.optional(),
|
||||
chatid: chatsChatid,
|
||||
message: z.string(),
|
||||
time: z.date(),
|
||||
isread: z.boolean().optional(),
|
||||
sender: usersId,
|
||||
reply_to_id: messagesMessageid.optional().nullable(),
|
||||
is_forwarded: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const MessagesUpdateSchema = z.object({
|
||||
messageid: messagesMessageid.optional(),
|
||||
chatid: chatsChatid.optional(),
|
||||
message: z.string().optional(),
|
||||
time: z.date().optional(),
|
||||
isread: z.boolean().optional(),
|
||||
sender: usersId.optional(),
|
||||
reply_to_id: messagesMessageid.optional().nullable(),
|
||||
is_forwarded: z.boolean().optional(),
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { MessagesMessageid } from './Messages';
|
||||
import type { UsersStorageUserStorageId } from './UsersStorage';
|
||||
import { messagesMessageid, type MessagesMessageid } from './Messages';
|
||||
import { usersStorageUserStorageId, type UsersStorageUserStorageId } from './UsersStorage';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.messages_attachments */
|
||||
export default interface MessagesAttachmentsTable {
|
||||
|
|
@ -13,4 +14,19 @@ export type MessagesAttachments = Selectable<MessagesAttachmentsTable>;
|
|||
|
||||
export type NewMessagesAttachments = Insertable<MessagesAttachmentsTable>;
|
||||
|
||||
export type MessagesAttachmentsUpdate = Updateable<MessagesAttachmentsTable>;
|
||||
export type MessagesAttachmentsUpdate = Updateable<MessagesAttachmentsTable>;
|
||||
|
||||
export const MessagesAttachmentsSchema = z.object({
|
||||
messageId: messagesMessageid,
|
||||
userStorageId: usersStorageUserStorageId,
|
||||
});
|
||||
|
||||
export const NewMessagesAttachmentsSchema = z.object({
|
||||
messageId: messagesMessageid,
|
||||
userStorageId: usersStorageUserStorageId,
|
||||
});
|
||||
|
||||
export const MessagesAttachmentsUpdateSchema = z.object({
|
||||
messageId: messagesMessageid.optional(),
|
||||
userStorageId: usersStorageUserStorageId.optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.nazioni */
|
||||
export type NazioniId = number & { __brand: 'public.nazioni' };
|
||||
|
|
@ -18,4 +19,27 @@ export type Nazioni = Selectable<NazioniTable>;
|
|||
|
||||
export type NewNazioni = Insertable<NazioniTable>;
|
||||
|
||||
export type NazioniUpdate = Updateable<NazioniTable>;
|
||||
export type NazioniUpdate = Updateable<NazioniTable>;
|
||||
|
||||
export const nazioniId = z.number().transform(value => value as NazioniId);
|
||||
|
||||
export const NazioniSchema = z.object({
|
||||
id: nazioniId,
|
||||
nome: z.string(),
|
||||
catasto: z.string(),
|
||||
iso: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const NewNazioniSchema = z.object({
|
||||
id: nazioniId.optional(),
|
||||
nome: z.string(),
|
||||
catasto: z.string(),
|
||||
iso: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export const NazioniUpdateSchema = z.object({
|
||||
id: nazioniId.optional(),
|
||||
nome: z.string().optional(),
|
||||
catasto: z.string().optional(),
|
||||
iso: z.string().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
/** Represents the enum public.OrderTypeEnum */
|
||||
enum OrderTypeEnum {
|
||||
Acconto = 'Acconto',
|
||||
|
|
@ -7,4 +9,13 @@ enum OrderTypeEnum {
|
|||
Rinnovo = 'Rinnovo',
|
||||
};
|
||||
|
||||
export default OrderTypeEnum;
|
||||
export default OrderTypeEnum;
|
||||
|
||||
/** Zod schema for OrderTypeEnum */
|
||||
export const orderTypeEnum = z.enum([
|
||||
'Acconto',
|
||||
'Saldo',
|
||||
'Consulenza',
|
||||
'Altro',
|
||||
'Rinnovo',
|
||||
]);
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
import type { UsersId } from './Users';
|
||||
import type { PrezziarioIdprezziario } from './Prezziario';
|
||||
import type { ServizioServizioId } from './Servizio';
|
||||
import type { default as OrderTypeEnum } from './OrderTypeEnum';
|
||||
import type { default as PaymentStatusEnum } from './PaymentStatusEnum';
|
||||
import type { RinnoviId } from './Rinnovi';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import { prezziarioIdprezziario, type PrezziarioIdprezziario } from './Prezziario';
|
||||
import { servizioServizioId, type ServizioServizioId } from './Servizio';
|
||||
import { orderTypeEnum, type default as OrderTypeEnum } from './OrderTypeEnum';
|
||||
import { paymentStatusEnum, type default as PaymentStatusEnum } from './PaymentStatusEnum';
|
||||
import { rinnoviId, type RinnoviId } from './Rinnovi';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.ordini */
|
||||
export type OrdiniOrdineId = string & { __brand: 'public.ordini' };
|
||||
|
|
@ -44,4 +45,57 @@ export type Ordini = Selectable<OrdiniTable>;
|
|||
|
||||
export type NewOrdini = Insertable<OrdiniTable>;
|
||||
|
||||
export type OrdiniUpdate = Updateable<OrdiniTable>;
|
||||
export type OrdiniUpdate = Updateable<OrdiniTable>;
|
||||
|
||||
export const ordiniOrdineId = z.uuid().transform(value => value as OrdiniOrdineId);
|
||||
|
||||
export const OrdiniSchema = z.object({
|
||||
ordine_id: ordiniOrdineId,
|
||||
userid: usersId,
|
||||
created_at: z.date(),
|
||||
packid: prezziarioIdprezziario,
|
||||
servizio_id: servizioServizioId.nullable(),
|
||||
type: orderTypeEnum,
|
||||
isActive: z.boolean(),
|
||||
amount_cent: z.number(),
|
||||
paymentmethod: z.string().nullable(),
|
||||
paid_at: z.date().nullable(),
|
||||
intent_id: z.string().nullable(),
|
||||
paymentstatus: paymentStatusEnum.nullable(),
|
||||
sconto: z.number(),
|
||||
rinnovo_id: rinnoviId.nullable(),
|
||||
});
|
||||
|
||||
export const NewOrdiniSchema = z.object({
|
||||
ordine_id: ordiniOrdineId.optional(),
|
||||
userid: usersId,
|
||||
created_at: z.date().optional(),
|
||||
packid: prezziarioIdprezziario,
|
||||
servizio_id: servizioServizioId.optional().nullable(),
|
||||
type: orderTypeEnum,
|
||||
isActive: z.boolean().optional(),
|
||||
amount_cent: z.number(),
|
||||
paymentmethod: z.string().optional().nullable(),
|
||||
paid_at: z.date().optional().nullable(),
|
||||
intent_id: z.string().optional().nullable(),
|
||||
paymentstatus: paymentStatusEnum.optional().nullable(),
|
||||
sconto: z.number().optional(),
|
||||
rinnovo_id: rinnoviId.optional().nullable(),
|
||||
});
|
||||
|
||||
export const OrdiniUpdateSchema = z.object({
|
||||
ordine_id: ordiniOrdineId.optional(),
|
||||
userid: usersId.optional(),
|
||||
created_at: z.date().optional(),
|
||||
packid: prezziarioIdprezziario.optional(),
|
||||
servizio_id: servizioServizioId.optional().nullable(),
|
||||
type: orderTypeEnum.optional(),
|
||||
isActive: z.boolean().optional(),
|
||||
amount_cent: z.number().optional(),
|
||||
paymentmethod: z.string().optional().nullable(),
|
||||
paid_at: z.date().optional().nullable(),
|
||||
intent_id: z.string().optional().nullable(),
|
||||
paymentstatus: paymentStatusEnum.optional().nullable(),
|
||||
sconto: z.number().optional(),
|
||||
rinnovo_id: rinnoviId.optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
/** Represents the enum public.PaymentStatusEnum */
|
||||
enum PaymentStatusEnum {
|
||||
processing = 'processing',
|
||||
|
|
@ -5,4 +7,11 @@ enum PaymentStatusEnum {
|
|||
failed = 'failed',
|
||||
};
|
||||
|
||||
export default PaymentStatusEnum;
|
||||
export default PaymentStatusEnum;
|
||||
|
||||
/** Zod schema for PaymentStatusEnum */
|
||||
export const paymentStatusEnum = z.enum([
|
||||
'processing',
|
||||
'success',
|
||||
'failed',
|
||||
]);
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { UsersId } from './Users';
|
||||
import type { PotenzialiGroupsId } from './PotenzialiGroups';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import { potenzialiGroupsId, type PotenzialiGroupsId } from './PotenzialiGroups';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.potenziali */
|
||||
export type PotenzialiId = string & { __brand: 'public.potenziali' };
|
||||
|
|
@ -24,4 +25,33 @@ export type Potenziali = Selectable<PotenzialiTable>;
|
|||
|
||||
export type NewPotenziali = Insertable<PotenzialiTable>;
|
||||
|
||||
export type PotenzialiUpdate = Updateable<PotenzialiTable>;
|
||||
export type PotenzialiUpdate = Updateable<PotenzialiTable>;
|
||||
|
||||
export const potenzialiId = z.uuid().transform(value => value as PotenzialiId);
|
||||
|
||||
export const PotenzialiSchema = z.object({
|
||||
id: potenzialiId,
|
||||
name: z.string(),
|
||||
descrizione: z.string().nullable(),
|
||||
created_at: z.date(),
|
||||
userid: usersId.nullable(),
|
||||
potenziali_group_id: potenzialiGroupsId,
|
||||
});
|
||||
|
||||
export const NewPotenzialiSchema = z.object({
|
||||
id: potenzialiId.optional(),
|
||||
name: z.string(),
|
||||
descrizione: z.string().optional().nullable(),
|
||||
created_at: z.date().optional(),
|
||||
userid: usersId.optional().nullable(),
|
||||
potenziali_group_id: potenzialiGroupsId,
|
||||
});
|
||||
|
||||
export const PotenzialiUpdateSchema = z.object({
|
||||
id: potenzialiId.optional(),
|
||||
name: z.string().optional(),
|
||||
descrizione: z.string().optional().nullable(),
|
||||
created_at: z.date().optional(),
|
||||
userid: usersId.optional().nullable(),
|
||||
potenziali_group_id: potenzialiGroupsId.optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.potenziali_groups */
|
||||
export type PotenzialiGroupsId = string & { __brand: 'public.potenziali_groups' };
|
||||
|
|
@ -16,4 +17,24 @@ export type PotenzialiGroups = Selectable<PotenzialiGroupsTable>;
|
|||
|
||||
export type NewPotenzialiGroups = Insertable<PotenzialiGroupsTable>;
|
||||
|
||||
export type PotenzialiGroupsUpdate = Updateable<PotenzialiGroupsTable>;
|
||||
export type PotenzialiGroupsUpdate = Updateable<PotenzialiGroupsTable>;
|
||||
|
||||
export const potenzialiGroupsId = z.uuid().transform(value => value as PotenzialiGroupsId);
|
||||
|
||||
export const PotenzialiGroupsSchema = z.object({
|
||||
id: potenzialiGroupsId,
|
||||
name: z.string(),
|
||||
color: z.string(),
|
||||
});
|
||||
|
||||
export const NewPotenzialiGroupsSchema = z.object({
|
||||
id: potenzialiGroupsId.optional(),
|
||||
name: z.string(),
|
||||
color: z.string().optional(),
|
||||
});
|
||||
|
||||
export const PotenzialiGroupsUpdateSchema = z.object({
|
||||
id: potenzialiGroupsId.optional(),
|
||||
name: z.string().optional(),
|
||||
color: z.string().optional(),
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { default as OrderTypeEnum } from './OrderTypeEnum';
|
||||
import type { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
|
||||
import { orderTypeEnum, type default as OrderTypeEnum } from './OrderTypeEnum';
|
||||
import { tipologiaPosizioneEnum, type default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.prezziario */
|
||||
export type PrezziarioIdprezziario = string & { __brand: 'public.prezziario' };
|
||||
|
|
@ -36,4 +37,51 @@ export type Prezziario = Selectable<PrezziarioTable>;
|
|||
|
||||
export type NewPrezziario = Insertable<PrezziarioTable>;
|
||||
|
||||
export type PrezziarioUpdate = Updateable<PrezziarioTable>;
|
||||
export type PrezziarioUpdate = Updateable<PrezziarioTable>;
|
||||
|
||||
export const prezziarioIdprezziario = z.string().transform(value => value as PrezziarioIdprezziario);
|
||||
|
||||
export const PrezziarioSchema = z.object({
|
||||
idprezziario: prezziarioIdprezziario,
|
||||
prezzo_cent: z.number(),
|
||||
testo_condizioni: z.string().nullable(),
|
||||
isActive: z.boolean(),
|
||||
nome_it: z.string(),
|
||||
nome_en: z.string(),
|
||||
desc_it: z.string(),
|
||||
desc_en: z.string(),
|
||||
sconto: z.number(),
|
||||
order_type: orderTypeEnum.nullable(),
|
||||
service_type: tipologiaPosizioneEnum.nullable(),
|
||||
service_variant: z.number().nullable(),
|
||||
});
|
||||
|
||||
export const NewPrezziarioSchema = z.object({
|
||||
idprezziario: prezziarioIdprezziario,
|
||||
prezzo_cent: z.number(),
|
||||
testo_condizioni: z.string().optional().nullable(),
|
||||
isActive: z.boolean().optional(),
|
||||
nome_it: z.string(),
|
||||
nome_en: z.string(),
|
||||
desc_it: z.string(),
|
||||
desc_en: z.string(),
|
||||
sconto: z.number().optional(),
|
||||
order_type: orderTypeEnum.optional().nullable(),
|
||||
service_type: tipologiaPosizioneEnum.optional().nullable(),
|
||||
service_variant: z.number().optional().nullable(),
|
||||
});
|
||||
|
||||
export const PrezziarioUpdateSchema = z.object({
|
||||
idprezziario: prezziarioIdprezziario.optional(),
|
||||
prezzo_cent: z.number().optional(),
|
||||
testo_condizioni: z.string().optional().nullable(),
|
||||
isActive: z.boolean().optional(),
|
||||
nome_it: z.string().optional(),
|
||||
nome_en: z.string().optional(),
|
||||
desc_it: z.string().optional(),
|
||||
desc_en: z.string().optional(),
|
||||
sconto: z.number().optional(),
|
||||
order_type: orderTypeEnum.optional().nullable(),
|
||||
service_type: tipologiaPosizioneEnum.optional().nullable(),
|
||||
service_variant: z.number().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.provincie */
|
||||
export type ProvincieId = number & { __brand: 'public.provincie' };
|
||||
|
|
@ -16,4 +17,24 @@ export type Provincie = Selectable<ProvincieTable>;
|
|||
|
||||
export type NewProvincie = Insertable<ProvincieTable>;
|
||||
|
||||
export type ProvincieUpdate = Updateable<ProvincieTable>;
|
||||
export type ProvincieUpdate = Updateable<ProvincieTable>;
|
||||
|
||||
export const provincieId = z.number().transform(value => value as ProvincieId);
|
||||
|
||||
export const ProvincieSchema = z.object({
|
||||
id: provincieId,
|
||||
nome: z.string(),
|
||||
sigla: z.string(),
|
||||
});
|
||||
|
||||
export const NewProvincieSchema = z.object({
|
||||
id: provincieId.optional(),
|
||||
nome: z.string(),
|
||||
sigla: z.string(),
|
||||
});
|
||||
|
||||
export const ProvincieUpdateSchema = z.object({
|
||||
id: provincieId.optional(),
|
||||
nome: z.string().optional(),
|
||||
sigla: z.string().optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.ratelimiter */
|
||||
export default interface RatelimiterTable {
|
||||
|
|
@ -13,4 +14,22 @@ export type Ratelimiter = Selectable<RatelimiterTable>;
|
|||
|
||||
export type NewRatelimiter = Insertable<RatelimiterTable>;
|
||||
|
||||
export type RatelimiterUpdate = Updateable<RatelimiterTable>;
|
||||
export type RatelimiterUpdate = Updateable<RatelimiterTable>;
|
||||
|
||||
export const RatelimiterSchema = z.object({
|
||||
key: z.string(),
|
||||
request_timestamp: z.date(),
|
||||
request_count: z.number(),
|
||||
});
|
||||
|
||||
export const NewRatelimiterSchema = z.object({
|
||||
key: z.string(),
|
||||
request_timestamp: z.date(),
|
||||
request_count: z.number(),
|
||||
});
|
||||
|
||||
export const RatelimiterUpdateSchema = z.object({
|
||||
key: z.string().optional(),
|
||||
request_timestamp: z.date().optional(),
|
||||
request_count: z.number().optional(),
|
||||
});
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import type { UsersId } from './Users';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.rinnovi */
|
||||
export type RinnoviId = string & { __brand: 'public.rinnovi' };
|
||||
|
|
@ -23,4 +24,33 @@ export type Rinnovi = Selectable<RinnoviTable>;
|
|||
|
||||
export type NewRinnovi = Insertable<RinnoviTable>;
|
||||
|
||||
export type RinnoviUpdate = Updateable<RinnoviTable>;
|
||||
export type RinnoviUpdate = Updateable<RinnoviTable>;
|
||||
|
||||
export const rinnoviId = z.uuid().transform(value => value as RinnoviId);
|
||||
|
||||
export const RinnoviSchema = z.object({
|
||||
id: rinnoviId,
|
||||
userId: usersId,
|
||||
codice: z.string(),
|
||||
decorrenza: z.date(),
|
||||
gestionale_id: z.string().nullable(),
|
||||
scadenza: z.date(),
|
||||
});
|
||||
|
||||
export const NewRinnoviSchema = z.object({
|
||||
id: rinnoviId.optional(),
|
||||
userId: usersId,
|
||||
codice: z.string(),
|
||||
decorrenza: z.date(),
|
||||
gestionale_id: z.string().optional().nullable(),
|
||||
scadenza: z.date(),
|
||||
});
|
||||
|
||||
export const RinnoviUpdateSchema = z.object({
|
||||
id: rinnoviId.optional(),
|
||||
userId: usersId.optional(),
|
||||
codice: z.string().optional(),
|
||||
decorrenza: z.date().optional(),
|
||||
gestionale_id: z.string().optional().nullable(),
|
||||
scadenza: z.date().optional(),
|
||||
});
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import type { UsersId } from './Users';
|
||||
import type { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
|
||||
import type { UsersStorageUserStorageId } from './UsersStorage';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import { tipologiaPosizioneEnum, type default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
|
||||
import { usersStorageUserStorageId, type UsersStorageUserStorageId } from './UsersStorage';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.servizio */
|
||||
export type ServizioServizioId = string & { __brand: 'public.servizio' };
|
||||
|
|
@ -77,4 +78,111 @@ export type Servizio = Selectable<ServizioTable>;
|
|||
|
||||
export type NewServizio = Insertable<ServizioTable>;
|
||||
|
||||
export type ServizioUpdate = Updateable<ServizioTable>;
|
||||
export type ServizioUpdate = Updateable<ServizioTable>;
|
||||
|
||||
export const servizioServizioId = z.uuid().transform(value => value as ServizioServizioId);
|
||||
|
||||
export const ServizioSchema = z.object({
|
||||
servizio_id: servizioServizioId,
|
||||
user_id: usersId,
|
||||
created_at: z.date(),
|
||||
tipologia: tipologiaPosizioneEnum,
|
||||
arredato: z.boolean(),
|
||||
budget: z.number(),
|
||||
n_adulti: z.number(),
|
||||
n_minori: z.number(),
|
||||
animali: z.boolean(),
|
||||
fumatori: z.boolean(),
|
||||
giardino: z.boolean(),
|
||||
parcheggio: z.boolean(),
|
||||
terrazzo: z.boolean(),
|
||||
ascensore: z.boolean(),
|
||||
pianoterra: z.boolean(),
|
||||
motivazione_transitorio: z.string().nullable(),
|
||||
reddito: z.string().nullable(),
|
||||
decorrenza: z.date().nullable(),
|
||||
isInterrotto: z.boolean(),
|
||||
entromese: z.number().nullable(),
|
||||
permanenza: z.number().nullable(),
|
||||
isOkAcconto: z.boolean(),
|
||||
isOkSaldo: z.boolean(),
|
||||
isOkConsulenza: z.boolean(),
|
||||
doc_motivazione_ref: usersStorageUserStorageId.nullable(),
|
||||
scadenza_motivazione_transitoria: z.date().nullable(),
|
||||
skipPayment: z.boolean(),
|
||||
skipControlloDoc: z.boolean(),
|
||||
skipDocMotivazione: z.boolean(),
|
||||
onboardOk: z.boolean(),
|
||||
interruzioneDays: z.number(),
|
||||
acceptedInterr: z.boolean(),
|
||||
});
|
||||
|
||||
export const NewServizioSchema = z.object({
|
||||
servizio_id: servizioServizioId.optional(),
|
||||
user_id: usersId,
|
||||
created_at: z.date().optional(),
|
||||
tipologia: tipologiaPosizioneEnum,
|
||||
arredato: z.boolean().optional(),
|
||||
budget: z.number(),
|
||||
n_adulti: z.number(),
|
||||
n_minori: z.number(),
|
||||
animali: z.boolean().optional(),
|
||||
fumatori: z.boolean().optional(),
|
||||
giardino: z.boolean().optional(),
|
||||
parcheggio: z.boolean().optional(),
|
||||
terrazzo: z.boolean().optional(),
|
||||
ascensore: z.boolean().optional(),
|
||||
pianoterra: z.boolean().optional(),
|
||||
motivazione_transitorio: z.string().optional().nullable(),
|
||||
reddito: z.string().optional().nullable(),
|
||||
decorrenza: z.date().optional().nullable(),
|
||||
isInterrotto: z.boolean().optional(),
|
||||
entromese: z.number().optional().nullable(),
|
||||
permanenza: z.number().optional().nullable(),
|
||||
isOkAcconto: z.boolean().optional(),
|
||||
isOkSaldo: z.boolean().optional(),
|
||||
isOkConsulenza: z.boolean().optional(),
|
||||
doc_motivazione_ref: usersStorageUserStorageId.optional().nullable(),
|
||||
scadenza_motivazione_transitoria: z.date().optional().nullable(),
|
||||
skipPayment: z.boolean().optional(),
|
||||
skipControlloDoc: z.boolean().optional(),
|
||||
skipDocMotivazione: z.boolean().optional(),
|
||||
onboardOk: z.boolean().optional(),
|
||||
interruzioneDays: z.number().optional(),
|
||||
acceptedInterr: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const ServizioUpdateSchema = z.object({
|
||||
servizio_id: servizioServizioId.optional(),
|
||||
user_id: usersId.optional(),
|
||||
created_at: z.date().optional(),
|
||||
tipologia: tipologiaPosizioneEnum.optional(),
|
||||
arredato: z.boolean().optional(),
|
||||
budget: z.number().optional(),
|
||||
n_adulti: z.number().optional(),
|
||||
n_minori: z.number().optional(),
|
||||
animali: z.boolean().optional(),
|
||||
fumatori: z.boolean().optional(),
|
||||
giardino: z.boolean().optional(),
|
||||
parcheggio: z.boolean().optional(),
|
||||
terrazzo: z.boolean().optional(),
|
||||
ascensore: z.boolean().optional(),
|
||||
pianoterra: z.boolean().optional(),
|
||||
motivazione_transitorio: z.string().optional().nullable(),
|
||||
reddito: z.string().optional().nullable(),
|
||||
decorrenza: z.date().optional().nullable(),
|
||||
isInterrotto: z.boolean().optional(),
|
||||
entromese: z.number().optional().nullable(),
|
||||
permanenza: z.number().optional().nullable(),
|
||||
isOkAcconto: z.boolean().optional(),
|
||||
isOkSaldo: z.boolean().optional(),
|
||||
isOkConsulenza: z.boolean().optional(),
|
||||
doc_motivazione_ref: usersStorageUserStorageId.optional().nullable(),
|
||||
scadenza_motivazione_transitoria: z.date().optional().nullable(),
|
||||
skipPayment: z.boolean().optional(),
|
||||
skipControlloDoc: z.boolean().optional(),
|
||||
skipDocMotivazione: z.boolean().optional(),
|
||||
onboardOk: z.boolean().optional(),
|
||||
interruzioneDays: z.number().optional(),
|
||||
acceptedInterr: z.boolean().optional(),
|
||||
});
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import type { ServizioServizioId } from './Servizio';
|
||||
import type { AnnunciId } from './Annunci';
|
||||
import type { default as StatusConfermaEnum } from './StatusConfermaEnum';
|
||||
import { servizioServizioId, type ServizioServizioId } from './Servizio';
|
||||
import { annunciId, type AnnunciId } from './Annunci';
|
||||
import { statusConfermaEnum, type default as StatusConfermaEnum } from './StatusConfermaEnum';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.servizio_annunci */
|
||||
export type ServizioAnnunciServizioAnnunciId = number & { __brand: 'public.servizio_annunci' };
|
||||
|
|
@ -43,4 +44,60 @@ export type ServizioAnnunci = Selectable<ServizioAnnunciTable>;
|
|||
|
||||
export type NewServizioAnnunci = Insertable<ServizioAnnunciTable>;
|
||||
|
||||
export type ServizioAnnunciUpdate = Updateable<ServizioAnnunciTable>;
|
||||
export type ServizioAnnunciUpdate = Updateable<ServizioAnnunciTable>;
|
||||
|
||||
export const servizioAnnunciServizioAnnunciId = z.number().transform(value => value as ServizioAnnunciServizioAnnunciId);
|
||||
|
||||
export const ServizioAnnunciSchema = z.object({
|
||||
servizio_annunci_id: servizioAnnunciServizioAnnunciId,
|
||||
servizio_id: servizioServizioId,
|
||||
annunci_id: annunciId,
|
||||
created_at: z.date(),
|
||||
open_contatti_at: z.date().nullable(),
|
||||
doc_contratto_ref: z.string().nullable(),
|
||||
gestionale_id: z.number().nullable(),
|
||||
contratto_decorrenza: z.date().nullable(),
|
||||
contratto_scadenza: z.date().nullable(),
|
||||
contratto_tipo: z.string().nullable(),
|
||||
doc_registrazione_ref: z.string().nullable(),
|
||||
doc_contratto_added: z.boolean(),
|
||||
doc_registrazione_added: z.boolean(),
|
||||
note: z.string().nullable(),
|
||||
status_conferma: statusConfermaEnum.nullable(),
|
||||
});
|
||||
|
||||
export const NewServizioAnnunciSchema = z.object({
|
||||
servizio_annunci_id: servizioAnnunciServizioAnnunciId.optional(),
|
||||
servizio_id: servizioServizioId,
|
||||
annunci_id: annunciId,
|
||||
created_at: z.date().optional(),
|
||||
open_contatti_at: z.date().optional().nullable(),
|
||||
doc_contratto_ref: z.string().optional().nullable(),
|
||||
gestionale_id: z.number().optional().nullable(),
|
||||
contratto_decorrenza: z.date().optional().nullable(),
|
||||
contratto_scadenza: z.date().optional().nullable(),
|
||||
contratto_tipo: z.string().optional().nullable(),
|
||||
doc_registrazione_ref: z.string().optional().nullable(),
|
||||
doc_contratto_added: z.boolean().optional(),
|
||||
doc_registrazione_added: z.boolean().optional(),
|
||||
note: z.string().optional().nullable(),
|
||||
status_conferma: statusConfermaEnum.optional().nullable(),
|
||||
});
|
||||
|
||||
export const ServizioAnnunciUpdateSchema = z.object({
|
||||
servizio_annunci_id: servizioAnnunciServizioAnnunciId.optional(),
|
||||
servizio_id: servizioServizioId.optional(),
|
||||
annunci_id: annunciId.optional(),
|
||||
created_at: z.date().optional(),
|
||||
open_contatti_at: z.date().optional().nullable(),
|
||||
doc_contratto_ref: z.string().optional().nullable(),
|
||||
gestionale_id: z.number().optional().nullable(),
|
||||
contratto_decorrenza: z.date().optional().nullable(),
|
||||
contratto_scadenza: z.date().optional().nullable(),
|
||||
contratto_tipo: z.string().optional().nullable(),
|
||||
doc_registrazione_ref: z.string().optional().nullable(),
|
||||
doc_contratto_added: z.boolean().optional(),
|
||||
doc_registrazione_added: z.boolean().optional(),
|
||||
note: z.string().optional().nullable(),
|
||||
status_conferma: statusConfermaEnum.optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { AnnunciId } from './Annunci';
|
||||
import type { UsersId } from './Users';
|
||||
import { annunciId, type AnnunciId } from './Annunci';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.servizio_interessi */
|
||||
export default interface ServizioInteressiTable {
|
||||
|
|
@ -13,4 +14,19 @@ export type ServizioInteressi = Selectable<ServizioInteressiTable>;
|
|||
|
||||
export type NewServizioInteressi = Insertable<ServizioInteressiTable>;
|
||||
|
||||
export type ServizioInteressiUpdate = Updateable<ServizioInteressiTable>;
|
||||
export type ServizioInteressiUpdate = Updateable<ServizioInteressiTable>;
|
||||
|
||||
export const ServizioInteressiSchema = z.object({
|
||||
annuncioId: annunciId,
|
||||
userId: usersId,
|
||||
});
|
||||
|
||||
export const NewServizioInteressiSchema = z.object({
|
||||
annuncioId: annunciId,
|
||||
userId: usersId,
|
||||
});
|
||||
|
||||
export const ServizioInteressiUpdateSchema = z.object({
|
||||
annuncioId: annunciId.optional(),
|
||||
userId: usersId.optional(),
|
||||
});
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
/** Represents the enum public.StatusConfermaEnum */
|
||||
enum StatusConfermaEnum {
|
||||
'Inviato conferma' = 'Inviato conferma',
|
||||
|
|
@ -5,4 +7,11 @@ enum StatusConfermaEnum {
|
|||
'Caparra versata' = 'Caparra versata',
|
||||
};
|
||||
|
||||
export default StatusConfermaEnum;
|
||||
export default StatusConfermaEnum;
|
||||
|
||||
/** Zod schema for StatusConfermaEnum */
|
||||
export const statusConfermaEnum = z.enum([
|
||||
'Inviato conferma',
|
||||
'Conferma accettata',
|
||||
'Caparra versata',
|
||||
]);
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.testi_e_stringhe */
|
||||
export type TestiEStringheStingaId = string & { __brand: 'public.testi_e_stringhe' };
|
||||
|
|
@ -14,4 +15,21 @@ export type TestiEStringhe = Selectable<TestiEStringheTable>;
|
|||
|
||||
export type NewTestiEStringhe = Insertable<TestiEStringheTable>;
|
||||
|
||||
export type TestiEStringheUpdate = Updateable<TestiEStringheTable>;
|
||||
export type TestiEStringheUpdate = Updateable<TestiEStringheTable>;
|
||||
|
||||
export const testiEStringheStingaId = z.string().transform(value => value as TestiEStringheStingaId);
|
||||
|
||||
export const TestiEStringheSchema = z.object({
|
||||
stinga_id: testiEStringheStingaId,
|
||||
stringa_value: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const NewTestiEStringheSchema = z.object({
|
||||
stinga_id: testiEStringheStingaId,
|
||||
stringa_value: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export const TestiEStringheUpdateSchema = z.object({
|
||||
stinga_id: testiEStringheStingaId.optional(),
|
||||
stringa_value: z.string().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,7 +1,15 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
/** Represents the enum public.TipologiaPosizioneEnum */
|
||||
enum TipologiaPosizioneEnum {
|
||||
Transitorio = 'Transitorio',
|
||||
Stabile = 'Stabile',
|
||||
};
|
||||
|
||||
export default TipologiaPosizioneEnum;
|
||||
export default TipologiaPosizioneEnum;
|
||||
|
||||
/** Zod schema for TipologiaPosizioneEnum */
|
||||
export const tipologiaPosizioneEnum = z.enum([
|
||||
'Transitorio',
|
||||
'Stabile',
|
||||
]);
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { UsersId } from './Users';
|
||||
import type { EtichetteIdEtichetta } from './Etichette';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import { etichetteIdEtichetta, type EtichetteIdEtichetta } from './Etichette';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.user_etichette */
|
||||
export default interface UserEtichetteTable {
|
||||
|
|
@ -13,4 +14,19 @@ export type UserEtichette = Selectable<UserEtichetteTable>;
|
|||
|
||||
export type NewUserEtichette = Insertable<UserEtichetteTable>;
|
||||
|
||||
export type UserEtichetteUpdate = Updateable<UserEtichetteTable>;
|
||||
export type UserEtichetteUpdate = Updateable<UserEtichetteTable>;
|
||||
|
||||
export const UserEtichetteSchema = z.object({
|
||||
userId: usersId,
|
||||
etichettaId: etichetteIdEtichetta,
|
||||
});
|
||||
|
||||
export const NewUserEtichetteSchema = z.object({
|
||||
userId: usersId,
|
||||
etichettaId: etichetteIdEtichetta,
|
||||
});
|
||||
|
||||
export const UserEtichetteUpdateSchema = z.object({
|
||||
userId: usersId.optional(),
|
||||
etichettaId: etichetteIdEtichetta.optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.user_invites */
|
||||
export type UserInvitesId = string & { __brand: 'public.user_invites' };
|
||||
|
|
@ -20,4 +21,30 @@ export type UserInvites = Selectable<UserInvitesTable>;
|
|||
|
||||
export type NewUserInvites = Insertable<UserInvitesTable>;
|
||||
|
||||
export type UserInvitesUpdate = Updateable<UserInvitesTable>;
|
||||
export type UserInvitesUpdate = Updateable<UserInvitesTable>;
|
||||
|
||||
export const userInvitesId = z.uuid().transform(value => value as UserInvitesId);
|
||||
|
||||
export const UserInvitesSchema = z.object({
|
||||
id: userInvitesId,
|
||||
email: z.string(),
|
||||
token: z.string(),
|
||||
expires_at: z.date(),
|
||||
created_at: z.date().nullable(),
|
||||
});
|
||||
|
||||
export const NewUserInvitesSchema = z.object({
|
||||
id: userInvitesId.optional(),
|
||||
email: z.string(),
|
||||
token: z.string(),
|
||||
expires_at: z.date(),
|
||||
created_at: z.date().optional().nullable(),
|
||||
});
|
||||
|
||||
export const UserInvitesUpdateSchema = z.object({
|
||||
id: userInvitesId.optional(),
|
||||
email: z.string().optional(),
|
||||
token: z.string().optional(),
|
||||
expires_at: z.date().optional(),
|
||||
created_at: z.date().optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.users */
|
||||
export type UsersId = string & { __brand: 'public.users' };
|
||||
|
|
@ -50,4 +51,75 @@ export type Users = Selectable<UsersTable>;
|
|||
|
||||
export type NewUsers = Insertable<UsersTable>;
|
||||
|
||||
export type UsersUpdate = Updateable<UsersTable>;
|
||||
export type UsersUpdate = Updateable<UsersTable>;
|
||||
|
||||
export const usersId = z.uuid().transform(value => value as UsersId);
|
||||
|
||||
export const UsersSchema = z.object({
|
||||
id: usersId,
|
||||
username: z.string(),
|
||||
email: z.string(),
|
||||
isAdmin: z.boolean(),
|
||||
isBlocked: z.boolean(),
|
||||
password: z.string(),
|
||||
nome: z.string(),
|
||||
cognome: z.string(),
|
||||
created_at: z.date(),
|
||||
reset_password_token: z.string().nullable(),
|
||||
reset_password_expires: z.date().nullable(),
|
||||
telefono: z.string(),
|
||||
isAdminMade: z.boolean().nullable(),
|
||||
salt: z.string(),
|
||||
mustChangePassword: z.boolean(),
|
||||
note: z.string().nullable(),
|
||||
comms_enabled: z.boolean(),
|
||||
extra_telefono_titolo: z.string().nullable(),
|
||||
extra_telefono_numero: z.string().nullable(),
|
||||
usedInvite: z.boolean(),
|
||||
});
|
||||
|
||||
export const NewUsersSchema = z.object({
|
||||
id: usersId.optional(),
|
||||
username: z.string(),
|
||||
email: z.string(),
|
||||
isAdmin: z.boolean().optional(),
|
||||
isBlocked: z.boolean().optional(),
|
||||
password: z.string(),
|
||||
nome: z.string(),
|
||||
cognome: z.string(),
|
||||
created_at: z.date().optional(),
|
||||
reset_password_token: z.string().optional().nullable(),
|
||||
reset_password_expires: z.date().optional().nullable(),
|
||||
telefono: z.string(),
|
||||
isAdminMade: z.boolean().optional().nullable(),
|
||||
salt: z.string(),
|
||||
mustChangePassword: z.boolean().optional(),
|
||||
note: z.string().optional().nullable(),
|
||||
comms_enabled: z.boolean().optional(),
|
||||
extra_telefono_titolo: z.string().optional().nullable(),
|
||||
extra_telefono_numero: z.string().optional().nullable(),
|
||||
usedInvite: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const UsersUpdateSchema = z.object({
|
||||
id: usersId.optional(),
|
||||
username: z.string().optional(),
|
||||
email: z.string().optional(),
|
||||
isAdmin: z.boolean().optional(),
|
||||
isBlocked: z.boolean().optional(),
|
||||
password: z.string().optional(),
|
||||
nome: z.string().optional(),
|
||||
cognome: z.string().optional(),
|
||||
created_at: z.date().optional(),
|
||||
reset_password_token: z.string().optional().nullable(),
|
||||
reset_password_expires: z.date().optional().nullable(),
|
||||
telefono: z.string().optional(),
|
||||
isAdminMade: z.boolean().optional().nullable(),
|
||||
salt: z.string().optional(),
|
||||
mustChangePassword: z.boolean().optional(),
|
||||
note: z.string().optional().nullable(),
|
||||
comms_enabled: z.boolean().optional(),
|
||||
extra_telefono_titolo: z.string().optional().nullable(),
|
||||
extra_telefono_numero: z.string().optional().nullable(),
|
||||
usedInvite: z.boolean().optional(),
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { UsersId } from './Users';
|
||||
import type { UsersStorageUserStorageId } from './UsersStorage';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import { usersStorageUserStorageId, type UsersStorageUserStorageId } from './UsersStorage';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.users_anagrafica */
|
||||
export type UsersAnagraficaIdanagrafica = string & { __brand: 'public.users_anagrafica' };
|
||||
|
|
@ -42,4 +43,60 @@ export type UsersAnagrafica = Selectable<UsersAnagraficaTable>;
|
|||
|
||||
export type NewUsersAnagrafica = Insertable<UsersAnagraficaTable>;
|
||||
|
||||
export type UsersAnagraficaUpdate = Updateable<UsersAnagraficaTable>;
|
||||
export type UsersAnagraficaUpdate = Updateable<UsersAnagraficaTable>;
|
||||
|
||||
export const usersAnagraficaIdanagrafica = z.uuid().transform(value => value as UsersAnagraficaIdanagrafica);
|
||||
|
||||
export const UsersAnagraficaSchema = z.object({
|
||||
idanagrafica: usersAnagraficaIdanagrafica,
|
||||
userid: usersId,
|
||||
luogo_nascita: z.string().nullable(),
|
||||
data_nascita: z.date().nullable(),
|
||||
nazione_nascita: z.string().nullable(),
|
||||
codice_fiscale: z.string().nullable(),
|
||||
via_residenza: z.string().nullable(),
|
||||
civico_residenza: z.string().nullable(),
|
||||
comune_residenza: z.string().nullable(),
|
||||
provincia_residenza: z.string().nullable(),
|
||||
cap_residenza: z.string().nullable(),
|
||||
nazione_residenza: z.string().nullable(),
|
||||
sesso: z.string().nullable(),
|
||||
doc_personale_fronte_ref: usersStorageUserStorageId.nullable(),
|
||||
doc_personale_retro_ref: usersStorageUserStorageId.nullable(),
|
||||
});
|
||||
|
||||
export const NewUsersAnagraficaSchema = z.object({
|
||||
idanagrafica: usersAnagraficaIdanagrafica.optional(),
|
||||
userid: usersId,
|
||||
luogo_nascita: z.string().optional().nullable(),
|
||||
data_nascita: z.date().optional().nullable(),
|
||||
nazione_nascita: z.string().optional().nullable(),
|
||||
codice_fiscale: z.string().optional().nullable(),
|
||||
via_residenza: z.string().optional().nullable(),
|
||||
civico_residenza: z.string().optional().nullable(),
|
||||
comune_residenza: z.string().optional().nullable(),
|
||||
provincia_residenza: z.string().optional().nullable(),
|
||||
cap_residenza: z.string().optional().nullable(),
|
||||
nazione_residenza: z.string().optional().nullable(),
|
||||
sesso: z.string().optional().nullable(),
|
||||
doc_personale_fronte_ref: usersStorageUserStorageId.optional().nullable(),
|
||||
doc_personale_retro_ref: usersStorageUserStorageId.optional().nullable(),
|
||||
});
|
||||
|
||||
export const UsersAnagraficaUpdateSchema = z.object({
|
||||
idanagrafica: usersAnagraficaIdanagrafica.optional(),
|
||||
userid: usersId.optional(),
|
||||
luogo_nascita: z.string().optional().nullable(),
|
||||
data_nascita: z.date().optional().nullable(),
|
||||
nazione_nascita: z.string().optional().nullable(),
|
||||
codice_fiscale: z.string().optional().nullable(),
|
||||
via_residenza: z.string().optional().nullable(),
|
||||
civico_residenza: z.string().optional().nullable(),
|
||||
comune_residenza: z.string().optional().nullable(),
|
||||
provincia_residenza: z.string().optional().nullable(),
|
||||
cap_residenza: z.string().optional().nullable(),
|
||||
nazione_residenza: z.string().optional().nullable(),
|
||||
sesso: z.string().optional().nullable(),
|
||||
doc_personale_fronte_ref: usersStorageUserStorageId.optional().nullable(),
|
||||
doc_personale_retro_ref: usersStorageUserStorageId.optional().nullable(),
|
||||
});
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import type { UsersId } from './Users';
|
||||
import { usersId, type UsersId } from './Users';
|
||||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Identifier type for public.users_storage */
|
||||
export type UsersStorageUserStorageId = string & { __brand: 'public.users_storage' };
|
||||
|
|
@ -19,4 +20,27 @@ export type UsersStorage = Selectable<UsersStorageTable>;
|
|||
|
||||
export type NewUsersStorage = Insertable<UsersStorageTable>;
|
||||
|
||||
export type UsersStorageUpdate = Updateable<UsersStorageTable>;
|
||||
export type UsersStorageUpdate = Updateable<UsersStorageTable>;
|
||||
|
||||
export const usersStorageUserStorageId = z.uuid().transform(value => value as UsersStorageUserStorageId);
|
||||
|
||||
export const UsersStorageSchema = z.object({
|
||||
user_storage_id: usersStorageUserStorageId,
|
||||
userId: usersId,
|
||||
storageId: z.string(),
|
||||
from_admin: z.boolean(),
|
||||
});
|
||||
|
||||
export const NewUsersStorageSchema = z.object({
|
||||
user_storage_id: usersStorageUserStorageId.optional(),
|
||||
userId: usersId,
|
||||
storageId: z.string(),
|
||||
from_admin: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const UsersStorageUpdateSchema = z.object({
|
||||
user_storage_id: usersStorageUserStorageId.optional(),
|
||||
userId: usersId.optional(),
|
||||
storageId: z.string().optional(),
|
||||
from_admin: z.boolean().optional(),
|
||||
});
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||
import { z } from 'zod';
|
||||
|
||||
/** Represents the table public.videos_refs */
|
||||
export default interface VideosRefsTable {
|
||||
|
|
@ -17,4 +18,28 @@ export type VideosRefs = Selectable<VideosRefsTable>;
|
|||
|
||||
export type NewVideosRefs = Insertable<VideosRefsTable>;
|
||||
|
||||
export type VideosRefsUpdate = Updateable<VideosRefsTable>;
|
||||
export type VideosRefsUpdate = Updateable<VideosRefsTable>;
|
||||
|
||||
export const VideosRefsSchema = z.object({
|
||||
codice: z.string(),
|
||||
ordine: z.number(),
|
||||
video: z.string(),
|
||||
thumb: z.string(),
|
||||
og_url: z.string(),
|
||||
});
|
||||
|
||||
export const NewVideosRefsSchema = z.object({
|
||||
codice: z.string(),
|
||||
ordine: z.number(),
|
||||
video: z.string(),
|
||||
thumb: z.string(),
|
||||
og_url: z.string(),
|
||||
});
|
||||
|
||||
export const VideosRefsUpdateSchema = z.object({
|
||||
codice: z.string().optional(),
|
||||
ordine: z.number().optional(),
|
||||
video: z.string().optional(),
|
||||
thumb: z.string().optional(),
|
||||
og_url: z.string().optional(),
|
||||
});
|
||||
|
|
@ -1,5 +1,34 @@
|
|||
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";
|
||||
import z from "zod";
|
||||
import {
|
||||
ComuniUpdateSchema,
|
||||
comuniId,
|
||||
NewComuniSchema,
|
||||
} from "~/schemas/public/Comuni";
|
||||
import {
|
||||
NazioniUpdateSchema,
|
||||
NewNazioniSchema,
|
||||
nazioniId,
|
||||
} from "~/schemas/public/Nazioni";
|
||||
import {
|
||||
NewProvincieSchema,
|
||||
ProvincieUpdateSchema,
|
||||
provincieId,
|
||||
} from "~/schemas/public/Provincie";
|
||||
import {
|
||||
adminProcedure,
|
||||
createTRPCRouter,
|
||||
publicProcedure,
|
||||
} from "~/server/api/trpc";
|
||||
import {
|
||||
createComune,
|
||||
createNazione,
|
||||
createProvincia,
|
||||
deleteComune,
|
||||
deleteNazione,
|
||||
deleteProvincia,
|
||||
editComune,
|
||||
editNazione,
|
||||
editProvincia,
|
||||
getComuni,
|
||||
getNazioni,
|
||||
getProvincie,
|
||||
|
|
@ -9,11 +38,86 @@ export const catastoRouter = createTRPCRouter({
|
|||
getComuni: publicProcedure.query(async () => {
|
||||
return await getComuni();
|
||||
}),
|
||||
createComune: adminProcedure
|
||||
.input(NewComuniSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
return await createComune(input);
|
||||
}),
|
||||
editComune: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: comuniId,
|
||||
data: ComuniUpdateSchema,
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
const { id, data } = input;
|
||||
return await editComune({ id, data });
|
||||
}),
|
||||
deleteComune: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: comuniId,
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
return await deleteComune(input.id);
|
||||
}),
|
||||
|
||||
getProvincie: publicProcedure.query(async () => {
|
||||
return await getProvincie();
|
||||
}),
|
||||
createProvincia: adminProcedure
|
||||
.input(NewProvincieSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
return await createProvincia(input);
|
||||
}),
|
||||
editProvincia: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: provincieId,
|
||||
data: ProvincieUpdateSchema,
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
const { id, data } = input;
|
||||
return await editProvincia({ id, data });
|
||||
}),
|
||||
deleteProvincia: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: provincieId,
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
return await deleteProvincia(input.id);
|
||||
}),
|
||||
getNazioni: publicProcedure.query(async () => {
|
||||
return await getNazioni();
|
||||
}),
|
||||
createNazione: adminProcedure
|
||||
.input(NewNazioniSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
return await createNazione(input);
|
||||
}),
|
||||
editNazione: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: nazioniId,
|
||||
data: NazioniUpdateSchema,
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
const { id, data } = input;
|
||||
return await editNazione({ id, data });
|
||||
}),
|
||||
deleteNazione: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: nazioniId,
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
return await deleteNazione(input.id);
|
||||
}),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,20 @@
|
|||
import { TRPCError } from "@trpc/server";
|
||||
import { sql } from "kysely";
|
||||
import type {
|
||||
ComuniId,
|
||||
ComuniUpdate,
|
||||
NewComuni,
|
||||
} from "~/schemas/public/Comuni";
|
||||
import type {
|
||||
NazioniId,
|
||||
NazioniUpdate,
|
||||
NewNazioni,
|
||||
} from "~/schemas/public/Nazioni";
|
||||
import type {
|
||||
NewProvincie,
|
||||
ProvincieId,
|
||||
ProvincieUpdate,
|
||||
} from "~/schemas/public/Provincie";
|
||||
import { db } from "../db";
|
||||
|
||||
export const getComuni = async () => {
|
||||
|
|
@ -17,6 +32,48 @@ export const getComuni = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
export const editComune = async ({
|
||||
id,
|
||||
data,
|
||||
}: {
|
||||
id: ComuniId;
|
||||
data: ComuniUpdate;
|
||||
}) => {
|
||||
try {
|
||||
await db.updateTable("comuni").set(data).where("id", "=", id).execute();
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while editing Comune: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const createComune = async (data: NewComuni) => {
|
||||
const { id, ...rest } = data;
|
||||
try {
|
||||
await db.insertInto("comuni").values(rest).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while creating Comune: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteComune = async (id: ComuniId) => {
|
||||
try {
|
||||
await db.deleteFrom("comuni").where("id", "=", id).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while deleting Comune: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const getProvincie = async () => {
|
||||
try {
|
||||
return await db.selectFrom("provincie").selectAll().execute();
|
||||
|
|
@ -28,6 +85,49 @@ export const getProvincie = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
export const editProvincia = async ({
|
||||
id,
|
||||
data,
|
||||
}: {
|
||||
id: ProvincieId;
|
||||
data: ProvincieUpdate;
|
||||
}) => {
|
||||
try {
|
||||
await db.updateTable("provincie").set(data).where("id", "=", id).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while editing Provincia: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const createProvincia = async (data: NewProvincie) => {
|
||||
const { id, ...rest } = data;
|
||||
try {
|
||||
await db.insertInto("provincie").values(rest).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while creating Provincia: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteProvincia = async (id: ProvincieId) => {
|
||||
try {
|
||||
await db.deleteFrom("provincie").where("id", "=", id).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while deleting Provincia: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const getNazioni = async () => {
|
||||
try {
|
||||
return await db
|
||||
|
|
@ -43,3 +143,46 @@ export const getNazioni = async () => {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const editNazione = async ({
|
||||
id,
|
||||
data,
|
||||
}: {
|
||||
id: NazioniId;
|
||||
data: NazioniUpdate;
|
||||
}) => {
|
||||
try {
|
||||
await db.updateTable("nazioni").set(data).where("id", "=", id).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while editing Nazione: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const createNazione = async (data: NewNazioni) => {
|
||||
const { id, ...rest } = data;
|
||||
try {
|
||||
await db.insertInto("nazioni").values(rest).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while creating Nazione: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteNazione = async (id: NazioniId) => {
|
||||
try {
|
||||
await db.deleteFrom("nazioni").where("id", "=", id).execute();
|
||||
return "ok";
|
||||
} catch (e) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error while deleting Nazione: ${(e as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@ import type { AnnunciId } from "~/schemas/public/Annunci";
|
|||
import type { BanlistId } from "~/schemas/public/Banlist";
|
||||
import BanType from "~/schemas/public/BanType";
|
||||
import type { ChatsChatid } from "~/schemas/public/Chats";
|
||||
import type { ComuniId } from "~/schemas/public/Comuni";
|
||||
import type { EtichetteIdEtichetta } from "~/schemas/public/Etichette";
|
||||
import type { EventQueueEventId } from "~/schemas/public/EventQueue";
|
||||
import type { FlagsId } from "~/schemas/public/Flags";
|
||||
import type { MessagesMessageid } from "~/schemas/public/Messages";
|
||||
import type { NazioniId } from "~/schemas/public/Nazioni";
|
||||
import type { OrdiniOrdineId } from "~/schemas/public/Ordini";
|
||||
import type { PrezziarioIdprezziario } from "~/schemas/public/Prezziario";
|
||||
import type { ProvincieId } from "~/schemas/public/Provincie";
|
||||
import type { RinnoviId } from "~/schemas/public/Rinnovi";
|
||||
import type { ServizioServizioId } from "~/schemas/public/Servizio";
|
||||
import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
|
||||
|
|
@ -84,15 +87,20 @@ export const zServizioId = z.custom<ServizioServizioId>(
|
|||
"falied to validate ServizioId",
|
||||
);
|
||||
|
||||
// export const zComuneId = z.custom<ComuniId>(
|
||||
// (val) => typeof val === "number",
|
||||
// "falied to validate ComuneId",
|
||||
// );
|
||||
export const zComuneId = z.custom<ComuniId>(
|
||||
(val) => typeof val === "number",
|
||||
"falied to validate ComuneId",
|
||||
);
|
||||
|
||||
// export const zNazioneId = z.custom<NazioniId>(
|
||||
// (val) => typeof val === "number",
|
||||
// "falied to validate NazioneId",
|
||||
// );
|
||||
export const zProvincieId = z.custom<ProvincieId>(
|
||||
(val) => typeof val === "number",
|
||||
"falied to validate ProvinciaId",
|
||||
);
|
||||
|
||||
export const zNazioneId = z.custom<NazioniId>(
|
||||
(val) => typeof val === "number",
|
||||
"falied to validate NazioneId",
|
||||
);
|
||||
|
||||
export const zRinnovoId = z.custom<RinnoviId>(
|
||||
(val) => typeof val === "string",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue