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