entity_derive/
lib.rs

1// SPDX-FileCopyrightText: 2025 RAprogramm <andrey.rozanov.vl@gmail.com>
2// SPDX-License-Identifier: MIT
3
4//! # revelation-macros
5//!
6//! Procedural macros for domain code generation.
7//!
8//! ## Quick Start
9//!
10//! ```rust,ignore
11//! use revelation_macros::Entity;
12//!
13//! #[derive(Entity)]
14//! #[entity(table = "users", schema = "core")]
15//! pub struct User {
16//!     #[id]
17//!     pub id: Uuid,
18//!
19//!     #[field(create, update, response)]
20//!     pub name: Option<String>,
21//!
22//!     #[field(create, response)]
23//!     pub email: Option<String>,
24//!
25//!     #[field(skip)]
26//!     pub password_hash: String,
27//!
28//!     #[field(response)]
29//!     #[auto]
30//!     pub created_at: DateTime<Utc>,
31//! }
32//! ```
33//!
34//! Generates: `CreateUserRequest`, `UpdateUserRequest`, `UserResponse`,
35//! `UserRepository`, `UserRow`, `InsertableUser`, mappers, SQL impl.
36
37mod entity;
38mod utils;
39
40use proc_macro::TokenStream;
41
42/// Derive macro for generating domain boilerplate.
43#[proc_macro_derive(Entity, attributes(entity, field, id, auto, validate))]
44pub fn derive_entity(input: TokenStream) -> TokenStream {
45    entity::derive(input)
46}