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