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 marketplace;
57mod mcp;
58mod oauth;
59mod path;
60mod plugin;
61mod policy;
62mod profile;
63mod roles;
64mod section;
65mod session;
66mod task;
67mod tenant;
68mod trace;
69mod url;
70mod user;
71mod webhook;
72
73pub mod error;
74pub mod headers;
75pub mod macros;
76
77pub use agent::{AgentId, AgentName, ExternalAgentId};
78pub use ai::{
79    AiGatewayPolicyId, AiQuotaBucketId, AiRequestId, AiSafetyFindingId, ConfigId, MessageId,
80};
81pub use auth::{ApiKeyId, ApiKeySecret, CloudAuthToken, DeviceCertId, JwtToken, SessionToken};
82pub use client::{ClientId, ClientType};
83pub use cloud::{CheckoutSessionId, PriceId, TransactionId};
84pub use connection::ConnectionId;
85pub use content::{CategoryId, ContentId, FileId, SkillId, SourceId, TagId};
86pub use context::ContextId;
87pub use email::Email;
88pub use execution::{ArtifactId, ExecutionStepId, LogId, TokenId};
89pub use funnel::{EngagementEventId, FunnelId, FunnelProgressId};
90pub use hook::HookId;
91pub use jobs::{JobName, ScheduledJobId};
92pub use links::{CampaignId, LinkClickId, LinkId};
93pub use marketplace::MarketplaceId;
94pub use mcp::{AiToolCallId, McpExecutionId, McpServerId};
95pub use oauth::{AccessTokenId, AuthorizationCode, ChallengeId, RefreshTokenId};
96pub use path::ValidatedFilePath;
97pub use plugin::PluginId;
98pub use policy::PolicyVersion;
99pub use profile::ProfileName;
100pub use roles::RoleId;
101pub use section::SectionId;
102pub use session::{SessionId, SessionSource};
103pub use task::TaskId;
104pub use tenant::TenantId;
105pub use trace::TraceId;
106pub use url::ValidatedUrl;
107pub use user::UserId;
108pub use webhook::WebhookEndpointId;
109
110define_id!(RuleId, generate);