dtsx

package module
v0.0.0-...-432db21 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 15 Imported by: 0

README

DTSX - SQL Server Integration Services Package Parser

A comprehensive Go library for reading, writing, and analyzing DTSX (SQL Server Integration Services) XML files with advanced expression evaluation and package management capabilities.

Important Notice:

  • This project is under active development. While many features are implemented and tested, some advanced SSIS functionalities may not be fully supported yet.
  • This project is not affiliated with or endorsed by Microsoft. It is an independent implementation for working with SSIS DTSX files in Go.
  • DTSX files can be complex and may contain proprietary elements. This library aims to provide robust support for common DTSX features but may not cover all edge cases or custom components.
  • Use this library at your own risk, especially in production environments. Always validate and test packages thoroughly.
  • Contributions and feedback are welcome to improve compatibility and functionality.

Features

  • Parse DTSX files: Read and unmarshal DTSX XML files into Go structs
  • Generate DTSX files: Marshal Go structs back to DTSX XML format
  • Update DTSX elements: Modify existing variables, connections, expressions, and any properties safely
  • Advanced Expression Engine: Full SSIS expression evaluation with variables, functions, conditionals, and type casting
  • Package Builder API: Fluent API for programmatic package creation
  • Comprehensive Validation: Multi-level validation with error, warning, and info severities
  • Dependency Analysis: Graph-based analysis of package relationships and impact assessment
  • Query API: Convenient methods to analyze connections, variables, executables, and expressions
  • Connection Analysis: Comprehensive analysis of connection managers with drivers and dynamic properties
  • SQL Extraction: Extract SQL statements from control flow and dataflow tasks
  • Execution Order Analysis: Topological sorting and precedence constraint analysis with execution flow descriptions
  • Expression Details: Detailed expression analysis with evaluation results and dependency tracking
  • Package Parser: Centralized parsing with caching for performance
  • Utility Functions: Convenient getters for connection names, variable values, executable names, and more
  • Full schema support: Generated from official SSIS XSD schemas with container element support
  • Type-safe: Strongly typed Go structures for all DTSX elements
  • Public API (dtsx package): See docs/API.md for a consolidated list of public methods, types and usage examples.

Installation

go get github.com/7045kHz/dtsx

Usage

Reading a DTSX File
package main

import (
    "fmt"
    "log"

    "github.com/7045kHz/dtsx"
)

func main() {
    // Load DTSX file
    pkg, err := dtsx.UnmarshalFromFile("mypackage.dtsx")
    if err != nil {
        log.Fatal(err)
    }

    // Access package properties using query methods
    connections := pkg.GetConnections()
    variables := pkg.GetVariables()

    fmt.Printf("Connection Managers: %d\n", connections.Count)
    fmt.Printf("Variables: %d\n", variables.Count)

    // Access executables directly
    if pkg.Executable != nil {
        fmt.Printf("Executables: %d\n", len(pkg.Executable))
    }
}
Reading from a byte slice or io.Reader
// From bytes
data := []byte(xmlContent)
pkg, err := dtsx.Unmarshal(data)

// From io.Reader
file, _ := os.Open("package.dtsx")
pkg, err := dtsx.UnmarshalFromReader(file)
Writing a DTSX File
// Marshal to bytes
data, err := dtsx.Marshal(pkg)

// Write to file using the standard library (the package intentionally
// no longer exposes direct file-write helpers; write manually):
// err := os.WriteFile("output.dtsx", data, 0644)

// Or write to an io.Writer by writing `data` to the writer
// (e.g., writer.Write(data))

Advanced Features

Expression Evaluation

Evaluate SSIS expressions with full support for variables, arithmetic, functions, conditionals, and type casting:

// Create parser for efficient expression evaluation with caching
parser := dtsx.NewPackageParser(pkg)

// Basic arithmetic and variables
result, err := parser.EvaluateExpression("@[User::MyVar] + 1")

// Built-in functions
result, err = parser.EvaluateExpression("UPPER(@[User::Name])")
result, err = parser.EvaluateExpression("DATEADD(\"DAY\", 7, @[User::StartDate])")

// Conditional expressions
result, err = parser.EvaluateExpression("@[User::Count] > 10 ? \"High\" : \"Low\"")

// Type casting
result, err = parser.EvaluateExpression("(DT_STR) @[User::Number]")
Package Builder API

Create DTSX packages programmatically:

pkg := dtsx.NewPackageBuilder().
    AddVariable("User", "InputPath", "C:\\data\\input.csv").
    AddVariable("User", "OutputPath", "C:\\data\\output.csv").
    AddConnection("SourceDB", "OLEDB", "Server=myserver;Database=mydb;Trusted_Connection=True;").
    Build()
Package Validation

Validate packages for common issues using the comprehensive PackageValidator:

validator := dtsx.NewPackageValidator(pkg)
errors := validator.Validate()
for _, err := range errors {
    fmt.Printf("[%s] %s: %s\n", err.Severity, err.Path, err.Message)
}
Dependency Analysis

Analyze relationships between package elements:

graph := pkg.BuildDependencyGraph()
impact := graph.GetVariableImpact("User::MyVariable")
fmt.Printf("Variable used in %d locations\n", len(impact))
Package Parser

Use the centralized PackageParser for efficient analysis with caching:

parser := dtsx.NewPackageParser(pkg)

// Get SQL statements from all tasks
sqlStatements := parser.GetSQLStatements()
for _, stmt := range sqlStatements {
    fmt.Printf("Task: %s (%s) - SQL: %s\n", stmt.TaskName, stmt.TaskType, stmt.SQL)
}

// Evaluate expressions with caching
result, err := parser.EvaluateExpression("@[User::MyVar] + 1")
Execution Order Analysis

Analyze task execution order and precedence constraints:

analyzer := dtsx.NewPrecedenceAnalyzer(pkg)

// Get execution order for a specific task
order, err := analyzer.GetExecutionOrder("Package\\MyTask")
fmt.Printf("Task executes at order: %d\n", order)

// Get all execution orders
orders, err := analyzer.GetAllExecutionOrders()
for refId, order := range orders {
    fmt.Printf("%s: Order %d\n", refId, order)
}

// Get textual execution flow description
flowDesc := analyzer.GetExecutionFlowDescription()
fmt.Print(flowDesc)

// Validate precedence constraints
errors := analyzer.ValidateConstraints()
Expression Details Analysis

Get comprehensive information about expressions including evaluation results and dependencies:

expressions := pkg.GetExpressions()
exprs := expressions.Results.([]*dtsx.ExpressionInfo)

for _, expr := range exprs {
    details := dtsx.GetExpressionDetails(expr, pkg)
    fmt.Printf("Expression: %s\n", details.Expression)
    fmt.Printf("  Location: %s\n", details.Location)
    if details.EvaluatedValue != "" {
        fmt.Printf("  Evaluated: %s\n", details.EvaluatedValue)
    }
    if len(details.Dependencies) > 0 {
        fmt.Printf("  Dependencies: %v\n", details.Dependencies)
    }
}
Utility Functions

Convenient getter functions for common DTSX element properties:

// Get connection manager details
connName := dtsx.GetConnectionName(connectionManager)
connString := dtsx.GetConnectionString(connectionManager)

// Get variable details
varName := dtsx.GetVariableName(variable)
varValue := dtsx.GetVariableValue(variable)

// Get executable details
execName := dtsx.GetExecutableName(executable)

// Get detailed expression analysis
details := dtsx.GetExpressionDetails(exprInfo, pkg)
fmt.Printf("Evaluated: %s, Dependencies: %v\n", details.EvaluatedValue, details.Dependencies)
Enhanced Package Validation

Use the comprehensive PackageValidator for detailed analysis:

validator := dtsx.NewPackageValidator(pkg)
errors := validator.Validate()

for _, err := range errors {
    fmt.Printf("[%s] %s: %s\n", err.Severity, err.Path, err.Message)
}

Querying Packages

The library provides convenient query methods for analyzing DTSX packages:

Get Connection Managers
connections := pkg.GetConnections()
fmt.Printf("Found %d connection managers\n", connections.Count)
connMgrs := connections.Results.([]*schema.ConnectionManagerType)
Get Variables
variables := pkg.GetVariables()
fmt.Printf("Found %d variables\n", variables.Count)
vars := variables.Results.([]*schema.VariableType)
Find Specific Variable
variable, err := pkg.GetVariableByName("User::MyVariable")
if err != nil {
    fmt.Println("Variable not found")
}
Query Executables with Filters
// Get all executables
allExecutables := pkg.QueryExecutables(func(*schema.AnyNonPackageExecutableType) bool {
    return true
})

// Find SQL tasks
sqlTasks := pkg.QueryExecutables(func(exec *schema.AnyNonPackageExecutableType) bool {
    return exec.ExecutableTypeAttr == "ExecuteSQLTask"
})

// Find tasks with expressions
tasksWithExpressions := pkg.QueryExecutables(func(exec *schema.AnyNonPackageExecutableType) bool {
    return len(exec.PropertyExpression) > 0
})
Get All Expressions
expressions := pkg.GetExpressions()
fmt.Printf("Found %d expressions\n", expressions.Count)
exprs := expressions.Results.([]*dtsx.ExpressionInfo)

for _, expr := range exprs {
    fmt.Printf("Expression: %s (Location: %s, Context: %s)\n",
        expr.Expression, expr.Location, expr.Context)
}

API Reference

For a consolidated public API reference with usage examples, see docs/API.md.

// Note: package-provided file-write helpers have been internalized to // disable direct package-managed file writes. Use Marshal and the // standard library (e.g., os.WriteFile) to persist packages. UnmarshalFromFile(filename string) (*Package, error) - Read DTSX from file UnmarshalFromReader(r io.Reader) (*Package, error) - Read DTSX from reader Unmarshal(data []byte) (*Package, error) - Parse DTSX from bytes Marshal(pkg *Package) ([]byte, error) - Convert DTSX to bytes IsDTSXPackage(filename string) (*Package, bool) - Load and validate DTSX file

Execution Functions
  • RunPackage(dtexecPath, dtsxPath string, opts *RunOptions) (string, error) - Execute DTSX package with dtexec.exe
Query Methods
  • GetConnections() *QueryResult - Get all connection managers
  • GetVariables() *QueryResult - Get all variables
  • GetVariableByName(name string) (*schema.VariableType, error) - Find variable by name
  • QueryExecutables(filter func(*schema.AnyNonPackageExecutableType) bool) []*schema.AnyNonPackageExecutableType - Filter executables
  • GetExpressions() *QueryResult - Get all expressions with context
Update Methods

Note: Mutating helpers were removed from the public API. To programmatically modify packages, mutate the package structs directly (e.g., pkg.Variables, pkg.ConnectionManagers) or use internal functions within the package.

Advanced Methods
  • EvaluateExpression(expr string, pkg *Package) (interface{}, error) - Evaluate SSIS expression (use PackageParser for better performance)
  • Validate() []ValidationError - Validate package for issues (use PackageValidator for comprehensive validation)
  • BuildDependencyGraph() *DependencyGraph - Build dependency graph
  • GetUnusedVariables() []string - Find unused variables
  • GetOptimizationSuggestions() []ValidationError - Get optimization suggestions
  • NewPackageParser(pkg *Package) *PackageParser - Create centralized parser with caching
  • NewPrecedenceAnalyzer(pkg *Package) *PrecedenceAnalyzer - Create execution order analyzer
  • NewPackageValidator(pkg *Package) *PackageValidator - Create comprehensive validator
PackageParser Methods
  • GetVariableValue(name string) (interface{}, error) - Get variable value by name
  • GetConnectionManager(id string) (*schema.ConnectionManagerType, error) - Get connection manager
  • GetExecutable(refId string) (*schema.AnyNonPackageExecutableType, error) - Get executable
  • EvaluateExpression(expr string) (interface{}, error) - Evaluate expression with caching
  • GetSQLStatements() []*SQLStatement - Extract all SQL statements
PrecedenceAnalyzer Methods
  • GetExecutionOrder(refId string) (int, error) - Get execution order for task
  • GetAllExecutionOrders() (map[string]int, error) - Get all execution orders
  • GetExecutableChain(refId string) ([]string, error) - Get execution chain
  • GetExecutionFlowDescription() string - Get textual execution flow description
  • ValidateConstraints() []error - Validate precedence constraints
PackageValidator Methods
  • Validate() []*ValidationError - Comprehensive package validation
Builder API
  • NewPackageBuilder() *PackageBuilder - Create new package builder
  • AddVariable(namespace, name, value string) *PackageBuilder - Add string variable
  • AddVariableWithType(namespace, name, value, dataType string) *PackageBuilder - Add variable with specific data type
  • AddConnection(name, connectionType, connectionString string) *PackageBuilder - Add connection manager
  • AddConnectionExpression(connectionName, propertyName, expression string) *PackageBuilder - Add expression to connection
  • Build() *Package - Build the package
Package Structure

The Package type represents a complete DTSX package with the following main components:

  • Property - Package properties
  • ConnectionManager - Data source connections
  • Configuration - Package configurations
  • LogProvider - Logging configurations
  • Variable - Package variables
  • Executable - Tasks and containers
  • PrecedenceConstraint - Control flow constraints
  • EventHandler - Event handlers

Examples

See the examples directory for complete working examples:

  • Per-symbol, consolidated examples: examples/api_examples.go — run with:
# Run from repository root
go run examples/api_examples.go

This example demonstrates most exported symbols and writes a sample DTSX file named output_sample.dtsx in the current working directory when run.

Regenerate the generated API doc:

# From the repository root
go generate ./...
# Analyze package structure
go run examples/analyze_dtsx.go path/to/your/package.dtsx

# Demonstrate query methods with variables and expressions
go run examples/query_dtsx.go path/to/your/package.dtsx

# Comprehensive connection analysis with expressions and variables
go run examples/analyze_connections.go path/to/your/package.dtsx

# Advanced package analysis with parser, validator, and analyzer
go run examples/package_analysis.go path/to/your/package.dtsx

# Validate package for issues
go run examples/validate_dtsx.go path/to/your/package.dtsx

# Basic read example
go run examples/read_dtsx.go path/to/your/package.dtsx

# Run package with DTExec
go run examples/run_dtsx.go path/to/your/package.dtsx

# Run package with parameters
go run examples/run_with_params.go path/to/your/package.dtsx

# Debug output as JSON
go run examples/debug_dtsx.go path/to/your/package.dtsx

Schema Generation

This library uses schemas generated from the official SSIS XSD files using xgen:

# Regenerate schemas (if needed)
xgen -i ./schemas -o ./dtsx -l Go

Testing

go test ./...

Project Structure

.
├── dtsx.go                 # Main package with marshal/unmarshal functions, PackageParser, PrecedenceAnalyzer, PackageValidator
├── expression.go           # Advanced SSIS expression evaluator with caching
├── dtsx_test.go            # Comprehensive tests
├── dtsx/
│   └── schemas/            # Generated schema types
├── examples/               # Example code including package_analysis.go
├── schemas/                # XSD schema files
├── SSIS_EXAMPLES/          # Sample DTSX files (for testing)
├── QUICKSTART.md           # Detailed usage guide
└── README.md               # This file

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • xgen - XSD to Go struct generator

Acknowledgments

Schema definitions are based on Microsoft SQL Server Integration Services (SSIS) XSD schemas.

Documentation

Overview

Package dtsx provides functionality for reading and writing DTSX (SQL Server Integration Services) XML files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateExpression

func EvaluateExpression(expr string, pkg *Package) (interface{}, error)

EvaluateExpression evaluates an SSIS expression in the context of a package

func GetConnectionName

func GetConnectionName(cm *schema.ConnectionManagerType) string

GetConnectionName returns the name of a connection manager

func GetConnectionString

func GetConnectionString(cm *schema.ConnectionManagerType) string

GetConnectionString returns the connection string of a connection manager

func GetExecutableName

func GetExecutableName(exec *schema.AnyNonPackageExecutableType) string

GetExecutableName returns the name of an executable

func GetProperty

func GetProperty(s interface{}, name string) interface{}

GetProperty returns the value of the specified property by name for any struct

func GetSqlStatementSource

func GetSqlStatementSource(s *schema.SqlTaskDataType) string

GetSqlStatementSource returns the SQL statement source from SqlTaskDataType

func GetSqlStatementSourceFromBase

func GetSqlStatementSourceFromBase(s *schema.SqlTaskBaseAttributeGroup) string

GetSqlStatementSourceFromBase returns the SQL statement source from SqlTaskBaseAttributeGroup

func GetVariableName

func GetVariableName(v *schema.VariableType) string

GetVariableName returns the full name (namespace::name) of a variable

func GetVariableValue

func GetVariableValue(v *schema.VariableType) string

GetVariableValue returns the value of a variable

func Marshal

func Marshal(pkg *Package) ([]byte, error)

Marshal converts a Package to DTSX XML format

func RunPackage

func RunPackage(dtexecPath, dtsxPath string, opts *RunOptions) (string, error)

RunPackage executes a DTSX package using dtexec.exe. It takes the path to dtexec.exe, the path to the DTSX file, and optional RunOptions. Returns the combined stdout/stderr output and any error that occurred.

Types

type BinaryOp

type BinaryOp struct {
	Left  Expr
	Op    string
	Right Expr
}

BinaryOp represents a binary operation

func (*BinaryOp) Eval

func (b *BinaryOp) Eval(vars map[string]interface{}) (interface{}, error)

type Cast

type Cast struct {
	Type string
	Expr Expr
}

Cast represents a type cast

func (*Cast) Eval

func (c *Cast) Eval(vars map[string]interface{}) (interface{}, error)

type Conditional

type Conditional struct {
	Condition Expr
	TrueExpr  Expr
	FalseExpr Expr
}

Conditional represents a ternary conditional expression

func (*Conditional) Eval

func (c *Conditional) Eval(vars map[string]interface{}) (interface{}, error)

type DependencyGraph

type DependencyGraph struct {
	// VariableDependencies: variable name -> list of expressions/locations that use it
	VariableDependencies map[string][]string
	// ConnectionDependencies: connection name -> list of tasks/locations that use it
	ConnectionDependencies map[string][]string
	// TaskDependencies: task ID -> list of variables/connections it depends on
	TaskDependencies map[string][]string
	// ExpressionDependencies: expression -> list of variables it references
	ExpressionDependencies map[string][]string
}

DependencyGraph represents relationships between package elements

func (*DependencyGraph) GetConnectionImpact

func (dg *DependencyGraph) GetConnectionImpact(connName string) []string

GetConnectionImpact returns all tasks affected by a connection change

func (*DependencyGraph) GetVariableImpact

func (dg *DependencyGraph) GetVariableImpact(varName string) []string

GetVariableImpact returns all locations affected by a variable change

type Expr

type Expr interface {
	Eval(vars map[string]interface{}) (interface{}, error)
}

Expr represents an expression AST node

type ExpressionDetails

type ExpressionDetails struct {
	Expression      string
	Location        string
	Name            string
	Context         string
	EvaluatedValue  string
	EvaluationError string
	Dependencies    []string
}

ExpressionDetails provides comprehensive information about an expression

func GetExpressionDetails

func GetExpressionDetails(exprInfo *ExpressionInfo, pkg *Package) *ExpressionDetails

GetExpressionDetails returns detailed information about an expression including evaluation result and dependencies

type ExpressionInfo

type ExpressionInfo struct {
	Expression string
	Location   string // e.g., "Package", "Executable", "PrecedenceConstraint", etc.
	Name       string // property name if applicable
	Context    string // additional context like executable type, variable name, etc.
}

ExpressionInfo contains information about an expression found in the package

type FunctionCall

type FunctionCall struct {
	Name string
	Args []Expr
}

FunctionCall represents a function call

func (*FunctionCall) Eval

func (f *FunctionCall) Eval(vars map[string]interface{}) (interface{}, error)

type Literal

type Literal struct {
	Value interface{}
}

Literal represents a literal value

func (*Literal) Eval

func (l *Literal) Eval(vars map[string]interface{}) (interface{}, error)

type Package

type Package struct {
	XMLName                        xml.Name `xml:"Executable"`
	RefIdAttr                      *string  `xml:"refId,attr"`
	CreationDateAttr               *string  `xml:"CreationDate,attr"`
	CreationNameAttr               *string  `xml:"CreationName,attr"`
	CreatorComputerNameAttr        *string  `xml:"CreatorComputerName,attr"`
	CreatorNameAttr                *string  `xml:"CreatorName,attr"`
	DescriptionAttr                *string  `xml:"Description,attr"`
	DTSIDAttr                      *string  `xml:"DTSID,attr"`
	EnableConfigAttr               *string  `xml:"EnableConfig,attr"`
	ExecutableTypeAttr             *string  `xml:"ExecutableType,attr"`
	LastModifiedProductVersionAttr *string  `xml:"LastModifiedProductVersion,attr"`
	LocaleIDAttr                   *string  `xml:"LocaleID,attr"`
	ObjectNameAttr                 *string  `xml:"ObjectName,attr"`
	PackageTypeAttr                *string  `xml:"PackageType,attr"`
	VersionBuildAttr               *string  `xml:"VersionBuild,attr"`
	VersionGUIDAttr                *string  `xml:"VersionGUID,attr"`
	*schema.ExecutableTypePackage
}

Package represents a DTSX package structure

func IsDTSXPackage

func IsDTSXPackage(filename string) (*Package, bool)

IsDTSXPackage validates if the given filename is a valid DTSX package. It checks if the file exists, is readable, and contains valid DTSX XML structure. Returns the unmarshaled Package and true if the file is a valid DTSX package, nil and false otherwise.

func Unmarshal

func Unmarshal(data []byte) (*Package, error)

Unmarshal parses DTSX XML data and returns a Package

func UnmarshalFromFile

func UnmarshalFromFile(filename string) (*Package, error)

UnmarshalFromFile reads a DTSX file and returns a Package

func UnmarshalFromReader

func UnmarshalFromReader(r io.Reader) (*Package, error)

UnmarshalFromReader parses DTSX XML from an io.Reader and returns a Package

func (*Package) BuildDependencyGraph

func (p *Package) BuildDependencyGraph() *DependencyGraph

BuildDependencyGraph analyzes the package and builds a dependency graph

func (*Package) GetConnections

func (p *Package) GetConnections() *QueryResult

GetConnections returns all connection managers in the package

func (*Package) GetExpressions

func (p *Package) GetExpressions() *QueryResult

GetExpressions returns all expressions found in the package

func (*Package) GetOptimizationSuggestions

func (p *Package) GetOptimizationSuggestions() []ValidationError

GetOptimizationSuggestions returns performance and best practice suggestions

func (*Package) GetUnusedVariables

func (p *Package) GetUnusedVariables() []string

GetUnusedVariables returns variables that are not referenced anywhere

func (*Package) GetVariableByName

func (p *Package) GetVariableByName(name string) (*schema.VariableType, error)

GetVariableByName finds a variable by name (ObjectName property)

func (*Package) GetVariables

func (p *Package) GetVariables() *QueryResult

GetVariables returns all variables in the package

func (*Package) QueryExecutables

func (p *Package) QueryExecutables(filter func(*schema.AnyNonPackageExecutableType) bool) []*schema.AnyNonPackageExecutableType

QueryExecutables finds executables matching a filter function

func (*Package) Validate

func (p *Package) Validate() []ValidationError

Validate performs comprehensive validation on the package

type PackageBuilder

type PackageBuilder struct {
	// contains filtered or unexported fields
}

PackageBuilder provides a fluent API for constructing DTSX packages

func NewPackageBuilder

func NewPackageBuilder() *PackageBuilder

NewPackageBuilder creates a new package builder

func (*PackageBuilder) AddConnection

func (pb *PackageBuilder) AddConnection(name, connectionType, connectionString string) *PackageBuilder

AddConnection adds a connection manager to the package

func (*PackageBuilder) AddConnectionExpression

func (pb *PackageBuilder) AddConnectionExpression(connectionName, propertyName, expression string) *PackageBuilder

AddConnectionExpression adds a property expression to an existing connection manager

func (*PackageBuilder) AddVariable

func (pb *PackageBuilder) AddVariable(namespace, name, value string) *PackageBuilder

AddVariable adds a variable to the package

func (*PackageBuilder) AddVariableWithType

func (pb *PackageBuilder) AddVariableWithType(namespace, name, value string, dataType string) *PackageBuilder

AddVariableWithType adds a variable to the package with a specific data type

func (*PackageBuilder) Build

func (pb *PackageBuilder) Build() *Package

Build returns the constructed package

type PackageParser

type PackageParser struct {
	// contains filtered or unexported fields
}

PackageParser provides centralized parsing and analysis functionality for DTSX packages

func NewPackageParser

func NewPackageParser(pkg *Package) *PackageParser

NewPackageParser creates a new PackageParser for the given package

func (*PackageParser) EvaluateExpression

func (p *PackageParser) EvaluateExpression(expr string) (interface{}, error)

EvaluateExpression evaluates an expression with caching

func (*PackageParser) GetConnectionManager

func (p *PackageParser) GetConnectionManager(id string) (*schema.ConnectionManagerType, error)

GetConnectionManager returns a connection manager by refId or name

func (*PackageParser) GetExecutable

func (p *PackageParser) GetExecutable(refId string) (*schema.AnyNonPackageExecutableType, error)

GetExecutable returns an executable by refId

func (*PackageParser) GetSQLStatements

func (p *PackageParser) GetSQLStatements() []*SQLStatement

GetSQLStatements extracts SQL statements from all executables

func (*PackageParser) GetVariableValue

func (p *PackageParser) GetVariableValue(name string) (interface{}, error)

GetVariableValue returns the value of a variable by name

type PackageValidator

type PackageValidator struct {
	// contains filtered or unexported fields
}

PackageValidator provides validation functions for DTSX packages

func NewPackageValidator

func NewPackageValidator(pkg *Package) *PackageValidator

NewPackageValidator creates a new validator for the package

func (*PackageValidator) Validate

func (v *PackageValidator) Validate() []*ValidationError

Validate performs comprehensive validation of the package

type PrecedenceAnalyzer

type PrecedenceAnalyzer struct {
	// contains filtered or unexported fields
}

PrecedenceAnalyzer handles execution order calculation with support for complex precedence constraints

func NewPrecedenceAnalyzer

func NewPrecedenceAnalyzer(pkg *Package) *PrecedenceAnalyzer

NewPrecedenceAnalyzer creates a new analyzer for the given package

func (*PrecedenceAnalyzer) GetAllExecutionOrders

func (p *PrecedenceAnalyzer) GetAllExecutionOrders() (map[string]int, error)

GetAllExecutionOrders returns execution orders for all executables

func (*PrecedenceAnalyzer) GetExecutableChain

func (p *PrecedenceAnalyzer) GetExecutableChain(refId string) ([]string, error)

GetExecutableChain returns the execution chain for an executable (all predecessors)

func (*PrecedenceAnalyzer) GetExecutionFlowDescription

func (p *PrecedenceAnalyzer) GetExecutionFlowDescription() string

GetExecutionFlowDescription returns a textual description of the execution flow

func (*PrecedenceAnalyzer) GetExecutionOrder

func (p *PrecedenceAnalyzer) GetExecutionOrder(refId string) (int, error)

GetExecutionOrder returns the execution order for an executable

func (*PrecedenceAnalyzer) ValidateConstraints

func (p *PrecedenceAnalyzer) ValidateConstraints() []error

ValidateConstraints checks for constraint violations and circular dependencies

type QueryResult

type QueryResult struct {
	Count   int
	Results interface{}
}

QueryResult wraps query results with metadata

type RunOptions

type RunOptions struct {
	// Package parameters (format: "[$Package::|$Project::|$ServerOption::]ParamName[(DataType)];Value")
	Parameters []string

	// Environment variables (format: "Name=Value")
	EnvironmentVars []string

	// Connection manager overrides (format: "id_or_name;connection_string")
	Connections []string

	// Configuration file path
	ConfigFile string

	// Property overrides using /Set (format: "propertyPath;value")
	PropertySets []string

	// Decryption password for encrypted packages
	DecryptPassword string

	// SQL Server name (for /SQL or /DTS packages)
	Server string

	// SQL Server username (for SQL authentication)
	User string

	// SQL Server password (for SQL authentication)
	Password string

	// Enable checkpointing (on/off)
	Checkpointing string

	// Checkpoint file path
	CheckpointFile string

	// Restart mode (deny/force/ifPossible)
	Restart string

	// Maximum concurrent executables (-1 for auto)
	MaxConcurrent int

	// Validate only without executing
	Validate bool

	// Treat warnings as errors
	WarnAsError bool

	// Verify build number (format: "major;minor;build")
	VerifyBuild string

	// Verify package ID (GUID)
	VerifyPackageID string

	// Verify version ID (GUID)
	VerifyVersionID string

	// Verify digital signature
	VerifySigned bool

	// Reporting level (N=none, E=errors, W=warnings, I=info, C=custom, P=progress, V=verbose)
	ReportingLevel string

	// Console log options (format: "displayoptions;list_options;src_name_or_guid")
	ConsoleLog []string

	// Log provider configuration (format: "classid_or_progid;configstring")
	Loggers []string

	// Enable verbose logging to file
	VerboseLog string

	// Dump on error codes (semicolon-separated error codes)
	DumpOnCodes string

	// Dump on any error
	DumpOnError bool

	// Run in 32-bit mode (x86)
	X86 bool
}

RunOptions contains options for executing a DTSX package with dtexec.exe

type SQLStatement

type SQLStatement struct {
	TaskName    string
	TaskType    string
	SQL         string
	RefId       string
	Connections []string
}

SQLStatement represents a SQL statement found in the package

type Token

type Token struct {
	Type  string
	Value string
}

Token represents a lexical token

type UnaryOp

type UnaryOp struct {
	Op   string
	Expr Expr
}

UnaryOp represents a unary operator

func (*UnaryOp) Eval

func (u *UnaryOp) Eval(vars map[string]interface{}) (interface{}, error)

type ValidationError

type ValidationError struct {
	Severity string // "error", "warning", "info"
	Message  string
	Path     string // Location in the package, e.g., "Variables.User::MyVar"
}

ValidationError represents a validation issue in a DTSX package

type Variable

type Variable struct {
	Name string
}

Variable represents a variable reference

func (*Variable) Eval

func (v *Variable) Eval(vars map[string]interface{}) (interface{}, error)

Directories

Path Synopsis
cmd
genapi command

Jump to

Keyboard shortcuts

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