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