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 AttributeArgumentNode
- type AttributeNameToken
- type AttributeNode
- type DeclarationNode
- type DomainNode
- type EmailsNode
- type EnumNode
- type EnumValueNode
- type Error
- type Expression
- type ExpressionIdent
- type FieldNode
- type Ident
- type IdentFragment
- type JobInputNode
- type JobNode
- type JobSectionNode
- type MessageNode
- type ModelNode
- type ModelSectionNode
- type NameNode
- type RoleNode
- type RoleSectionNode
- type RouteNode
- type RoutesNode
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 ( FieldTypeID = "ID" // a uuid or similar FieldTypeText = "Text" // a string FieldTypeNumber = "Number" // an integer FieldTypeDecimal = "Decimal" // a decimal FieldTypeDate = "Date" // a date with no time element FieldTypeTimestamp = "Timestamp" // a UTC unix timestamp FieldTypeBoolean = "Boolean" // a boolean FieldTypeSecret = "Secret" // an encrypted secret FieldTypePassword = "Password" // a hashed password FieldTypeMarkdown = "Markdown" // a markdown rich text FieldTypeVector = "Vector" // a vector FieldTypeFile = "File" // a inline file supplied as a data-url FieldTypeDuration = "Duration" // a time duration )
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 ( FieldNameId = "id" FieldNameCreatedAt = "createdAt" FieldNameUpdatedAt = "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 ( IdentityModelName = "Identity" IdentityFieldNameEmail = "email" IdentityFieldNameEmailVerified = "emailVerified" IdentityFieldNamePassword = "password" IdentityFieldNameExternalId = "externalId" IdentityFieldNameIssuer = "issuer" IdentityFieldNameName = "name" IdentityFieldNameGivenName = "givenName" IdentityFieldNameFamilyName = "familyName" IdentityFieldNameMiddleName = "middleName" IdentityFieldNameNickName = "nickName" IdentityFieldNameProfile = "profile" IdentityFieldNamePicture = "picture" IdentityFieldNameWebsite = "website" IdentityFieldNameGender = "gender" IdentityFieldNameZoneInfo = "zoneInfo" IdentityFieldNameLocale = "locale" )
View Source
const ( 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" AttributeEmbed = "embed" AttributeComputed = "computed" AttributeFacet = "facet" )
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 ActionTypes = []string{ ActionTypeCreate, ActionTypeGet, ActionTypeDelete, ActionTypeList, ActionTypeUpdate, ActionTypeRead, ActionTypeWrite, }
View Source
var BuiltInTypes = map[string]bool{ FieldTypeID: true, FieldTypeText: true, FieldTypeNumber: true, FieldTypeDecimal: true, FieldTypeDate: true, FieldTypeTimestamp: true, FieldTypeBoolean: true, FieldTypeSecret: true, FieldTypePassword: true, FieldTypeMarkdown: true, FieldTypeVector: true, FieldTypeFile: true, FieldTypeDuration: true, }
View Source
var ErrInvalidAssignmentExpression = errors.New("expression is not a valid assignment")
View Source
var (
FieldNames = []string{FieldNameId, FieldNameCreatedAt, FieldNameUpdatedAt}
)
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 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 DeclarationNode ¶
type DeclarationNode struct { node.Node Model *ModelNode `("model" @@` Role *RoleNode `| "role" @@` API *APINode `| "api" @@` Enum *EnumNode `| "enum" @@` Message *MessageNode `| "message" @@` Job *JobNode `| "job" @@` Routes *RoutesNode `| "routes" @@)` }
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 ¶
func ParseExpression ¶
func ParseExpression(source string) (*Expression, error)
func (*Expression) CleanString ¶ added in v0.400.0
func (e *Expression) CleanString() string
CleanString removes new lines and unnecessary whitespaces, preserving single spaces between tokens
func (*Expression) Parse ¶ added in v0.400.0
func (e *Expression) Parse(lex *lexer.PeekingLexer) error
func (*Expression) String ¶ added in v0.400.0
func (e *Expression) String() string
func (*Expression) ToAssignmentExpression ¶ added in v0.400.0
func (expr *Expression) ToAssignmentExpression() (*Expression, *Expression, error)
ToAssignmentExpression splits an assignment expression into two separate expressions. E.g. the expression `post.age = 1 + 1` will become `post.age` and `1 + 1`
type ExpressionIdent ¶ added in v0.400.0
func (ExpressionIdent) String ¶ added in v0.400.0
func (ident ExpressionIdent) String() string
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 `( @@ ( "." @@ )* )` }
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 RoleNode ¶
type RoleNode struct { node.Node Name NameNode `@@` Sections []*RoleSectionNode `"{" @@* "}"` }
type RoleSectionNode ¶
type RoleSectionNode struct { node.Node Domains []*DomainNode `("domains" "{" @@* "}"` Emails []*EmailsNode `| "emails" "{" @@* "}")` }
type RoutesNode ¶ added in v0.405.2
Click to show internal directories.
Click to hide internal directories.