Skip to main content

systemprompt_identifiers/
lib.rs

1//! Typed newtype identifiers for systemprompt.io.
2//!
3//! Every entity in the platform is referenced through a wrapper newtype
4//! rather than a raw `String`.
5//!
6//! This crate provides both the macros that generate those wrappers
7//! ([`define_id!`], [`define_token!`]) and the canonical concrete types
8//! (`UserId`, `AgentId`, `TaskId`, `TraceId`, `ContextId`, `SessionId`,
9//! `McpServerId`, ...).
10//!
11//! Boundary types for talking to the database — [`DbValue`], [`ToDbValue`],
12//! [`FromDbValue`], [`JsonRow`] — also live here so that identifier modules
13//! can interoperate without depending on the database crate.
14//!
15//! # Construction
16//!
17//! ```ignore
18//! use systemprompt_identifiers::{TaskId, UserId};
19//!
20//! // Known string value (literal, parsed input, DB row).
21//! let user = UserId::new("user_abc");
22//!
23//! // Mint a fresh UUID-backed identifier.
24//! let task = TaskId::generate();
25//! ```
26//!
27//! Validated identifiers (`McpServerId`, `Email`, `ProfileName`,
28//! `ValidatedUrl`, `ValidatedFilePath`, `AgentName`) additionally expose a
29//! fallible `try_new` constructor returning [`error::IdValidationError`].
30//!
31//! # Feature flags
32//!
33//! | Feature | Effect |
34//! |---------|--------|
35//! | (default) | Pure-Rust types only. |
36//! | `sqlx` | Derives `sqlx::Type` on every identifier, allowing direct binding in `query_as!` macros. |
37
38pub mod db_value;
39
40pub use db_value::{DbValue, FromDbValue, JsonRow, ToDbValue, parse_database_datetime};
41
42mod agent;
43mod ai;
44mod auth;
45mod client;
46mod cloud;
47mod connection;
48mod content;
49mod context;
50mod email;
51mod execution;
52mod funnel;
53mod hook;
54mod jobs;
55mod links;
56mod mcp;
57mod oauth;
58mod path;
59mod plugin;
60mod policy;
61mod profile;
62mod roles;
63mod section;
64mod session;
65mod task;
66mod tenant;
67mod trace;
68mod url;
69mod user;
70mod webhook;
71
72pub mod error;
73pub mod headers;
74pub mod macros;
75
76pub use agent::{AgentId, AgentName};
77pub use ai::{
78    AiGatewayPolicyId, AiQuotaBucketId, AiRequestId, AiSafetyFindingId, ConfigId, MessageId,
79};
80pub use auth::{ApiKeyId, ApiKeySecret, CloudAuthToken, DeviceCertId, JwtToken, SessionToken};
81pub use client::{ClientId, ClientType};
82pub use cloud::{CheckoutSessionId, PriceId, TransactionId};
83pub use connection::ConnectionId;
84pub use content::{CategoryId, ContentId, FileId, SkillId, SourceId, TagId};
85pub use context::ContextId;
86pub use email::Email;
87pub use execution::{ArtifactId, ExecutionStepId, LogId, TokenId};
88pub use funnel::{EngagementEventId, FunnelId, FunnelProgressId};
89pub use hook::HookId;
90pub use jobs::{JobName, ScheduledJobId};
91pub use links::{CampaignId, LinkClickId, LinkId};
92pub use mcp::{AiToolCallId, McpExecutionId, McpServerId};
93pub use oauth::{AccessTokenId, AuthorizationCode, ChallengeId, RefreshTokenId};
94pub use path::ValidatedFilePath;
95pub use plugin::PluginId;
96pub use policy::PolicyVersion;
97pub use profile::ProfileName;
98pub use roles::RoleId;
99pub use section::SectionId;
100pub use session::{SessionId, SessionSource};
101pub use task::TaskId;
102pub use tenant::TenantId;
103pub use trace::TraceId;
104pub use url::ValidatedUrl;
105pub use user::UserId;
106pub use webhook::WebhookEndpointId;