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