Générateur de schémas TypeScript TypeBox depuis SQL DDL
Convertissez les instructions SQL CREATE TABLE en schémas de validation à l'exécution @sinclair/typebox utilisant Type.Object, Type.String, Type.Number et Type.Optional.
import { Type, Static } from '@sinclair/typebox';
UserRole {
SUPERADMIN = 'SUPERADMIN',
ORG_ADMIN = 'ORG_ADMIN',
MEMBER = 'MEMBER',
BILLING = 'BILLING',
GUEST = 'GUEST',
}
UserRoleSchema = Type.Enum(UserRole);
UserRoleType = Static<typeof UserRoleSchema>;
SubscriptionStatus {
TRIALING = 'TRIALING',
ACTIVE = 'ACTIVE',
PAST_DUE = 'PAST_DUE',
CANCELED = 'CANCELED',
}
SubscriptionStatusSchema = Type.Enum(SubscriptionStatus);
SubscriptionStatusType = Static<typeof SubscriptionStatusSchema>;
/**
* TypeBox Schema for SQL table "organizations"
* Primary Key: [id]
*/
OrganizationSchema = Type.Object({
id: Type.String({ format: 'uuid' }),
slug: Type.String({ maxLength: 64 }),
name: Type.String({ maxLength: 255 }),
billingEmail: Type.String({ format: 'email', maxLength: 255 }),
status: SubscriptionStatusSchema,
settings: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
isActive: Type.Boolean({ default: true }),
createdAt: Type.String({ format: 'date-time' }),
updatedAt: Type.String({ format: 'date-time' }),
}, { additionalProperties: false });
Organization = Static<typeof OrganizationSchema>;
/**
* TypeBox Schema for SQL table "users"
* Primary Key: [id]
*/
UserSchema = Type.Object({
id: Type.String({ format: 'uuid' }),
organizationId: Type.String({ format: 'uuid' }),
email: Type.String({ format: 'email', maxLength: 255 }),
fullName: Type.Optional(Type.String({ maxLength: 120 })),
avatarUrl: Type.Optional(Type.String({ format: 'uri', maxLength: 500 })),
role: UserRoleSchema,
phoneNumber: Type.Optional(Type.String({ maxLength: 32 })),
isVerified: Type.Boolean({ default: false }),
lastLoginAt: Type.Optional(Type.String({ format: 'date-time' })),
createdAt: Type.String({ format: 'date-time' }),
}, { additionalProperties: false });
User = Static<typeof UserSchema>;
/**
* TypeBox Schema for SQL table "audit_logs"
* Primary Key: [id]
*/
AuditLogSchema = Type.Object({
id: Type.Integer({ minimum: 0 }),
organizationId: Type.String({ format: 'uuid' }),
actorId: Type.Optional(Type.String({ format: 'uuid' })),
eventName: Type.String({ maxLength: 100 }),
ipAddress: Type.Optional(Type.String({ format: 'ipv4' })),
userAgent: Type.Optional(Type.String({ maxLength: 500 })),
payload: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
createdAt: Type.String({ format: 'date-time' }),
}, { additionalProperties: false });
AuditLog = Static<typeof AuditLogSchema>;
Traitement côté client
Traitement haute performance exécuté entièrement dans la mémoire de votre navigateur.
Confidentialité sans envoi au serveur
Toutes les données restent strictement locales sans aucune communication vers un serveur externe.
Export prêt pour la production
Formats de sortie propres et optimisés, prêts pour un déploiement immédiat en production.