generation

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

package generation provides the ability to generate resource, handler, and typescript permissions and metadata code from a resource file.

Index

Constants

View Source
const (
	// Adds permission.ts to generator output
	TSPerm tsGenMode = 1 << iota

	// Adds resource.ts to generator output
	TSMeta
)

Variables

This section is empty.

Functions

func RemoveGeneratedFiles added in v0.1.14

func RemoveGeneratedFiles(directory string, method GeneratedFileDeleteMethod) error

Types

type FileWriter added in v0.1.14

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

func (*FileWriter) GoFormatBytes added in v0.1.14

func (f *FileWriter) GoFormatBytes(fileName string, data []byte) ([]byte, error)

func (*FileWriter) WriteBytesToFile added in v0.1.14

func (f *FileWriter) WriteBytesToFile(file *os.File, data []byte) error

type GeneratedFileDeleteMethod added in v0.0.9

type GeneratedFileDeleteMethod int
const (
	// Used to remove files with the genPrefix value instead of reading the contents of the file.
	Prefix GeneratedFileDeleteMethod = iota
	// Used to remove files that contain the header comment "// Code generated by resourcegeneration. DO NOT EDIT."
	HeaderComment
)

type Generator added in v0.0.16

type Generator interface {
	Generate(ctx context.Context) error
	Close()
}

func NewResourceGenerator added in v0.0.14

func NewResourceGenerator(ctx context.Context, resourceSourcePath, migrationSourceURL string, localPackages []string, options ...ResourceOption) (Generator, error)

func NewTypescriptGenerator added in v0.0.14

func NewTypescriptGenerator(ctx context.Context, resourceSourcePath, migrationSourceURL string, targetDir string, rc *resource.Collection, mode TSGenMode, options ...TSOption) (Generator, error)

type HandlerType

type HandlerType string
const (
	AllHandlers  HandlerType = "allHandlers"
	ListHandler  HandlerType = "listHandler"
	ReadHandler  HandlerType = "readHandler"
	PatchHandler HandlerType = "patchHandler"
)

func (HandlerType) Method added in v0.0.13

func (h HandlerType) Method() string

type InformationSchemaResult

type InformationSchemaResult struct {
	TableName            string  `spanner:"TABLE_NAME"`
	ColumnName           string  `spanner:"COLUMN_NAME"`
	ConstraintName       *string `spanner:"CONSTRAINT_NAME"`
	IsPrimaryKey         bool    `spanner:"IS_PRIMARY_KEY"`
	IsForeignKey         bool    `spanner:"IS_FOREIGN_KEY"`
	ReferencedTable      *string `spanner:"REFERENCED_TABLE"`
	ReferencedColumn     *string `spanner:"REFERENCED_COLUMN"`
	SpannerType          string  `spanner:"SPANNER_TYPE"`
	IsNullable           bool    `spanner:"IS_NULLABLE"`
	IsView               bool    `spanner:"IS_VIEW"`
	ViewDefinition       *string `spanner:"VIEW_DEFINITION"`
	IsIndex              bool    `spanner:"IS_INDEX"`
	IsUniqueIndex        bool    `spanner:"IS_UNIQUE_INDEX"`
	GenerationExpression *string `spanner:"GENERATION_EXPRESSION"`
	OrdinalPosition      int64   `spanner:"ORDINAL_POSITION"`
	KeyOrdinalPosition   int64   `spanner:"KEY_ORDINAL_POSITION"`
	HasDefault           bool    `spanner:"HAS_DEFAULT"`
}

type Option added in v0.0.16

type Option func(any) error

func CaserInitialismOverrides added in v0.0.10

func CaserInitialismOverrides(overrides map[string]bool) Option

func WithConsolidatedHandlers added in v0.0.13

func WithConsolidatedHandlers(route string, consolidateAll bool, resources ...string) Option

func WithPluralOverrides added in v0.0.10

func WithPluralOverrides(overrides map[string]string) Option

func WithRPC added in v0.0.16

func WithRPC(rpcPackageDir string, businessPackageDir string) Option

func WithSpannerEmulatorVersion added in v0.1.18

func WithSpannerEmulatorVersion(version string) Option

type OptionType

type OptionType string

type PatchType

type PatchType string
const (
	CreatePatch PatchType = "Create"
	UpdatePatch PatchType = "Update"
)

type ResourceOption added in v0.0.14

type ResourceOption interface {
	// contains filtered or unexported methods
}

func GenerateHandlers added in v0.0.10

func GenerateHandlers(targetDir string) ResourceOption

ignoredHandlers maps the name of a resource and to handler types (list, read, patch) that you do not want generated for that resource

func GenerateRoutes added in v0.0.13

func GenerateRoutes(targetDir, targetPackage, routePrefix string) ResourceOption

type TSGenMode added in v0.0.14

type TSGenMode interface {
	// contains filtered or unexported methods
}

type TSOption added in v0.0.14

type TSOption interface {
	// contains filtered or unexported methods
}

func WithTypescriptOverrides added in v0.0.13

func WithTypescriptOverrides(overrides map[string]string) TSOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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