codegen

package
v1.17.11 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{Use: "codegen", Short: "Code generator for substreams"}
View Source
var SQLCmd = &cobra.Command{
	Use:   "sql [<manifest_url>]",
	Short: "Generate sql extension from substreams manifest",
	Args:  cobra.RangeArgs(0, 1),
	RunE:  generateSQLEnv,
}
View Source
var SubgraphCmd = &cobra.Command{
	Use:   "subgraph [<manifest_url>]",
	Short: "Generate subgraph dev environment from substreams manifest",
	Args:  cobra.RangeArgs(0, 1),
	RunE:  generateSubgraphEnv,
}

Functions

func ParseFS added in v1.10.0

func ParseFS(myFuncs template.FuncMap, fsys fs.FS, pattern string) (*template.Template, error)

func ToMarkdown added in v1.10.1

func ToMarkdown(input string) string

Types

type EntityInfo added in v1.10.1

type EntityInfo struct {
	HasAnID     bool
	IDFieldName string
}

type EntityType added in v1.10.1

type EntityType interface {
	ToEntityTypeOut() string
}

type OutputType added in v1.10.1

type OutputType string
const (
	Subgraph OutputType = "subgraph"
	Sql      OutputType = "sql"
)

func (OutputType) String added in v1.10.1

func (t OutputType) String() string

type Project added in v1.10.0

type Project struct {
	Name             string
	Network          string
	Module           *pbsubstreams.Module
	OutputDescriptor *descriptorpb.DescriptorProto

	EntityTypes     []EntityType
	EntityInfo      EntityInfo
	SpkgProjectName string
	ManifestPath    string
	OutputType      OutputType
	Flavor          string
	// contains filtered or unexported fields
}

func NewProject added in v1.10.0

func NewProject(
	name string,
	spkgProjectName string,
	network, manifestPath string,
	module *pbsubstreams.Module,
	outputDescriptor *descriptorpb.DescriptorProto,
	protoTypeMapping map[string]*descriptorpb.DescriptorProto,
	outputType OutputType,
	flavor string,
) *Project

func (*Project) AddClickHouseSQLType added in v1.10.1

func (p *Project) AddClickHouseSQLType(name string, field *descriptorpb.FieldDescriptorProto)

func (*Project) AddPostgreSQLType added in v1.10.1

func (p *Project) AddPostgreSQLType(name string, field *descriptorpb.FieldDescriptorProto)

func (*Project) AddSubgraphEntityType added in v1.10.1

func (p *Project) AddSubgraphEntityType(name string, field *descriptorpb.FieldDescriptorProto)

func (*Project) BuildOutputEntity added in v1.10.1

func (p *Project) BuildOutputEntity() error

func (*Project) ChainEndpoint added in v1.10.0

func (p *Project) ChainEndpoint() (string, error)

func (*Project) DatabaseChangeImportVersion added in v1.10.1

func (p *Project) DatabaseChangeImportVersion() string

func (*Project) GetModuleName added in v1.10.0

func (p *Project) GetModuleName() string

func (*Project) GetOutputProtoPath added in v1.10.0

func (p *Project) GetOutputProtoPath() string

func (*Project) GetOutputProtobufPath added in v1.10.0

func (p *Project) GetOutputProtobufPath() string

func (*Project) GetRustOutputProtobufPath added in v1.10.1

func (p *Project) GetRustOutputProtobufPath() string

func (*Project) HasExampleEntity added in v1.10.0

func (p *Project) HasExampleEntity() bool

func (*Project) ModuleInitialBlock added in v1.10.1

func (p *Project) ModuleInitialBlock() uint64

func (*Project) OutputName added in v1.10.0

func (p *Project) OutputName() string

func (*Project) ProtoOutputName added in v1.10.0

func (p *Project) ProtoOutputName() string

func (*Project) ProtoOutputNameToSnake added in v1.10.0

func (p *Project) ProtoOutputNameToSnake() string

func (*Project) Render added in v1.10.0

func (p *Project) Render(withDevEnv bool) (projectFiles map[string][]byte, err error)

func (*Project) SQLExtensionName added in v1.10.1

func (p *Project) SQLExtensionName() string

func (*Project) SQLImportVersion added in v1.10.1

func (p *Project) SQLImportVersion() string

func (*Project) SpkgNameWithoutExt added in v1.10.1

func (p *Project) SpkgNameWithoutExt() string

func (*Project) SubstreamsKebabName added in v1.10.0

func (p *Project) SubstreamsKebabName() string

type ProtoGenerator

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

func NewProtoGenerator

func NewProtoGenerator(outputPath string, excludedPaths []string, generateMod bool) *ProtoGenerator

func (*ProtoGenerator) GenerateProto added in v0.1.0

func (g *ProtoGenerator) GenerateProto(pkg *pbsubstreams.Package) error

type SQLEntityType added in v1.10.1

type SQLEntityType struct {
	Name string
	Type SQLType
}

func (*SQLEntityType) ToEntityTypeOut added in v1.10.1

func (e *SQLEntityType) ToEntityTypeOut() string

func (*SQLEntityType) ToSQLType added in v1.10.1

func (e *SQLEntityType) ToSQLType() string

type SQLType added in v1.10.1

type SQLType string
var (
	PostgresSqlText    SQLType = "TEXT"
	PostgresSqlBoolean SQLType = "BOOL"
	PostgresSqlInt     SQLType = "Int"
	PostgresSqlDecimal SQLType = "DECIMAL"
	PostgresSqlBytes   SQLType = "BYTEA"
	ClickhouseString   SQLType = "String"
	ClickhouseBoolean  SQLType = "Bool"
	ClickhouseUInt32   SQLType = "UInt32"
	ClickhouseInt32    SQLType = "Int32"
	ClickhouseUInt64   SQLType = "UInt64"
	ClickhouseInt64    SQLType = "Int64"
	ClickhouseDecimal  SQLType = "Decimal64(%d)"
)

type SubgraphEntityType added in v1.10.1

type SubgraphEntityType struct {
	Name string
	Type SubgraphType
}

func (*SubgraphEntityType) ToEntityTypeOut added in v1.10.1

func (e *SubgraphEntityType) ToEntityTypeOut() string

func (*SubgraphEntityType) ToGraphQLType added in v1.10.1

func (e *SubgraphEntityType) ToGraphQLType() string

type SubgraphType added in v1.10.1

type SubgraphType string
var (
	SubgraphBytes      SubgraphType = "Bytes"
	SubgraphString     SubgraphType = "String"
	SubgraphBoolean    SubgraphType = "Boolean"
	SubgraphInt        SubgraphType = "Int"
	SubgraphInt8       SubgraphType = "Int8"
	SubgraphBigInt     SubgraphType = "BigInt"
	SubgraphBigDecimal SubgraphType = "BigDecimal"
	SubgraphTimestamp  SubgraphType = "Timestamp" // this is an alias for i64
)

func (SubgraphType) String added in v1.10.1

func (t SubgraphType) String() string

Jump to

Keyboard shortcuts

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