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