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 { makePgTsGenerator } = require("kanel");
const ignoredTables = ["schema_migrations"];
/** @type {import('kanel').Config} */
@ -11,11 +11,9 @@ module.exports = {
password: "rootpost",
port: 5433,
},
typeFilter: (pgType) => !ignoredTables.includes(pgType.name),
preDeleteOutputFolder: true,
filter: (pgTable) => !ignoredTables.includes(pgTable.name),
outputPath: "./src/schemas",
generators: [makePgTsGenerator({
customTypeMap: {
"pg_catalog.tsvector": "string",
"pg_catalog.bpchar": "string",
@ -24,4 +22,8 @@ module.exports = {
},
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';
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';
/** Identifier type for public.annunci */
@ -89,7 +85,7 @@ export default interface AnnunciTable {
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>;

View file

@ -1,12 +1,8 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
/** Represents the enum public.BanType */
enum BanType {
ip = 'ip',
email = 'email',
phone = 'phone',
cf = 'cf',
};
type BanType =
| 'ip'
| 'email'
| 'phone'
| 'cf';
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 { 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';
/** 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 { 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 { EtichetteIdEtichetta } from './Etichette';
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';
/** 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 { 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';
/** 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';
/** 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';
/** 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 */
enum GenericStatusEnum {
pending = 'pending',
success = 'success',
failed = 'failed',
};
type GenericStatusEnum =
| 'pending'
| 'success'
| 'failed';
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';
/** 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 { UsersId } from './Users';
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';
/** 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 */
enum OrderTypeEnum {
Acconto = 'Acconto',
Saldo = 'Saldo',
Consulenza = 'Consulenza',
Altro = 'Altro',
Rinnovo = 'Rinnovo',
};
type OrderTypeEnum =
| 'Acconto'
| 'Saldo'
| 'Consulenza'
| 'Altro'
| 'Rinnovo';
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 { PrezziarioIdprezziario } from './Prezziario';
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 */
enum PaymentStatusEnum {
processing = 'processing',
success = 'success',
failed = 'failed',
};
type PaymentStatusEnum =
| 'processing'
| 'success'
| 'failed';
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 { PotenzialiGroupsId } from './PotenzialiGroups';
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';
/** 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 TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
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';
/** 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 FlagsTable } from './Flags';
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 BannersTable } from './Banners';
import type { default as ServizioTable } from './Servizio';
import type { default as MessagesAttachmentsTable } from './MessagesAttachments';
export default interface PublicSchema {
servizio_interessi: ServizioInteressiTable;
@ -92,4 +90,6 @@ export default interface PublicSchema {
banners: BannersTable;
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';
/** 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 { 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 { default as TipologiaPosizioneEnum } from './TipologiaPosizioneEnum';
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 { AnnunciId } from './Annunci';
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 { UsersId } from './Users';
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 */
enum StatusConfermaEnum {
'Inviato conferma' = 'Inviato conferma',
'Conferma accettata' = 'Conferma accettata',
'Caparra versata' = 'Caparra versata',
};
type StatusConfermaEnum =
| 'Inviato conferma'
| 'Conferma accettata'
| 'Caparra versata';
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';
/** 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 */
enum TipologiaPosizioneEnum {
Transitorio = 'Transitorio',
Stabile = 'Stabile',
};
type TipologiaPosizioneEnum =
| 'Transitorio'
| 'Stabile';
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 { EtichetteIdEtichetta } from './Etichette';
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';
/** 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';
/** 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 { UsersStorageUserStorageId } from './UsersStorage';
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 { 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';
/** Represents the table public.videos_refs */