Documentation
¶
Overview ¶
Package render provides diagram rendering for PIDL protocols.
Package render provides diagram renderers for PIDL protocols.
Index ¶
- Constants
- func IsDocumentFormat(format Format) bool
- func ReadPostmanTargets(path string) (map[string]PostmanTarget, error)
- func RenderString(format Format, p *pidl.Protocol) (string, error)
- func SupportsIncludes(format Format) bool
- type D2Renderer
- type D2Style
- type DOTRenderer
- type Format
- type InfographicOptions
- type InfographicRenderer
- type InfographicSize
- type InfographicTheme
- type MarkdownMatrixRenderer
- type MermaidComponentRenderer
- type MermaidRenderer
- type MermaidStateRenderer
- type MermaidTrustRenderer
- type NodeShape
- type OutlineJSONRenderer
- type OutlineRenderer
- type PlantUMLRenderer
- type PostmanBody
- type PostmanCollection
- type PostmanEnvironment
- type PostmanEnvironmentRenderer
- type PostmanEnvironmentValue
- type PostmanEvent
- type PostmanHeader
- type PostmanInfo
- type PostmanItem
- type PostmanOptions
- type PostmanRawOptions
- type PostmanRenderer
- type PostmanRequest
- type PostmanResponse
- type PostmanScript
- type PostmanTarget
- type PostmanVariable
- type Renderer
- type SVGComponentRenderer
- type SVGNetworkRenderer
- type SVGRenderer
- type SVGTrustRenderer
- type ScenarioMatrixRenderer
- type SequenceRenderOptions
- type TokenTableRenderer
- type TraceRenderer
- func (r *TraceRenderer) Render(w io.Writer, trace *pidl.ExecutionTrace, opts TraceTextOptions) error
- func (r *TraceRenderer) RenderJSON(trace *pidl.ExecutionTrace) ([]byte, error)
- func (r *TraceRenderer) RenderMermaid(trace *pidl.ExecutionTrace, p *pidl.Protocol) string
- func (r *TraceRenderer) RenderSVG(trace *pidl.ExecutionTrace, p *pidl.Protocol) (string, error)
- func (r *TraceRenderer) RenderText(trace *pidl.ExecutionTrace, opts TraceTextOptions) string
- type TraceRendererInterface
- type TraceTextOptions
- type ViewerRenderer
- type WalkthroughJSONRenderer
- func (r *WalkthroughJSONRenderer) Build(p *pidl.Protocol) (pidl.Walkthrough, error)
- func (r *WalkthroughJSONRenderer) Format() Format
- func (r *WalkthroughJSONRenderer) Render(w io.Writer, p *pidl.Protocol) error
- func (r *WalkthroughJSONRenderer) RenderString(p *pidl.Protocol) (string, error)
- func (r *WalkthroughJSONRenderer) Walkthrough(p *pidl.Protocol) pidl.Walkthrough
Constants ¶
const ( // SignerNone sends requests directly, with their example headers. SignerNone = "" // SignerProxy sends requests with HTTP message signatures (RFC 9421) // through a signing proxy at {{signer_url}}: the target URL follows // the proxy's address. Postman cannot sign, so the example's // Signature, Signature-Input and Content-Digest headers are left out // for the proxy to create, and Signature-Key names only how to sign: // its scheme, and for the jwt scheme the token to present when an // earlier response delivered it. Requests without signatures are sent // directly. SignerProxy = "proxy" )
Signer profiles name how a signing helper receives a request.
const PostmanSchema = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
PostmanSchema is the Postman Collection format the renderer writes.
Variables ¶
This section is empty.
Functions ¶
func IsDocumentFormat ¶ added in v0.7.0
IsDocumentFormat reports whether the format describes the whole document (every scenario) rather than one flow list, so callers should not project a single scenario before rendering it.
func ReadPostmanTargets ¶ added in v0.9.0
func ReadPostmanTargets(path string) (map[string]PostmanTarget, error)
ReadPostmanTargets reads a targets file: a JSON object mapping target names (such as "sandbox" or "mock") to targets.
func RenderString ¶
RenderString renders a protocol using the specified format.
func SupportsIncludes ¶ added in v0.7.0
SupportsIncludes reports whether the format draws a scenario include step itself (as a labeled box). For other formats, callers expand includes before rendering.
Types ¶
type D2Renderer ¶ added in v0.2.0
type D2Renderer struct {
// SequenceRenderOptions contains common sequence diagram options.
SequenceRenderOptions
// Style determines the diagram style (sequence, flow, or arch).
Style D2Style
// ShowDescriptions includes flow descriptions as tooltips.
ShowDescriptions bool
// Direction sets the diagram direction (down, right, left, up).
Direction string
// ShowStepTypes includes visual styling for process step types.
ShowStepTypes bool
}
D2Renderer renders PIDL protocols as D2 diagrams.
func NewD2 ¶ added in v0.2.0
func NewD2() *D2Renderer
NewD2 creates a new D2 renderer with default options (sequence diagram).
func NewD2Arch ¶ added in v0.2.0
func NewD2Arch() *D2Renderer
NewD2Arch creates a new D2 renderer for architecture diagrams.
func NewD2Flow ¶ added in v0.2.0
func NewD2Flow() *D2Renderer
NewD2Flow creates a new D2 renderer for data flow diagrams.
func (*D2Renderer) Format ¶ added in v0.2.0
func (r *D2Renderer) Format() Format
Format returns the output format.
func (*D2Renderer) RenderString ¶ added in v0.2.0
func (r *D2Renderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the D2 diagram as a string.
type DOTRenderer ¶
type DOTRenderer struct {
// Title includes the protocol name as graph label.
Title bool
// RankDir sets the graph direction (LR, TB, RL, BT).
RankDir string
// MergeEdges combines multiple flows between the same entities.
MergeEdges bool
// ShowPhases groups nodes by phase using subgraphs.
ShowPhases bool
// ShowConditions includes condition text in edge labels.
ShowConditions bool
// ShowAnnotations includes annotation counts in edge labels.
ShowAnnotations bool
}
DOTRenderer renders PIDL protocols as Graphviz DOT data flow diagrams.
func (*DOTRenderer) Format ¶
func (r *DOTRenderer) Format() Format
Format returns the output format.
func (*DOTRenderer) RenderString ¶
func (r *DOTRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the DOT diagram as a string.
type Format ¶
type Format string
Format represents a diagram output format.
const ( FormatPlantUML Format = "plantuml" FormatMermaid Format = "mermaid" FormatMermaidState Format = "mermaid-state" FormatMermaidComponent Format = "mermaid-component" FormatMermaidTrust Format = "mermaid-trust" FormatMarkdownMatrix Format = "markdown-matrix" FormatDOT Format = "dot" FormatD2 Format = "d2" FormatD2Flow Format = "d2-flow" FormatD2Arch Format = "d2-arch" FormatSVG Format = "svg" FormatSVGAnimated Format = "svg-animated" FormatSVGNetwork Format = "svg-network" FormatSVGComponent Format = "svg-component" FormatSVGTrust Format = "svg-trust" FormatInfographic Format = "infographic" FormatScenarioMatrix Format = "scenario-matrix" FormatTokenTable Format = "token-table" FormatOutline Format = "outline" FormatOutlineJSON Format = "outline-json" FormatWalkthroughJSON Format = "walkthrough-json" FormatViewer Format = "viewer" FormatPostman Format = "postman" FormatPostmanEnvironment Format = "postman-environment" )
func MustParseFormat ¶
MustParseFormat parses a format string, panicking on error.
func ParseFormat ¶
ParseFormat parses a format string, returning an error if invalid.
func SupportedFormats ¶
func SupportedFormats() []Format
SupportedFormats returns all supported output formats.
func (Format) FileExtension ¶
FileExtension returns the conventional file extension for this format.
type InfographicOptions ¶ added in v0.5.0
type InfographicOptions struct {
// Canvas size preset
Size InfographicSize
// Custom dimensions (override Size preset)
Width int
Height int
// Theme
Theme InfographicTheme
// Title to display at top (optional)
Title string
// Animation
AnimateDots bool // Enable animated dots on edges
DotSpeed float64 // Animation duration in seconds
DotsPerEdge int // Number of dots per edge
BidirectionalDots bool // Dots go both directions
// Layout
Direction string // "horizontal" or "vertical"
Padding int // Padding around content
// Simplification
MaxNodes int // Warn if exceeded
TruncateLabels int // Max label chars (0 = no truncation)
ShowLabels bool // Show node labels
ShowEdgeLabels bool // Show edge labels
// Styling
NodeRadius int // Corner radius for rectangle nodes
StrokeWidth int // Line thickness
FontSize int // Base font size
TitleFontSize int // Title font size
UseCustomShapes bool // Use shape based on entity/step type
}
InfographicOptions configures the infographic renderer.
func DatasheetTileOptions ¶ added in v0.5.0
func DatasheetTileOptions() InfographicOptions
DatasheetTileOptions returns options optimized for datasheet tiles.
func DefaultInfographicOptions ¶ added in v0.5.0
func DefaultInfographicOptions() InfographicOptions
DefaultInfographicOptions returns sensible defaults for LinkedIn.
type InfographicRenderer ¶ added in v0.5.0
type InfographicRenderer struct {
// contains filtered or unexported fields
}
InfographicRenderer renders process specs as compact infographics.
func NewInfographicRenderer ¶ added in v0.5.0
func NewInfographicRenderer(opts InfographicOptions) *InfographicRenderer
NewInfographicRenderer creates a new infographic renderer.
type InfographicSize ¶ added in v0.5.0
type InfographicSize string
InfographicSize defines preset canvas sizes.
const ( // SizeLinkedInSquare is 1200x1200 for LinkedIn feed posts. SizeLinkedInSquare InfographicSize = "linkedin-square" // SizeLinkedInPortrait is 1080x1350 for LinkedIn portrait posts. SizeLinkedInPortrait InfographicSize = "linkedin-portrait" // SizeLinkedInLandscape is 1200x627 for LinkedIn link previews. SizeLinkedInLandscape InfographicSize = "linkedin-landscape" // SizeDatasheetTile is 400x400 for datasheet grid layouts. SizeDatasheetTile InfographicSize = "datasheet-tile" // SizeDatasheetWide is 600x300 for wide datasheet tiles. SizeDatasheetWide InfographicSize = "datasheet-wide" )
type InfographicTheme ¶ added in v0.5.0
type InfographicTheme string
InfographicTheme defines color themes.
const ( ThemeBold InfographicTheme = "bold" // High contrast, saturated ThemeMinimal InfographicTheme = "minimal" // Clean, subtle ThemeDark InfographicTheme = "dark" // Dark background ThemeTech InfographicTheme = "tech" // Tech/engineering feel ThemeCorporate InfographicTheme = "corporate" // Professional blues/grays ThemeAccessible InfographicTheme = "accessible" // Colorblind-friendly (CVD safe) )
type MarkdownMatrixRenderer ¶ added in v0.4.0
type MarkdownMatrixRenderer struct {
// Title includes a title header
Title bool
// ShowDescription includes entity descriptions
ShowDescription bool
}
MarkdownMatrixRenderer generates a Markdown table showing protocol roles by entity.
func NewMarkdownMatrix ¶ added in v0.4.0
func NewMarkdownMatrix() *MarkdownMatrixRenderer
NewMarkdownMatrix creates a new MarkdownMatrixRenderer with default settings.
func (*MarkdownMatrixRenderer) Format ¶ added in v0.4.0
func (r *MarkdownMatrixRenderer) Format() Format
Format returns the output format identifier.
func (*MarkdownMatrixRenderer) Render ¶ added in v0.4.0
Render writes the Markdown matrix to the given writer.
func (*MarkdownMatrixRenderer) RenderString ¶ added in v0.4.0
func (r *MarkdownMatrixRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the Markdown matrix as a string.
type MermaidComponentRenderer ¶ added in v0.4.0
type MermaidComponentRenderer struct {
// Title includes the protocol name as diagram title.
Title bool
// ShowEntities includes entity nodes within components.
ShowEntities bool
// ShowRoles includes protocol roles on components.
ShowRoles bool
}
MermaidComponentRenderer renders PIDL protocols as Mermaid flowcharts showing deployment components and their relationships.
func NewMermaidComponent ¶ added in v0.4.0
func NewMermaidComponent() *MermaidComponentRenderer
NewMermaidComponent creates a new Mermaid component diagram renderer.
func (*MermaidComponentRenderer) Format ¶ added in v0.4.0
func (r *MermaidComponentRenderer) Format() Format
Format returns the output format.
func (*MermaidComponentRenderer) Render ¶ added in v0.4.0
Render writes the Mermaid diagram to the writer.
func (*MermaidComponentRenderer) RenderString ¶ added in v0.4.0
func (r *MermaidComponentRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the Mermaid diagram as a string.
type MermaidRenderer ¶
type MermaidRenderer struct {
// SequenceRenderOptions contains common sequence diagram options.
SequenceRenderOptions
// Autonumber adds sequence numbers to messages.
Autonumber bool
// ShowStepTypes includes step type indicators for process specs.
ShowStepTypes bool
}
MermaidRenderer renders PIDL protocols as Mermaid sequence diagrams.
func NewMermaid ¶
func NewMermaid() *MermaidRenderer
NewMermaid creates a new Mermaid renderer with default options.
func (*MermaidRenderer) Format ¶
func (r *MermaidRenderer) Format() Format
Format returns the output format.
func (*MermaidRenderer) RenderString ¶
func (r *MermaidRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the Mermaid diagram as a string.
type MermaidStateRenderer ¶ added in v0.4.0
type MermaidStateRenderer struct {
// Title includes the protocol name as diagram title.
Title bool
// EntityFilter limits output to a specific entity (empty for all).
EntityFilter string
// ShowDescriptions includes state descriptions as notes.
ShowDescriptions bool
}
MermaidStateRenderer renders PIDL protocols as Mermaid state diagrams.
func NewMermaidState ¶ added in v0.4.0
func NewMermaidState() *MermaidStateRenderer
NewMermaidState creates a new Mermaid state diagram renderer with default options.
func (*MermaidStateRenderer) Format ¶ added in v0.4.0
func (r *MermaidStateRenderer) Format() Format
Format returns the output format.
func (*MermaidStateRenderer) Render ¶ added in v0.4.0
Render writes the Mermaid state diagram to the writer.
func (*MermaidStateRenderer) RenderString ¶ added in v0.4.0
func (r *MermaidStateRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the Mermaid state diagram as a string.
type MermaidTrustRenderer ¶ added in v0.4.0
type MermaidTrustRenderer struct {
// Title includes the protocol name as diagram title.
Title bool
// ShowCredentials includes credential types on edges.
ShowCredentials bool
// ShowComponents groups entities by their components.
ShowComponents bool
}
MermaidTrustRenderer renders PIDL protocols as Mermaid flowcharts showing trust relationships between entities and components.
func NewMermaidTrust ¶ added in v0.4.0
func NewMermaidTrust() *MermaidTrustRenderer
NewMermaidTrust creates a new Mermaid trust diagram renderer.
func (*MermaidTrustRenderer) Format ¶ added in v0.4.0
func (r *MermaidTrustRenderer) Format() Format
Format returns the output format.
func (*MermaidTrustRenderer) Render ¶ added in v0.4.0
Render writes the Mermaid diagram to the writer.
func (*MermaidTrustRenderer) RenderString ¶ added in v0.4.0
func (r *MermaidTrustRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the Mermaid diagram as a string.
type NodeShape ¶ added in v0.5.0
type NodeShape string
NodeShape defines the shape of a node.
const ( ShapeRectangle NodeShape = "rectangle" // Rounded rectangle (default) ShapeCircle NodeShape = "circle" // Circle for users/humans ShapeHexagon NodeShape = "hexagon" // Hexagon for agents/LLMs ShapeCylinder NodeShape = "cylinder" // Cylinder for databases/resources ShapeCloud NodeShape = "cloud" // Cloud for external services ShapeDiamond NodeShape = "diamond" // Diamond for tools/decisions )
type OutlineJSONRenderer ¶ added in v0.7.0
type OutlineJSONRenderer struct{}
OutlineJSONRenderer writes a protocol's Outline as indented JSON, for deck and guide tooling.
func NewOutlineJSON ¶ added in v0.7.0
func NewOutlineJSON() *OutlineJSONRenderer
NewOutlineJSON creates an OutlineJSONRenderer.
func (*OutlineJSONRenderer) Format ¶ added in v0.7.0
func (r *OutlineJSONRenderer) Format() Format
Format returns the output format identifier.
func (*OutlineJSONRenderer) RenderString ¶ added in v0.7.0
func (r *OutlineJSONRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the outline as indented JSON.
type OutlineRenderer ¶ added in v0.7.0
type OutlineRenderer struct{}
OutlineRenderer writes a protocol's Outline as Markdown: roles, then scenarios with numbered steps, then tokens, all in document order. It is a starting point for guides and slide decks.
func NewOutline ¶ added in v0.7.0
func NewOutline() *OutlineRenderer
NewOutline creates an OutlineRenderer.
func (*OutlineRenderer) Format ¶ added in v0.7.0
func (r *OutlineRenderer) Format() Format
Format returns the output format identifier.
func (*OutlineRenderer) RenderString ¶ added in v0.7.0
func (r *OutlineRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the outline as Markdown.
type PlantUMLRenderer ¶
type PlantUMLRenderer struct {
// SequenceRenderOptions contains common sequence diagram options.
SequenceRenderOptions
// ShowDescriptions includes flow descriptions as notes.
ShowDescriptions bool
// ShowStepTypes includes visual styling for process step types.
ShowStepTypes bool
}
PlantUMLRenderer renders PIDL protocols as PlantUML sequence diagrams.
func NewPlantUML ¶
func NewPlantUML() *PlantUMLRenderer
NewPlantUML creates a new PlantUML renderer with default options.
func (*PlantUMLRenderer) Format ¶
func (r *PlantUMLRenderer) Format() Format
Format returns the output format.
func (*PlantUMLRenderer) RenderString ¶
func (r *PlantUMLRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the PlantUML diagram as a string.
type PostmanBody ¶ added in v0.9.0
type PostmanBody struct {
Mode string `json:"mode"`
Raw string `json:"raw"`
Options *PostmanRawOptions `json:"options,omitempty"`
}
PostmanBody is a raw request body.
type PostmanCollection ¶ added in v0.9.0
type PostmanCollection struct {
Info PostmanInfo `json:"info"`
Item []PostmanItem `json:"item"`
Event []PostmanEvent `json:"event,omitempty"`
Variable []PostmanVariable `json:"variable,omitempty"`
}
PostmanCollection is a collection.
type PostmanEnvironment ¶ added in v0.9.0
type PostmanEnvironment struct {
ID string `json:"id"`
Name string `json:"name"`
Values []PostmanEnvironmentValue `json:"values"`
Scope string `json:"_postman_variable_scope"`
}
PostmanEnvironment is a Postman environment file.
func NewPostmanEnvironment ¶ added in v0.9.0
func NewPostmanEnvironment(p *pidl.Protocol, name string, t PostmanTarget) (*PostmanEnvironment, error)
NewPostmanEnvironment builds the environment for one target, checking that every role and scenario it names exists in the protocol.
func (*PostmanEnvironment) JSON ¶ added in v0.9.0
func (e *PostmanEnvironment) JSON() (string, error)
JSON returns the environment as indented JSON.
type PostmanEnvironmentRenderer ¶ added in v0.9.0
type PostmanEnvironmentRenderer struct {
Name string
Target *PostmanTarget
}
PostmanEnvironmentRenderer writes the environment for one target. With no target, roles point at the origins of the protocol's example URLs.
func (*PostmanEnvironmentRenderer) Format ¶ added in v0.9.0
func (r *PostmanEnvironmentRenderer) Format() Format
Format returns the output format identifier.
func (*PostmanEnvironmentRenderer) RenderString ¶ added in v0.9.0
func (r *PostmanEnvironmentRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the environment as indented JSON.
type PostmanEnvironmentValue ¶ added in v0.9.0
type PostmanEnvironmentValue struct {
Key string `json:"key"`
Value string `json:"value"`
Type string `json:"type"`
Enabled bool `json:"enabled"`
}
PostmanEnvironmentValue is one environment variable.
type PostmanEvent ¶ added in v0.9.0
type PostmanEvent struct {
Listen string `json:"listen"`
Script PostmanScript `json:"script"`
}
PostmanEvent is a script run before a request or after its response.
type PostmanHeader ¶ added in v0.9.0
PostmanHeader is one header.
type PostmanInfo ¶ added in v0.9.0
type PostmanInfo struct {
PostmanID string `json:"_postman_id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Schema string `json:"schema"`
}
PostmanInfo describes a collection.
type PostmanItem ¶ added in v0.9.0
type PostmanItem struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Item []PostmanItem `json:"item,omitempty"`
Request *PostmanRequest `json:"request,omitempty"`
Response []PostmanResponse `json:"response,omitempty"`
Event []PostmanEvent `json:"event,omitempty"`
}
PostmanItem is a folder (Item set) or a request (Request set).
type PostmanOptions ¶ added in v0.9.0
type PostmanOptions struct {
// Client is the role whose requests become Postman requests. Empty
// selects the first entity of type agent or client.
Client string
// Signer is a signer profile; SignerNone sends requests directly.
Signer string
// Mock saves example responses as Postman examples, adds the
// x-mock-response-name header, and checks only status codes.
Mock bool
// PollLimit is how many times a deferred request is polled before the
// run fails. Zero means 30.
PollLimit int
}
PostmanOptions configure the collection.
type PostmanRawOptions ¶ added in v0.9.0
type PostmanRawOptions struct {
Raw struct {
Language string `json:"language"`
} `json:"raw"`
}
PostmanRawOptions names a raw body's language.
type PostmanRenderer ¶ added in v0.9.0
type PostmanRenderer struct {
Options PostmanOptions
}
PostmanRenderer writes a Postman collection (format v2.1) with a folder per scenario and a request per step the client role sends, chaining values from responses into later requests.
func NewPostman ¶ added in v0.9.0
func NewPostman(opts PostmanOptions) *PostmanRenderer
NewPostman creates a PostmanRenderer.
func (*PostmanRenderer) Collection ¶ added in v0.9.0
func (r *PostmanRenderer) Collection(p *pidl.Protocol) (*PostmanCollection, error)
Collection builds the collection.
func (*PostmanRenderer) Format ¶ added in v0.9.0
func (r *PostmanRenderer) Format() Format
Format returns the output format identifier.
func (*PostmanRenderer) RenderString ¶ added in v0.9.0
func (r *PostmanRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the collection as indented JSON.
type PostmanRequest ¶ added in v0.9.0
type PostmanRequest struct {
Method string `json:"method"`
Header []PostmanHeader `json:"header"`
Body *PostmanBody `json:"body,omitempty"`
URL string `json:"url"`
}
PostmanRequest is a request.
type PostmanResponse ¶ added in v0.9.0
type PostmanResponse struct {
Name string `json:"name"`
OriginalRequest *PostmanRequest `json:"originalRequest,omitempty"`
Status string `json:"status"`
Code int `json:"code"`
Header []PostmanHeader `json:"header"`
Body string `json:"body"`
PreviewLanguage string `json:"_postman_previewlanguage,omitempty"`
}
PostmanResponse is a saved example response.
type PostmanScript ¶ added in v0.9.0
PostmanScript is JavaScript, one line per element.
type PostmanTarget ¶ added in v0.9.0
type PostmanTarget struct {
// Signer is the signing helper's base URL, such as
// "http://127.0.0.1:8099".
Signer string `json:"signer,omitempty"`
// Roles maps a role ID to its base URL.
Roles map[string]string `json:"roles"`
// Scenarios maps a scenario ID to role base URLs that apply to that
// scenario's folder only.
Scenarios map[string]map[string]string `json:"scenarios,omitempty"`
// Variables are extra environment variables, such as "mock_url".
Variables map[string]string `json:"variables,omitempty"`
}
PostmanTarget says where a collection's roles run: a base URL per role, optional per-scenario overrides, and an optional signing helper.
type PostmanVariable ¶ added in v0.9.0
PostmanVariable is a collection variable.
type Renderer ¶
type Renderer interface {
// Render writes the diagram to the writer.
Render(w io.Writer, p *pidl.Protocol) error
// RenderString returns the diagram as a string.
RenderString(p *pidl.Protocol) (string, error)
// Format returns the output format name.
Format() Format
}
Renderer generates diagram output from a Protocol.
type SVGComponentRenderer ¶ added in v0.4.0
type SVGComponentRenderer struct {
// Title includes a title header
Title bool
// Theme selects the color scheme ("light", "dark")
Theme string
// ShowEntities shows entities within components
ShowEntities bool
// ShowRoles shows protocol roles on components
ShowRoles bool
}
SVGComponentRenderer renders deployment component diagrams as SVG.
func NewSVGComponent ¶ added in v0.4.0
func NewSVGComponent() *SVGComponentRenderer
NewSVGComponent creates a new SVGComponentRenderer with default settings.
func (*SVGComponentRenderer) Format ¶ added in v0.4.0
func (r *SVGComponentRenderer) Format() Format
Format returns the output format identifier.
func (*SVGComponentRenderer) Render ¶ added in v0.4.0
Render writes the SVG diagram to the given writer.
func (*SVGComponentRenderer) RenderString ¶ added in v0.4.0
func (r *SVGComponentRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the SVG diagram as a string.
type SVGNetworkRenderer ¶ added in v0.3.0
type SVGNetworkRenderer struct {
// Animated enables CSS animations.
Animated bool
// Theme selects the color scheme ("light", "dark", "auto").
Theme string
// Title includes the protocol name in the diagram.
Title bool
// Direction is the layout direction ("horizontal" or "vertical").
Direction string
// ShowTrust enables trust level display on entities.
ShowTrust bool
// InferBoundariesFromTrust infers network boundaries from entity trust levels.
InferBoundariesFromTrust bool
// BoundaryOverrides allows CLI-specified boundary assignments.
// Map of boundary ID to entity IDs.
BoundaryOverrides map[string][]string
// contains filtered or unexported fields
}
SVGNetworkRenderer renders PIDL protocols as SVG network boundary diagrams.
func NewSVGNetwork ¶ added in v0.3.0
func NewSVGNetwork() *SVGNetworkRenderer
NewSVGNetwork creates a new SVG network renderer with default options.
func (*SVGNetworkRenderer) AddBoundaryOverride ¶ added in v0.3.0
func (r *SVGNetworkRenderer) AddBoundaryOverride(boundaryID string, entityIDs []string)
AddBoundaryOverride adds a CLI-specified boundary assignment.
func (*SVGNetworkRenderer) Format ¶ added in v0.3.0
func (r *SVGNetworkRenderer) Format() Format
Format returns the output format.
func (*SVGNetworkRenderer) RenderString ¶ added in v0.3.0
func (r *SVGNetworkRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the SVG diagram as a string.
type SVGRenderer ¶ added in v0.3.0
type SVGRenderer struct {
// SequenceRenderOptions contains common sequence diagram options.
SequenceRenderOptions
// Animated enables CSS animations (moving dots along message lines).
// This is used by FormatSVGAnimated.
Animated bool
// Theme selects the color scheme ("light", "dark", "auto").
Theme string
// ShowStepNumbers shows step numbers on messages.
ShowStepNumbers bool
// ShowPhases renders phase boxes around grouped flows.
ShowPhases bool
// ShowStepTypes includes visual styling for process step types.
ShowStepTypes bool
// ParticipantSpacing sets horizontal spacing between participants.
ParticipantSpacing int
// MessageSpacing sets vertical spacing between messages.
MessageSpacing int
// Template is the name of a built-in template to use.
Template string
// TemplateDir is a path to a custom template directory.
TemplateDir string
// AnimationConfig contains global animation settings.
AnimationConfig svg.AnimationConfig
// contains filtered or unexported fields
}
SVGRenderer renders PIDL protocols as SVG sequence diagrams.
func NewSVG ¶ added in v0.3.0
func NewSVG() *SVGRenderer
NewSVG creates a new SVG renderer with default options.
func NewSVGAnimated ¶ added in v0.3.0
func NewSVGAnimated() *SVGRenderer
NewSVGAnimated creates a new SVG renderer with animations enabled.
func NewSVGWithTemplate ¶ added in v0.3.0
func NewSVGWithTemplate(templateName string) (*SVGRenderer, error)
NewSVGWithTemplate creates an SVG renderer using the specified template.
func NewSVGWithTemplateDir ¶ added in v0.3.0
func NewSVGWithTemplateDir(dir string) (*SVGRenderer, error)
NewSVGWithTemplateDir creates an SVG renderer using a template from a directory.
func (*SVGRenderer) Format ¶ added in v0.3.0
func (r *SVGRenderer) Format() Format
Format returns the output format.
func (*SVGRenderer) RenderString ¶ added in v0.3.0
func (r *SVGRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the SVG diagram as a string.
type SVGTrustRenderer ¶ added in v0.4.0
type SVGTrustRenderer struct {
// Title includes a title header
Title bool
// Theme selects the color scheme ("light", "dark")
Theme string
// ShowCredentials shows credential types on edges
ShowCredentials bool
// ShowComponents uses component names instead of entity/component IDs
ShowComponents bool
}
SVGTrustRenderer renders trust relationship diagrams as SVG.
func NewSVGTrust ¶ added in v0.4.0
func NewSVGTrust() *SVGTrustRenderer
NewSVGTrust creates a new SVGTrustRenderer with default settings.
func (*SVGTrustRenderer) Format ¶ added in v0.4.0
func (r *SVGTrustRenderer) Format() Format
Format returns the output format identifier.
func (*SVGTrustRenderer) Render ¶ added in v0.4.0
Render writes the SVG diagram to the given writer.
func (*SVGTrustRenderer) RenderString ¶ added in v0.4.0
func (r *SVGTrustRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the SVG diagram as a string.
type ScenarioMatrixRenderer ¶ added in v0.7.0
type ScenarioMatrixRenderer struct {
// Title adds a heading with the protocol name.
Title bool
// IncludeFragments adds a column per fragment after the main scenarios.
IncludeFragments bool
}
ScenarioMatrixRenderer generates a Markdown table of entities (rows, in entities order) by scenarios (columns, main scenarios then fragments). A cell is "●" when the scenario's own flows use the entity and "○" when the entity takes part only through an included fragment.
func NewScenarioMatrix ¶ added in v0.7.0
func NewScenarioMatrix() *ScenarioMatrixRenderer
NewScenarioMatrix creates a ScenarioMatrixRenderer with fragments shown.
func (*ScenarioMatrixRenderer) Format ¶ added in v0.7.0
func (r *ScenarioMatrixRenderer) Format() Format
Format returns the output format identifier.
func (*ScenarioMatrixRenderer) RenderString ¶ added in v0.7.0
func (r *ScenarioMatrixRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the matrix as Markdown.
type SequenceRenderOptions ¶ added in v0.4.0
type SequenceRenderOptions struct {
// Title includes the protocol name as diagram title.
Title bool
// ShowNotes renders flow notes.
ShowNotes bool
// ShowAnnotations renders flow annotations.
ShowAnnotations bool
// ShowConditions wraps conditional flows in opt blocks.
ShowConditions bool
// ShowAlternatives renders alternative paths.
ShowAlternatives bool
// ShowSecurity renders security requirement notes/badges.
ShowSecurity bool
// ShowDataPorts renders input/output data ports for process steps.
ShowDataPorts bool
// ShowVerification renders flow verification provenance badges.
ShowVerification bool
}
SequenceRenderOptions contains common options for sequence diagram renderers. Renderers can embed this struct to get standard options.
func DefaultSequenceRenderOptions ¶ added in v0.4.0
func DefaultSequenceRenderOptions() SequenceRenderOptions
DefaultSequenceRenderOptions returns the default sequence render options.
type TokenTableRenderer ¶ added in v0.7.0
type TokenTableRenderer struct {
// Title adds a heading with the protocol name.
Title bool
}
TokenTableRenderer generates a Markdown table of the protocol's token definitions, in the order they are declared: issuer, audience, binding, who checks each token and which claims they rely on, and the scenarios that issue and check it. A second table lists claim descriptions.
func NewTokenTable ¶ added in v0.7.0
func NewTokenTable() *TokenTableRenderer
NewTokenTable creates a TokenTableRenderer.
func (*TokenTableRenderer) Format ¶ added in v0.7.0
func (r *TokenTableRenderer) Format() Format
Format returns the output format identifier.
func (*TokenTableRenderer) RenderString ¶ added in v0.7.0
func (r *TokenTableRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the token table as Markdown.
type TraceRenderer ¶ added in v0.4.0
type TraceRenderer struct {
// ShowStates includes entity states in output.
ShowStates bool
// ShowTimings includes timing information.
ShowTimings bool
// HighlightSkipped emphasizes skipped flows.
HighlightSkipped bool
}
TraceRenderer renders execution traces in various formats.
func NewTraceRenderer ¶ added in v0.4.0
func NewTraceRenderer() *TraceRenderer
NewTraceRenderer creates a new TraceRenderer with default options.
func (*TraceRenderer) Render ¶ added in v0.4.0
func (r *TraceRenderer) Render(w io.Writer, trace *pidl.ExecutionTrace, opts TraceTextOptions) error
Render implements the Renderer interface for trace format.
func (*TraceRenderer) RenderJSON ¶ added in v0.4.0
func (r *TraceRenderer) RenderJSON(trace *pidl.ExecutionTrace) ([]byte, error)
RenderJSON renders the trace as JSON (simply marshals the trace).
func (*TraceRenderer) RenderMermaid ¶ added in v0.4.0
func (r *TraceRenderer) RenderMermaid(trace *pidl.ExecutionTrace, p *pidl.Protocol) string
RenderMermaid renders the trace as a Mermaid sequence diagram.
func (*TraceRenderer) RenderSVG ¶ added in v0.4.0
func (r *TraceRenderer) RenderSVG(trace *pidl.ExecutionTrace, p *pidl.Protocol) (string, error)
RenderSVG renders the trace as an SVG sequence diagram.
func (*TraceRenderer) RenderText ¶ added in v0.4.0
func (r *TraceRenderer) RenderText(trace *pidl.ExecutionTrace, opts TraceTextOptions) string
RenderText renders the trace as formatted text.
type TraceRendererInterface ¶ added in v0.4.0
type TraceRendererInterface interface {
RenderText(trace *pidl.ExecutionTrace, opts TraceTextOptions) string
RenderMermaid(trace *pidl.ExecutionTrace, p *pidl.Protocol) string
RenderSVG(trace *pidl.ExecutionTrace, p *pidl.Protocol) (string, error)
}
TraceRendererInterface defines the interface for trace renderers.
type TraceTextOptions ¶ added in v0.4.0
type TraceTextOptions struct {
// ShowTimestamps includes step timestamps.
ShowTimestamps bool
// ShowStates shows entity states after each step.
ShowStates bool
// Compact uses single-line output per step.
Compact bool
// UseColors enables ANSI color codes (for terminals).
UseColors bool
}
TraceTextOptions configures text trace rendering.
func DefaultTraceTextOptions ¶ added in v0.4.0
func DefaultTraceTextOptions() TraceTextOptions
DefaultTraceTextOptions returns default text rendering options.
type ViewerRenderer ¶ added in v0.8.0
type ViewerRenderer struct {
// Walkthrough produces the embedded data, including analyzer findings.
Walkthrough *WalkthroughJSONRenderer
}
ViewerRenderer writes a self-contained HTML walkthrough viewer with the protocol's walkthrough embedded, so the file opens in a browser with no server.
func NewViewer ¶ added in v0.8.0
func NewViewer() *ViewerRenderer
NewViewer creates a ViewerRenderer with the default walkthrough options.
func (*ViewerRenderer) Format ¶ added in v0.8.0
func (r *ViewerRenderer) Format() Format
Format returns the output format identifier.
func (*ViewerRenderer) RenderString ¶ added in v0.8.0
func (r *ViewerRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the viewer HTML with the walkthrough embedded.
type WalkthroughJSONRenderer ¶ added in v0.8.0
type WalkthroughJSONRenderer struct {
// Analysis configures the analyzer run whose findings are attached.
// Set Analyze to false to attach none.
Analyze bool
Analysis analyze.AnalysisOptions
// Transform, when set, changes the walkthrough after it is built and
// before it is written, such as adding a run observed in a real system.
Transform func(*pidl.Walkthrough) error
}
WalkthroughJSONRenderer writes a protocol's walkthrough (pidl.Walkthrough) as JSON for step-by-step viewers, with analyzer findings attached to the steps they concern.
func NewWalkthroughJSON ¶ added in v0.8.0
func NewWalkthroughJSON() *WalkthroughJSONRenderer
NewWalkthroughJSON creates a WalkthroughJSONRenderer that attaches findings of every severity except SEC016 (flow provenance), which is meant for incident attack-flows and would flag every step of an ordinary protocol.
func (*WalkthroughJSONRenderer) Build ¶ added in v0.10.0
func (r *WalkthroughJSONRenderer) Build(p *pidl.Protocol) (pidl.Walkthrough, error)
Build returns the walkthrough with findings attached and Transform applied.
func (*WalkthroughJSONRenderer) Format ¶ added in v0.8.0
func (r *WalkthroughJSONRenderer) Format() Format
Format returns the output format identifier.
func (*WalkthroughJSONRenderer) RenderString ¶ added in v0.8.0
func (r *WalkthroughJSONRenderer) RenderString(p *pidl.Protocol) (string, error)
RenderString returns the walkthrough as indented JSON.
func (*WalkthroughJSONRenderer) Walkthrough ¶ added in v0.8.0
func (r *WalkthroughJSONRenderer) Walkthrough(p *pidl.Protocol) pidl.Walkthrough
Walkthrough returns the walkthrough with findings attached.