templates

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) string

func GenerateAllGoFiles

func GenerateAllGoFiles(config Config, outputDir string, packageName string)

func GenerateAllTSFiles

func GenerateAllTSFiles(config Config, outputDir string)

func GetGoItemType

func GetGoItemType(field Field, config Config, withPackagePrefix bool) string

func GoEnumConst

func GoEnumConst(s string) string

GoEnumConst converts an enum value string into a valid, exported Go constant name. - Keeps the original value string intact for assignment - Strips/replaces special characters (e.g., '-') from the identifier name - Converts words to PascalCase - Ensures the identifier does not start with a digit by prefixing with 'X'

func HasComplexField

func HasComplexField(fields []Field, config Config) bool

func HasGeopointField

func HasGeopointField(fields []Field) bool

func HasStringIDField

func HasStringIDField(fields []Field) bool

func HasTimeField

func HasTimeField(fields []Field) bool

func IsArray

func IsArray(field Field) bool

getGoType returns the proper Go type for a field, handling enums and schema references

func PascalCase

func PascalCase(s string) string

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts strings to PascalCase for TypeScript naming conventions Examples: "in_progress" -> "InProgress", "iOS" -> "Ios", "hello-world" -> "HelloWorld"

Types

type Collection

type Collection struct {
	Name         string   `yaml:"name"`             // Collection name
	FirebasePath string   `yaml:"firebasePath"`     // Path in Firebase where this collection lives
	Params       []string `yaml:"params,omitempty"` // URL parameters for the path (optional)
	Schema       string   `yaml:"schema"`           // Reference to which schema this collection uses
}

type Config

type Config struct {
	Enums       []Enum       `yaml:"enums"`       // All enum definitions
	Schemas     []Schema     `yaml:"schemas"`     // All schema definitions
	Collections []Collection `yaml:"collections"` // All collection definitions
}

type Enum

type Enum struct {
	Name   string   `yaml:"name"`   // The name of the enum (e.g., "TaskStatus")
	Values []string `yaml:"values"` // Array of possible values (e.g., ["pending", "completed"])
}

type Field

type Field struct {
	Name     string      `yaml:"name"`            // Field name (e.g., "title", "status")
	Type     string      `yaml:"type"`            // Field type (e.g., "string", "number", "boolean")
	Required bool        `yaml:"required"`        // Whether this field is required
	Enum     string      `yaml:"enum,omitempty"`  // Reference to an enum type (optional)
	Items    interface{} `yaml:"items,omitempty"` // For array types, what type of items (schema name or basic type)
}

type Schema

type Schema struct {
	Name   string  `yaml:"name"`   // Schema name (e.g., "Users", "Tasks")
	Fields []Field `yaml:"fields"` // Array of fields that make up this schema
}

Jump to

Keyboard shortcuts

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