input

package
v0.0.33-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAbsoluteRootPathForTest

func GetAbsoluteRootPathForTest() string

func GetAbsoluteSchemaPathForTest

func GetAbsoluteSchemaPathForTest() string

Types

type Action

type Action struct {
	Operation         ent.ActionOperation `json:"operation"`
	Fields            []string            `json:"fields"`
	CustomActionName  string              `json:"actionName"`
	CustomGraphQLName string              `json:"graphQLName"`
	CustomInputName   string              `json:"inputName"`
	HideFromGraphQL   bool                `json:"hideFromGraphQL"`
	ActionOnlyFields  []*ActionField      `json:"actionOnlyFields"`
}

func (*Action) GetTSStringOperation

func (a *Action) GetTSStringOperation() string

type ActionField

type ActionField struct {
	Name     string
	Type     ActionType
	Nullable bool

	ActionName string
	// contains filtered or unexported fields
}

func (*ActionField) GetEntType

func (f *ActionField) GetEntType(inputName string) (enttype.TSGraphQLType, error)

func (*ActionField) UnmarshalJSON

func (f *ActionField) UnmarshalJSON(data []byte) error

type ActionType

type ActionType string
const (
	// Note that these types should match ActionField.Type in schema.ts
	ActionTypeID      ActionType = "ID"
	ActionTypeBoolean ActionType = "Boolean"
	ActionTypeInt     ActionType = "Int"
	ActionTypeFloat   ActionType = "Float"
	ActionTypeString  ActionType = "String"
	ActionTypeTime    ActionType = "Time"
	ActionTypeObject  ActionType = "Object"
)

type AssocEdge

type AssocEdge struct {
	Name        string            `json:"name"`
	SchemaName  string            `json:"schemaName"`
	Symmetric   bool              `json:"symmetric"`
	Unique      bool              `json:"unique"`
	TableName   string            `json:"tableName"`
	InverseEdge *InverseAssocEdge `json:"inverseEdge"`
	EdgeActions []*EdgeAction     `json:"edgeActions"`
	// Go specific
	EntConfig       *schemaparser.EntConfigInfo
	HideFromGraphQL bool   `json:"hideFromGraphQL"`
	EdgeConstName   string `json:"edgeConstName"`
	PatternName     string `json:"patternName"`
}

type AssocEdgeGroup

type AssocEdgeGroup struct {
	Name            string        `json:"name"`
	GroupStatusName string        `json:"groupStatusName"`
	TableName       string        `json:"tableName"`
	AssocEdges      []*AssocEdge  `json:"assocEdges"`
	EdgeActions     []*EdgeAction `json:"edgeActions"`
	StatusEnums     []string      `json:"statusEnums"`
	NullStateFn     string        `json:"nullStateFn"`
	NullStates      []string      `json:"nullStates"`

	// TS specific
	EdgeAction *EdgeAction `json:"edgeAction"`

	// Go specific
	ActionEdges []string
}

func (*AssocEdgeGroup) AddAssocEdge

func (g *AssocEdgeGroup) AddAssocEdge(edge *AssocEdge)

type Constraint

type Constraint struct {
	Name       string          `json:"name"`
	Type       ConstraintType  `json:"type"`
	Columns    []string        `json:"columns"`
	ForeignKey *ForeignKeyInfo `json:"fkey"`
	Condition  string          `json:"condition"`
}

func (*Constraint) GetConstraintTypeString

func (c *Constraint) GetConstraintTypeString() string

type ConstraintType

type ConstraintType string
const (
	// Note that these type should match enum ConstraintType in schema.ts
	PrimaryKeyConstraint ConstraintType = "primary"
	ForeignKeyConstraint ConstraintType = "foreign"
	UniqueConstraint     ConstraintType = "unique"
	CheckConstraint      ConstraintType = "check"
)

type CustomType

type CustomType string
const (
	EmailType    CustomType = "email"
	PhoneType    CustomType = "phone"
	PasswordType CustomType = "password"
)

type DBType

type DBType string
const (
	// Note that these types should match enum DBType in schema.ts
	UUID        DBType = "UUID"
	Int64ID     DBType = "Int64ID"
	Boolean     DBType = "Boolean"
	Int         DBType = "Int"
	BigInt      DBType = "BigInt"
	Float       DBType = "Float"
	String      DBType = "String"
	Timestamp   DBType = "Timestamp"
	Timestamptz DBType = "Timestamptz"
	Time        DBType = "Time"
	Timetz      DBType = "Timetz"
	Date        DBType = "Date"
	JSON        DBType = "JSON"
	JSONB       DBType = "JSONB"
	Enum        DBType = "Enum"
	StringEnum  DBType = "StringEnum"
	List        DBType = "List"
)

type EdgeAction

type EdgeAction struct {
	Operation         ent.ActionOperation `json:"operation"`
	CustomActionName  string              `json:"actionName"`
	CustomGraphQLName string              `json:"graphQLName"`
	CustomInputName   string              `json:"inputName"`
	HideFromGraphQL   bool                `json:"hideFromGraphQL"`
	ActionOnlyFields  []*ActionField      `json:"actionOnlyFields"`
}

func (*EdgeAction) GetTSStringOperation

func (e *EdgeAction) GetTSStringOperation() string

type Field

type Field struct {
	Name       string     `json:"name"`
	Type       *FieldType `json:"type"`
	Nullable   bool       `json:"nullable"`
	StorageKey string     `json:"storageKey"`
	// TODO need a way to indicate unique edge is Required also. this changes type generated in ent and graphql
	Unique                  bool   `json:"unique"`
	HideFromGraphQL         bool   `json:"hideFromGraphQL"`
	Private                 bool   `json:"private"`
	GraphQLName             string `json:"graphqlName"`
	Index                   bool   `json:"index"`
	PrimaryKey              bool   `json:"primaryKey"`
	DefaultToViewerOnCreate bool   `json:"defaultToViewerOnCreate"`

	FieldEdge     *FieldEdge  `json:"fieldEdge"` // this only really makes sense on id fields...
	ForeignKey    *ForeignKey `json:"foreignKey"`
	ServerDefault interface{} `json:"serverDefault"`
	// DisableUserEditable true == DefaultValueOnCreate required OR set in trigger
	DisableUserEditable     bool `json:"disableUserEditable"`
	HasDefaultValueOnCreate bool `json:"hasDefaultValueOnCreate"`
	HasDefaultValueOnEdit   bool `json:"hasDefaultValueOnEdit"`

	Polymorphic         *PolymorphicOptions `json:"polymorphic"`
	DerivedWhenEmbedded bool                `json:"derivedWhenEmbedded"`
	DerivedFields       []*Field            `json:"derivedFields"`

	// Go specific information here
	TagMap          map[string]string
	GoType          types.Type
	PkgPath         string
	DataTypePkgPath string

	// set when parsed via tsent generate schema
	Import enttype.Import
}

func (*Field) GetEntType

func (f *Field) GetEntType() (enttype.TSGraphQLType, error)

func (*Field) GetImport

func (f *Field) GetImport() (enttype.Import, error)

type FieldEdge

type FieldEdge struct {
	Schema      string `json:"schema"`
	InverseEdge string `json:"inverseEdge"`
}

type FieldType

type FieldType struct {
	DBType DBType `json:"dbType"`
	// required when DBType == DBType.List
	ListElemType *FieldType `json:"listElemType"`
	// required when DBType == DBType.Enum || DBType.StringEnum
	Values      []string          `json:"values"`
	EnumMap     map[string]string `json:"enumMap"`
	Type        string            `json:"type"`
	GraphQLType string            `json:"graphQLType"`
	// optional used by generator to specify different types e.g. email, phone, password
	CustomType CustomType               `json:"customType"`
	ImportType *enttype.InputImportType `json:"importType"`
}

type ForeignKey

type ForeignKey struct {
	Schema       string `json:"schema"`
	Column       string `json:"column"`
	Name         string `json:"name"`
	DisableIndex bool   `json:"disableIndex"`
}

type ForeignKeyInfo

type ForeignKeyInfo struct {
	TableName string       `json:"tableName"`
	Columns   []string     `json:"columns"`
	OnDelete  OnDeleteFkey `json:"ondelete"`
}

type Index

type Index struct {
	Name    string   `json:"name"`
	Columns []string `json:"columns"`
	Unique  bool     `json:"unique"`
}

type InverseAssocEdge

type InverseAssocEdge struct {
	// TODO need to be able to mark this as unique
	// this is an easy way to get 1->many
	Name          string `json:"name"`
	EdgeConstName string `json:"edgeConstName"`
}

type Node

type Node struct {
	TableName       *string                  `json:"tableName"`
	Fields          []*Field                 `json:"fields"`
	AssocEdges      []*AssocEdge             `json:"assocEdges"`
	AssocEdgeGroups []*AssocEdgeGroup        `json:"assocEdgeGroups"`
	Actions         []*Action                `json:"actions"`
	EnumTable       bool                     `json:"enumTable"`
	DBRows          []map[string]interface{} `json:"dbRows"`
	Constraints     []*Constraint            `json:"constraints"`
	Indices         []*Index                 `json:"indices"`
	HideFromGraphQL bool                     `json:"hideFromGraphQL"`
	EdgeConstName   string                   `json:"edgeConstName"`
	PatternName     string                   `json:"patternName"`
}

func (*Node) AddAssocEdge

func (n *Node) AddAssocEdge(edge *AssocEdge)

func (*Node) AddAssocEdgeGroup

func (n *Node) AddAssocEdgeGroup(edgeGroup *AssocEdgeGroup)

type NullableItem

type NullableItem string
const NullableContents NullableItem = "contents"
const NullableContentsAndList NullableItem = "contentsAndList"
const NullableTrue NullableItem = "true"

type OnDeleteFkey

type OnDeleteFkey string
const (
	// Note that these type should match enum ForeignKeyInfo.ondelete in schema.ts
	Restrict   OnDeleteFkey = "RESTRICT"
	Cascade    OnDeleteFkey = "CASCADE"
	SetNull    OnDeleteFkey = "SET NULL"
	SetDefault OnDeleteFkey = "SET DEFAULT"
	NoAction   OnDeleteFkey = "NO ACTION"
)

type Pattern

type Pattern struct {
	Name       string       `json:"name"`
	AssocEdges []*AssocEdge `json:"assocEdges"`
}

type PolymorphicOptions

type PolymorphicOptions struct {
	Types                  []string `json:"types"`
	HideFromInverseGraphQL bool     `json:"hideFromInverseGraphQL"`
}

type Schema

type Schema struct {
	Nodes    map[string]*Node    `json:"schemas"`
	Patterns map[string]*Pattern `json:"patterns"`
}

func ParseSchema

func ParseSchema(input []byte) (*Schema, error)

func ParseSchemaFromTSDir

func ParseSchemaFromTSDir(dirPath string, fromTest bool) (*Schema, error)

TODO: environment variable flag for fromTest instead of passing it in TODO: environment variable or flag for src/schema path instead of hardcoding it here

Jump to

Keyboard shortcuts

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