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