systemprompt_users/repository/
mod.rs1mod api_key;
14mod banned_ip;
15mod device_cert;
16mod federated_identity;
17mod rate_limit_bucket;
18mod role_directory;
19mod session;
20mod sso_login_events;
21mod user;
22
23pub use api_key::CreateApiKeyParams;
24pub use banned_ip::{
25 BanDuration, BanIpParams, BanIpWithMetadataParams, BannedIp, BannedIpRepository,
26};
27pub use device_cert::EnrollDeviceCertParams;
28pub use rate_limit_bucket::UserRateLimitBucketRepository;
29pub use role_directory::UsersRoleDirectory;
30pub use session::SessionRepository;
31pub use sso_login_events::{NewSsoLoginEvent, SsoLoginEvent, SsoLoginEventRepository};
32pub use user::{
33 ArchiveOutcome, ArchiveParams, ArchiveState, MERGE_EXCLUDED_SECURITY_TABLES, MergeResult,
34 NewServiceAccount, PurgeCount, UpdateUserParams,
35};
36
37use sqlx::PgPool;
38use std::sync::Arc;
39use systemprompt_database::DbPool;
40
41const MAX_PAGE_SIZE: i64 = 100;
42
43#[derive(Debug, Clone)]
44pub struct UserRepository {
45 pool: Arc<PgPool>,
46 write_pool: Arc<PgPool>,
47}
48
49impl UserRepository {
50 pub fn new(db: &DbPool) -> Self {
51 let pool = db.pool();
52 let write_pool = db.write_pool();
53 Self { pool, write_pool }
54 }
55}