Documentation ¶
Overview ¶
Package genpkgs is a library for creating packages to describe the queryable sobjects in a salesforce instance. Using the Config object, a developer can create a single or multiple packages containg struct definitions for the desired objects.
Index ¶
- func LintName(name string) (should string)
- type Config
- func (cfg *Config) CreateJob(ctx context.Context, sv *salesforce.Service) (*Job, error)
- func (cfg *Config) MakeSource(ctx context.Context, sv *salesforce.Service, tmpl *template.Template) (map[string][]byte, error)
- func (cfg *Config) MakeTemplateData(ctx context.Context, sv *salesforce.Service) ([]*TemplateData, error)
- func (cfg *Config) ReadSObjectDescriptions(ctx context.Context, sv *salesforce.Service) (*Job, error)
- type Duplicate
- type DuplicateField
- type ErrorList
- type Field
- type FldOverride
- type Job
- func (job *Job) AssignSObjects(ctx context.Context, sv *salesforce.Service, obj salesforce.SObjectDefinition) error
- func (job *Job) Match(p *Parameters, obj *salesforce.SObjectDefinition) bool
- func (job *Job) Struct(p *Parameters, objdef *salesforce.SObjectDefinition) *Struct
- func (job *Job) TemplateData(p *Parameters) *TemplateData
- type Override
- type Parameters
- type Struct
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { SoapTypes map[string]string `json:"soap_type,omitempty"` // salesforce soap type to go type map. Used to replace or insert to default mappings SkipObjects []string `json:"skip,omitempty"` // objects to exclude from generated package StructOverrides map[string]*Override `json:"struct_overrides,omitempty"` // map of structs with override SkipRelationshipGlobal map[string]bool `json:"skip_relationship_global,omitempty"` // relationshipnames to skip in every object Packages []Parameters `json:"packages,omitempty"` // list of Packages to create IncludeCodeGeneratedComment bool `json:"include_code_generated_comment,omitempty"` // add Code generated .* DO NOT EDIT.$ }
Config holds parameters for code generation
func (*Config) CreateJob ¶
CreateJob initializes a Job struct with the salesforce instance's list of SObjects, and creates maps for caching related data
func (*Config) MakeSource ¶
func (cfg *Config) MakeSource(ctx context.Context, sv *salesforce.Service, tmpl *template.Template) (map[string][]byte, error)
MakeSource creates formatted source code from Config parameters. The returned map's keys are the go_filename from the PackageParams and the byte array is the generated and formatted code. If tmp is nil, the procedure uses the defaultTemplate.
func (*Config) MakeTemplateData ¶
func (cfg *Config) MakeTemplateData(ctx context.Context, sv *salesforce.Service) ([]*TemplateData, error)
MakeTemplateData generates a slice of Templates
func (*Config) ReadSObjectDescriptions ¶
func (cfg *Config) ReadSObjectDescriptions(ctx context.Context, sv *salesforce.Service) (*Job, error)
ReadSObjectDescriptions iterates through salesforce instance's objects and attaches them to the appropriate package.
type Duplicate ¶
type Duplicate struct { MatchingAPIName string `json:"matching_api_name,omitempty"` Label string `json:"label,omitempty"` GoName string `json:"go_name,omitempty"` Fields []DuplicateField `json:"fields,omitempty"` }
Duplicate is an sobject whose goname previously exists in the definition. Use to identify and create necessary overrides.
type DuplicateField ¶
type DuplicateField struct { MatchingAPIName string `json:"matching_api_name,omitempty"` APIName string `json:"api_name,omitempty"` Label string `json:"label,omitempty"` GoName string `json:"go_name,omitempty"` }
DuplicateField provides parameter for a duplicated goname in a struct
type Field ¶
type Field struct { GoName string GoType string Tag string Comment string APIName string Relationship *Field }
Field contains all fields for creating struct definition
type FldOverride ¶
type FldOverride struct { Name string `json:"name,omitempty"` IsPointer bool `json:"is_pointer,omitempty"` SkipRelationship bool `json:"skip_relationship,omitempty"` }
FldOverride contains a replacement name and whether the field should be defined as a pointer
type Job ¶
type Job struct { *Config InstanceName string TypeMap map[string]string // map of SoapTypes to go types ObjMap map[string]salesforce.SObjectDefinition // map of all salesforce instance definitions StructMap map[*Parameters][]Struct // slice of Struct record by package config Include map[*Parameters]*regexp.Regexp Replace map[*Parameters]*regexp.Regexp ReplaceText map[*Parameters]string Duplicates map[*Parameters]map[string]*Duplicate // contains filtered or unexported fields }
Job handles creation of package output
func (*Job) AssignSObjects ¶
func (job *Job) AssignSObjects(ctx context.Context, sv *salesforce.Service, obj salesforce.SObjectDefinition) error
AssignSObjects adds object definitions read from channel to appropriate packages
func (*Job) Match ¶
func (job *Job) Match(p *Parameters, obj *salesforce.SObjectDefinition) bool
Match checks whether an object definition matches the package file criteria
func (*Job) Struct ¶
func (job *Job) Struct(p *Parameters, objdef *salesforce.SObjectDefinition) *Struct
Struct compile all needed data for outputting a go struct definition representing the sobject
func (*Job) TemplateData ¶
func (job *Job) TemplateData(p *Parameters) *TemplateData
TemplateData creates a simplified data structure for use with templates
type Override ¶
type Override struct { Name string `json:"name,omitempty"` Fields map[string]FldOverride `json:"fields,omitempty"` AssociateEntityName string `json:"associated_entity,omitempty"` }
Override defines struct and fld overrides to set struct name. The name is not tested against go linting rules. Point will set the field as a ptr to allow zero values to be sent.
func (*Override) Field ¶
func (o *Override) Field(fx salesforce.Field, goName string, typeNm string, skipRelationship bool) *Field
Field determines comments, type, tag and name
func (*Override) FieldOverride ¶
func (o *Override) FieldOverride(nm, lbl string) *FldOverride
FieldOverride returns all field overrides as well as linted go name
type Parameters ¶
type Parameters struct { Description string `json:"description,omitempty"` // package documentation top line Name string `json:"name,omitempty"` // name of generated package GoFilename string `json:"go_filename,omitempty"` IncludeCustom bool `json:"include_custom,omitempty"` // include custom objects IncludeStandard bool `json:"include_standard,omitempty"` // include standard objecdts AssociatedIdentityType string `json:"associated_identity_type,omitempty"` // include only associated types equal to value (use for Feed, Share, Change Event, etc.) IncludeNames []string `json:"include,omitempty"` // list of objects to include in package IncludeMatch string `json:"include_match,omitempty"` // include in package if Object Name matches any ReplaceMatch string `json:"replace_match,omitempty"` // replace match in name ReplaceWith string `json:"replace_with,omitempty"` // replace with this string if match UseLabel bool `json:"label_as_name,omitempty"` // use Label field rather than name for calculating go name }
Parameters contains all data needed for generating a package
func (*Parameters) GoName ¶
func (p *Parameters) GoName(objdef *salesforce.SObjectDefinition) string
GoName returns the field that will be the basis of the struct name
func (*Parameters) Include ¶
func (p *Parameters) Include(nm string) bool
Include decides whether the sobject is in the IncludedNames list
type Struct ¶
type Struct struct { GoName string `json:"name,omitempty"` Label string `json:"label,omitempty"` APIName string `json:"api_name,omitempty"` Receiver string `json:"receiver,omitempty"` Readonly bool `json:"readonly,omitempty"` KeyPrefix string `json:"keyPrefix,omitempty"` AssociatedEntity string `json:"associated_entity,omitempty"` FieldProps []*Field `json:"field_props,omitempty"` }
Struct contains all needed information to create a salesforce.SObject definition
type TemplateData ¶
type TemplateData struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` GoFilename string `json:"go_filename,omitempty"` IncludeCodeGeneratedComment bool `json:"include_code_generated_comment,omitempty"` Instance string `json:"instance,omitempty"` Structs []Struct `json:"structs,omitempty"` Duplicates string `json:"duplicate_json"` }
TemplateData provides formatted data for a package's template exec