stream_transform

package
v0.5.3-alpha10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XProtocolQuery   = "query"
	XProtocolEC2     = "ec2"
	XProtocolRestXML = "rest-xml"
)

AWS wire-protocol identifiers, carried by the spec's info.x-protocol extension.

View Source
const (
	BinResponseShapeUnsafe = "response-shape-unsafe"
	BinEmptyResponseUnsafe = "empty-response-unsafe"
)

Warning bin tags — must stay in sync with discovery.Bin* constants.

View Source
const (
	GolangTemplateXMLV1         = "golang_template_mxj_v0.1.0"
	GolangTemplateXMLV2         = "golang_template_mxj_v0.2.0"
	GolangTemplateXMLV3         = "golang_template_mxj_v0.3.0"
	GolangTemplateJSONV1        = "golang_template_json_v0.1.0"
	GolangTemplateJSONV3        = "golang_template_json_v0.3.0"
	GolangTemplateTextV1        = "golang_template_text_v0.1.0"
	GolangTemplateTextV3        = "golang_template_text_v0.3.0"
	GolangTemplateUnspecifiedV1 = "golang_template_v0.1.0"
	GolangTemplateUnspecifiedV3 = "golang_template_v0.3.0"
)
View Source
const SchemaDrivenXMLV1 = "schema_driven_xml_v0.1.0"

SchemaDrivenXMLV1 is a new transform family (distinct from golang_template_mxj_v*) that projects mxj-decoded XML rows using the schema referenced by response.schema_override, instead of a hand-rolled per-op Go template.

Variables

This section is empty.

Functions

func FixTemplate

func FixTemplate(body string, tplType string) string

FixTemplate attempts to produce a corrected version of a busted template. Returns the fixed template body, or empty string if no fix is applicable.

func ValidateFixedTemplate

func ValidateFixedTemplate(fixedBody string, tplType string) error

ValidateFixedTemplate checks that a proposed fixed template: 1. Passes the same static analysis (no chained index, no unguarded dot access) 2. Parses successfully 3. Executes against empty input without error

func ValidateFixedTemplateWithOriginal

func ValidateFixedTemplateWithOriginal(fixedBody string, originalBody string, tplType string) error

ValidateFixedTemplateWithOriginal performs the full validation including empty-input execution, only failing if the fix introduces NEW errors that the original template didn't have.

Types

type EmpiricalTestResult

type EmpiricalTestResult struct {
	Input  string `json:"input"`
	Output string `json:"output,omitempty"`
	Error  string `json:"error,omitempty"`
	OK     bool   `json:"ok"`
}

EmpiricalTestResult holds the outcome of running a template against test inputs.

func RunEmpiricalTestWithInput

func RunEmpiricalTestWithInput(templateBody string, templateType string, input string) EmpiricalTestResult

RunEmpiricalTestWithInput executes a template against a specific input.

type EmpiricalTestSuite

type EmpiricalTestSuite struct {
	Results []EmpiricalTestResult `json:"results"`
}

EmpiricalTestSuite holds all empirical test results for a template.

func RunEmpiricalTests

func RunEmpiricalTests(templateBody string, templateType string) EmpiricalTestSuite

RunEmpiricalTests executes a response transform template against a suite of test inputs including empty string, and returns structured results.

func (*EmpiricalTestSuite) FailureMessages

func (s *EmpiricalTestSuite) FailureMessages() []string

func (*EmpiricalTestSuite) HasFailures

func (s *EmpiricalTestSuite) HasFailures() bool

type ObjectReader

type ObjectReader interface {
	Read() (interface{}, error)
}

type RegexpShorthand

type RegexpShorthand interface {
	GetFirstMatch(string, string) (string, error)
	GetAllMatches(string, string) ([]string, error)
}

func NewRegexpShorthand

func NewRegexpShorthand() RegexpShorthand

type SchemaTree

type SchemaTree interface {
	// Type returns the OpenAPI type: object | array | string | integer | number | boolean.
	Type() string
	// Items returns the element schema for an array node.
	Items() (SchemaTree, bool)
	// Property returns the named child property schema for an object node.
	Property(name string) (SchemaTree, bool)
	// Properties returns all child property schemas keyed by their wire name.
	Properties() map[string]SchemaTree
}

SchemaTree is the minimal, dependency-free view of a schema node the walker needs. The caller (any-sdk's operation store) adapts its own Schema to this so that this package never imports internal/anysdk (which would be an import cycle).

type StreamTransformer

type StreamTransformer interface {
	Transform() error
	GetOutStream() io.Reader
}

type StreamTransformerFactory

type StreamTransformerFactory interface {
	IsTransformable() bool
	GetTransformer(input string) (StreamTransformer, error)
}

func NewSchemaDrivenXMLStreamTransformerFactory

func NewSchemaDrivenXMLStreamTransformerFactory(
	tplType string,
	schema SchemaTree,
	protocol string,
	listProperty string,
) StreamTransformerFactory

NewSchemaDrivenXMLStreamTransformerFactory builds a factory for the schema_driven_xml family. The caller adapts its own schema to SchemaTree and supplies the wire protocol (info.x-protocol) plus the envelope list property (derived from response.objectKey, e.g. "line_items").

func NewStreamTransformerFactory

func NewStreamTransformerFactory(tplType string, tplStr string) StreamTransformerFactory

type TemplateAnalysisContext

type TemplateAnalysisContext struct {
	ProviderName    string
	ServiceName     string
	MethodName      string
	ResourceKey     string
	TemplateType    string
	TemplateBody    string
	IsFixValidation bool // true when analyzing a proposed fix — suppresses fix generation
}

TemplateAnalysisContext provides the caller's context.

type TemplateAnalysisResult

type TemplateAnalysisResult interface {
	GetErrors() []error
	GetWarnings() []string
	GetAffirmatives() []string
	GetFindings() []TemplateFinding
}

TemplateAnalysisResult holds the outcomes of template static analysis.

type TemplateFinding

type TemplateFinding struct {
	Level         string `json:"level"`
	Bin           string `json:"bin,omitempty"`
	Provider      string `json:"provider,omitempty"`
	Service       string `json:"service,omitempty"`
	Resource      string `json:"resource,omitempty"`
	Method        string `json:"method,omitempty"`
	Message       string `json:"message"`
	PriorTemplate string `json:"prior_template,omitempty"`
	FixedTemplate string `json:"fixed_template,omitempty"`
}

TemplateFinding is a structured finding from template static analysis.

func (TemplateFinding) Error

func (f TemplateFinding) Error() string

func (TemplateFinding) String

func (f TemplateFinding) String() string

type TemplateStaticAnalyzer

type TemplateStaticAnalyzer interface {
	Analyze() TemplateAnalysisResult
}

TemplateStaticAnalyzer performs static analysis on Go templates.

type XMLShorthand

type XMLShorthand interface {
	GetFirstFull(io.Reader, string) (string, error)
	GetAllFull(io.Reader, string) ([]string, error)
	GetFirstInner(io.Reader, string) (string, error)
	GetAllInner(io.Reader, string) ([]string, error)
}

func NewXMLShorthand

func NewXMLShorthand() XMLShorthand

type XMLStringShorthand

type XMLStringShorthand interface {
	GetFirstFull(string, string) (string, error)
	GetAllFull(string, string) ([]string, error)
	GetFirstInner(string, string) (string, error)
	GetAllInner(string, string) ([]string, error)
}

func NewXMLStringShorthand

func NewXMLStringShorthand() XMLStringShorthand

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL