Documentation
¶
Overview ¶
Package pidl provides types and utilities for the Protocol Interaction Description Language. PIDL is a JSON-based DSL for describing protocol choreography that compiles to diagrams.
Index ¶
- func IsValidAnnotationType(t AnnotationType) bool
- func SanitizeID(s string) string
- func TitleCase(s string) string
- func ValidateFile(filename string) (*Protocol, ValidationErrors, error)
- func WriteProtocolFile(filename string, p *Protocol) error
- type Alternative
- type Annotation
- type AnnotationType
- type Category
- type Entity
- type EntityType
- type FileValidationResult
- type Flow
- type FlowMode
- type Phase
- type Protocol
- func MustParse(data []byte) *Protocol
- func MustParseFile(filename string) *Protocol
- func NewMinimalProtocol(id, name string) *Protocol
- func NewProtocol(id, name string) *Protocol
- func Parse(data []byte) (*Protocol, error)
- func ParseFile(filename string) (*Protocol, error)
- func ParseReader(r io.Reader) (*Protocol, error)
- func (p *Protocol) ChildPhases(parentID string) []Phase
- func (p *Protocol) EntityByID(id string) *Entity
- func (p *Protocol) EntityIDs() []string
- func (p *Protocol) FlowsByPhase(phaseID string) []Flow
- func (p *Protocol) IsValid() bool
- func (p *Protocol) PhaseByID(id string) *Phase
- func (p *Protocol) PhaseDepth(phaseID string) int
- func (p *Protocol) PhaseIDs() []string
- func (p *Protocol) RootPhases() []Phase
- func (p *Protocol) ToJSON() ([]byte, error)
- func (p *Protocol) ToJSONCompact() ([]byte, error)
- func (p *Protocol) Validate() ValidationErrors
- func (p *Protocol) WriteFile(filename string) error
- type ProtocolMeta
- type Reference
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidAnnotationType ¶ added in v0.2.0
func IsValidAnnotationType(t AnnotationType) bool
IsValidAnnotationType checks if the annotation type is valid.
func SanitizeID ¶
SanitizeID converts a string to a valid PIDL ID (lowercase, alphanumeric, underscores/hyphens).
func ValidateFile ¶
func ValidateFile(filename string) (*Protocol, ValidationErrors, error)
ValidateFile parses and validates a PIDL file, returning any validation errors.
func WriteProtocolFile ¶
WriteProtocolFile writes a protocol to a file as formatted JSON.
Types ¶
type Alternative ¶ added in v0.2.0
type Alternative struct {
// Condition describes when this alternative is taken.
Condition string `json:"condition"`
// Flows are the steps in this alternative path.
Flows []Flow `json:"flows"`
// Description provides additional context.
Description string `json:"description,omitempty"`
}
Alternative represents an alternative path in the flow.
type Annotation ¶ added in v0.2.0
type Annotation struct {
// Type categorizes the annotation.
Type AnnotationType `json:"type"`
// Text is the annotation message.
Text string `json:"text"`
// Details provides additional context.
Details string `json:"details,omitempty"`
}
Annotation represents a typed annotation on a flow.
type AnnotationType ¶ added in v0.2.0
type AnnotationType string
AnnotationType represents the type of annotation.
const ( AnnotationTypeSecurity AnnotationType = "security" AnnotationTypePerformance AnnotationType = "performance" AnnotationTypeDeprecated AnnotationType = "deprecated" AnnotationTypeInfo AnnotationType = "info" AnnotationTypeWarning AnnotationType = "warning" AnnotationTypeError AnnotationType = "error" )
type Entity ¶
type Entity struct {
// ID is the unique identifier used in flow references.
ID string `json:"id"`
// Name is the human-readable display name.
Name string `json:"name"`
// Type classifies the entity.
Type EntityType `json:"type"`
// Description of the entity's role.
Description string `json:"description,omitempty"`
}
Entity represents a participant in the protocol.
type EntityType ¶
type EntityType string
EntityType represents the type of an entity.
const ( EntityTypeClient EntityType = "client" EntityTypeAuthorizationServer EntityType = "authorization_server" EntityTypeResourceServer EntityType = "resource_server" EntityTypeUser EntityType = "user" EntityTypeBrowser EntityType = "browser" EntityTypeAgent EntityType = "agent" EntityTypeToolServer EntityType = "tool_server" EntityTypeTool EntityType = "tool" EntityTypeDelegatedAgent EntityType = "delegated_agent" EntityTypeIdentityProvider EntityType = "identity_provider" EntityTypeServiceProvider EntityType = "service_provider" EntityTypeServer EntityType = "server" EntityTypeOther EntityType = "other" )
type FileValidationResult ¶
type FileValidationResult struct {
Filename string
Protocol *Protocol
Errors ValidationErrors
ParseErr error
}
FileValidationResult contains the result of validating a single file.
func ValidateFiles ¶
func ValidateFiles(filenames []string) []FileValidationResult
ValidateFiles validates multiple PIDL files, returning results for each.
func (FileValidationResult) IsValid ¶
func (r FileValidationResult) IsValid() bool
IsValid returns true if the file parsed and validated successfully.
type Flow ¶
type Flow struct {
// From is the source entity ID.
From string `json:"from"`
// To is the target entity ID.
To string `json:"to"`
// Action identifies the action being performed.
Action string `json:"action"`
// Label is the display label (defaults to Action).
Label string `json:"label,omitempty"`
// Mode is the interaction mode.
Mode FlowMode `json:"mode,omitempty"`
// Phase is the phase ID this flow belongs to.
Phase string `json:"phase,omitempty"`
// Description provides additional details.
Description string `json:"description,omitempty"`
// Sequence provides explicit ordering.
Sequence int `json:"sequence,omitempty"`
// Condition specifies when this flow is executed (e.g., "token_valid", "error").
Condition string `json:"condition,omitempty"`
// Note is a visible annotation displayed on the diagram.
Note string `json:"note,omitempty"`
// Annotations are typed annotations for tooling and documentation.
Annotations []Annotation `json:"annotations,omitempty"`
// Alternatives are alternative paths from this flow point.
Alternatives []Alternative `json:"alternatives,omitempty"`
}
Flow represents an interaction between two entities.
func (Flow) DisplayLabel ¶
DisplayLabel returns the label for display, falling back to Action if Label is empty.
func (Flow) EffectiveMode ¶
EffectiveMode returns the flow mode, defaulting to FlowModeRequest if empty.
func (Flow) HasAlternatives ¶ added in v0.2.0
HasAlternatives returns true if the flow has alternative paths.
func (Flow) HasAnnotations ¶ added in v0.2.0
HasAnnotations returns true if the flow has annotations.
func (Flow) HasCondition ¶ added in v0.2.0
HasCondition returns true if the flow has a condition.
type FlowMode ¶
type FlowMode string
FlowMode represents the type of interaction.
const ( FlowModeRequest FlowMode = "request" FlowModeResponse FlowMode = "response" FlowModeRedirect FlowMode = "redirect" FlowModeCallback FlowMode = "callback" FlowModeInteractive FlowMode = "interactive" FlowModeEvent FlowMode = "event" FlowModeToolCall FlowMode = "tool_call" FlowModeToolResult FlowMode = "tool_result" )
type Phase ¶
type Phase struct {
// ID is the unique identifier.
ID string `json:"id"`
// Name is the human-readable name.
Name string `json:"name"`
// Description of the phase.
Description string `json:"description,omitempty"`
// Parent is the ID of the parent phase for nested phases.
Parent string `json:"parent,omitempty"`
}
Phase represents a logical grouping of flows.
type Protocol ¶
type Protocol struct {
// ProtocolMeta contains metadata about the protocol.
ProtocolMeta ProtocolMeta `json:"protocol"`
// Entities are the participants in the protocol (systems, actors, services).
Entities []Entity `json:"entities"`
// Phases provide optional logical grouping of flows.
Phases []Phase `json:"phases,omitempty"`
// Flows are the interactions between entities.
Flows []Flow `json:"flows"`
}
Protocol represents a complete PIDL document describing a protocol's choreography.
func MustParse ¶
MustParse parses PIDL JSON data and panics on error. Use only in tests or initialization code.
func MustParseFile ¶
MustParseFile reads and parses a PIDL JSON file, panicking on error. Use only in tests or initialization code.
func NewMinimalProtocol ¶
NewMinimalProtocol creates a minimal valid protocol scaffold.
func NewProtocol ¶
NewProtocol creates a new Protocol with the given ID and name.
func ParseReader ¶
ParseReader parses PIDL JSON from an io.Reader.
func (*Protocol) ChildPhases ¶ added in v0.2.0
ChildPhases returns phases that have the given parent ID.
func (*Protocol) EntityByID ¶
EntityByID returns the entity with the given ID, or nil if not found.
func (*Protocol) FlowsByPhase ¶
FlowsByPhase returns all flows belonging to the given phase.
func (*Protocol) PhaseDepth ¶ added in v0.2.0
PhaseDepth returns the nesting depth of a phase (0 for root phases).
func (*Protocol) RootPhases ¶ added in v0.2.0
RootPhases returns phases that have no parent (top-level phases).
func (*Protocol) ToJSONCompact ¶
ToJSONCompact serializes a Protocol to compact JSON.
func (*Protocol) Validate ¶
func (p *Protocol) Validate() ValidationErrors
Validate checks the Protocol for errors and returns all found issues.
type ProtocolMeta ¶
type ProtocolMeta struct {
// ID is the unique identifier for the protocol.
ID string `json:"id"`
// Name is the human-readable name.
Name string `json:"name"`
// Version of this protocol description.
Version string `json:"version,omitempty"`
// Description provides a brief summary.
Description string `json:"description,omitempty"`
// Category classifies the protocol type.
Category Category `json:"category,omitempty"`
// References links to relevant specifications.
References []Reference `json:"references,omitempty"`
}
ProtocolMeta contains metadata about a protocol.
type Reference ¶
type Reference struct {
// Name of the reference (e.g., "RFC 6749").
Name string `json:"name"`
// URL to the reference.
URL string `json:"url"`
}
Reference links to external documentation.
type ValidationError ¶
ValidationError represents a validation error with context.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is a collection of validation errors.
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string
func (ValidationErrors) HasErrors ¶
func (e ValidationErrors) HasErrors() bool
HasErrors returns true if there are any validation errors.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pidl
command
Command pidl is the CLI tool for the Protocol Interaction Description Language.
|
Command pidl is the CLI tool for the Protocol Interaction Description Language. |
|
Package examples provides embedded PIDL example protocols.
|
Package examples provides embedded PIDL example protocols. |
|
Package render provides diagram renderers for PIDL protocols.
|
Package render provides diagram renderers for PIDL protocols. |
|
Package schema provides the embedded PIDL JSON Schema.
|
Package schema provides the embedded PIDL JSON Schema. |