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//!
38//! Copyright (c) systemprompt.io — Business Source License 1.1.
39//! See <https://systemprompt.io> for licensing details.
40
41pub mod db_value;
42
43pub use db_value::{DbValue, FromDbValue, JsonRow, ToDbValue, parse_database_datetime};
44
45mod actor;
46mod agent;
47mod ai;
48mod auth;
49mod client;
50mod client_session;
51mod cloud;
52mod connection;
53mod content;
54mod context;
55mod email;
56mod evaluation;
57mod events;
58mod execution;
59mod funnel;
60mod gateway_boot;
61mod gateway_conversation;
62mod hook;
63mod instance;
64mod jobs;
65mod links;
66mod locale;
67mod marketplace;
68mod mcp;
69mod oauth;
70mod path;
71mod plugin;
72mod policy;
73mod profile;
74mod provider_request;
75mod roles;
76mod section;
77mod session;
78mod slack;
79mod task;
80mod teams;
81mod tenant;
82mod trace;
83mod url;
84mod user;
85mod webhook;
86
87pub mod error;
88pub mod headers;
89pub mod macros;
90
91pub use actor::{Actor, ActorKind, ActorKindTag};
92pub use agent::{AgentId, AgentName, ExternalAgentId};
93pub use ai::{
94    AiGatewayPolicyId, AiQuotaBucketId, AiRequestId, AiSafetyFindingId, ConfigId, MessageId,
95};
96pub use auth::{
97    ApiKeyId, ApiKeySecret, CloudAuthToken, DeviceCertId, DeviceId, JwtToken, SessionToken,
98};
99pub use client::{ClientId, ClientType};
100pub use client_session::ClientSessionId;
101pub use cloud::PriceId;
102pub use connection::ConnectionId;
103pub use content::{CategoryId, ContentId, FileId, SkillId, SourceId, TagId};
104pub use context::ContextId;
105pub use email::Email;
106pub use evaluation::{
107    EvalBudgetId, EvalCaseId, EvalExecutionId, EvalExperimentId, EvalJudgeCallId, EvalPairId,
108    EvalReservationId, EvalResultId, EvalRevisionId, EvalRubricId, EvalRunId, EvalWorkerId,
109};
110pub use events::EventOutboxId;
111pub use execution::{ArtifactId, ExecutionStepId, LogId, TokenId};
112pub use funnel::{EngagementEventId, FunnelId, FunnelProgressId};
113pub use gateway_boot::{DepartmentId, DepartmentName, ModelId, ProviderId, RouteId, SecretName};
114pub use gateway_conversation::GatewayConversationId;
115pub use hook::HookId;
116pub use instance::InstanceId;
117pub use jobs::{JobName, ScheduledJobId};
118pub use links::{CampaignId, LinkClickId, LinkId};
119pub use locale::LocaleCode;
120pub use marketplace::MarketplaceId;
121pub use mcp::{AiToolCallId, McpExecutionId, McpServerId, McpToolName};
122pub use oauth::{AccessTokenId, AuthorizationCode, ChallengeId, RefreshTokenId};
123pub use path::ValidatedFilePath;
124pub use plugin::PluginId;
125pub use policy::{CallId, PolicyId, PolicyVersion, SecretPatternId};
126pub use profile::ProfileName;
127pub use provider_request::ProviderRequestId;
128pub use roles::RoleId;
129pub use section::SectionId;
130pub use session::{SessionId, SessionSource};
131pub use slack::{SlackChannelId, SlackUserId, SlackWorkspaceId};
132pub use task::TaskId;
133pub use teams::{TeamsConversationId, TeamsTenantId, TeamsUserId};
134pub use tenant::TenantId;
135pub use trace::TraceId;
136pub use url::ValidatedUrl;
137pub use user::UserId;
138pub use webhook::WebhookEndpointId;
139
140define_id!(RuleId, generate);