appdef

package
v1.202405300917.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 12 Imported by: 0

README

Application Definition

codecov

Types

Types inheritance
classDiagram
    class IAppDef {
        <<interface>>
        +Type(QName) IType
        +Data(QName) IData
        +GDoc(QName) IGDoc
        +CDoc(QName) ICDoc
        +WDoc(QName) IWDoc
        +ODoc(QName) IODoc
        +View(QName) IView
        +Command(QName) ICommand
        +Query(QName) IQuery
        +Role(QName) IRole
        +Projector(QName) IProjector
        +Workspace(QName) IWorkspace
    }
    IAppDef "1" *--> "0..*" IType : compose

    class IType {
        <<interface>>
        +QName() QName
        +Kind()* TypeKind
        +Comment() []string
    }

    IData --|> IType : inherits
    class IData {
        <<interface>>
        +Kind()* TypeKind_Data
        +Ancestor() IData
        +Constraints() []IConstraint
    }

    IArray --|> IType : inherits
    class IArray {
        <<interface>>
        +Kind()* TypeKind_Array
        +MaxLen() uint
        +Elem() IType
    }

    IType <|-- IStructure : inherits
    class IStructure {
        <<interface>>
        +Abstract() bool
        +Fields() []IField
        +Containers() []IContainer
        +Uniques() []IUnique
        +SystemField_QName() IField
    }

    IStructure <|-- IRecord  : inherits
    class IRecord {
        <<interface>>
        +SystemField_ID() IField
        +SystemField_IsActive() IField
    }

    IDoc --|> IRecord : inherits
    class IDoc {
        <<interface>>
    }

    ISingleton --|> IDoc : inherits
    class ISingleton {
        <<interface>>
        +Singleton() bool
    }

    IGDoc --|> IDoc : inherits
    class IGDoc {
        <<interface>>
        +Kind()* TypeKind_GDoc
    }

    ICDoc --|> ISingleton : inherits
    class ICDoc {
        <<interface>>
        +Kind()* TypeKind_CDoc
    }

    IWDoc --|> ISingleton : inherits
    class IWDoc {
        <<interface>>
        +Kind()* TypeKind_WDoc
    }
                    
    IODoc --|> IDoc: inherits
    class IODoc {
        <<interface>>
        +Kind()* TypeKind_ODoc
    }

    IRecord <|-- IContainedRecord  : inherits
    class IContainedRecord {
        <<interface>>
        +SystemField_ParentID() IField
        +SystemField_Container() IField
    }

    IContainedRecord <|-- IGRecord : inherits
    class IGRecord {
        <<interface>>
        +Kind()* TypeKind_GRecord
    }

    IContainedRecord <|-- ICRecord : inherits
    class ICRecord {
        <<interface>>
        +Kind()* TypeKind_CRecord
    }

    IContainedRecord <|-- IWRecord : inherits
    class IWRecord {
        <<interface>>
        +Kind()* TypeKind_WRecord
    }

    IContainedRecord <|-- IORecord : inherits
    class IORecord {
        <<interface>>
        +Kind()* TypeKind_ORecord
    }

    IObject --|> IStructure : inherits
    class IObject {
        <<interface>>
        +Kind()* TypeKind_Object
    }

    IType <|-- IView : inherits
    class IView {
        <<interface>>
        +Kind()* TypeKind_ViewRecord
        +Key() IViewKey
        +Value() IViewValue
    }
            
    IType <|-- IExtension : inherits
    class IExtension {
        <<interface>>
        +Name() string
        +Engine() ExtensionEngineKind
    }

    IExtension <|-- IFunction : inherits
    class IFunction {
        <<interface>>
        +Param() IType
        +Result() IType
    }

    IFunction <|-- ICommand : inherits
    class ICommand {
        <<interface>>
        +Kind()* TypeKind_Command
        +UnloggedParam() IType
    }

    IFunction <|-- IQuery : inherits
    class IQuery {
        <<interface>>
        +Kind()* TypeKind_Query
    }

    IExtension <|-- IProjector : inherits
    class IProjector {
        <<interface>>
        +Kind()* TypeKind_Projector
        +Extension() IExtension
        +WantErrors() bool
        +Events() IProjectorEvents
        +CronSchedule() string
        +States() IStorages
        +Intents() IStorages
    }

    IWorkspace --|> IType : inherits
    class IWorkspace {
        <<interface>>
        +Kind()* TypeKind_Workspace
        +Abstract() bool
        +Descriptor() QName
        +Types() []IType
    }

    IRole --|> IType : inherits
    class IRole {
        <<interface>>
        +Kind()* TypeKind_Role
        +Privileges() []IPrivilege
    }
Data types
classDiagram
    direction BT

  class IAppDef {
    <<Interface>>
    +DataTypes(inclSys bool) []IData
    +SysData(DataKind) IData
  }

  IData "0..*" <--o "1" IAppDef : DataTypes
  IData "1..DataKind_count" <--o "1" IAppDef : SysData

    class IType {
        <<interface>>
        +Name() QName
        +Kind() TypeKind
    }

    IData --|> IType : inherits
    class IData {
        <<interface>>
        +Name()* QName
        +Kind()* TypeKind_Data
        +DataKind() DataKind
        +Ancestor() IData
        +Constraints() []IConstraint
    }

    Name "1" <--* "1" IData : Name
    class Name {
        <<QName>>
    }
    note for Name "- for built-in types sys.int32, sys.float64, etc.,
                   - for custom types — user-defined and
                   - NullQName for anonymous types"

    DataKind "1" <--* "1" IData : Kind
    class DataKind {
        <<DataKind>>
    }
    note for DataKind " - null
                        - int32
                        - int64
                        - float32
                        - float64
                        - bytes
                        - string
                        - QName
                        - bool
                        - RecordID
                        - Record
                        - Event"
 
    Ancestor "1" <--* "1" IData : Ancestor
    class Ancestor {
        <<IData>>
    }
    note for Ancestor "  - data type from which the user data type is inherits or 
                         - nil for built-in types"

    IConstraint "0..*" <--*  "1" IData : Constraints
    class IConstraint {
        <<interface>>
        +Kind() ConstraintKind
        +Value() any
    }
    note for IConstraint " - minLen() uint
                           - maxLen() uint
                           - Pattern() RegExp
                           - MinInclusive() float
                           - MinExclusive() float
                           - MaxInclusive() float
                           - MaxExclusive() float
                           - Enum() []enumerable"
Structures

Structured (documents, records, objects) are those structural types that have fields and can contain containers with other structural types.

The inheritance and composing diagrams given below are expanded general diagrams of the types above.

Structures inheritance
classDiagram
    direction BT
%%    namespace _ {
        class IStructure {
            <<interface>>
            +Abstract() bool
            +Fields() []IField
            +Containers() []IContainer
            +Uniques() []IUnique
            +SystemField_QName() IField
        }

        class IRecord {
            <<interface>>
            +SystemField_ID() IField
            +SystemField_IsActive() IField
        }
%%    }

    IRecord --|> IStructure : inherits

    IDoc --|> IRecord : inherits
    class IDoc {
        <<interface>>
    }

    ISingleton --|> IDoc : inherits
    class ISingleton {
        <<interface>>
        +Singleton() bool
    }

    IGDoc --|> IDoc : inherits
    class IGDoc {
        <<interface>>
        +Kind()* TypeKind_GDoc
    }

    ICDoc --|> ISingleton : inherits
    class ICDoc {
        <<interface>>
        +Kind()* TypeKind_CDoc
    }

    IWDoc --|> ISingleton : inherits
    class IWDoc {
        <<interface>>
        +Kind()* TypeKind_WDoc
    }
                    
    IODoc --|> IDoc: inherits
    class IODoc {
        <<interface>>
        +Kind()* TypeKind_ODoc
    }

    IRecord <|-- IContainedRecord  : inherits
    class IContainedRecord {
        <<interface>>
        +SystemField_ParentID() IField
        +SystemField_Container() IField
    }

    IContainedRecord <|-- IGRecord : inherits
    class IGRecord {
        <<interface>>
        +Kind()* TypeKind_GRecord
    }

    IContainedRecord <|-- ICRecord : inherits
    class ICRecord {
        <<interface>>
        +Kind()* TypeKind_CRecord
    }

    IContainedRecord <|-- IWRecord : inherits
    class IWRecord {
        <<interface>>
        +Kind()* TypeKind_WRecord
    }

    IContainedRecord <|-- IORecord : inherits
    class IORecord {
        <<interface>>
        +Kind()* TypeKind_ORecord
    }
Structures composing
classDiagram
  direction TB

  class IAppDef {
    <<Interface>>
    +Structures() []IStructure
    +Records() []IRecord
    +Singletons() []ISingleton
    +GDocs()[]IGDoc
    +GRecords()[]IGRecord
    +CDocs()[]ICDoc
    +CRecords()[]ICRecord
    +WDocs()[]IWDoc
    +WRecords()[]IWRecord
    +ODocs()[]IODoc
    +ORecords()[]IORecord
    +Objects()[]IObject
  }
  IAppDef "1" o--> "0..*" IStructure : Structures
  IAppDef "1" o--> "0..*" IRecord : Records
  IAppDef "1" o--> "0..*" ISingleton : Singletons
  IAppDef "1" o--> "0..*" IGDoc : GDocs
  IAppDef "1" o--> "0..*" IGRecord : GRecords
  IAppDef "1" o--> "0..*" ICDoc : CDocs
  IAppDef "1" o--> "0..*" ICRecord : CRecords
  IAppDef "1" o--> "0..*" IWDoc : WDocs
  IAppDef "1" o--> "0..*" IWRecord : WRecords
  IAppDef "1" o--> "0..*" IODoc : ODocs
  IAppDef "1" o--> "0..*" IORecord : ORecords
  IAppDef "1" o--> "0..*" IObject : Objects

  IGDoc "1" o--> "0..*" IGRecord : children
  IGRecord "1" o--> "0..*" IGRecord : children

  ICDoc "1" o--> "0..*" ICRecord : children
  ICRecord "1" o--> "0..*" ICRecord : children

  IWDoc "1" o--> "0..*" IWRecord : children
  IWRecord "1" o--> "0..*" IWRecord : children

  IODoc "1" o--> "0..*" IORecord : children
  IODoc "1" o--> "0..*" IODoc : children document
  IORecord "1" o--> "0..*" IORecord : children

  IObject "1" o--> "0..*" IObject : children
Fields, Containers, Uniques
classDiagram

  class IField {
    <<Interface>>
    +Name() FieldName
    +DataKind() DataKind
    +Required() bool
    +Verified() bool
    +VerificationKind() []VerificationKind
    +Constraints() []IConstraint
  }

  class IFields{
    <<Interface>>
    Field(FieldName) IField
    FieldCount() int
    Fields() []IField
  }
  IFields "1" --* "0..*" IField : compose

  IFieldsBuilder --|> IFields : inherits
  class IFieldsBuilder {
    <<Interface>>
    AddField(…)
    AddVerifiedField(…)
    AddRefField(…)
    AddStringField(…)
    AddConstraints(IConstraint...)
  }

  IRefField --|> IField : inherits
  class IRefField {
    <<Interface>>
    Refs() []QName
  }

  class IContainer {
    <<Interface>>
    +Name() string
    +Def() IDef
    +MinOccurs() int
    +MaxOccurs() int
  }

  class IContainers{
    <<Interface>>
    Container(string) IContainer
    ContainerCount() int
    ContainerDef() [string]IType
    Containers() []IContainer
  }
  IContainers "1" --* "0..*" IContainer : compose

  IContainersBuilder --|> IContainers : inherits
  class IContainersBuilder {
    <<Interface>>
    AddContainer(…) IContainer
  }

  class IUnique {
    <<Interface>>
    +Name() QName
    +Fields() []IFeld
  }

  class IUniques{
    <<Interface>>
    UniqueByName(QName) IUnique
    UniqueCount() int
    Uniques() []IUnique
  }
  IUniques "1" --* "0..*" IUnique : compose

  IUniquesBuilder --|> IUniques : inherits
  class IUniquesBuilder {
    <<Interface>>
    AddUnique(…) IUnique
  }
Views
classDiagram
  class IType{
    <<Interface>>
    +Kind()* TypeKind
    +QName() QName
  }

  IType <|-- IView : inherits
  class IView {
    <<Interface>>
    +Kind()* TypeKind_View
    IFields
    +Key() IViewKey
    +Value() IViewValue
  }
  IView "1" *--> "1" IViewKey : Key
  IView "1" *--> "1" IViewValue : Value

  class IViewKey {
    <<Interface>>
    IFields
    +PartKey() IViewPartKey
    +ClustCols() IViewClustCols
  }
  IViewKey "1" *--> "1..*" IField : fields
  IViewKey "1" *--> "1" IViewPartKey : PartKey
  IViewKey "1" *--> "1" IViewClustCols : ClustCols

  class IViewPartKey {
    <<Interface>>
    IFields
  }
  IViewPartKey "1" *--> "1..*" IField : fields

  class IViewClustCols {
    <<Interface>>
    IFields
  }
  IViewClustCols "1" *--> "1..*" IField : fields

  class IViewValue {
    <<Interface>>
    IFields
  }
  IViewValue "1" *--> "1..*" IField : fields

  class IField {
    <<interface>>
    …
  }

    class IAppDef {
      …
      +Views() []IView
    }

    IAppDef "1" *--> "0..*" IView : Views
Extensions
    classDiagram
    IType <|-- IExtension : inherits
    class IExtension {
        <<interface>>
        +Name() string
        +Engine() ExtensionEngineKind
        +States() IStorages
        +Intents() IStorages
    }

    IExtension "1" ..> "1" ExtensionEngineKind : Engine
    class ExtensionEngineKind {
        <<enumeration>>
        BuiltIn
        WASM
    }

    IExtension "1" *--> "1" IStorages : States
    IExtension "1" *--> "1" IStorages : Intents
    class IStorages {
        <<interface>>
        +Enum(func(IStorage))
        +Len() int
        +Map() map[QName] []QName
        +Storage(QName) IStorage
    }
    IStorages "1" *--> "0..*" IStorage : Storages
    class IStorage {
        <<interface>>
        +Comment() : []string
        +Name(): QName
        +QNames() []QName
    }

    IExtension <|-- IFunction : inherits
    class IFunction {
        <<interface>>
        +Param() IType
        +Result() IType
    }

    IFunction <|-- ICommand : inherits
    class ICommand {
        <<interface>>
        +Kind()* TypeKind_Command
        +UnloggedParam() IType
    }

    IFunction <|-- IQuery : inherits
    class IQuery {
        <<interface>>
        +Kind()* TypeKind_Query
    }

    IExtension <|-- IProjector : inherits
    class IProjector {
        <<interface>>
        +Kind()* TypeKind_Projector
        +WantErrors() bool
        +Events() IProjectorEvents
        +CronSchedule() string
    }

    IProjector "1" *--> "1" IProjectorEvents : Events
    IProjectorEvents "1" *--> "1..*" IProjectorEvent : Event
    class IProjectorEvents {
        <<interface>>
        +Enum(func(IProjectorEvent))
        +Event(QName) IProjectorEvent
        +Len() int
        +Map() map[QName] []ProjectorEventKind
    }
    class IProjectorEvent {
        <<interface>>
        +Comment() []string
        +On() IType
        +Kind() []ProjectorEventKind
    }

    IProjectorEvent "1" ..> "1..*" ProjectorEventKind : Kind
    class ProjectorEventKind {
        <<enumeration>>
        Insert
        Update
        Activate
        Deactivate
        Execute
        ExecuteWithParam
    }

    class IAppDef {
      …
      +Extensions() []IExtension
      +Functions() []IFunction
      +Commands() []ICommand
      +Queries() []IQuery
      +Projectors() []IProjector
    }

    IAppDef "1" *--> "0..*" IExtension : Extensions
    IAppDef "1" *--> "0..*" IFunction : Functions
    IAppDef "1" *--> "0..*" ICommand : Commands
    IAppDef "1" *--> "0..*" IQuery : Queries
    IAppDef "1" *--> "0..*" IProjector : Projectors

Rem: In the above diagram the Param and Result of the function are IType, in future versions it will be changed to an array of []IParam and renamed to plural (Params, Results).

Workspaces
Roles and privileges
    classDiagram
    IType <|-- IRole : inherits
    class IRole {
        <<interface>>
        +Kind()* TypeKind_Role
        +Privileges() []IPrivilege
    }

    IRole "1" *--> "1..*" IPrivilege : On

    class IPrivilege {
        <<interface>>
        +Comment() []string
        +Kinds() []PrivilegeKind
        +IsGranted() bool
        +IsRevoked() bool
        +On() QNames
        +Fields() []FieldName
    }

    IPrivilege "1" *--> "1..*" PrivilegeKind : Kinds
    
    class PrivilegeKind {
        <<enumeration>>
        Insert
        Update
        Select
        Execute
        Inherits
    }

    IPrivilege "1" *--> "1..*" QName : On
    note for QName "types on which the privilege is granted or revoked"

    class IAppDef {
      …
      +Roles() []IRole
      +Privileges() []IPrivilege
    }

    IAppDef "1" *--> "0..*" IRole : Roles
    IAppDef "1" *--> "0..*" IPrivilege : all application privileges

Restrictions

Names
  • Only letters (from A to Z and from a to z), digits (from 0 to 9) and underscore symbol (_) are used.
  • First symbol must be letter or underscore.
  • Maximum length of name is 255.
  • Names are case sensitive.
  • System level names can contains buck char ($).

Valid names examples:

  Foo
  bar
  FooBar
  foo_bar
  f007
  _f00_bar

Invalid names examples:

  Fo-o
  7bar
Fields
  • Maximum fields per structure is 65536.
  • Maximum string and bytes field length is 65535.
Containers
  • Maximum containers per structure is 65536.
Uniques
  • Maximum fields per unique is 256
  • Maximum uniques per structure is 100.
Singletons
  • Maximum singletons per application is 512.

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

Examples

Constants

View Source
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

View Source
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"
)
View Source
const (
	SystemField_ID        = SystemPackagePrefix + "ID"
	SystemField_ParentID  = SystemPackagePrefix + "ParentID"
	SystemField_IsActive  = SystemPackagePrefix + "IsActive"
	SystemField_Container = SystemPackagePrefix + "Container"
	SystemField_QName     = SystemPackagePrefix + "QName"
)

System field names

View Source
const (
	Occurs_Unbounded    = Occurs(0xffff)
	Occurs_UnboundedStr = "unbounded"
)
View Source
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`.

View Source
const MaxFieldLength = uint16(math.MaxUint16)

Maximum string and bytes data length

View Source
const MaxIdentLen = 255

Maximum identifier length

View Source
const MaxTypeContainerCount = 65536

Maximum containers per one structured type

View Source
const MaxTypeFieldCount = 65536

Maximum fields per one structured type

View Source
const MaxTypeUniqueCount = 100

Maximum uniques

View Source
const MaxTypeUniqueFieldsCount = 256

Maximum fields per one unique

View Source
const NullName = ""

Empty name

Variables

View Source
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)

View Source
var (
	QNameForNull  = NewQName(NullName, NullName)
	NullQName     = QNameForNull
	NullFullQName = NewFullQName(NullName, NullName)
)

Null (empty) QName

View Source
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.

View Source
var AnyType = newAnyType(QNameANY)

AnyType is used for return then type is any

View Source
var DefaultRateScopes = []RateScope{RateScope_AppPartition}
View Source
var ErrAlreadyExistsError = errors.New("already exists")
View Source
var ErrConvertError = errors.New("convert error")
View Source
var ErrIncompatibleError = errors.New("incompatible")
View Source
var ErrInvalidError = errors.New("not valid")
View Source
var ErrMissedError = errors.New("missed")
View Source
var ErrNotFoundError = errors.New("not found")
View Source
var ErrOutOfBoundsError = errors.New("out of bounds")
View Source
var ErrTooManyError = errors.New("too many")
View Source
var ErrUnsupportedError = errors.ErrUnsupported
View Source
var NullAppDef = New().MustBuild()

NullAppDef is IAppDef without any user definitions

View Source
var NullFields = new(nullFields)

NullFields is used for return then IFields is not supported

View Source
var NullType = new(nullType)

NullType is used for return then type is not founded

ProjectorEventKind_AnyChanges describes events for record any change.

QNameANY is substitution denotes that a Function param or result can be any type

See #858 (Support QNameAny as function result)

Functions

func CompareFullQName

func CompareFullQName(a, b FullQName) int

Compare two full qualified names

func CompareQName

func CompareQName(a, b QName) int

Compare two qualified names

func ErrAlreadyExists

func ErrAlreadyExists(msg string, args ...any) error

func ErrConvert

func ErrConvert(msg string, args ...any) error

func ErrFieldNotFound

func ErrFieldNotFound(f string) error

func ErrIncompatible

func ErrIncompatible(msg string, args ...any) error

func ErrInvalid

func ErrInvalid(msg string, args ...any) error

func ErrMissed

func ErrMissed(msg string, args ...any) error

func ErrNotFound

func ErrNotFound(msg string, args ...any) error

func ErrOutOfBounds

func ErrOutOfBounds(msg string, args ...any) error

func ErrRoleNotFound

func ErrRoleNotFound(r QName) error

func ErrTooMany

func ErrTooMany(msg string, args ...any) error

func ErrTypeNotFound

func ErrTypeNotFound(t QName) error

func ErrUnsupported

func ErrUnsupported(msg string, args ...any) error

func IsSysField

func IsSysField(n FieldName) bool

Returns is field system

func ParseFullQualifiedName

func ParseFullQualifiedName(val string) (s1, s2 string, err error)

func ParseQualifiedName

func ParseQualifiedName(val, delimiter string) (part1, part2 string, err error)

Parse a qualified name from string using specified delimiter

func PrivilegeAccessControlString

func PrivilegeAccessControlString(grant bool) string

Returns "grant" if grant is true, otherwise "revoke".

func ValidFieldName

func ValidFieldName(ident FieldName) (bool, error)

Returns is string is valid field name and error if not

func ValidFullQName

func ValidFullQName(fqn FullQName) (bool, error)

Returns has FullQName valid package path and entity identifier and error if not

func ValidIdent

func ValidIdent(ident string) (bool, error)

Returns is string is valid identifier and error if not

func ValidPackagePath

func ValidPackagePath(path string) (bool, error)

TODO: implement Parsing a URI Reference with a Regular Expression [RFC3986, app B](https://datatracker.ietf.org/doc/html/rfc3986#appendix-B)

func ValidQName

func ValidQName(qName QName) (bool, error)

Returns has qName valid package and entity identifiers and error if not

func ValidQNames

func ValidQNames(qName ...QName) (ok bool, err error)

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) IsFixed

func (k DataKind) IsFixed() bool

Returns is fixed width data kind

func (DataKind) MarshalText

func (k DataKind) MarshalText() ([]byte, error)

func (DataKind) String

func (i DataKind) String() string

func (DataKind) TrimString

func (k DataKind) TrimString() string

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 FieldName

type FieldName = string

type FullQName

type FullQName struct {
	// contains filtered or unexported fields
}

FullQName

Full qualified name

<pkgPath>.<entity>

func MustParseFullQName

func MustParseFullQName(val string) FullQName

Parse a full qualified name from string.

Panics:

  • if string is not a valid full qualified name

func NewFullQName

func NewFullQName(pkgPath, entityName string) FullQName

Builds a full qualified name from from package path and entity name

func ParseFullQName

func ParseFullQName(val string) (FullQName, error)

Parse a qualified name from string

func (FullQName) Entity

func (fqn FullQName) Entity() string

Returns entity name

func (FullQName) MarshalJSON

func (fqn FullQName) MarshalJSON() ([]byte, error)

JSON marshaling support

func (FullQName) MarshalText

func (fqn FullQName) MarshalText() (text []byte, err error)

need to marshal map[FullQName]any

func (FullQName) PkgPath

func (fqn FullQName) PkgPath() string

Returns package path

func (FullQName) String

func (fqn FullQName) String() string

Returns FullQName as string

func (*FullQName) UnmarshalJSON

func (fqn *FullQName) UnmarshalJSON(text []byte) error

JSON unmarshaling support

func (*FullQName) UnmarshalText

func (fqn *FullQName) UnmarshalText([]byte) error

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 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
}

func New

func New() IAppDefBuilder

Creates and return new application builder

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.

func Pattern

func Pattern(v string, c ...string) IConstraint

Return new pattern restriction for string or bytes data types.

Panics:

  • if value is not valid regular expression

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 ILimit

type ILimit interface {
	IType
	On() QNames
	Rate() IRate
}

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

type ISingleton interface {
	IDoc

	// Returns whether the document is a singleton
	Singleton() bool
}

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 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.

https://opensource.com/article/20/5/apache-cassandra#:~:text=As%20a%20rule%20of%20thumb%2C,design%20supports%20desired%20cluster%20performance

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 IWithCommands interface {
	// Returns Command by name.
	//
	// Returns nil if not found.
	Command(QName) ICommand

	// Enumerates all commands
	//
	// Commands are enumerated in alphabetical order by QName
	Commands(func(ICommand))
}

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 IWithFunctions interface {
	// Return function by name.
	//
	// Returns nil if not found.
	Function(QName) IFunction

	// Enumerates all application functions (commands & queries)
	//
	// Functions are enumerated in alphabetical order by QName
	Functions(func(IFunction))
}

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 IWithLimits interface {
	// Returns Limit by name.
	//
	// Returns nil if not found.
	Limit(QName) ILimit

	// Enumerates all limits
	//
	// Limits are enumerated in alphabetical order by QName
	Limits(func(ILimit))
}

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 IWithObjects interface {
	// Return Object by name.
	//
	// Returns nil if not found.
	Object(name QName) IObject

	// Enumerates all application objects
	//
	// Objects are enumerated in alphabetical order by QName
	Objects(func(IObject))
}

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 IWithQueries interface {
	// Returns Query by name.
	//
	// Returns nil if not found.
	Query(QName) IQuery

	// Enumerates all queries
	//
	// Queries are enumerated in alphabetical order by QName
	Queries(func(IQuery))
}

type IWithRates

type IWithRates interface {
	// Returns Rate by name.
	//
	// Returns nil if not found.
	Rate(QName) IRate

	// Enumerates all rates
	//
	// Rates are enumerated in alphabetical order by QName
	Rates(func(IRate))
}

type IWithRecords

type IWithRecords interface {
	// Return record by name.
	//
	// Returns nil if not found.
	Record(QName) IRecord

	// Enumerates all application records, e.g. documents and contained records
	//
	// Records are enumerated in alphabetical order by QName
	Records(func(IRecord))
}

type IWithRoles

type IWithRoles interface {
	// Returns Role by name.
	//
	// Returns nil if not found.
	Role(QName) IRole

	// Enumerates all roles
	//
	// Roles are enumerated in alphabetical order by QName
	Roles(func(IRole))
}

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 IWithViews interface {
	// Return View by name.
	//
	// Returns nil if not found.
	View(name QName) IView

	// Enumerates all application views
	//
	// Views are enumerated in alphabetical order by QName
	Views(func(IView))
}

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 (o Occurs) MarshalJSON() ([]byte, error)

func (Occurs) String

func (o Occurs) String() string

func (*Occurs) UnmarshalJSON

func (o *Occurs) UnmarshalJSON(data []byte) (err error)

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

func MustParseQName(val string) QName

Parse a qualified name from string.

Panics:

  • if string is not a valid qualified name

func NewQName

func NewQName(pkgName, entityName string) QName

Builds a qualified name from two parts (from package name and from entity name)

func ParseQName

func ParseQName(val string) (res QName, err error)

Parse a qualified name from string

func SysDataName

func SysDataName(k DataKind) QName

Returns name of system data type by data kind.

Returns NullQName if data kind is out of bounds.

func UniqueQName

func UniqueQName(docQName QName, uniqueName string) QName

Constructs and returns QName for the unique for the document.

func (QName) Entity

func (qn QName) Entity() string

Returns entity name

func (QName) MarshalJSON

func (qn QName) MarshalJSON() ([]byte, error)

JSON marshaling support

func (QName) MarshalText

func (qn QName) MarshalText() (text []byte, err error)

need to marshal map[QName]any

func (QName) Pkg

func (qn QName) Pkg() string

Returns package name

func (QName) String

func (qn QName) String() string

Returns QName as string

func (*QName) UnmarshalJSON

func (qn *QName) UnmarshalJSON(text []byte) (err error)

JSON unmarshaling support

func (*QName) UnmarshalText

func (qn *QName) UnmarshalText(text []byte) (err error)

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

func QNamesFrom(n ...QName) QNames

Returns slice of QNames from variadic arguments.

Result slice is sorted and has no duplicates.

func QNamesFromMap

func QNamesFromMap[V any, M ~map[QName]V](m M) QNames

Returns slice of QNames from map keys.

Result slice is sorted and has no duplicates.

func (*QNames) Add

func (qns *QNames) Add(n ...QName)

Adds QNames to slice. Duplicate values are ignored. Result slice is sorted.

func (QNames) Contains

func (qns QNames) Contains(n QName) bool

Returns true if slice contains specified QName

func (QNames) ContainsAll

func (qns QNames) ContainsAll(names ...QName) bool

Returns true if slice contains all specified QNames.

If no names specified then returns true.

func (QNames) ContainsAny

func (qns QNames) ContainsAny(names ...QName) bool

Returns true if slice contains any from specified QName.

If no names specified then returns true.

func (QNames) Find

func (qns QNames) Find(n QName) (int, bool)

Returns index of QName in slice and true if found.

type RateCount

type RateCount = uint

type RatePeriod

type RatePeriod = time.Duration

type RateScope

type RateScope uint8

Rate scopes enumeration

const (
	RateScope_null RateScope = iota

	RateScope_AppPartition
	RateScope_Workspace
	RateScope_User
	RateScope_IP

	RateScope_count
)

func (RateScope) String

func (i RateScope) String() string

func (RateScope) TrimString

func (rs RateScope) TrimString() string

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

func (k TypeKind) ContainerKindAvailable(s TypeKind) bool

Is specified type kind may be used in child containers.

func (TypeKind) FieldKindAvailable

func (k TypeKind) FieldKindAvailable(d DataKind) bool

Is field with data kind allowed.

func (TypeKind) HasSystemField

func (k TypeKind) HasSystemField(f FieldName) (exists, required bool)

Is specified system field exists and required.

func (TypeKind) MarshalText

func (k TypeKind) MarshalText() ([]byte, error)

func (TypeKind) String

func (i TypeKind) String() string

func (TypeKind) TrimString

func (k TypeKind) TrimString() string

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)

Jump to

Keyboard shortcuts

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