Documentation
¶
Overview ¶
Example ¶
package main import ( "fmt" "github.com/voedger/voedger/pkg/appdef" ) func main() { var app appdef.IAppDef docName, recName := appdef.NewQName("test", "doc"), appdef.NewQName("test", "rec") // how to build AppDef with CDoc { adb := appdef.New() adb.AddPackage("test", "test.com/test") doc := adb.AddCDoc(docName) doc.SetComment("This is example doc") doc. AddField("f1", appdef.DataKind_int64, true).SetFieldComment("f1", "Field may have comments too"). AddField("f2", appdef.DataKind_string, false) rec := adb.AddCRecord(recName) doc.AddContainer("rec", recName, 0, appdef.Occurs_Unbounded) rec. AddField("f1", appdef.DataKind_int64, true). AddField("f2", appdef.DataKind_string, false) app = adb.MustBuild() } // how to inspect builded AppDef with CDoc { // how to find type by name t := app.Type(docName) fmt.Printf("type %q: %v\n", t.QName(), t.Kind()) // how to cast type to cdoc d, ok := t.(appdef.ICDoc) fmt.Printf("%q is CDoc: %v\n", d.QName(), ok && (d.Kind() == appdef.TypeKind_CDoc)) // how to find CDoc by name doc := app.CDoc(docName) fmt.Printf("doc %q: %v. %s\n", doc.QName(), doc.Kind(), d.Comment()) // how to inspect doc fields fmt.Printf("doc field count: %v\n", doc.UserFieldCount()) fmt.Println("founded", doc.Field("f1")) fldCnt := 0 for _, f := range doc.Fields() { fldCnt++ if f.IsSys() { fmt.Print("*") } else { fmt.Print(" ") } info := fmt.Sprintf("%d. %v, required: %v", fldCnt, f, f.Required()) if f.Comment() != "" { info += ". " + f.Comment() } fmt.Println(info) } // how to inspect doc containers fmt.Printf("doc container count: %v\n", doc.ContainerCount()) fmt.Println("founded", doc.Container("rec")) contCnt := 0 for _, c := range doc.Containers() { contCnt++ fmt.Printf("%d. %v, occurs: %v…%v\n", contCnt, c, c.MinOccurs(), c.MaxOccurs()) } // what if unknown type fmt.Println("unknown type:", app.Type(appdef.NewQName("test", "unknown"))) } }
Output: type "test.doc": TypeKind_CDoc "test.doc" is CDoc: true doc "test.doc": TypeKind_CDoc. This is example doc doc field count: 2 founded int64-field «f1» *1. QName-field «sys.QName», required: true *2. RecordID-field «sys.ID», required: true *3. bool-field «sys.IsActive», required: false 4. int64-field «f1», required: true. Field may have comments too 5. string-field «f2», required: false doc container count: 1 founded container «rec: test.rec» 1. container «rec: test.rec», occurs: 0…unbounded unknown type: null type
Index ¶
- Constants
- Variables
- func CompareFullQName(a, b FullQName) int
- func CompareQName(a, b QName) int
- func ErrAlreadyExists(msg string, args ...any) error
- func ErrConvert(msg string, args ...any) error
- func ErrFieldNotFound(f string) error
- func ErrIncompatible(msg string, args ...any) error
- func ErrInvalid(msg string, args ...any) error
- func ErrMissed(msg string, args ...any) error
- func ErrNotFound(msg string, args ...any) error
- func ErrOutOfBounds(msg string, args ...any) error
- func ErrRoleNotFound(r QName) error
- func ErrTooMany(msg string, args ...any) error
- func ErrTypeNotFound(t QName) error
- func ErrUnsupported(msg string, args ...any) error
- func IsSysField(n FieldName) bool
- func ParseFullQualifiedName(val string) (s1, s2 string, err error)
- func ParseQualifiedName(val, delimiter string) (part1, part2 string, err error)
- func PrivilegeAccessControlString(grant bool) string
- func ValidFieldName(ident FieldName) (bool, error)
- func ValidFullQName(fqn FullQName) (bool, error)
- func ValidIdent(ident string) (bool, error)
- func ValidPackagePath(path string) (bool, error)
- func ValidQName(qName QName) (bool, error)
- func ValidQNames(qName ...QName) (ok bool, err error)
- type ConstraintKind
- type DataKind
- type ExtensionEngineKind
- type FieldName
- type FullQName
- func (fqn FullQName) Entity() string
- func (fqn FullQName) MarshalJSON() ([]byte, error)
- func (fqn FullQName) MarshalText() (text []byte, err error)
- func (fqn FullQName) PkgPath() string
- func (fqn FullQName) String() string
- func (fqn *FullQName) UnmarshalJSON(text []byte) error
- func (fqn *FullQName) UnmarshalText([]byte) error
- type IAppDef
- type IAppDefBuilder
- type ICDoc
- type ICDocBuilder
- type ICDocsBuilder
- type ICRecord
- type ICRecordBuilder
- type ICommand
- type ICommandBuilder
- type ICommandsBuilder
- type ICommentsBuilder
- type IConstraint
- func Enum[T enumerable](v ...T) IConstraint
- func MaxExcl(v float64, c ...string) IConstraint
- func MaxIncl(v float64, c ...string) IConstraint
- func MaxLen(v uint16, c ...string) IConstraint
- func MinExcl(v float64, c ...string) IConstraint
- func MinIncl(v float64, c ...string) IConstraint
- func MinLen(v uint16, c ...string) IConstraint
- func NewConstraint(kind ConstraintKind, value any, c ...string) IConstraint
- func Pattern(v string, c ...string) IConstraint
- type IContainedRecord
- type IContainedRecordBuilder
- type IContainer
- type IContainers
- type IContainersBuilder
- type IData
- type IDataBuilder
- type IDataTypesBuilder
- type IDoc
- type IDocBuilder
- type IExtension
- type IExtensionBuilder
- type IField
- type IFields
- type IFieldsBuilder
- type IFunction
- type IFunctionBuilder
- type IGDoc
- type IGDocBuilder
- type IGDocsBuilder
- type IGRecord
- type IGRecordBuilder
- type ILimit
- type ILimitsBuilder
- type IODoc
- type IODocBuilder
- type IODocsBuilder
- type IORecord
- type IORecordBuilder
- type IObject
- type IObjectBuilder
- type IObjectsBuilder
- type IPackagesBuilder
- type IPrivilege
- type IPrivilegesBuilder
- type IProjector
- type IProjectorBuilder
- type IProjectorEvent
- type IProjectorEvents
- type IProjectorEventsBuilder
- type IProjectorsBuilder
- type IQueriesBuilder
- type IQuery
- type IQueryBuilder
- type IRate
- type IRatesBuilder
- type IRecord
- type IRecordBuilder
- type IRefField
- type IRole
- type IRoleBuilder
- type IRolesBuilder
- type ISingleton
- type ISingletonBuilder
- type IStorage
- type IStorages
- type IStoragesBuilder
- type IStructure
- type IStructureBuilder
- type IType
- type ITypeBuilder
- type IUnique
- type IUniques
- type IUniquesBuilder
- type IView
- type IViewBuilder
- type IViewClustCols
- type IViewClustColsBuilder
- type IViewKey
- type IViewKeyBuilder
- type IViewPartKey
- type IViewPartKeyBuilder
- type IViewValue
- type IViewValueBuilder
- type IViewsBuilder
- type IWDoc
- type IWDocBuilder
- type IWDocsBuilder
- type IWRecord
- type IWRecordBuilder
- type IWithAbstract
- type IWithAbstractBuilder
- type IWithCDocs
- type IWithCommands
- type IWithComments
- type IWithDataTypes
- type IWithExtensions
- type IWithFunctions
- type IWithGDocs
- type IWithLimits
- type IWithODocs
- type IWithObjects
- type IWithPackages
- type IWithPrivileges
- type IWithProjectors
- type IWithQueries
- type IWithRates
- type IWithRecords
- type IWithRoles
- type IWithSingletons
- type IWithStructures
- type IWithTypes
- type IWithViews
- type IWithWDocs
- type IWithWorkspaces
- type IWorkspace
- type IWorkspaceBuilder
- type IWorkspacesBuilder
- type Occurs
- type PrivilegeKind
- type ProjectorEventKind
- type QName
- func (qn QName) Entity() string
- func (qn QName) MarshalJSON() ([]byte, error)
- func (qn QName) MarshalText() (text []byte, err error)
- func (qn QName) Pkg() string
- func (qn QName) String() string
- func (qn *QName) UnmarshalJSON(text []byte) (err error)
- func (qn *QName) UnmarshalText(text []byte) (err error)
- type QNames
- type RateCount
- type RatePeriod
- type RateScope
- type TypeKind
- func (k TypeKind) ContainerKindAvailable(s TypeKind) bool
- func (k TypeKind) FieldKindAvailable(d DataKind) bool
- func (k TypeKind) HasSystemField(f FieldName) (exists, required bool)
- func (k TypeKind) MarshalText() ([]byte, error)
- func (i TypeKind) String() string
- func (k TypeKind) TrimString() string
- type VerificationKind
Examples ¶
Constants ¶
const ( AnyName = "ANY" AnyStructureName = "AnyStructure" AnyRecordName = "AnyRecord" AnyGDocName = "AnyGDoc" AnyCDocName = "AnyCDoc" AnyWDocName = "AnyWDoc" AnySingletonName = "AnySingleton" AnyODocName = "AnyODoc" AnyObjectName = "AnyObject" AnyViewName = "AnyView" AnyExtensionName = "AnyExtension" AnyFunctionName = "AnyFunction" AnyCommandName = "AnyCommand" AnyQueryName = "AnyQuery" )
Any names
const ( // System package name SysPackage = "sys" // Used as delimiter in qualified names QNameQualifierChar = "." // Used as prefix for names of system fields and containers SystemPackagePrefix = SysPackage + QNameQualifierChar // System package path SysPackagePath = "voedger.com/packages/sys" )
const ( SystemField_ID = SystemPackagePrefix + "ID" SystemField_ParentID = SystemPackagePrefix + "ParentID" SystemField_IsActive = SystemPackagePrefix + "IsActive" SystemField_Container = SystemPackagePrefix + "Container" SystemField_QName = SystemPackagePrefix + "QName" )
System field names
const ( Occurs_Unbounded = Occurs(0xffff) Occurs_UnboundedStr = "unbounded" )
const DefaultFieldMaxLength = uint16(255)
Default string and bytes data max length.
This value is used for MaxLen() constraint in system data types `sys.string` and `sys.bytes`.
const MaxFieldLength = uint16(math.MaxUint16)
Maximum string and bytes data length
const MaxIdentLen = 255
Maximum identifier length
const MaxTypeContainerCount = 65536
Maximum containers per one structured type
const MaxTypeFieldCount = 65536
Maximum fields per one structured type
const MaxTypeUniqueCount = 100
Maximum uniques
const MaxTypeUniqueFieldsCount = 256
Maximum fields per one unique
const NullName = ""
Empty name
Variables ¶
var ( // QNameAnyStructure is a substitution for any structure type (record, object or view record). QNameAnyStructure = NewQName(SysPackage, AnyStructureName) // QNameAnyStructure is a substitution for any structure type (record, object or view record). QNameAnyRecord = NewQName(SysPackage, AnyRecordName) // QNameAnyGDoc is a substitution for any GDoc type. QNameAnyGDoc = NewQName(SysPackage, AnyGDocName) // QNameAnyCDoc is a substitution for any CDoc type. QNameAnyCDoc = NewQName(SysPackage, AnyCDocName) // QNameAnyWDoc is a substitution for any WDoc type. QNameAnyWDoc = NewQName(SysPackage, AnyWDocName) // QNameAnySingleton is a substitution for any singleton type. QNameAnySingleton = NewQName(SysPackage, AnySingletonName) // QNameAnyODoc is a substitution for any ODoc type. QNameAnyODoc = NewQName(SysPackage, AnyODocName) // QNameAnyObject is a substitution for any Object type. QNameAnyObject = NewQName(SysPackage, AnyObjectName) // QNameAnyView is a substitution for any view record type. QNameAnyView = NewQName(SysPackage, AnyViewName) // QNameAnyExtension is a substitution for any extension type (function or projector). QNameAnyExtension = NewQName(SysPackage, AnyExtensionName) // QNameAnyFunction is a substitution for any function type (command or query). QNameAnyFunction = NewQName(SysPackage, AnyFunctionName) // QNameAnyCommand is a substitution for any command type. QNameAnyCommand = NewQName(SysPackage, AnyCommandName) // QNameAnyQuery is a substitution for any query type. QNameAnyQuery = NewQName(SysPackage, AnyQueryName) )
QNameAny××× are substitutions, which used to limit with rates. See #868 (VSQL: Rate limits)
var ( QNameForNull = NewQName(NullName, NullName) NullQName = QNameForNull NullFullQName = NewFullQName(NullName, NullName) )
Null (empty) QName
var ( AnyStructureType = newAnyType(QNameAnyStructure) AnyRecordType = newAnyType(QNameAnyRecord) AnyGDocType = newAnyType(QNameAnyGDoc) AnyCDocType = newAnyType(QNameAnyCDoc) AnyWDocType = newAnyType(QNameAnyWDoc) AnySingletonType = newAnyType(QNameAnySingleton) AnyODocType = newAnyType(QNameAnyODoc) AnyObjectType = newAnyType(QNameAnyObject) AnyViewType = newAnyType(QNameAnyView) AnyExtensionType = newAnyType(QNameAnyExtension) AnyFunctionType = newAnyType(QNameAnyFunction) AnyCommandType = newAnyType(QNameAnyCommand) AnyQueryType = newAnyType(QNameAnyQuery) )
Any×××Type are used for substitution, e.g. for rate limits, projector events, etc.
var AnyType = newAnyType(QNameANY)
AnyType is used for return then type is any
var DefaultRateScopes = []RateScope{RateScope_AppPartition}
var ErrAlreadyExistsError = errors.New("already exists")
var ErrConvertError = errors.New("convert error")
var ErrIncompatibleError = errors.New("incompatible")
var ErrInvalidError = errors.New("not valid")
var ErrMissedError = errors.New("missed")
var ErrNotFoundError = errors.New("not found")
var ErrOutOfBoundsError = errors.New("out of bounds")
var ErrTooManyError = errors.New("too many")
var ErrUnsupportedError = errors.ErrUnsupported
var NullAppDef = New().MustBuild()
NullAppDef is IAppDef without any user definitions
var NullFields = new(nullFields)
NullFields is used for return then IFields is not supported
var NullType = new(nullType)
NullType is used for return then type is not founded
var ProjectorEventKind_AnyChanges = []ProjectorEventKind{ ProjectorEventKind_Insert, ProjectorEventKind_Update, ProjectorEventKind_Activate, ProjectorEventKind_Deactivate, }
ProjectorEventKind_AnyChanges describes events for record any change.
var QNameANY = NewQName(SysPackage, AnyName)
QNameANY is substitution denotes that a Function param or result can be any type
See #858 (Support QNameAny as function result)
var VerificationKind_Any = []VerificationKind{VerificationKind_EMail, VerificationKind_Phone}
Functions ¶
func ErrAlreadyExists ¶
func ErrConvert ¶
func ErrFieldNotFound ¶
func ErrIncompatible ¶
func ErrInvalid ¶
func ErrNotFound ¶
func ErrOutOfBounds ¶
func ErrRoleNotFound ¶
func ErrTooMany ¶
func ErrTypeNotFound ¶
func ErrUnsupported ¶
func ParseFullQualifiedName ¶
func ParseQualifiedName ¶
Parse a qualified name from string using specified delimiter
func PrivilegeAccessControlString ¶
Returns "grant" if grant is true, otherwise "revoke".
func ValidFieldName ¶
Returns is string is valid field name and error if not
func ValidFullQName ¶
Returns has FullQName valid package path and entity identifier and error if not
func ValidIdent ¶
Returns is string is valid identifier and error if not
func ValidPackagePath ¶
TODO: implement Parsing a URI Reference with a Regular Expression [RFC3986, app B](https://datatracker.ietf.org/doc/html/rfc3986#appendix-B)
func ValidQName ¶
Returns has qName valid package and entity identifiers and error if not
func ValidQNames ¶
Returns is slice with valid qNames and error if not
Types ¶
type ConstraintKind ¶
type ConstraintKind uint8
Data constraint kind enumeration.
Ref. data-constraint-kind.go for constants and methods.
const ( // null - no-value type. Returned when the requested kind does not exist ConstraintKind_null ConstraintKind = iota ConstraintKind_MinLen ConstraintKind_MaxLen ConstraintKind_Pattern ConstraintKind_MinIncl ConstraintKind_MinExcl ConstraintKind_MaxIncl ConstraintKind_MaxExcl ConstraintKind_Enum ConstraintKind_Count )
func (ConstraintKind) MarshalText ¶
func (k ConstraintKind) MarshalText() ([]byte, error)
func (ConstraintKind) String ¶
func (i ConstraintKind) String() string
func (ConstraintKind) TrimString ¶
func (k ConstraintKind) TrimString() string
Renders an DataConstraintKind in human-readable form, without "DataConstraintKind_" prefix, suitable for debugging or error messages
type DataKind ¶
type DataKind uint8
Data kind enumeration.
Ref. data-kind.go for constants and methods
const ( // null - no-value type. Returned when the requested type does not exist DataKind_null DataKind = iota DataKind_int32 DataKind_int64 DataKind_float32 DataKind_float64 DataKind_bytes DataKind_string DataKind_QName DataKind_bool DataKind_RecordID DataKind_Record DataKind_Event DataKind_FakeLast )
func (DataKind) IsCompatibleWithConstraint ¶
func (k DataKind) IsCompatibleWithConstraint(c ConstraintKind) bool
Returns is data kind supports specified constraint kind.
Bytes data supports: ¶
- ConstraintKind_MinLen
- ConstraintKind_MaxLen
- ConstraintKind_Pattern
String data supports: ¶
- ConstraintKind_MinLen
- ConstraintKind_MaxLen
- ConstraintKind_Pattern
- ConstraintKind_Enum
Numeric data supports: ¶
- ConstraintKind_MinIncl
- ConstraintKind_MinExcl
- ConstraintKind_MaxIncl
- ConstraintKind_MaxExcl
- ConstraintKind_Enum
func (DataKind) MarshalText ¶
func (DataKind) TrimString ¶
Renders an DataKind in human-readable form, without "DataKind_" prefix, suitable for debugging or error messages
type ExtensionEngineKind ¶
type ExtensionEngineKind uint8
Extension engine kind enumeration.
const ( ExtensionEngineKind_null ExtensionEngineKind = iota ExtensionEngineKind_BuiltIn ExtensionEngineKind_WASM ExtensionEngineKind_Count )
func (ExtensionEngineKind) MarshalText ¶
func (k ExtensionEngineKind) MarshalText() ([]byte, error)
func (ExtensionEngineKind) String ¶
func (i ExtensionEngineKind) String() string
func (ExtensionEngineKind) TrimString ¶
func (k ExtensionEngineKind) TrimString() string
Renders an ExtensionEngineKind in human-readable form, without "ExtensionEngineKind_" prefix, suitable for debugging or error messages
type FullQName ¶
type FullQName struct {
// contains filtered or unexported fields
}
FullQName ¶
Full qualified name ¶
<pkgPath>.<entity>
func MustParseFullQName ¶
Parse a full qualified name from string.
Panics: ¶
- if string is not a valid full qualified name
func NewFullQName ¶
Builds a full qualified name from from package path and entity name
func ParseFullQName ¶
Parse a qualified name from string
func (FullQName) MarshalJSON ¶
JSON marshaling support
func (FullQName) MarshalText ¶
need to marshal map[FullQName]any
func (*FullQName) UnmarshalJSON ¶
JSON unmarshaling support
func (*FullQName) UnmarshalText ¶
need unmarshal map[FullQName]any golang json looks on UnmarshalText presence only on unmarshal map[FullQName]any. UnmarshalJSON() will be used anyway but no UnmarshalText -> fail to unmarshal map[FullQName]any see https://github.com/golang/go/issues/29732
type IAppDef ¶
type IAppDef interface { IWithComments IWithPackages IWithWorkspaces IWithTypes IWithDataTypes IWithStructures IWithRecords IWithGDocs IWithCDocs IWithWDocs IWithSingletons IWithODocs IWithObjects IWithViews IWithExtensions IWithFunctions IWithCommands IWithQueries IWithProjectors IWithRoles IWithPrivileges IWithRates IWithLimits }
Application definition is a set of types, views, commands, queries and workspaces.
type IAppDefBuilder ¶
type IAppDefBuilder interface { ICommentsBuilder IPackagesBuilder IWorkspacesBuilder IDataTypesBuilder IGDocsBuilder ICDocsBuilder IWDocsBuilder IODocsBuilder IObjectsBuilder IViewsBuilder ICommandsBuilder IQueriesBuilder IProjectorsBuilder IRolesBuilder IPrivilegesBuilder IRatesBuilder ILimitsBuilder // Returns application definition while building. // // Can be called before or after all entities added. // Does not validate application definition, some types may be invalid. AppDef() IAppDef // Builds application definition. // // Validates and returns builded application type or error. // Must be called after all entities added. Build() (IAppDef, error) // Builds application definition. // // Validates and returns builded application type. // Must be called after all entities added. // // # Panics if error occurred. MustBuild() IAppDef }
type ICDoc ¶
type ICDoc interface { ISingleton // contains filtered or unexported methods }
Configuration document.
type ICDocBuilder ¶
type ICDocBuilder interface { ISingletonBuilder }
type ICDocsBuilder ¶
type ICDocsBuilder interface { // Adds new CDoc type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddCDoc(name QName) ICDocBuilder // Adds new CRecord type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddCRecord(name QName) ICRecordBuilder }
type ICRecord ¶
type ICRecord interface { IContainedRecord // contains filtered or unexported methods }
Configuration document record.
type ICRecordBuilder ¶
type ICRecordBuilder interface { IContainedRecordBuilder }
type ICommand ¶
type ICommand interface { IFunction // Unlogged (secure) parameter. Returns nil if not assigned UnloggedParam() IType }
Command is a function that changes system state. Command may have unlogged parameter. Unlogged parameter is a secure parameter that is not logged.
type ICommandBuilder ¶
type ICommandBuilder interface { IFunctionBuilder // Sets command unlogged (secure) parameter. Must be known type from next kinds: // - Data // - ODoc // - Object // // If NullQName passed then it means that command has no unlogged parameter. // If QNameANY passed then it means that command unlogged parameter may be any. SetUnloggedParam(QName) ICommandBuilder }
type ICommandsBuilder ¶
type ICommandsBuilder interface { // Adds new command. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddCommand(QName) ICommandBuilder }
type ICommentsBuilder ¶
type ICommentsBuilder interface { // Sets comment as string with lines, concatenated with LF SetComment(...string) }
type IConstraint ¶
type IConstraint interface { IWithComments // Returns constraint kind. Kind() ConstraintKind // Returns constraint value. // // # Returns: // - uint16 value for min/max length constraints, // - *regexp.Regexp value for pattern constraint, // - float64 value for min/max inclusive/exclusive constraints. // - sorted slice with values for enumeration constraint. Value() any }
Data constraint interface.
Ref. data-constraint.go for constraints constructors and methods.
func Enum ¶
func Enum[T enumerable](v ...T) IConstraint
Return new enumeration constraint for char or numeric data types.
Enumeration values must be one of the following types:
- string
- int32
- int64
- float32
- float64
Passed values will be sorted and duplicates removed before placing into returning constraint.
Panics: ¶
- if enumeration values list is empty
func MaxExcl ¶
func MaxExcl(v float64, c ...string) IConstraint
Return new maximum exclusive constraint for numeric data types.
Panics: ¶
- if value is NaN
- if value is -infinite
func MaxIncl ¶
func MaxIncl(v float64, c ...string) IConstraint
Return new maximum inclusive constraint for numeric data types.
Panics: ¶
- if value is NaN
- if value is -infinite
func MaxLen ¶
func MaxLen(v uint16, c ...string) IConstraint
Return new maximum length restriction for string or bytes data types.
Using MaxLen(), you can both limit the maximum length by a smaller value, and increase it to MaxFieldLength (65535).
Panics: ¶
- if value is zero
func MinExcl ¶
func MinExcl(v float64, c ...string) IConstraint
Return new minimum exclusive constraint for numeric data types.
Panics: ¶
- if value is NaN
- if value is +infinite
func MinIncl ¶
func MinIncl(v float64, c ...string) IConstraint
Return new minimum inclusive constraint for numeric data types.
Panics: ¶
- if value is NaN
- if value is +infinite
func MinLen ¶
func MinLen(v uint16, c ...string) IConstraint
Return new minimum length constraint for string or bytes data types.
func NewConstraint ¶
func NewConstraint(kind ConstraintKind, value any, c ...string) IConstraint
Creates and returns new constraint.
Panics: ¶
- if kind is unknown,
- id value is not compatible with kind.
type IContainedRecord ¶
type IContainedRecord interface { IRecord // Returns definition for «sys.ParentID» field SystemField_ParentID() IField // Returns definition for «sys.Container» field SystemField_Container() IField }
Contained record is a record that has parent.
type IContainedRecordBuilder ¶
type IContainedRecordBuilder interface { IRecordBuilder }
type IContainer ¶
type IContainer interface { IWithComments // Returns name of container Name() string // Returns type name of included in container child QName() QName // Returns type of included in container child. // // Returns nil if not found Type() IType // Returns minimum occurs of child MinOccurs() Occurs // Returns maximum occurs of child MaxOccurs() Occurs }
Describes single inclusion of child in parent.
type IContainers ¶
type IContainers interface { // Finds container by name. // // Returns nil if not found. Container(name string) IContainer // Returns containers count ContainerCount() int // All containers in add order. Containers() []IContainer }
Final structures with containers are:
- TypeKind_GDoc and TypeKind_GRecord,
- TypeKind_CDoc and TypeKind_CRecord,
- TypeKind_ODoc and TypeKind_CRecord,
- TypeKind_WDoc and TypeKind_WRecord,
- TypeKind_Object,
type IContainersBuilder ¶
type IContainersBuilder interface { // Adds container specified name and occurs. // // # Panics: // - if name is empty, // - if name is invalid, // - if container with name already exists, // - if type name is empty, // - if invalid occurrences, // - if container type kind is not compatible with parent type kind. AddContainer(name string, typeName QName, min, max Occurs, comment ...string) IContainersBuilder }
type IData ¶
type IData interface { IType DataKind() DataKind // Ancestor type. // // All user types should have ancestor. System types may has no ancestor. Ancestor() IData // All data type constraints. // // To obtain all constraints include ancestor data types, pass true to withInherited parameter. Constraints(withInherited bool) map[ConstraintKind]IConstraint }
Data type interface.
Describe simple types, like string, number, date, etc.
type IDataBuilder ¶
type IDataBuilder interface { ITypeBuilder // Add data constraint. // // # Panics: // - if constraint is not compatible with data type. AddConstraints(c ...IConstraint) IDataBuilder }
type IDataTypesBuilder ¶
type IDataTypesBuilder interface { // Adds new data type with specified name and kind. // // If ancestor is not empty, then new data type inherits from. // If ancestor is empty, then new data type inherits from system data types with same data kind. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists, // - if ancestor is not found, // - if ancestor is not data, // - if ancestor has different kind, // - if constraints are not compatible with data kind. AddData(name QName, kind DataKind, ancestor QName, constraints ...IConstraint) IDataBuilder }
Data types builder interface.
type IDoc ¶
type IDoc interface { IRecord // contains filtered or unexported methods }
Document is a record.
Document can contains records.
type IDocBuilder ¶
type IDocBuilder interface { IRecordBuilder }
type IExtension ¶
type IExtension interface { IType // Extension entry point name. // // After construction new extension has a default name from type QName entity. Name() string // Engine kind. // // After construction new extension has a default BuiltIn engine. Engine() ExtensionEngineKind // Returns states. // // States are used to retrieve data. States() IStorages // Returns intents. // // Intents are used to store data. Intents() IStorages }
Entry point is a type that can be executed.
type IExtensionBuilder ¶
type IExtensionBuilder interface { ITypeBuilder // Sets name. // // # Panics: // - if name is empty or invalid identifier SetName(string) IExtensionBuilder // Sets engine. SetEngine(ExtensionEngineKind) IExtensionBuilder // Returns states builder. States() IStoragesBuilder // Returns intents builder. Intents() IStoragesBuilder }
type IField ¶
type IField interface { IWithComments // Returns field name Name() FieldName // Returns data type Data() IData // Returns data kind for field DataKind() DataKind // Returns is field required Required() bool // Returns is field verifiable Verifiable() bool // Returns is field verifiable by specified verification kind VerificationKind(VerificationKind) bool // Returns is field has fixed width data kind IsFixedWidth() bool // Returns is field system IsSys() bool // All field constraints. // // Result contains throughout the data types hierarchy, include all ancestors recursively. // If any constraint (for example `MinLen`) is specified by the ancestor, but redefined in the descendant, // then the constraint from the descendant will include in result. Constraints() map[ConstraintKind]IConstraint }
Describe single field.
type IFields ¶
type IFields interface { // Finds field by name. // // Returns nil if not found. Field(FieldName) IField // Returns fields count FieldCount() int // All fields in add order. Fields() []IField // Finds reference field by name. // // Returns nil if field is not found, or field found but it is not a reference field RefField(FieldName) IRefField // All reference fields. System field (sys.ParentID) is also included RefFields() []IRefField // Returns user fields count. System fields (sys.QName, sys.ID, …) do not count UserFieldCount() int }
Final types with fields are:
- TypeKind_GDoc and TypeKind_GRecord,
- TypeKind_CDoc and TypeKind_CRecord,
- TypeKind_ODoc and TypeKind_CRecord,
- TypeKind_WDoc and TypeKind_WRecord,
- TypeKind_Object and TypeKind_Element,
- TypeKind_ViewRecord
type IFieldsBuilder ¶
type IFieldsBuilder interface { // Adds field specified name and kind. // // # Panics: // - if name is empty, // - if name is invalid, // - if field with name is already exists, // - if specified data kind is not allowed by structured type kind, // - if constraints are not compatible with specified data type. AddField(name FieldName, kind DataKind, required bool, constraints ...IConstraint) IFieldsBuilder // Adds field with specified data type. // // If constraints specified, then new anonymous data type inherits from specified // type will be created and this new type will be used as field data type. // // # Panics: // - if field name is empty, // - if field name is invalid, // - if field with name is already exists, // - if specified data type is not found, // - if specified data kind is not allowed by structured type kind, // - if constraints are not compatible with specified data type. AddDataField(name FieldName, data QName, required bool, constraints ...IConstraint) IFieldsBuilder // Adds reference field specified name and target refs. // // # Panics: // - if name is empty, // - if name is invalid, // - if field with name is already exists. AddRefField(name FieldName, required bool, ref ...QName) IFieldsBuilder // Sets fields comment. // Useful for reference or verified fields, what Add×××Field has not comments // argument. // // # Panics: // - if field not found. SetFieldComment(name FieldName, comment ...string) IFieldsBuilder // Sets verification kind for specified field. // // If not verification kinds are specified then it means that field is not verifiable. // // # Panics: // - if field not found. SetFieldVerify(FieldName, ...VerificationKind) IFieldsBuilder }
type IFunction ¶
type IFunction interface { IExtension // Parameter. Returns nil if not assigned Param() IType // Result. Returns nil if not assigned Result() IType }
Function is a type of extension that can take params and return value.
Function may be query or command.
type IFunctionBuilder ¶
type IFunctionBuilder interface { IExtensionBuilder // Sets function parameter. Must be known type from next kinds: // - Data // - ODoc // - Object // // If NullQName passed then it means that function has no parameter. // If QNameANY passed then it means that parameter may be any. SetParam(QName) IFunctionBuilder // Sets function result. Must be known type from next kinds: // - Data // - GDoc, CDoc, WDoc, ODoc // - Object // // If NullQName passed then it means that function has no result. // If QNameANY passed then it means that result may be any. SetResult(QName) IFunctionBuilder }
type IGDoc ¶
type IGDoc interface { IDoc // contains filtered or unexported methods }
Global document.
type IGDocBuilder ¶
type IGDocBuilder interface { IDocBuilder }
type IGDocsBuilder ¶
type IGDocsBuilder interface { // Adds new GDoc type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddGDoc(QName) IGDocBuilder // Adds new GRecord type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddGRecord(QName) IGRecordBuilder }
type IGRecord ¶
type IGRecord interface { IContainedRecord // contains filtered or unexported methods }
Global document record.
type IGRecordBuilder ¶
type IGRecordBuilder interface { IContainedRecordBuilder }
type ILimitsBuilder ¶
type ILimitsBuilder interface { // Adds new Limit type with specified name. // // # Limited object names // // on which limit is applied, must be specified. // If these contain a function (command or query), this limits count of execution. // If these contain a structural (record or view record), this limits count of create/update operations. // Object names can contain `QNameANY` or one of `QNameAny×××` names. // // # Panics: // - if name is empty or invalid, // - if type with the same name already exists, // - if no limited objects names specified, // - if rate is not found. AddLimit(name QName, on []QName, rate QName, comment ...string) }
type IODoc ¶
type IODoc interface { IDoc // contains filtered or unexported methods }
Operation document.
type IODocBuilder ¶
type IODocBuilder interface { IDocBuilder }
type IODocsBuilder ¶
type IODocsBuilder interface { // Adds new ODoc type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddODoc(name QName) IODocBuilder // Adds new ORecord type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddORecord(name QName) IORecordBuilder }
type IORecord ¶
type IORecord interface { IContainedRecord // contains filtered or unexported methods }
Operation document record.
type IORecordBuilder ¶
type IORecordBuilder interface { IContainedRecordBuilder }
type IObject ¶
type IObject interface { IStructure // contains filtered or unexported methods }
Object type.
type IObjectBuilder ¶
type IObjectBuilder interface { IStructureBuilder }
type IObjectsBuilder ¶
type IObjectsBuilder interface { // Adds new Object type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddObject(name QName) IObjectBuilder }
type IPackagesBuilder ¶
type IPackagesBuilder interface { // Adds new package with specified local name and path. // // # Panics: // - if local name is empty, // - if local name is invalid, // - if package with local name already exists, // - if path is empty, // - if package with path already exists. AddPackage(localName, path string) IAppDefBuilder }
type IPrivilege ¶
type IPrivilege interface { IWithComments // Returns privilege kinds Kinds() []PrivilegeKind // Returns is privilege has been granted. The opposite of `IsRevoked()` IsGranted() bool // Returns is privilege has been revoked. The opposite of `IsGranted()` IsRevoked() bool // Returns objects names on which privilege was applied. // // # For PrivilegeKind_Insert, GrantKind_Update and GrantKind_Select: // - records or view records names or // - workspaces names. // // # For PrivilegeKind_Execute: // - commands & queries names or // - workspaces names. // // # For PrivilegeKind_Inherits: // - roles names. On() QNames // Returns fields (of objects) which was granted or revoked. // // For PrivilegeKind_Update and PrivilegeKind_Select returns field names of records or view records. Fields() []FieldName // Returns the role to which the privilege was granted or revoked. To() IRole }
Represents a privilege (specific rights or permissions) to be granted to role or revoked from.
type IPrivilegesBuilder ¶
type IPrivilegesBuilder interface { // Grants new privilege with specified kinds on specified objects to specified role. // // # Panics: // - if kinds is empty, // - if objects are empty, // - if objects contains unknown names, // - if objects are mixed, e.g. records and commands, // - if kinds are not compatible with objects, // - if fields are not applicable for privilege, // - if fields contains unknown names, // - if role is unknown. Grant(kinds []PrivilegeKind, on []QName, fields []FieldName, toRole QName, comment ...string) IPrivilegesBuilder // Grants all available privileges on specified objects to specified role. // Object names can include `QNameANY` or `QNameAny×××` names. // // If the objects are records or view records, then insert, update, and select are granted. // // If the objects are commands or queries, their execution is granted. // // If the objects are workspaces, then: // - insert, update and select records and view records of these workspaces are granted, // - execution of commands & queries from these workspaces is granted. // // If the objects are roles, then all privileges from these roles are granted to specified role. // // No mixed objects are allowed. GrantAll(on []QName, toRole QName, comment ...string) IPrivilegesBuilder // Revokes privilege with specified kind on specified objects from specified role. Revoke(kinds []PrivilegeKind, on []QName, fromRole QName, comment ...string) IPrivilegesBuilder // Remove all available privileges on specified objects from specified role. RevokeAll(on []QName, fromRole QName, comment ...string) IPrivilegesBuilder }
type IProjector ¶
type IProjector interface { IExtension // Returns is synchronous projector. Sync() bool // Events to trigger. Events() IProjectorEvents // Schedule to trigger projector as cron expression. CronSchedule() string // Returns is projector is able to handle `sys.Error` events. // False by default. WantErrors() bool }
Projector is a extension that executes every time when some event is triggered and data need to be updated.
type IProjectorBuilder ¶
type IProjectorBuilder interface { IExtensionBuilder // Sets is synchronous projector. SetSync(bool) IProjectorBuilder // Events builder. Events() IProjectorEventsBuilder // Schedule to trigger projector as cron expression. SetCronSchedule(string) IProjectorBuilder // Sets is projector is able to handle `sys.Error` events. SetWantErrors() IProjectorBuilder }
type IProjectorEvent ¶
type IProjectorEvent interface { IWithComments // Returns type to trigger projector. // // This can be a record or command. On() IType // Returns set (sorted slice) of event kind to trigger. Kind() []ProjectorEventKind }
Describe event to trigger the projector.
type IProjectorEvents ¶
type IProjectorEvents interface { // Enumerate events to trigger the projector. // // Events enumerated in alphabetical QNames order. Enum(func(IProjectorEvent)) // Returns event by name. // // Returns nil if event not found. Event(QName) IProjectorEvent // Returns number of events. Len() int // Returns events to trigger as map. Map() map[QName][]ProjectorEventKind }
Describe all events to trigger the projector.
type IProjectorEventsBuilder ¶
type IProjectorEventsBuilder interface { // Adds event to trigger the projector. // // QName can be some record type or command. QName can be one of QNameAny××× compatible substitutions. // // If event kind is missed then default is: // - ProjectorEventKind_Any for GDoc/GRecords, CDoc/CRecords and WDoc/WRecords // - ProjectorEventKind_Execute for Commands // - ProjectorEventKind_ExecuteWith for Objects and ODocs // // # Panics: // - if QName is empty (NullQName) // - if QName type is not a record and not a command // - if event kind is not applicable for QName type. Add(on QName, event ...ProjectorEventKind) IProjectorEventsBuilder // Sets event comment. // // # Panics: // - if event for QName is not added. SetComment(on QName, comment ...string) IProjectorEventsBuilder }
type IProjectorsBuilder ¶
type IProjectorsBuilder interface { // Adds new projector. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddProjector(QName) IProjectorBuilder }
type IQueriesBuilder ¶
type IQueriesBuilder interface { // Adds new query. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddQuery(QName) IQueryBuilder }
type IQuery ¶
type IQuery interface { IFunction // contains filtered or unexported methods }
Query is a function that returns data from system state.
type IQueryBuilder ¶
type IQueryBuilder interface { IFunctionBuilder }
type IRate ¶
type IRate interface { IType Count() RateCount Period() RatePeriod Scopes() []RateScope }
type IRatesBuilder ¶
type IRatesBuilder interface { // Adds new Rate type with specified name. // // If no scope is specified, DefaultRateScopes is used. // // # Panics: // - if name is empty or invalid, // - if type with the same name already exists, // - if count is zero, // - if period is zero. AddRate(name QName, count RateCount, period RatePeriod, scopes []RateScope, comment ...string) }
type IRecord ¶
type IRecord interface { IStructure // Returns definition for «sys.ID» field SystemField_ID() IField }
Record is a structure.
Record has ID field.
type IRecordBuilder ¶
type IRecordBuilder interface { IStructureBuilder }
type IRefField ¶
type IRefField interface { IField // Returns list of target references Refs() QNames // Returns, is the link available Ref(QName) bool }
Reference field. Describe field with DataKind_RecordID.
Use Refs() to obtain list of target references.
type IRole ¶
type IRole interface { IType IWithPrivileges }
type IRoleBuilder ¶
type IRoleBuilder interface { ITypeBuilder // Adds new privilege with specified kinds on specified objects. // // # Panics: // - if kinds is empty, // - if objects are empty, // - if objects contains unknown names, // - if kinds are not compatible with objects, // - if fields contains unknown names. Grant(kinds []PrivilegeKind, on []QName, fields []FieldName, comment ...string) IRoleBuilder // Grants all available privileges on specified objects. // // If the objects are records or view records, then insert, update, and select are granted. // // If the objects are commands or queries, their execution is granted. // // If the objects are workspaces, then: // - insert, update and select records and view records of these workspaces are granted, // - execution of commands & queries from these workspaces is granted. // // If the objects are roles, then all privileges from these roles are granted. GrantAll(on []QName, comment ...string) IRoleBuilder // Revokes privilege with specified kinds on specified objects. Revoke(kinds []PrivilegeKind, on []QName, comment ...string) IRoleBuilder // Remove all available privileges on specified objects. RevokeAll(on []QName, comment ...string) IRoleBuilder }
type IRolesBuilder ¶
type IRolesBuilder interface { // Adds new Role type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddRole(QName) IRoleBuilder }
type ISingleton ¶
Singleton is a document that can be only one instance.
type ISingletonBuilder ¶
type ISingletonBuilder interface { IDocBuilder // Устанавливает, что документ является синглтоном SetSingleton() }
type IStorage ¶
type IStorage interface { IWithComments // Returns storage name. Name() QName // Returns names in storage. Names() QNames }
type IStorages ¶
type IStorages interface { // Returns storage by name. // // Returns nil if storage not found. Storage(name QName) IStorage // Enums storages. // // Storages enumerated in alphabetical QNames order. // Names slice in every storage is sorted and deduplicated. Enum(func(IStorage)) // Returns number of storages. Len() int // Returns storages as map. Map() map[QName]QNames }
type IStoragesBuilder ¶
type IStoragesBuilder interface { // Add storage. // // If storage with name is already exists in states then names will be added to existing storage. // // # Panics: // - if name is empty, // - if name is invalid, // - if names contains invalid name(s). Add(name QName, names ...QName) IStoragesBuilder // Sets comment for storage. // // # Panics: // - if storage with name is not added. SetComment(name QName, comment string) IStoragesBuilder }
type IStructure ¶
type IStructure interface { IType IFields IContainers IUniques IWithAbstract // Returns definition for «sys.QName» field SystemField_QName() IField }
Structure is a type with fields, containers and uniques.
type IStructureBuilder ¶
type IStructureBuilder interface { ITypeBuilder IFieldsBuilder IContainersBuilder IUniquesBuilder IWithAbstractBuilder }
type IType ¶
type IType interface { IWithComments // Parent cache App() IAppDef // Type qualified name. QName() QName // Type kind Kind() TypeKind // Returns is type from system package. IsSystem() bool }
Type ¶
Type describes the entity, such as document, record or view.
type ITypeBuilder ¶
type ITypeBuilder interface { ICommentsBuilder }
type IUnique ¶
type IUnique interface { IWithComments // Returns qualified name of unique. Name() QName // Returns unique fields list. Fields are sorted alphabetically Fields() []IField }
Describe single unique for structure.
type IUniques ¶
type IUniques interface { // Return unique by qualified name. // // Returns nil if not unique found UniqueByName(QName) IUnique // Return uniques count UniqueCount() int // All uniques. Uniques() map[QName]IUnique // Returns single field unique. // // This is old-style unique support. See [issue #173](https://github.com/voedger/voedger/issues/173) UniqueField() IField }
Final structures with uniques are: - TypeKind_GDoc and TypeKind_GRecord, - TypeKind_CDoc and TypeKind_CRecord, - TypeKind_WDoc and TypeKind_WRecord
type IUniquesBuilder ¶
type IUniquesBuilder interface { // Adds new unique with specified name and fields. // // # Panics: // - if unique name is empty, // - if unique name is invalid, // - if name is already exists, // - if structured type kind is not supports uniques, // - if fields list is empty, // - if fields has duplicates, // - if fields is already exists or overlaps with an existing unique, // - if some field not found. AddUnique(name QName, fields []FieldName, comment ...string) IUniquesBuilder // Sets single field unique. // Calling SetUniqueField again changes unique field. If specified name is empty, then clears unique field. // // This is old-style unique support. See [issue #173](https://github.com/voedger/voedger/issues/173) // // # Panics: // - if field name is invalid, // - if field not found, // - if field is not required. SetUniqueField(FieldName) IUniquesBuilder }
type IView ¶
type IView interface { IType // All view fields, include key and value. IFields // Returns full (pk + ccols) view key Key() IViewKey // Returns view value Value() IViewValue }
View is a type with key and value.
Example ¶
package main import ( "fmt" "sort" "strings" "github.com/voedger/voedger/pkg/appdef" ) func main() { var app appdef.IAppDef viewName := appdef.NewQName("test", "view") // how to build AppDef with view { adb := appdef.New() adb.AddPackage("test", "test.com/test") docName := appdef.NewQName("test", "doc") _ = adb.AddCDoc(docName) view := adb.AddView(viewName) view.SetComment("view comment") view.Key().PartKey(). AddField("pk_int", appdef.DataKind_int64). AddRefField("pk_ref", docName) view.Key().ClustCols(). AddField("cc_int", appdef.DataKind_int64). AddRefField("cc_ref", docName). AddField("cc_name", appdef.DataKind_string, appdef.MaxLen(100)) view.Value(). AddField("vv_int", appdef.DataKind_int64, true). AddRefField("vv_ref", true, docName). AddField("vv_code", appdef.DataKind_string, false, appdef.MaxLen(10), appdef.Pattern(`^\w+$`)). AddField("vv_data", appdef.DataKind_bytes, false, appdef.MaxLen(1024)) app = adb.MustBuild() } // now to enum views { cnt := 0 app.Views(func(v appdef.IView) { cnt++ fmt.Println(cnt, v) }) fmt.Println("overall view(s):", cnt) } // how to inspect view { // how to find view by name view := app.View(viewName) fmt.Printf("view %q: %v, %s\n", view.QName(), view.Kind(), view.Comment()) fields := func(ff []appdef.IField) { for _, f := range ff { fmt.Printf("- %s: %s", f.Name(), f.DataKind().TrimString()) if f.IsSys() { fmt.Print(", sys") } if f.Required() { fmt.Print(", required") } if r, ok := f.(appdef.IRefField); ok { if len(r.Refs()) != 0 { fmt.Printf(", refs: %v", r.Refs()) } } str := []string{} for _, c := range f.Constraints() { str = append(str, fmt.Sprint(c)) } if len(str) > 0 { sort.Strings(str) fmt.Printf(", constraints: [%v]", strings.Join(str, `, `)) } fmt.Println() } } // how to inspect all view fields fmt.Printf("view has %d fields:\n", view.FieldCount()) fields(view.Fields()) // how to inspect view key fields fmt.Printf("view key has %d fields:\n", view.Key().FieldCount()) fields(view.Key().Fields()) // how to inspect view partition key fmt.Printf("view partition key has %d fields:\n", view.Key().PartKey().FieldCount()) fields(view.Key().PartKey().Fields()) // how to inspect view clustering columns fmt.Printf("view clustering columns key has %d fields:\n", view.Key().ClustCols().FieldCount()) fields(view.Key().ClustCols().Fields()) // how to inspect view value fmt.Printf("view value has %d fields:\n", view.Value().FieldCount()) fields(view.Value().Fields()) } }
Output: 1 ViewRecord «test.view» overall view(s): 1 view "test.view": TypeKind_ViewRecord, view comment view has 10 fields: - sys.QName: QName, sys, required - pk_int: int64, required - pk_ref: RecordID, required, refs: [test.doc] - cc_int: int64 - cc_ref: RecordID, refs: [test.doc] - cc_name: string, constraints: [MaxLen: 100] - vv_int: int64, required - vv_ref: RecordID, required, refs: [test.doc] - vv_code: string, constraints: [MaxLen: 10, Pattern: `^\w+$`] - vv_data: bytes, constraints: [MaxLen: 1024] view key has 5 fields: - pk_int: int64, required - pk_ref: RecordID, required, refs: [test.doc] - cc_int: int64 - cc_ref: RecordID, refs: [test.doc] - cc_name: string, constraints: [MaxLen: 100] view partition key has 2 fields: - pk_int: int64, required - pk_ref: RecordID, required, refs: [test.doc] view clustering columns key has 3 fields: - cc_int: int64 - cc_ref: RecordID, refs: [test.doc] - cc_name: string, constraints: [MaxLen: 100] view value has 5 fields: - sys.QName: QName, sys, required - vv_int: int64, required - vv_ref: RecordID, required, refs: [test.doc] - vv_code: string, constraints: [MaxLen: 10, Pattern: `^\w+$`] - vv_data: bytes, constraints: [MaxLen: 1024]
type IViewBuilder ¶
type IViewBuilder interface { ITypeBuilder // Returns full (pk + ccols) view key builder Key() IViewKeyBuilder // Returns view value builder Value() IViewValueBuilder }
type IViewClustCols ¶
type IViewClustCols interface { // Clustering columns fields. IFields // contains filtered or unexported methods }
Defines fields for sorting values inside partition.
type IViewClustColsBuilder ¶
type IViewClustColsBuilder interface { // Adds clustering columns field. // // Only last column field can be variable length. // // # Panics: // - if field already exists in view; // - if already contains a variable length field. AddField(name FieldName, kind DataKind, constraints ...IConstraint) IViewClustColsBuilder AddDataField(name FieldName, dataType QName, constraints ...IConstraint) IViewClustColsBuilder AddRefField(name FieldName, ref ...QName) IViewClustColsBuilder // Sets fields comment. // Useful for reference or verified fields, what Add×××Field has not comments // argument. // // # Panics: // - if field not found. SetFieldComment(name FieldName, comment ...string) IViewClustColsBuilder }
type IViewKey ¶
type IViewKey interface { // All key fields, include partition key and clustering columns. // // Partition key fields is required, clustering columns is not. IFields // Returns partition key PartKey() IViewPartKey // Returns clustering columns ClustCols() IViewClustCols }
View full (pk + cc) key.
type IViewKeyBuilder ¶
type IViewKeyBuilder interface { // Returns partition key type builder PartKey() IViewPartKeyBuilder // Returns clustering columns type builder ClustCols() IViewClustColsBuilder }
type IViewPartKey ¶
type IViewPartKey interface { // Partition key fields. IFields // contains filtered or unexported methods }
View partition key contains fields for partitioning. Fields for partitioning should be selected so that the size of the partition does not exceed 100 MB. Perfectly if it is around 10 MB. The size of the basket (partition) can be evaluated by the formula:
(ViewValue_Size + ClustCols_Size) * KeysPerPartition.
type IViewPartKeyBuilder ¶
type IViewPartKeyBuilder interface { // Adds partition key field. // // # Panics: // - if field already exists in clustering columns or value fields, // - if not fixed size data kind. AddField(name FieldName, kind DataKind, constraints ...IConstraint) IViewPartKeyBuilder AddDataField(name FieldName, dataType QName, constraints ...IConstraint) IViewPartKeyBuilder AddRefField(name FieldName, ref ...QName) IViewPartKeyBuilder // Sets fields comment. // Useful for reference or verified fields, what Add×××Field has not comments // argument. // // # Panics: // - if field not found. SetFieldComment(name FieldName, comment ...string) IViewPartKeyBuilder }
type IViewValue ¶
type IViewValue interface { // View value fields. IFields // contains filtered or unexported methods }
View value. Like a structure, view value has fields, but has not containers and uniques.
type IViewValueBuilder ¶
type IViewValueBuilder interface { IFieldsBuilder }
type IViewsBuilder ¶
type IViewsBuilder interface { // Adds new types for view. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddView(QName) IViewBuilder }
type IWDoc ¶
type IWDoc interface { ISingleton // contains filtered or unexported methods }
Workflow document.
type IWDocBuilder ¶
type IWDocBuilder interface { ISingletonBuilder }
type IWDocsBuilder ¶
type IWDocsBuilder interface { // Adds new WDoc type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddWDoc(QName) IWDocBuilder // Adds new WRecord type with specified name. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddWRecord(QName) IWRecordBuilder }
type IWRecord ¶
type IWRecord interface { IContainedRecord // contains filtered or unexported methods }
Workflow document record.
type IWRecordBuilder ¶
type IWRecordBuilder interface { IContainedRecordBuilder }
type IWithAbstract ¶
type IWithAbstract interface { // Returns is type abstract Abstract() bool }
See [Issue #524](https://github.com/voedger/voedger/issues/524). Final types can be abstract are:
- TypeKind_GDoc and TypeKind_GRecord,
- TypeKind_CDoc and TypeKind_CRecord,
- TypeKind_ODoc and TypeKind_CRecord,
- TypeKind_WDoc and TypeKind_WRecord,
- TypeKind_Object and TypeKind_Element
- TypeKind_Workspace
type IWithAbstractBuilder ¶
type IWithAbstractBuilder interface {
// Makes type abstract
SetAbstract()
}
type IWithCDocs ¶
type IWithCDocs interface { // Return CDoc by name. // // Returns nil if not found. CDoc(name QName) ICDoc // Return CRecord by name. // // Returns nil if not found. CRecord(name QName) ICRecord // Enumerates all application configuration documents // // Configuration documents are enumerated in alphabetical order by QName CDocs(func(ICDoc)) // Enumerates all application configuration records // // Configuration records are enumerated in alphabetical order by QName CRecords(func(ICRecord)) }
type IWithCommands ¶
type IWithComments ¶
type IWithComments interface { // Returns comment Comment() string // Returns comment as string array CommentLines() []string }
See [Issue #488](https://github.com/voedger/voedger/issues/488)
Any type may have comment
type IWithDataTypes ¶
type IWithDataTypes interface { // Return data type by name. // // Returns nil if not found. Data(QName) IData // Enumerates all application data types. // // If incSys specified then system data types are included into enumeration. // // Data types are enumerated in alphabetical order by QName. DataTypes(incSys bool, cb func(IData)) // Returns system data type (sys.int32, sys.float654, etc.) by data kind. // // Returns nil if not found. SysData(DataKind) IData }
Data types interface.
type IWithExtensions ¶
type IWithExtensions interface { // Return extension by name. // // Returns nil if not found. Extension(QName) IExtension // Enumerates all application extensions (commands, queries and extensions) // // Extensions are enumerated in alphabetical order by QName Extensions(func(IExtension)) }
type IWithFunctions ¶
type IWithGDocs ¶
type IWithGDocs interface { // Return GDoc by name. // // Returns nil if not found. GDoc(QName) IGDoc // Enumerates all global documents // // Global documents are enumerated in alphabetical order by QName GDocs(func(IGDoc)) // Return GRecord by name. // // Returns nil if not found. GRecord(QName) IGRecord // Enumerates all global records // // Global records are enumerated in alphabetical order by QName GRecords(func(IGRecord)) }
type IWithLimits ¶
type IWithODocs ¶
type IWithODocs interface { // Return ODoc by name. // // Returns nil if not found. ODoc(name QName) IODoc // Enumerates all application operation documents // // Operation documents are enumerated in alphabetical order by QName ODocs(func(IODoc)) // Return ORecord by name. // // Returns nil if not found. ORecord(name QName) IORecord // Enumerates all application operation records // // Operation records are enumerated in alphabetical order by QName ORecords(func(IORecord)) }
type IWithObjects ¶
type IWithPackages ¶
type IWithPackages interface { // Returns package path by package local name. // // Returns empty string if not found PackageFullPath(localName string) string // Returns package local name by package path. // // Returns empty string if not found PackageLocalName(fullPath string) string // Return all local names of packages in alphabetical order PackageLocalNames() []string // Enumerates all packages. // // Packages are enumerated in alphabetical order by local name Packages(func(localName, fullPath string)) // Returns full qualified name by qualified name. // // Returns NullFullQName if QName.Pkg() is unknown. FullQName(QName) FullQName // Returns qualified name by full qualified name. // // Returns NullQName if FullQName.PkgPath() is unknown. LocalQName(FullQName) QName }
type IWithPrivileges ¶
type IWithPrivileges interface { // Enumerates all privileges. // // Privileges are enumerated in the order they are added. Privileges(func(IPrivilege)) // Returns all privileges on specified entities, which contains at least one from specified kinds. // // If no kinds specified then all privileges on entities are returned. // // Privileges are returned in the order they are added. PrivilegesOn(on []QName, kind ...PrivilegeKind) []IPrivilege }
IWithPrivileges is an interface for entities that have grants.
type IWithProjectors ¶
type IWithProjectors interface { // Return projector by name. // // Returns nil if not found. Projector(QName) IProjector // Enumerates all application projectors. // // Projectors are enumerated in alphabetical order by QName. Projectors(func(IProjector)) }
type IWithQueries ¶
type IWithRates ¶
type IWithRecords ¶
type IWithRoles ¶
type IWithSingletons ¶
type IWithSingletons interface { // Return Singleton by name. // // Returns nil if not found. Singleton(QName) ISingleton // Enumerates all application singletons // // Singletons are enumerated in alphabetical order by QName Singletons(func(ISingleton)) }
type IWithStructures ¶
type IWithStructures interface { // Return structure by name. // // Returns nil if not found. Structure(QName) IStructure // Enumerates all application structures // // Structures are enumerated in alphabetical order by QName Structures(func(IStructure)) }
type IWithTypes ¶
type IWithTypes interface { // Returns type by name. // // If not found then empty type with TypeKind_null is returned Type(name QName) IType // Returns type by name. // // Returns nil if type not found. TypeByName(name QName) IType // Enumerates all internal types. // // Types are enumerated in alphabetical order of QNames. Types(func(IType)) }
Interface describes the entity with types.
type IWithViews ¶
type IWithWDocs ¶
type IWithWDocs interface { // Return WDoc by name. // // Returns nil if not found. WDoc(QName) IWDoc // Enumerates all application workflow documents // // Workflow documents are enumerated in alphabetical order by QName WDocs(func(IWDoc)) // Return WRecord by name. // // Returns nil if not found. WRecord(QName) IWRecord // Enumerates all application workflow records // // Workflow records are enumerated in alphabetical order by QName WRecords(func(IWRecord)) }
type IWithWorkspaces ¶
type IWithWorkspaces interface { // Returns workspace by name. // // Returns nil if not found. Workspace(QName) IWorkspace // Returns workspace by descriptor. // // Returns nil if not found. WorkspaceByDescriptor(QName) IWorkspace // Enumerates all application workspaces. // // Workspaces are enumerated in alphabetical order by QName Workspaces(func(IWorkspace)) }
type IWorkspace ¶
type IWorkspace interface { IType IWithAbstract IWithTypes // Workspace descriptor document. // See [#466](https://github.com/voedger/voedger/issues/466) // // Descriptor is CDoc document. // If the Descriptor is an abstract document, the workspace must also be abstract. Descriptor() QName }
Workspace is a set of types.
Example ¶
package main import ( "fmt" "github.com/voedger/voedger/pkg/appdef" ) func main() { var app appdef.IAppDef wsName, descName, docName, recName := appdef.NewQName("test", "ws"), appdef.NewQName("test", "desc"), appdef.NewQName("test", "doc"), appdef.NewQName("test", "rec") // how to build AppDef with workspace { adb := appdef.New() adb.AddPackage("test", "test.com/test") adb.AddCDoc(descName). AddField("f1", appdef.DataKind_int64, true). AddField("f2", appdef.DataKind_string, false) adb.AddCRecord(recName). AddField("r1", appdef.DataKind_int64, true). AddField("r2", appdef.DataKind_string, false) cDoc := adb.AddCDoc(docName) cDoc. AddField("d1", appdef.DataKind_int64, true). AddField("d2", appdef.DataKind_string, false) cDoc. AddContainer("rec", recName, 0, 100) adb.AddWorkspace(wsName). SetDescriptor(descName). AddType(recName). AddType(docName) app = adb.MustBuild() } // how to enum workspaces { cnt := 0 app.Workspaces(func(ws appdef.IWorkspace) { cnt++ fmt.Println(cnt, ws) }) fmt.Println("overall:", cnt) } // how to inspect workspace { // how to find workspace by name ws := app.Workspace(wsName) fmt.Printf("workspace %q: %v\n", ws.QName(), ws.Kind()) // how to inspect workspace fmt.Printf("workspace %q descriptor is %q\n", ws.QName(), ws.Descriptor()) cnt := 0 ws.Types(func(t appdef.IType) { fmt.Printf("- Type: %q, kind: %v\n", t.QName(), t.Kind()) cnt++ }) fmt.Println("types count:", cnt) } // how to find workspace by descriptor { ws := app.WorkspaceByDescriptor(descName) fmt.Println() fmt.Printf("founded by descriptor %q: %v\n", descName, ws) } }
Output: 1 Workspace «test.ws» overall: 1 workspace "test.ws": TypeKind_Workspace workspace "test.ws" descriptor is "test.desc" - Type: "test.doc", kind: TypeKind_CDoc - Type: "test.rec", kind: TypeKind_CRecord types count: 2 founded by descriptor "test.desc": Workspace «test.ws»
type IWorkspaceBuilder ¶
type IWorkspaceBuilder interface { ITypeBuilder IWithAbstractBuilder // Adds (includes) type to workspace. Type must be defined for application before. // // # Panics: // - if name is empty // - if name is not defined for application AddType(QName) IWorkspaceBuilder // Sets descriptor. // // # Panics: // - if name is empty // - if name is not defined for application // - if name is not CDoc SetDescriptor(QName) IWorkspaceBuilder // Returns workspace definition while building. // // Can be called before or after all workspace entities added. // Does not validate workspace definition, may be invalid. Workspace() IWorkspace }
type IWorkspacesBuilder ¶
type IWorkspacesBuilder interface { // Adds new workspace. // // # Panics: // - if name is empty (appdef.NullQName), // - if name is invalid, // - if type with name already exists. AddWorkspace(QName) IWorkspaceBuilder }
type Occurs ¶
type Occurs uint16
Numeric with OccursUnbounded value.
Ref. occurs.go for constants and methods
func (Occurs) MarshalJSON ¶
func (*Occurs) UnmarshalJSON ¶
type PrivilegeKind ¶
type PrivilegeKind uint8
Enumeration of privileges.
const ( PrivilegeKind_null PrivilegeKind = iota // # Privilege to insert records or view records. // - Privilege applicable on records, view records or workspaces. // - Then applied to workspaces, it means insert on all tables and views of the workspace. // - Fields are not applicable. PrivilegeKind_Insert // # Privilege to update records or view records. // - Privilege applicable on records, view records or workspaces. // - Then applied to workspaces, it means update on all tables and views of the workspace. // - Fields are applicable and specify fields of records or view records that can be updated. PrivilegeKind_Update // # Privilege to select records or view records. // - Privilege applicable on records, view records or workspaces. // - Then applied to workspaces, it means select on all tables and views of the workspace. // - Fields are applicable and specify fields of records or view records that can be selected. PrivilegeKind_Select // # Privilege to execute functions. // - Privilege applicable on commands, queries or workspaces. // - Then applied to workspaces, it means execute on all queries and commands of the workspace. // - Fields are not applicable. PrivilegeKind_Execute // # Privilege to inherit privileges from other roles. // - Privilege applicable on roles only. // - Fields are not applicable. PrivilegeKind_Inherits PrivilegeKind_count )
func (PrivilegeKind) String ¶
func (i PrivilegeKind) String() string
func (PrivilegeKind) TrimString ¶
func (k PrivilegeKind) TrimString() string
Renders an PrivilegeKind in human-readable form, without "PrivilegeKind_" prefix, suitable for debugging or error messages
type ProjectorEventKind ¶
type ProjectorEventKind uint8
Events enumeration to trigger the projector
const ( ProjectorEventKind_Insert ProjectorEventKind = iota + 1 ProjectorEventKind_Update ProjectorEventKind_Activate ProjectorEventKind_Deactivate ProjectorEventKind_Execute ProjectorEventKind_ExecuteWithParam ProjectorEventKind_Count )
func (ProjectorEventKind) MarshalText ¶
func (i ProjectorEventKind) MarshalText() ([]byte, error)
func (ProjectorEventKind) String ¶
func (i ProjectorEventKind) String() string
func (ProjectorEventKind) TrimString ¶
func (i ProjectorEventKind) TrimString() string
Renders an ProjectorEventKind in human-readable form, without `ProjectorEventKind_` prefix, suitable for debugging or error messages
type QName ¶
type QName struct {
// contains filtered or unexported fields
}
QName ¶
Qualified name ¶
<pkg>.<entity>
var ( // System data type names SysData_int32 QName = SysDataName(DataKind_int32) SysData_int64 QName = SysDataName(DataKind_int64) SysData_float32 QName = SysDataName(DataKind_float32) SysData_float64 QName = SysDataName(DataKind_float64) SysData_bytes QName = SysDataName(DataKind_bytes) SysData_String QName = SysDataName(DataKind_string) SysData_QName QName = SysDataName(DataKind_QName) SysData_bool QName = SysDataName(DataKind_bool) SysData_RecordID QName = SysDataName(DataKind_RecordID) )
func MustParseQName ¶
Parse a qualified name from string.
Panics: ¶
- if string is not a valid qualified name
func ParseQName ¶
Parse a qualified name from string
func SysDataName ¶
Returns name of system data type by data kind.
Returns NullQName if data kind is out of bounds.
func UniqueQName ¶
Constructs and returns QName for the unique for the document.
func (QName) MarshalText ¶
need to marshal map[QName]any
func (*QName) UnmarshalJSON ¶
JSON unmarshaling support
func (*QName) UnmarshalText ¶
need unmarshal map[QName]any golang json looks on UnmarshalText presence only on unmarshal map[QName]any. UnmarshalJSON() will be used anyway but no UnmarshalText -> fail to unmarshal map[QName]any see https://github.com/golang/go/issues/29732
type QNames ¶
type QNames []QName
Slice of QNames.
Slice is sorted and has no duplicates.
Use QNamesFrom() to create QNames slice from variadic arguments. Use Add() to add QNames to slice. Use Contains() and Find() to search for QName in slice.
Example ¶
package main import ( "fmt" "github.com/voedger/voedger/pkg/appdef" ) func main() { product, order, customer := appdef.NewQName("test", "product"), appdef.NewQName("test", "order"), appdef.NewQName("test", "customer") // Create empty QNames qnames := appdef.QNames{} // Add some QNames qnames.Add(product, order, customer, product) // Iterate over QNames for _, qname := range qnames { fmt.Println(qname) } // Check is QNames contains some QName fmt.Println(qnames.Contains(product)) fmt.Println(qnames.Contains(appdef.NewQName("test", "unknown"))) // Find QName by name fmt.Println(qnames.Find(order)) fmt.Println(qnames.Find(appdef.NewQName("test", "data"))) // Print length and content fmt.Println(len(qnames), qnames) }
Output: test.customer test.order test.product true false 1 true 1 false 3 [test.customer test.order test.product]
func QNamesFrom ¶
Returns slice of QNames from variadic arguments.
Result slice is sorted and has no duplicates.
func QNamesFromMap ¶
Returns slice of QNames from map keys.
Result slice is sorted and has no duplicates.
func (QNames) ContainsAll ¶
Returns true if slice contains all specified QNames.
If no names specified then returns true.
func (QNames) ContainsAny ¶
Returns true if slice contains any from specified QName.
If no names specified then returns true.
type RatePeriod ¶
type RateScope ¶
type RateScope uint8
Rate scopes enumeration
func (RateScope) TrimString ¶
Renders an RateScope in human-readable form, without `RateScope_` prefix, suitable for debugging or error messages
type TypeKind ¶
type TypeKind uint8
Types kinds enumeration
const ( TypeKind_null TypeKind = iota // Any type. // // Used as result types kind for functions that has parameter or result of any type. TypeKind_Any // Simple data types, like string, number, date, etc. TypeKind_Data // Глобальный Global configuration, WSID==0 (глобальная номенклатура): UserProfileLocation, SystemConfig TypeKind_GDoc // Конфигурационный документ (per workspace articles, prices, clients) TypeKind_CDoc // Operational documents: bills, orders // https://vocable.ru/termin/operacionnyi-dokument.html // ОПЕРАЦИОННЫЙ ДОКУМЕНТ счет-фактура, чек, заказ, свидетельствующий о совершении сделки. // Might not be edited TypeKind_ODoc // bill // Workflow document, extends ODoc // Might be edited TypeKind_WDoc // Parts of documents, article_price, bill_item TypeKind_GRecord TypeKind_CRecord TypeKind_ORecord TypeKind_WRecord // collection (BO) ((wsid, qname), id), record // logins ((wsid0), login) id TypeKind_ViewRecord // Function params, results, Event.command (this is command function params) TypeKind_Object // Functions TypeKind_Query TypeKind_Command TypeKind_Projector TypeKind_Workspace // Roles and grants TypeKind_Role // Rates and limits TypeKind_Rate TypeKind_Limit TypeKind_count )
func (TypeKind) ContainerKindAvailable ¶
Is specified type kind may be used in child containers.
func (TypeKind) FieldKindAvailable ¶
Is field with data kind allowed.
func (TypeKind) HasSystemField ¶
Is specified system field exists and required.
func (TypeKind) MarshalText ¶
func (TypeKind) TrimString ¶
Renders an TypeKind in human-readable form, without `TypeKind_` prefix, suitable for debugging or error messages
type VerificationKind ¶
type VerificationKind uint8
Field Verification kind
const ( VerificationKind_EMail VerificationKind = iota VerificationKind_Phone VerificationKind_FakeLast )
func (VerificationKind) MarshalJSON ¶
func (k VerificationKind) MarshalJSON() ([]byte, error)
func (VerificationKind) String ¶
func (i VerificationKind) String() string
func (VerificationKind) TrimString ¶
func (k VerificationKind) TrimString() string
Renders an VerificationKind in human-readable form, without "VerificationKind_" prefix, suitable for debugging or error messages
func (*VerificationKind) UnmarshalJSON ¶
func (k *VerificationKind) UnmarshalJSON(data []byte) (err error)
Source Files
¶
- consts.go
- consts_null.go
- errors.go
- impl_abstract.go
- impl_appdef.go
- impl_cdoc.go
- impl_command.go
- impl_comment.go
- impl_container.go
- impl_data.go
- impl_extension.go
- impl_field.go
- impl_function.go
- impl_gdoc.go
- impl_object.go
- impl_odoc.go
- impl_packages.go
- impl_privilege.go
- impl_projector.go
- impl_query.go
- impl_ratelimit.go
- impl_role.go
- impl_singleton.go
- impl_storage.go
- impl_structure.go
- impl_type.go
- impl_unique.go
- impl_view.go
- impl_wdoc.go
- impl_workspace.go
- interface.go
- interface_abstract.go
- interface_cdoc.go
- interface_command.go
- interface_comment.go
- interface_container.go
- interface_data.go
- interface_extension.go
- interface_field.go
- interface_function.go
- interface_gdoc.go
- interface_object.go
- interface_odoc.go
- interface_packages.go
- interface_privilege.go
- interface_projector.go
- interface_query.go
- interface_ratelimit.go
- interface_role.go
- interface_singleton.go
- interface_storage.go
- interface_structure.go
- interface_type.go
- interface_unique.go
- interface_view.go
- interface_wdoc.go
- interface_workspace.go
- provide.go
- stringer_constraintkind.go
- stringer_datakind.go
- stringer_extensionenginekind.go
- stringer_privilegekind.go
- stringer_projectoreventkind.go
- stringer_ratescope.go
- stringer_typekind.go
- stringer_verificationkind.go
- utils.go
- utils_data.go
- utils_privilege.go
- utils_projector.go
- utils_qname.go
- utils_ratelimit.go
- utils_types.go
- utils_unique.go