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