Refactor Kanel configuration and update schema files

- Updated kanel.config.js to use makePgTsGenerator and adjusted type filtering.
- Modified various schema files to remove autogenerated comments and updated type definitions for enums to use union types.
- Added new MessagesAttachments schema and integrated it into PublicSchema.
- Ensured consistency in export types across all schema files.
This commit is contained in:
Marco Pedone 2026-04-27 16:53:54 +02:00
parent 98463da038
commit 2ac16e4f33
40 changed files with 97 additions and 197 deletions

View file

@ -1,5 +1,5 @@
const { makeKyselyHook } = require("kanel-kysely"); const { makeKyselyHook } = require("kanel-kysely");
const { makePgTsGenerator } = require("kanel");
const ignoredTables = ["schema_migrations"]; const ignoredTables = ["schema_migrations"];
/** @type {import('kanel').Config} */ /** @type {import('kanel').Config} */
@ -11,17 +11,19 @@ module.exports = {
password: "rootpost", password: "rootpost",
port: 5433, port: 5433,
}, },
filter: (pgTable) => !ignoredTables.includes(pgTable.name),
typeFilter: (pgType) => !ignoredTables.includes(pgType.name),
preDeleteOutputFolder: true,
outputPath: "./src/schemas", outputPath: "./src/schemas",
generators: [makePgTsGenerator({
customTypeMap: {
"pg_catalog.tsvector": "string",
"pg_catalog.bpchar": "string",
'pg_catalog.numeric': 'number',
//"pg_catalog.json": "string",
},
preRenderHooks: [makeKyselyHook()],
customTypeMap: { }),
"pg_catalog.tsvector": "string", ],
"pg_catalog.bpchar": "string",
'pg_catalog.numeric': 'number',
//"pg_catalog.json": "string",
},
preRenderHooks: [makeKyselyHook()],
preDeleteOutputFolder: true,
}; };

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { default as PublicSchema } from './public/PublicSchema'; import type { default as PublicSchema } from './public/PublicSchema';
type Database = PublicSchema; type Database = PublicSchema;

View file

@ -1,7 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { Caratteristiche } from '../../utils/kanel-types.ts';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.annunci */ /** Identifier type for public.annunci */
@ -89,7 +85,7 @@ export default interface AnnunciTable {
web: ColumnType<boolean | null, boolean | null, boolean | null>; web: ColumnType<boolean | null, boolean | null, boolean | null>;
caratteristiche: ColumnType<Caratteristiche | null, Caratteristiche | null, Caratteristiche | null>; caratteristiche: ColumnType<unknown | null, unknown | null, unknown | null>;
homepage: ColumnType<boolean | null, boolean | null, boolean | null>; homepage: ColumnType<boolean | null, boolean | null, boolean | null>;

View file

@ -1,12 +1,8 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.BanType */ /** Represents the enum public.BanType */
enum BanType { type BanType =
ip = 'ip', | 'ip'
email = 'email', | 'email'
phone = 'phone', | 'phone'
cf = 'cf', | 'cf';
};
export default BanType; export default BanType;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { default as BanType } from './BanType'; import type { default as BanType } from './BanType';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.banners */ /** Identifier type for public.banners */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ChatsChatid } from './Chats'; import type { ChatsChatid } from './Chats';
import type { EtichetteIdEtichetta } from './Etichette'; import type { EtichetteIdEtichetta } from './Etichette';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.comuni */ /** Identifier type for public.comuni */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.etichette */ /** Identifier type for public.etichette */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.event_queue */ /** Identifier type for public.event_queue */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.flags */ /** Identifier type for public.flags */

View file

@ -1,11 +1,7 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.GenericStatusEnum */ /** Represents the enum public.GenericStatusEnum */
enum GenericStatusEnum { type GenericStatusEnum =
pending = 'pending', | 'pending'
success = 'success', | 'success'
failed = 'failed', | 'failed';
};
export default GenericStatusEnum; export default GenericStatusEnum;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Represents the table public.images_refs */ /** Represents the table public.images_refs */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ChatsChatid } from './Chats'; import type { ChatsChatid } from './Chats';
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -0,0 +1,16 @@
import type { MessagesMessageid } from './Messages';
import type { UsersStorageUserStorageId } from './UsersStorage';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Represents the table public.messages_attachments */
export default interface MessagesAttachmentsTable {
messageId: ColumnType<MessagesMessageid, MessagesMessageid, MessagesMessageid>;
userStorageId: ColumnType<UsersStorageUserStorageId, UsersStorageUserStorageId, UsersStorageUserStorageId>;
}
export type MessagesAttachments = Selectable<MessagesAttachmentsTable>;
export type NewMessagesAttachments = Insertable<MessagesAttachmentsTable>;
export type MessagesAttachmentsUpdate = Updateable<MessagesAttachmentsTable>;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.nazioni */ /** Identifier type for public.nazioni */

View file

@ -1,13 +1,9 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.OrderTypeEnum */ /** Represents the enum public.OrderTypeEnum */
enum OrderTypeEnum { type OrderTypeEnum =
Acconto = 'Acconto', | 'Acconto'
Saldo = 'Saldo', | 'Saldo'
Consulenza = 'Consulenza', | 'Consulenza'
Altro = 'Altro', | 'Altro'
Rinnovo = 'Rinnovo', | 'Rinnovo';
};
export default OrderTypeEnum; export default OrderTypeEnum;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { PrezziarioIdprezziario } from './Prezziario'; import type { PrezziarioIdprezziario } from './Prezziario';
import type { ServizioServizioId } from './Servizio'; import type { ServizioServizioId } from './Servizio';

View file

@ -1,11 +1,7 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.PaymentStatusEnum */ /** Represents the enum public.PaymentStatusEnum */
enum PaymentStatusEnum { type PaymentStatusEnum =
processing = 'processing', | 'processing'
success = 'success', | 'success'
failed = 'failed', | 'failed';
};
export default PaymentStatusEnum; export default PaymentStatusEnum;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { PotenzialiGroupsId } from './PotenzialiGroups'; import type { PotenzialiGroupsId } from './PotenzialiGroups';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.potenziali_groups */ /** Identifier type for public.potenziali_groups */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { default as OrderTypeEnum } from './OrderTypeEnum'; import type { default as OrderTypeEnum } from './OrderTypeEnum';
import type { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum'; import type { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.provincie */ /** Identifier type for public.provincie */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { default as ServizioInteressiTable } from './ServizioInteressi'; import type { default as ServizioInteressiTable } from './ServizioInteressi';
import type { default as FlagsTable } from './Flags'; import type { default as FlagsTable } from './Flags';
import type { default as AnnunciTable } from './Annunci'; import type { default as AnnunciTable } from './Annunci';
@ -31,6 +28,7 @@ import type { default as NazioniTable } from './Nazioni';
import type { default as ImagesRefsTable } from './ImagesRefs'; import type { default as ImagesRefsTable } from './ImagesRefs';
import type { default as BannersTable } from './Banners'; import type { default as BannersTable } from './Banners';
import type { default as ServizioTable } from './Servizio'; import type { default as ServizioTable } from './Servizio';
import type { default as MessagesAttachmentsTable } from './MessagesAttachments';
export default interface PublicSchema { export default interface PublicSchema {
servizio_interessi: ServizioInteressiTable; servizio_interessi: ServizioInteressiTable;
@ -92,4 +90,6 @@ export default interface PublicSchema {
banners: BannersTable; banners: BannersTable;
servizio: ServizioTable; servizio: ServizioTable;
messages_attachments: MessagesAttachmentsTable;
} }

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Represents the table public.ratelimiter */ /** Represents the table public.ratelimiter */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum'; import type { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
import type { UsersStorageUserStorageId } from './UsersStorage'; import type { UsersStorageUserStorageId } from './UsersStorage';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ServizioServizioId } from './Servizio'; import type { ServizioServizioId } from './Servizio';
import type { AnnunciId } from './Annunci'; import type { AnnunciId } from './Annunci';
import type { default as StatusConfermaEnum } from './StatusConfermaEnum'; import type { default as StatusConfermaEnum } from './StatusConfermaEnum';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { AnnunciId } from './Annunci'; import type { AnnunciId } from './Annunci';
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,11 +1,7 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.StatusConfermaEnum */ /** Represents the enum public.StatusConfermaEnum */
enum StatusConfermaEnum { type StatusConfermaEnum =
'Inviato conferma' = 'Inviato conferma', | 'Inviato conferma'
'Conferma accettata' = 'Conferma accettata', | 'Conferma accettata'
'Caparra versata' = 'Caparra versata', | 'Caparra versata';
};
export default StatusConfermaEnum; export default StatusConfermaEnum;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.testi_e_stringhe */ /** Identifier type for public.testi_e_stringhe */

View file

@ -1,10 +1,6 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.TipologiaPosizioneEnum */ /** Represents the enum public.TipologiaPosizioneEnum */
enum TipologiaPosizioneEnum { type TipologiaPosizioneEnum =
Transitorio = 'Transitorio', | 'Transitorio'
Stabile = 'Stabile', | 'Stabile';
};
export default TipologiaPosizioneEnum; export default TipologiaPosizioneEnum;

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { EtichetteIdEtichetta } from './Etichette'; import type { EtichetteIdEtichetta } from './Etichette';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.user_invites */ /** Identifier type for public.user_invites */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Identifier type for public.users */ /** Identifier type for public.users */

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { UsersStorageUserStorageId } from './UsersStorage'; import type { UsersStorageUserStorageId } from './UsersStorage';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';

View file

@ -1,6 +1,3 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Represents the table public.videos_refs */ /** Represents the table public.videos_refs */