registry

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TSImportRootParamsKey contains the key for common_import_root in parameters
	TSImportRootParamsKey = "ts_import_roots"
	// TSImportRootAliasParamsKey contains the key for common_import_root_alias in parameters
	TSImportRootAliasParamsKey = "ts_import_root_aliases"
	// TSImportRootSeparator separates the ts import root inside ts_import_roots & ts_import_root_aliases
	TSImportRootSeparator = ";"
	// FetchModuleDirectory is the parameter for directory where fetch module will live
	FetchModuleDirectory = "fetch_module_directory"
	// FetchModuleFileName is the file name for the individual fetch module
	FetchModuleFileName = "fetch_module_filename"
	// UseProtoNames will make the generator to generate field name the same as defined in the proto
	UseProtoNames = "use_proto_names"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	// Types stores the type information keyed by the fully qualified name of a type
	Types map[string]*TypeInformation

	// FilesToGenerate contains a list of actual file to generate, different from all the files from the request, some of which are import files
	FilesToGenerate map[string]bool

	// TSImportRoots represents the ts import root for the generator to figure out required import path, will default to cwd
	TSImportRoots []string

	// TSImportRootAliases if not empty will substitutes the common import root when writing the import into the js file
	TSImportRootAliases []string

	// FetchModuleDirectory is the directory to place fetch module file
	FetchModuleDirectory string

	// FetchModuleFilename is the filename for the fetch module
	FetchModuleFilename string

	// FetchModuleR is the alias for fetch module directory
	FetchModuleDirectoryAlias string

	// UseProtoNames will cause the generator to generate field name the same as defined in the proto
	UseProtoNames bool

	// TSPackages stores the package name keyed by the TS file name
	TSPackages map[string]string
}

Registry analyse generation request, spits out the data the the rendering process it also holds the information about all the types

func NewRegistry

func NewRegistry(paramsMap map[string]string) (*Registry, error)

NewRegistry initialise the registry and return the instance

func (*Registry) Analyse

func (r *Registry) Analyse(req *plugin.CodeGeneratorRequest) (map[string]*data.File, error)

Analyse analyses the the file inputs, stores types information and spits out the rendering data

func (*Registry) IsFileToGenerate

func (r *Registry) IsFileToGenerate(name string) bool

IsFileToGenerate contains the file to be generated in the request

type TypeInformation

type TypeInformation struct {
	// Fully qualified name of the type, it starts with `.` and followed by packages and the nested structure path.
	FullyQualifiedName string
	// Package is the package of the type it belongs to
	Package string
	// Files is the file of the type belongs to, this is important in Typescript as modules is the namespace for types defined inside
	File string
	// ModuleIdentifier is the identifier of the type inside the package, this will be useful for enum and nested enum.
	PackageIdentifier string
	// LocalIdentifier is the identifier inside the types local scope
	LocalIdentifier string
	// ProtoType is the type inside the proto. This is used to tell whether it's an enum or a message
	ProtoType descriptorpb.FieldDescriptorProto_Type
	// IsMapEntry indicates whether this type is a Map Entry
	IsMapEntry bool
	// KeyType is the type information for the map key
	KeyType *data.MapEntryType
	// Value type is the type information for the map value
	ValueType *data.MapEntryType
}

TypeInformation store the information about a given type

Jump to

Keyboard shortcuts

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