Documentation
¶
Overview ¶
Package id defines TypeID-based identity types for all Shield entities.
Every entity in Shield uses a single ID struct with a prefix that identifies the entity type. IDs are K-sortable (UUIDv7-based), globally unique, and URL-safe in the format "prefix_suffix".
Index ¶
- type AnyID
- type AwarenessID
- type BoundaryID
- type CheckID
- type ComplianceReportID
- type FindingID
- type ID
- func MustParse(s string) ID
- func MustParseWithPrefix(s string, expected Prefix) ID
- func New(prefix Prefix) ID
- func NewAwarenessID() ID
- func NewBoundaryID() ID
- func NewCheckID() ID
- func NewComplianceReportID() ID
- func NewFindingID() ID
- func NewInstinctID() ID
- func NewJudgmentID() ID
- func NewPIITokenID() ID
- func NewPolicyID() ID
- func NewReflexID() ID
- func NewSafetyProfileID() ID
- func NewScanID() ID
- func NewValueID() ID
- func Parse(s string) (ID, error)
- func ParseAny(s string) (ID, error)
- func ParseAwarenessID(s string) (ID, error)
- func ParseBoundaryID(s string) (ID, error)
- func ParseCheckID(s string) (ID, error)
- func ParseComplianceReportID(s string) (ID, error)
- func ParseFindingID(s string) (ID, error)
- func ParseInstinctID(s string) (ID, error)
- func ParseJudgmentID(s string) (ID, error)
- func ParsePIITokenID(s string) (ID, error)
- func ParsePolicyID(s string) (ID, error)
- func ParseReflexID(s string) (ID, error)
- func ParseSafetyProfileID(s string) (ID, error)
- func ParseScanID(s string) (ID, error)
- func ParseValueID(s string) (ID, error)
- func ParseWithPrefix(s string, expected Prefix) (ID, error)
- func (i ID) IsNil() bool
- func (i ID) MarshalBSONValue() (bsonType byte, data []byte, err error)
- func (i ID) MarshalText() ([]byte, error)
- func (i ID) Prefix() Prefix
- func (i *ID) Scan(src any) error
- func (i ID) String() string
- func (i *ID) UnmarshalBSONValue(t byte, data []byte) error
- func (i *ID) UnmarshalText(data []byte) error
- func (i ID) Value() (driver.Value, error)
- type InstinctID
- type JudgmentID
- type PIITokenID
- type PolicyID
- type Prefix
- type ReflexID
- type SafetyProfileID
- type ScanID
- type ValueID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AwarenessID ¶
type AwarenessID = ID
AwarenessID is a type-safe identifier for awareness detectors (prefix: "awr").
type BoundaryID ¶
type BoundaryID = ID
BoundaryID is a type-safe identifier for boundaries (prefix: "bnd").
type CheckID ¶
type CheckID = ID
CheckID is a type-safe identifier for safety checks (prefix: "schk").
type ComplianceReportID ¶
type ComplianceReportID = ID
ComplianceReportID is a type-safe identifier for compliance reports (prefix: "crpt").
type FindingID ¶
type FindingID = ID
FindingID is a type-safe identifier for findings (prefix: "find").
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is the primary identifier type for all Shield entities. It wraps a TypeID providing a prefix-qualified, globally unique, sortable, URL-safe identifier in the format "prefix_suffix".
var Nil ID
Nil is the zero-value ID.
func MustParseWithPrefix ¶
MustParseWithPrefix is like ParseWithPrefix but panics on error.
func New ¶
New generates a new globally unique ID with the given prefix. It panics if prefix is not a valid TypeID prefix (programming error).
func NewComplianceReportID ¶
func NewComplianceReportID() ID
NewComplianceReportID generates a new unique compliance report ID.
func NewSafetyProfileID ¶
func NewSafetyProfileID() ID
NewSafetyProfileID generates a new unique safety profile ID.
func Parse ¶
Parse parses a TypeID string (e.g., "scan_01h2xcejqtf2nbrexx3vqjhp41") into an ID. Returns an error if the string is not valid.
func ParseAwarenessID ¶
ParseAwarenessID parses a string and validates the "awr" prefix.
func ParseBoundaryID ¶
ParseBoundaryID parses a string and validates the "bnd" prefix.
func ParseCheckID ¶
ParseCheckID parses a string and validates the "schk" prefix.
func ParseComplianceReportID ¶
ParseComplianceReportID parses a string and validates the "crpt" prefix.
func ParseFindingID ¶
ParseFindingID parses a string and validates the "find" prefix.
func ParseInstinctID ¶
ParseInstinctID parses a string and validates the "inst" prefix.
func ParseJudgmentID ¶
ParseJudgmentID parses a string and validates the "jdg" prefix.
func ParsePIITokenID ¶
ParsePIITokenID parses a string and validates the "pii" prefix.
func ParsePolicyID ¶
ParsePolicyID parses a string and validates the "pol" prefix.
func ParseReflexID ¶
ParseReflexID parses a string and validates the "rflx" prefix.
func ParseSafetyProfileID ¶
ParseSafetyProfileID parses a string and validates the "sprf" prefix.
func ParseScanID ¶
ParseScanID parses a string and validates the "scan" prefix.
func ParseValueID ¶
ParseValueID parses a string and validates the "val" prefix.
func ParseWithPrefix ¶
ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.
func (ID) MarshalBSONValue ¶
MarshalBSONValue satisfies bson.ValueMarshaler (mongo-driver v2) so the ID is stored as a BSON string instead of an opaque struct. No bson import needed because Go uses structural typing for interface satisfaction.
func (ID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (ID) String ¶
String returns the full TypeID string representation (prefix_suffix). Returns an empty string for the Nil ID.
func (*ID) UnmarshalBSONValue ¶
UnmarshalBSONValue satisfies bson.ValueUnmarshaler (mongo-driver v2).
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type InstinctID ¶
type InstinctID = ID
InstinctID is a type-safe identifier for instincts (prefix: "inst").
type JudgmentID ¶
type JudgmentID = ID
JudgmentID is a type-safe identifier for judgments (prefix: "jdg").
type PIITokenID ¶
type PIITokenID = ID
PIITokenID is a type-safe identifier for PII tokens (prefix: "pii").
type Prefix ¶
type Prefix string
Prefix identifies the entity type encoded in a TypeID.
const ( PrefixScan Prefix = "scan" PrefixPolicy Prefix = "pol" PrefixFinding Prefix = "find" PrefixPIIToken Prefix = "pii" PrefixComplianceReport Prefix = "crpt" PrefixCheck Prefix = "schk" PrefixInstinct Prefix = "inst" PrefixJudgment Prefix = "jdg" PrefixAwareness Prefix = "awr" PrefixValue Prefix = "val" PrefixReflex Prefix = "rflx" PrefixBoundary Prefix = "bnd" PrefixSafetyProfile Prefix = "sprf" )
Prefix constants for all Shield entity types.
type ReflexID ¶
type ReflexID = ID
ReflexID is a type-safe identifier for reflexes (prefix: "rflx").
type SafetyProfileID ¶
type SafetyProfileID = ID
SafetyProfileID is a type-safe identifier for safety profiles (prefix: "sprf").