generation

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: MIT Imports: 29 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 CaserInitialismOverrides added in v0.0.10

func CaserInitialismOverrides[G ResourceGenerator | TypescriptGenerator](overrides map[string]bool) func(*G) error

func WithConsolidatedHandlers added in v0.0.13

func WithConsolidatedHandlers[G ResourceGenerator | TypescriptGenerator](route string, consolidateAll bool, resources ...string) func(*G) error

func WithPluralOverrides added in v0.0.10

func WithPluralOverrides[G ResourceGenerator | TypescriptGenerator](overrides map[string]string) func(*G) error

Types

type ColumnMeta added in v0.0.13

type ColumnMeta struct {
	ColumnName         string
	ConstraintTypes    []ConstraintType
	IsPrimaryKey       bool
	IsForeignKey       bool
	SpannerType        string
	IsNullable         bool
	IsIndex            bool
	IsUniqueIndex      bool
	OrdinalPosition    int64
	KeyOrdinalPosition int64
	ReferencedTable    string
	ReferencedColumn   string
}

type ConstraintType

type ConstraintType string
const (
	PrimaryKey ConstraintType = "PRIMARY KEY"
	ForeignKey ConstraintType = "FOREIGN KEY"
)

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 HandlerType

type HandlerType string
const (
	List  HandlerType = "list"
	Read  HandlerType = "read"
	Patch HandlerType = "patch"
)

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"`
	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"`
}

type OptionType

type OptionType string
const (
	Regenerate OptionType = "regenerate"
	NoGenerate OptionType = "nogenerate"
)

type PatchType

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

type ResourceGenerator added in v0.0.14

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

func NewResourceGenerator added in v0.0.14

func NewResourceGenerator(ctx context.Context, resourceFilePath, migrationSourceURL string, options ...ResourceOption) (*ResourceGenerator, error)

func (ResourceGenerator) Close added in v0.0.14

func (c ResourceGenerator) Close()

func (*ResourceGenerator) Generate added in v0.0.14

func (r *ResourceGenerator) Generate() error

type ResourceOption added in v0.0.14

type ResourceOption func(*ResourceGenerator) error

func GenerateHandlers added in v0.0.10

func GenerateHandlers(targetDir string, overrides map[string][]HandlerType) ResourceOption

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 func(*TypescriptGenerator) error

func WithTypescriptOverrides added in v0.0.13

func WithTypescriptOverrides(overrides map[string]string) TSOption

type TableMetadata

type TableMetadata struct {
	Columns       map[string]ColumnMeta
	SearchIndexes map[string][]*expressionField
	IsView        bool
	PkCount       int
}

type TypescriptGenerator added in v0.0.14

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

func NewTypescriptGenerator added in v0.0.14

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

func (TypescriptGenerator) Close added in v0.0.14

func (c TypescriptGenerator) Close()

func (*TypescriptGenerator) Generate added in v0.0.14

func (t *TypescriptGenerator) Generate() error

Jump to

Keyboard shortcuts

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