Documentation
¶
Index ¶
- func CompareConstraints(existing, constraints []*Constraint) []change.Change
- func CompareIndices(existing, indices []*Index) []change.Change
- func GetAbsoluteRootPathForTest() string
- func GetAbsoluteSchemaPathForTest() string
- func GetRawSchema(dirPath string, fromTest bool) ([]byte, error)
- func IndexEdgeOptionsEqual(existing, i *IndexEdgeOptions) bool
- func InverseFieldEdgeEqual(existing, inverseFieldEdge *InverseFieldEdge) bool
- func NodeEqual(existing, node *Node) bool
- func PatternEqual(existing, pattern *Pattern) bool
- func PolymorphicOptionsEqual(existing, p *PolymorphicOptions) bool
- func PrivateOptionsEqual(existing, p *PrivateOptions) bool
- func UserConvertTypeEqual(existing, convert *UserConvertType) bool
- type Action
- type ActionField
- type ActionType
- type AssocEdge
- type AssocEdgeGroup
- type BiomeConfig
- type CanViewerDo
- type Config
- type Constraint
- type ConstraintType
- type CustomType
- type DBType
- type EdgeAction
- type Field
- type FieldEdge
- type FieldOverride
- type FieldType
- type ForeignKey
- type ForeignKeyInfo
- type FullText
- type FullTextLanguage
- type FullTextWeight
- type GlobalSchema
- type Index
- type IndexEdgeOptions
- type IndexType
- type InverseAssocEdge
- type InverseFieldEdge
- type Node
- type NullableItem
- type OnDeleteFkey
- type Pattern
- type PolymorphicOptions
- type PrivateOptions
- type Schema
- type TransformsLoaderCodegen
- type UserConvertType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareConstraints ¶ added in v0.0.39
func CompareConstraints(existing, constraints []*Constraint) []change.Change
func CompareIndices ¶ added in v0.0.39
TODO tests...
func GetAbsoluteRootPathForTest ¶
func GetAbsoluteRootPathForTest() string
func GetAbsoluteSchemaPathForTest ¶
func GetAbsoluteSchemaPathForTest() string
func GetRawSchema ¶ added in v0.0.37
func IndexEdgeOptionsEqual ¶ added in v0.1.0
func IndexEdgeOptionsEqual(existing, i *IndexEdgeOptions) bool
func InverseFieldEdgeEqual ¶ added in v0.0.38
func InverseFieldEdgeEqual(existing, inverseFieldEdge *InverseFieldEdge) bool
func PatternEqual ¶ added in v0.0.38
func PolymorphicOptionsEqual ¶ added in v0.0.38
func PolymorphicOptionsEqual(existing, p *PolymorphicOptions) bool
func PrivateOptionsEqual ¶ added in v0.1.0
func PrivateOptionsEqual(existing, p *PrivateOptions) bool
func UserConvertTypeEqual ¶ added in v0.1.0
func UserConvertTypeEqual(existing, convert *UserConvertType) bool
Types ¶
type Action ¶
type Action struct {
// Note that anytime anything changes here, have to update actionEqual in compare.go
Operation ent.ActionOperation `json:"operation,omitempty"`
Fields []string `json:"fields,omitempty"`
ExcludedFields []string `json:"excludedFields,omitempty"`
OptionalFields []string `json:"optionalFields,omitempty"`
RequiredFields []string `json:"requiredFields,omitempty"`
NoFields bool `json:"noFields,omitempty"`
CustomActionName string `json:"actionName,omitempty"`
CustomGraphQLName string `json:"graphQLName,omitempty"`
CustomInputName string `json:"inputName,omitempty"`
HideFromGraphQL bool `json:"hideFromGraphQL,omitempty"`
ActionOnlyFields []*ActionField `json:"actionOnlyFields,omitempty"`
CanViewerDo *CanViewerDo `json:"canViewerDo,omitempty"`
CanFail bool `json:"__canFailBETA,omitempty"`
}
func (*Action) GetTSStringOperation ¶
type ActionField ¶
type ActionField struct {
// Note that anytime anything changes here, have to update actionOnlyFieldEqual in compare.go
Name string
Type ActionType
Nullable bool
Optional bool
ActionName string
ExcludedFields []string
HideFromGraphQL bool
// contains filtered or unexported fields
}
func (*ActionField) GetEntType ¶
func (f *ActionField) GetEntType(inputName string) (enttype.TSType, error)
func (*ActionField) MarshalJSON ¶ added in v0.0.38
func (f *ActionField) MarshalJSON() ([]byte, 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" ActionTypeJSON ActionType = "JSON" )
type AssocEdge ¶
type AssocEdge struct {
// Note that anytime anything changes here, have to update assocEdgeEqual in compare.go
Name string `json:"name,omitempty"`
SchemaName string `json:"schemaName,omitempty"`
Symmetric bool `json:"symmetric,omitempty"`
Unique bool `json:"unique,omitempty"`
TableName string `json:"tableName,omitempty"`
InverseEdge *InverseAssocEdge `json:"inverseEdge,omitempty"`
EdgeActions []*EdgeAction `json:"edgeActions,omitempty"`
HideFromGraphQL bool `json:"hideFromGraphQL,omitempty"`
EdgeConstName string `json:"edgeConstName,omitempty"`
PatternName string `json:"patternName,omitempty"`
}
type AssocEdgeGroup ¶
type AssocEdgeGroup struct {
// Note that anytime anything changes here, have to update assocEdgeGroupEqual in compare.go
Name string `json:"name,omitempty"`
GroupStatusName string `json:"groupStatusName,omitempty"`
TableName string `json:"tableName,omitempty"`
AssocEdges []*AssocEdge `json:"assocEdges,omitempty"`
EdgeActions []*EdgeAction `json:"edgeActions,omitempty"`
ViewerBased bool `json:"viewerBased,omitempty"`
StatusEnums []string `json:"statusEnums,omitempty"`
NullStateFn string `json:"nullStateFn,omitempty"`
NullStates []string `json:"nullStates,omitempty"`
// TS specific
EdgeAction *EdgeAction `json:"edgeAction,omitempty"`
// Go specific
ActionEdges []string `json:"-"`
}
func (*AssocEdgeGroup) AddAssocEdge ¶
func (g *AssocEdgeGroup) AddAssocEdge(edge *AssocEdge)
type BiomeConfig ¶ added in v0.1.7
type BiomeConfig struct {
// we always do --indent-style=space
IndentStyle *string `json:"indentStyle"`
LineWidth *int `json:"lineWidth"`
IndentSize *int `json:"indentSize"`
QuoteStyle *string `json:"quoteStyle"`
QuoteProperties *string `json:"quoteProperties"`
TrailingComma *string `json:"trailingComma"`
}
indicates the biome onfig that should be used here taken from the prettier config https://prettier.io/docs/en/options.html#quotes https://biomejs.dev/reference/cli/#biome
func (*BiomeConfig) GetArgs ¶ added in v0.1.7
func (cfg *BiomeConfig) GetArgs() []string
type CanViewerDo ¶ added in v0.1.0
type Config ¶ added in v0.1.0
type Config struct {
// the prettier config that's being used is parsed and sent up to format the files as needed
// since we're trying to use biome...
// for now keep this named as rome but eventually change to biome?
BiomeConfig *BiomeConfig `json:"rome"`
}
type Constraint ¶
type Constraint struct {
// Note that anytime anything changes here, have to update constraintEqual in compare.go
Name string `json:"name,omitempty"`
Type ConstraintType `json:"type,omitempty"`
Columns []string `json:"columns,omitempty"`
ForeignKey *ForeignKeyInfo `json:"fkey,omitempty"`
Condition string `json:"condition,omitempty"`
}
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" IntEnum DBType = "IntEnum" List DBType = "List" Bytea DBType = "Bytea" StringByte DBType = "StringByte" )
type EdgeAction ¶
type EdgeAction struct {
// Note that anytime anything changes here, have to update edgeActionEqual in compare.go
Operation ent.ActionOperation `json:"operation,omitempty"`
CustomActionName string `json:"actionName,omitempty"`
CustomGraphQLName string `json:"graphQLName,omitempty"`
CustomInputName string `json:"inputName,omitempty"`
HideFromGraphQL bool `json:"hideFromGraphQL,omitempty"`
ActionOnlyFields []*ActionField `json:"actionOnlyFields,omitempty"`
CanViewerDo *CanViewerDo `json:"canViewerDo,omitempty"`
CanFail bool `json:"__canFailBETA,omitempty"`
}
func (*EdgeAction) GetTSStringOperation ¶
func (e *EdgeAction) GetTSStringOperation() string
type Field ¶
type Field struct {
// Note that anytime anything changes here, have to update fieldEqual in compare.go
Name string `json:"name,omitempty"`
Type *FieldType `json:"type,omitempty"`
Nullable bool `json:"nullable,omitempty"`
StorageKey string `json:"storageKey,omitempty"`
// TODO need a way to indicate unique edge is Required also. this changes type generated in ent and graphql
Unique bool `json:"unique,omitempty"`
HideFromGraphQL bool `json:"hideFromGraphQL,omitempty"`
Private *PrivateOptions `json:"private,omitempty"`
GraphQLName string `json:"graphqlName,omitempty"`
Index bool `json:"index,omitempty"`
PrimaryKey bool `json:"primaryKey,omitempty"`
DefaultToViewerOnCreate bool `json:"defaultToViewerOnCreate,omitempty"`
FieldEdge *FieldEdge `json:"fieldEdge,omitempty"` // this only really makes sense on id fields...
ForeignKey *ForeignKey `json:"foreignKey,omitempty"`
ServerDefault *string `json:"serverDefault,omitempty"`
// DisableUserEditable true == DefaultValueOnCreate required OR set in trigger
DisableUserEditable bool `json:"disableUserEditable,omitempty"`
DisableUserGraphQLEditable bool `json:"disableUserGraphQLEditable,omitempty"`
HasDefaultValueOnCreate bool `json:"hasDefaultValueOnCreate,omitempty"`
HasDefaultValueOnEdit bool `json:"hasDefaultValueOnEdit,omitempty"`
HasFieldPrivacy bool `json:"hasFieldPrivacy,omitempty"`
HasEditFieldPrivacy bool `json:"hasEditFieldPrivacy,omitempty"`
Polymorphic *PolymorphicOptions `json:"polymorphic,omitempty"`
DerivedWhenEmbedded bool `json:"derivedWhenEmbedded,omitempty"`
DerivedFields []*Field `json:"derivedFields,omitempty"`
UserConvert *UserConvertType `json:"convert,omitempty"`
FetchOnDemand bool `json:"fetchOnDemand,omitempty"`
DBOnly bool `json:"dbOnly,omitempty"`
Immutable bool `json:"immutable,omitempty"`
// set when parsed via tsent generate schema
Import enttype.Import `json:"-"`
PatternName string `json:"patternName,omitempty"`
}
func (*Field) ApplyOverride ¶ added in v0.1.0
func (f *Field) ApplyOverride(override *FieldOverride)
func (*Field) GetEntType ¶
need nodeName for enum ideally, there's a more elegant way of doing this in the future but we don't know the parent
type FieldEdge ¶
type FieldEdge struct {
// Note that anytime anything changes here, have to update fieldEdgeEqual in compare.go
Schema string `json:"schema,omitempty"`
InverseEdge *InverseFieldEdge `json:"inverseEdge,omitempty"`
DisableBuilderType bool `json:"disableBuilderType,omitempty"`
IndexEdge *IndexEdgeOptions `json:"indexEdge,omitempty"`
EdgeConstName string `json:"edgeConstName,omitempty"`
}
func (*FieldEdge) InverseEdgeName ¶ added in v0.0.35
type FieldOverride ¶ added in v0.1.0
type FieldOverride struct {
Nullable *bool `json:"nullable,omitempty"`
StorageKey string `json:"storageKey,omitempty"`
Unique *bool `json:"unique,omitempty"`
HideFromGraphQL *bool `json:"hideFromGraphQL,omitempty"`
GraphQLName string `json:"graphqlName,omitempty"`
Index *bool `json:"index,omitempty"`
ServerDefault *string `json:"serverDefault,omitempty"`
}
type FieldType ¶
type FieldType struct {
// Note that anytime anything changes here, have to update fieldTypeEqual in compare.go
DBType DBType `json:"dbType,omitempty"`
// required when DBType == DBType.List
// also sometimes used when DBType == JSON or JSONB for json that we store as json(b) in the db but represent as lists
// in graphql and typescript
ListElemType *FieldType `json:"listElemType,omitempty"`
// required when DBType == DBType.Enum || DBType.StringEnum
Values []string `json:"values,omitempty"`
EnumMap map[string]string `json:"enumMap,omitempty"`
IntEnumMap map[string]int `json:"intEnumMap,omitempty"`
DeprecatedIntEnumMap map[string]int `json:"deprecatedIntEnumMap,omitempty"`
Type string `json:"type,omitempty"`
GraphQLType string `json:"graphQLType,omitempty"`
// optional used by generator to specify different types e.g. email, phone, password
CustomType CustomType `json:"customType,omitempty"`
DisableUnknownType bool `json:"disableUnknownType"`
GlobalType string `json:"globalType,omitempty"`
ImportType *tsimport.ImportPath `json:"importType,omitempty"`
// list because go-lang map not stable and don't want generated fields to change often
SubFields []*Field `json:"subFields,omitempty"`
UnionFields []*Field `json:"unionFields,omitempty"`
}
type ForeignKey ¶
type ForeignKey struct {
// Note that anytime anything changes here, have to update foreignKeyEqual in compare.go
Schema string `json:"schema,omitempty"`
Column string `json:"column,omitempty"`
Name string `json:"name,omitempty"`
DisableIndex bool `json:"disableIndex,omitempty"`
DisableBuilderType bool `json:"disableBuilderType,omitempty"`
}
type ForeignKeyInfo ¶
type ForeignKeyInfo struct {
// Note that anytime anything changes here, have to update foreignKeyInfoEqual in compare.go
TableName string `json:"tableName,omitempty"`
Columns []string `json:"columns,omitempty"`
OnDelete OnDeleteFkey `json:"ondelete,omitempty"`
}
type FullText ¶ added in v0.0.39
type FullText struct {
GeneratedColumnName string `json:"generatedColumnName,omitempty"`
Language FullTextLanguage `json:"language,omitempty"`
LanguageColumn string `json:"languageColumn,omitempty"`
IndexType IndexType `json:"indexType,omitempty"`
Weights *FullTextWeight `json:"weights,omitempty"`
}
type FullTextLanguage ¶ added in v0.0.39
type FullTextLanguage string
const ( // rename to search config? English FullTextLanguage = "english" French FullTextLanguage = "french" German FullTextLanguage = "german" Simple FullTextLanguage = "simple" )
type FullTextWeight ¶ added in v0.0.39
type FullTextWeight struct {
A []string `json:"A,omitempty"`
B []string `json:"B,omitempty"`
C []string `json:"C,omitempty"`
D []string `json:"D,omitempty"`
}
func (*FullTextWeight) HasWeights ¶ added in v0.0.39
func (w *FullTextWeight) HasWeights() bool
type GlobalSchema ¶ added in v0.1.0
type Index ¶
type Index struct {
// Note that anytime anything changes here, have to update indexEqual in compare.go
Name string `json:"name,omitempty"`
Columns []string `json:"columns,omitempty"`
Unique bool `json:"unique,omitempty"`
FullText *FullText `json:"fullText,omitempty"`
// for regular indices. doesn't apply for full text...
IndexType IndexType `json:"indexType,omitempty"`
}
type IndexEdgeOptions ¶ added in v0.1.0
type IndexEdgeOptions struct {
Name string `json:"name,omitempty"`
}
type IndexType ¶ added in v0.0.39
type IndexType string
full text only supports gin | gist TODO https://github.com/lolopinto/ent/issues/1029 Index only currently supports gin | btree (will eventually support gist)
type InverseAssocEdge ¶
type InverseAssocEdge struct {
// Note that anytime anything changes here, have to update inverseAssocEdgeEqual in compare.go
// TODO need to be able to mark this as unique
// this is an easy way to get 1->many
Name string `json:"name,omitempty"`
EdgeConstName string `json:"edgeConstName,omitempty"`
}
type InverseFieldEdge ¶ added in v0.0.35
type InverseFieldEdge struct {
// Note that anytime anything changes here, have to update InverseFieldEdgeEqual in compare.go
Name string `json:"name,omitempty"`
TableName string `json:"tableName,omitempty"`
HideFromGraphQL bool `json:"hideFromGraphQL,omitempty"`
EdgeConstName string `json:"edgeConstName,omitempty"`
}
type Node ¶
type Node struct {
// Note that anytime anything changes here, have to update nodeEqual in compare.go
TableName string `json:"tableName,omitempty"`
Fields []*Field `json:"fields,omitempty"`
FieldOverrides map[string]*FieldOverride `json:"fieldOverrides"`
AssocEdges []*AssocEdge `json:"assocEdges,omitempty"`
AssocEdgeGroups []*AssocEdgeGroup `json:"assocEdgeGroups,omitempty"`
Actions []*Action `json:"actions,omitempty"`
EnumTable bool `json:"enumTable,omitempty"`
DBRows []map[string]interface{} `json:"dbRows,omitempty"`
Constraints []*Constraint `json:"constraints,omitempty"`
Indices []*Index `json:"indices,omitempty"`
HideFromGraphQL bool `json:"hideFromGraphQL,omitempty"`
EdgeConstName string `json:"edgeConstName,omitempty"`
PatternName string `json:"patternName,omitempty"`
TransformsSelect bool `json:"transformsSelect,omitempty"`
TransformsDelete bool `json:"transformsDelete,omitempty"`
TransformsLoaderCodegen *TransformsLoaderCodegen `json:"transformsLoaderCodegen,omitempty"`
SchemaPath string `json:"schemaPath,omitempty"`
Patterns []string `json:"patternNames,omitempty"`
CustomGraphQLInterfaces []string `json:"customGraphQLInterfaces,omitempty"`
SupportUpsert bool `json:"supportUpsert,omitempty"`
ShowCanViewerSee bool `json:"showCanViewerSee,omitempty"`
ShowCanViewerEdit bool `json:"showCanViewerEdit,omitempty"`
HasDefaultActionPrivacy bool `json:"hasDefaultActionPrivacy,omitempty"`
}
func (*Node) AddAssocEdge ¶
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 {
// Note that anytime anything changes here, have to update patternEqual in compare.go
Name string `json:"name,omitempty"`
// at this point, should we support everything in Node
Fields []*Field `json:"fields,omitempty"`
AssocEdges []*AssocEdge `json:"assocEdges,omitempty"`
DisableMixin bool `json:"disableMixin,omitempty"`
}
type PolymorphicOptions ¶
type PolymorphicOptions struct {
// Note that anytime anything changes here, have to update PolymorphicOptionsEqual in compare.go
Types []string `json:"types,omitempty"`
HideFromInverseGraphQL bool `json:"hideFromInverseGraphQL,omitempty"`
DisableBuilderType bool `json:"disableBuilderType,omitempty"`
Name string `json:"name,omitempty"`
EdgeConstName string `json:"edgeConstName,omitempty"`
}
type PrivateOptions ¶ added in v0.1.0
type PrivateOptions struct {
ExposeToActions bool `json:"exposeToActions,omitempty"`
}
type Schema ¶
type Schema struct {
Nodes map[string]*Node `json:"schemas,omitempty"`
Patterns map[string]*Pattern `json:"patterns,omitempty"`
GlobalSchema *GlobalSchema `json:"globalSchema"`
Config *Config `json:"config"`
}
func ParseSchema ¶
type TransformsLoaderCodegen ¶ added in v0.1.0
type TransformsLoaderCodegen struct {
Code string `json:"code,omitempty"`
Imports []*tsimport.ImportPath `json:"imports,omitempty"`
}
type UserConvertType ¶ added in v0.1.0
Click to show internal directories.
Click to hide internal directories.