Documentation ¶
Index ¶
- Constants
- Variables
- func IsBuiltInFieldType(s string) bool
- type APIModelActionNode
- type APIModelNode
- type APIModelSectionNode
- type APINode
- type APISectionNode
- type AST
- type ActionInputNode
- type ActionNode
- type Array
- type AttributeArgumentNode
- type AttributeNameToken
- type AttributeNode
- type Condition
- type ConditionWrap
- type DeclarationNode
- type DomainNode
- type EmailsNode
- type EnumNode
- type EnumValueNode
- type Error
- type Expression
- func (e *Expression) Conditions() []*Condition
- func (expr *Expression) IsAssignment() bool
- func (expr *Expression) IsValue() bool
- func (expr *Expression) ToAssignmentCondition() (*Condition, error)
- func (expr *Expression) ToString() (string, error)
- func (expr *Expression) ToValue() (*Operand, error)
- type FieldNode
- type Ident
- func (ident *Ident) IsContext() bool
- func (ident *Ident) IsContextEnvField() bool
- func (ident *Ident) IsContextHeadersField() bool
- func (ident *Ident) IsContextIdentity() bool
- func (ident *Ident) IsContextIdentityId() bool
- func (ident *Ident) IsContextIsAuthenticatedField() bool
- func (ident *Ident) IsContextNowField() bool
- func (ident *Ident) IsContextSecretField() bool
- func (ident *Ident) LastFragment() string
- func (ident *Ident) ToString() string
- type IdentFragment
- type JobInputNode
- type JobNode
- type JobSectionNode
- type MessageNode
- type ModelNode
- type ModelSectionNode
- type NameNode
- type Operand
- type Operator
- type OrExpression
- type RoleNode
- type RoleSectionNode
Constants ¶
View Source
const ( KeywordModel = "model" KeywordModels = "models" KeywordApi = "api" KeywordMessage = "message" KeywordField = "field" KeywordFields = "fields" KeywordActions = "actions" KeywordDomains = "domains" KeywordEmails = "emails" KeywordRole = "role" KeywordEnum = "enum" KeywordWith = "with" KeywordReturns = "returns" KeywordJob = "job" KeywordInput = "inputs" )
Keywords
View Source
const ( TypeNumber = "Number" TypeText = "Text" TypeBoolean = "Boolean" // These are unique to expressions TypeNull = "Null" TypeArray = "Array" TypeIdent = "Ident" TypeEnum = "Enum" TypeModel = "Model" )
Types are roughly analogous to field types but they are used to type expressions
View Source
const ( FieldTypeID = "ID" // a uuid or similar FieldTypeText = "Text" // a string FieldTypeNumber = "Number" // an integer FieldTypeDate = "Date" // a date with no time element FieldTypeDatetime = "Timestamp" // a UTC unix timestamp FieldTypeBoolean = "Boolean" // a boolean FieldTypeSecret = "Secret" // an encrypted secret FieldTypePassword = "Password" // a hashed password )
Built in Keel types. Worth noting a field type can also reference another user-defined model
View Source
const ( ActionTypeGet = "get" ActionTypeCreate = "create" ActionTypeUpdate = "update" ActionTypeList = "list" ActionTypeDelete = "delete" // Arbitrary function action types ActionTypeRead = "read" ActionTypeWrite = "write" )
All possible action types
View Source
const ( ImplicitFieldNameId = "id" ImplicitFieldNameCreatedAt = "createdAt" ImplicitFieldNameUpdatedAt = "updatedAt" )
All models get a field named "id" implicitly. This set of constants provides the set of this, and other similar implicit fields.
View Source
const ( ImplicitIdentityModelName = "Identity" ImplicitIdentityFieldNameEmail = "email" ImplicitIdentityFieldNameEmailVerified = "emailVerified" ImplicitIdentityFieldNamePassword = "password" ImplicitIdentityFieldNameExternalId = "externalId" ImplicitIdentityFieldNameIssuer = "issuer" )
View Source
const ( AuthenticateActionName = "authenticate" RequestPasswordResetActionName = "requestPasswordReset" PasswordResetActionName = "resetPassword" )
View Source
const ( AttributeUnique = "unique" AttributePermission = "permission" AttributeWhere = "where" AttributeSet = "set" AttributePrimaryKey = "primaryKey" AttributeDefault = "default" AttributeValidate = "validate" AttributeRelation = "relation" AttributeOrderBy = "orderBy" AttributeSortable = "sortable" AttributeSchedule = "schedule" AttributeFunction = "function" AttributeOn = "on" )
View Source
const ( OrderByAscending = "asc" OrderByDescending = "desc" )
View Source
const (
DefaultApi = "Api"
)
View Source
const (
MessageFieldTypeAny = "Any"
)
Types for Message fields
Variables ¶
View Source
var ( AssignmentCondition = "assignment" LogicalCondition = "logical" ValueCondition = "value" UnknownCondition = "unknown" )
View Source
var ( OperatorEquals = "==" OperatorAssignment = "=" OperatorNotEquals = "!=" OperatorGreaterThanOrEqualTo = ">=" OperatorLessThanOrEqualTo = "<=" OperatorLessThan = "<" OperatorGreaterThan = ">" OperatorIn = "in" OperatorNotIn = "notin" OperatorIncrement = "+=" OperatorDecrement = "-=" )
View Source
var ActionTypes = []string{ ActionTypeCreate, ActionTypeGet, ActionTypeDelete, ActionTypeList, ActionTypeUpdate, ActionTypeRead, ActionTypeWrite, }
View Source
var AssignmentOperators = []string{ OperatorAssignment, }
View Source
var BuiltInTypes = map[string]bool{ FieldTypeID: true, FieldTypeText: true, FieldTypeNumber: true, FieldTypeDate: true, FieldTypeDatetime: true, FieldTypeBoolean: true, FieldTypeSecret: true, FieldTypePassword: true, }
View Source
var ErrNotAssignment = errors.New("expression is not using an assignment, e.g. a = b")
View Source
var ErrNotValue = errors.New("expression is not a single value")
View Source
var (
ImplicitFieldNames = []string{ImplicitFieldNameId, ImplicitFieldNameCreatedAt, ImplicitFieldNameUpdatedAt}
)
View Source
var LogicalOperators = []string{ OperatorEquals, OperatorNotEquals, OperatorGreaterThan, OperatorGreaterThanOrEqualTo, OperatorLessThan, OperatorLessThanOrEqualTo, OperatorIn, OperatorNotIn, }
Functions ¶
func IsBuiltInFieldType ¶
Types ¶
type APIModelActionNode ¶ added in v0.377.0
type APIModelNode ¶ added in v0.377.0
type APIModelNode struct { node.Node Name NameNode `@@` Sections []*APIModelSectionNode `("{" @@* "}")*` }
type APIModelSectionNode ¶ added in v0.377.0
type APIModelSectionNode struct { node.Node Actions []*APIModelActionNode `"actions" "{" @@* "}"` }
type APINode ¶
type APINode struct { node.Node Name NameNode `@@` Sections []*APISectionNode `"{" @@* "}"` }
type APISectionNode ¶
type APISectionNode struct { node.Node Models []*APIModelNode `("models" "{" @@* "}"` Attribute *AttributeNode `| @@)` }
type AST ¶
type AST struct { node.Node Declarations []*DeclarationNode `@@*` EnvironmentVariables []string Secrets []string }
type ActionInputNode ¶
type ActionInputNode struct { node.Node Label *NameNode `(@@ ":")?` Type Ident `@@` Optional bool `@( "?" )?` }
func (*ActionInputNode) Name ¶
func (a *ActionInputNode) Name() string
type ActionNode ¶
type ActionNode struct { node.Node Type NameNode `@@` Name NameNode `@@` Inputs []*ActionInputNode `"(" ( @@ ( "," @@ )* ","? )? ")"` With []*ActionInputNode `( ( "with" "(" ( @@ ( "," @@ )* ","? )? ")" )` Returns []*ActionInputNode `| ( "returns" "(" ( @@ ( "," @@ )* ) ")" ) )?` Attributes []*AttributeNode `( "{" @@+ "}" | @@+ )?` BuiltIn bool }
func (*ActionNode) IsArbitraryFunction ¶
func (a *ActionNode) IsArbitraryFunction() bool
func (*ActionNode) IsFunction ¶
func (a *ActionNode) IsFunction() bool
type AttributeArgumentNode ¶
type AttributeArgumentNode struct { node.Node Label *NameNode `(@@ ":")?` Expression *Expression `@@` }
type AttributeNameToken ¶
type AttributeNode ¶
type AttributeNode struct { node.Node Name AttributeNameToken `@@` // This supports: // - no parenthesis at all // - empty parenthesis // - parenthesis with args Arguments []*AttributeArgumentNode `(( "(" @@ ( "," @@ )* ")" ) | ( "(" ")" ) )?` }
Attributes: - @permission - @set - @validate - @where - @unique - @default - @orderBy - @sortable - @on
type ConditionWrap ¶
type ConditionWrap struct { node.Node Expression *Expression `( "(" @@ ")"` Condition *Condition `| @@ )` }
type DeclarationNode ¶
type DomainNode ¶
type EmailsNode ¶
type EnumNode ¶
type EnumNode struct { node.Node Name NameNode `@@` Values []*EnumValueNode `"{" @@* "}"` }
type EnumValueNode ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func (Error) GetPositionRange ¶
func (Error) HasEndPosition ¶
type Expression ¶
type Expression struct { node.Node Or []*OrExpression `@@ ("or" @@)*` }
func ParseExpression ¶
func ParseExpression(source string) (*Expression, error)
func (*Expression) Conditions ¶
func (e *Expression) Conditions() []*Condition
func (*Expression) IsAssignment ¶
func (expr *Expression) IsAssignment() bool
func (*Expression) IsValue ¶
func (expr *Expression) IsValue() bool
func (*Expression) ToAssignmentCondition ¶
func (expr *Expression) ToAssignmentCondition() (*Condition, error)
func (*Expression) ToString ¶
func (expr *Expression) ToString() (string, error)
func (*Expression) ToValue ¶
func (expr *Expression) ToValue() (*Operand, error)
type FieldNode ¶
type FieldNode struct { node.Node Name NameNode `@@` Type NameNode `@@` Repeated bool `( @( "[" "]" )` Optional bool `| @( "?" ))?` Attributes []*AttributeNode `( "{" @@+ "}" | @@+ )?` // Some fields are added implicitly after parsing the schema // For these fields this value is set to true so we can distinguish // them from fields defined by the user in the schema BuiltIn bool }
type Ident ¶
type Ident struct { node.Node Fragments []*IdentFragment `( @@ ( "." @@ )* )` }
func (*Ident) IsContextEnvField ¶
func (*Ident) IsContextHeadersField ¶
func (*Ident) IsContextIdentity ¶ added in v0.370.1
func (*Ident) IsContextIdentityId ¶ added in v0.370.1
func (*Ident) IsContextIsAuthenticatedField ¶
func (*Ident) IsContextNowField ¶
func (*Ident) IsContextSecretField ¶
func (*Ident) LastFragment ¶
type IdentFragment ¶
type JobInputNode ¶
type JobNode ¶
type JobNode struct { node.Node Name NameNode `@@` Sections []*JobSectionNode `"{" @@* "}"` }
type JobSectionNode ¶
type JobSectionNode struct { node.Node Inputs []*JobInputNode `( "inputs" "{" @@* "}"` Attribute *AttributeNode `| @@)` }
type MessageNode ¶
type MessageNode struct { node.Node Name NameNode `@@` Fields []*FieldNode `"{" @@* "}"` BuiltIn bool }
func (*MessageNode) NameNode ¶
func (e *MessageNode) NameNode() NameNode
type ModelNode ¶
type ModelNode struct { node.Node Name NameNode `@@` Sections []*ModelSectionNode `"{" @@* "}"` BuiltIn bool }
type ModelSectionNode ¶
type ModelSectionNode struct { node.Node Fields []*FieldNode `( "fields" "{" @@* "}"` Actions []*ActionNode `| "actions" "{" @@* "}"` Attribute *AttributeNode `| @@)` }
type Operand ¶
type Operand struct { node.Node Number *int64 ` @('-'? Int)` String *string `| @String` Null bool `| @"null"` True bool `| @"true"` False bool `| @"false"` Array *Array `| @@` Ident *Ident `| @@` }
func (*Operand) IsLiteralType ¶
type Operator ¶
type OrExpression ¶
type OrExpression struct { node.Node And []*ConditionWrap `@@ ("and" @@)*` }
type RoleNode ¶
type RoleNode struct { node.Node Name NameNode `@@` Sections []*RoleSectionNode `"{" @@* "}"` }
type RoleSectionNode ¶
type RoleSectionNode struct { node.Node Domains []*DomainNode `("domains" "{" @@* "}"` Emails []*EmailsNode `| "emails" "{" @@* "}")` }
Click to show internal directories.
Click to hide internal directories.