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`, `ContextId`, `Email`, `ProfileName`,
28//! `ValidatedUrl`, `ValidatedFilePath`, `AgentName`, ...) expose **only** the
29//! fallible `try_new` constructor returning [`error::IdValidationError`];
30//! there is no infallible `new` that could panic on runtime input. Values
31//! minted by the platform itself (`ContextId::generate`, `AgentName::system`)
32//! come from dedicated constructors.
33//!
34//! # Feature flags
35//!
36//! | Feature | Effect |
37//! |---------|--------|
38//! | (default) | Pure-Rust types only. |
39//! | `sqlx` | Derives `sqlx::Type` on every identifier, allowing direct binding in `query_as!` macros. |
40//!
41//! Copyright (c) systemprompt.io — Business Source License 1.1.
42//! See <https://systemprompt.io> for licensing details.
43
44pub mod db_value;
45
46pub use db_value::{DbValue, FromDbValue, JsonRow, ToDbValue, parse_database_datetime};
47
48mod actor;
49mod agent;
50mod ai;
51mod auth;
52mod client;
53mod client_session;
54mod cloud;
55mod connection;
56mod content;
57mod context;
58mod email;
59mod evaluation;
60mod events;
61mod execution;
62mod funnel;
63mod gateway_boot;
64mod gateway_conversation;
65mod hook;
66mod instance;
67mod jobs;
68mod links;
69mod locale;
70mod managed;
71mod marketplace;
72mod mcp;
73mod oauth;
74mod path;
75mod plugin;
76mod policy;
77mod profile;
78mod provider_request;
79mod roles;
80mod section;
81mod session;
82mod slack;
83mod task;
84mod teams;
85mod tenant;
86mod trace;
87mod url;
88mod user;
89mod webhook;
90
91pub mod error;
92pub mod headers;
93pub mod macros;
94
95pub use actor::{Actor, ActorKind, ActorKindTag};
96pub use agent::{AgentId, AgentName, ExternalAgentId};
97pub use ai::{
98    AiGatewayPolicyId, AiQuotaBucketId, AiRequestId, AiSafetyFindingId, ConfigId, MessageId,
99};
100pub use auth::{
101    ApiKeyId, ApiKeySecret, CloudAuthToken, DeviceCertId, DeviceId, JwtToken, SessionToken,
102};
103pub use client::{ClientId, ClientType};
104pub use client_session::ClientSessionId;
105pub use cloud::PriceId;
106pub use connection::ConnectionId;
107pub use content::{CategoryId, ContentId, FileId, SkillId, SourceId, TagId};
108pub use context::ContextId;
109pub use email::Email;
110pub use evaluation::{
111    EvalApprovalId, EvalBudgetId, EvalCampaignId, EvalCaseId, EvalExecutionId, EvalExperimentId,
112    EvalHoldoutProposalId, EvalReservationId, EvalRevisionId, EvalSuggestionId, EvalWorkerId,
113};
114pub use events::EventOutboxId;
115pub use execution::{ArtifactId, ExecutionStepId, LogId, TokenId};
116pub use funnel::{EngagementEventId, FunnelId, FunnelProgressId};
117pub use gateway_boot::{DepartmentId, DepartmentName, ModelId, ProviderId, RouteId, SecretName};
118pub use gateway_conversation::GatewayConversationId;
119pub use hook::HookId;
120pub use instance::InstanceId;
121pub use jobs::{JobName, ScheduledJobId};
122pub use links::{CampaignId, LinkClickId, LinkId};
123pub use locale::LocaleCode;
124pub use managed::{
125    AnalyticsChangeId, AnalyticsFactId, AnalyticsSnapshotJobId, AnalyticsWorkerId,
126    ConsumerInstallationId, DependencyVerificationId, DistributionId, InstallationReceiptId,
127    InstallationSessionBindingId, InventoryEntryId, InvocationAttributionId,
128    ManagedReconciliationId, ManagedResourceId, ManagedSourceId, NativeSessionId, PublicationId,
129    PublicationReviewId, ResourceRevisionId, SourceSnapshotId, WithdrawalProposalId,
130};
131pub use marketplace::MarketplaceId;
132pub use mcp::{AiToolCallId, McpExecutionId, McpServerId, McpToolName};
133pub use oauth::{AccessTokenId, AuthorizationCode, ChallengeId, RefreshTokenId};
134pub use path::ValidatedFilePath;
135pub use plugin::PluginId;
136pub use policy::{CallId, PolicyId, PolicyVersion, SecretPatternId};
137pub use profile::ProfileName;
138pub use provider_request::ProviderRequestId;
139pub use roles::RoleId;
140pub use section::SectionId;
141pub use session::{SessionId, SessionSource};
142pub use slack::{SlackChannelId, SlackUserId, SlackWorkspaceId};
143pub use task::TaskId;
144pub use teams::{TeamsConversationId, TeamsTenantId, TeamsUserId};
145pub use tenant::TenantId;
146pub use trace::TraceId;
147pub use url::ValidatedUrl;
148pub use user::UserId;
149pub use webhook::WebhookEndpointId;
150
151define_id!(RuleId, generate);
152pub use managed::ResourceInvocationId;