$k

The i-views namespace

Classes

AbstractEditorConfiguration
AbstractNetClient
AbstractTextDocument
AccessParameterAssignment
Action
ActionResponse
ActionResult
ActionView
AlternativeGroupCondition
ApplicationConfiguration
Attribute
AttributeType
AttributeValueCondition
Blob
Cause
Choice
ChoiceRange
CollectionView
Color
Cookie
Copier
Crypto
DataConnection
Date
DateTime
Decision
Domain
DOMDocument
ElasticsearchParameter
ElasticsearchQuery
ElasticsearchTerm
ElementsCondition
EncryptedAccount
ExternalCommandJob
ExternalDataObject
ExternalDataRow
ExternalDataSourceValues
ExternalDataXMLNode
FlexDateTime
Folder
FolderElement
FormEntryView
FormSelectView
FormTypeAheadView
GeoPosition
GeoRange
GraphConfiguration
HasAttributeCondition
Hash
HasPropertyCondition
HasRelationCondition
HistoryChangeLogEntry
Hit
HitCollection
HttpConnection
HttpRequest
HttpResponse
ImageWrapper
Index
IndexFilter
InfluxClient
Instance
InstanceType
Interval
IntervalRange
Job
JSONRenderContext
JWT
KScript
KScriptDocument
LinkedQueryCondition
MailMessage
Mapping
MappingContext
Measurement
MQTTClient
Mustache
NetEntity
NewCookie
NodeCategoryElements
NullDocument
Operator
PanelConfiguration
PanelView
PersistentCollection
PipelineParameter
Property
PropertyFilter
PropertySourceCondition
PropertyType
PropertyView
QuantityKind
Query
Query
Query
QueryCondition
QueryParameter
QueryParameterValue
QueryReference
QueryResult
RDFExporter
RDFImporter
RegistryElement
Relation
RelationTargetCondition
RelationTargets
RelationType
RuleSet
Script
ScriptJob
SemanticCollection
SemanticElement
SemanticElementCollection
Session
SharePointAppClient
SharePointClient
SmtpConnection
StructuredQuery
TableConfiguration
Tag
TaggingConfiguration
TaggingContext
TagTypeConfiguration
TextDocument
Time
Type
TypeAheadProposal
UI
Unit
User
User
User
ValueRange
ValueString
VCMOptions
View
ViewConfiguration
XMLWriter
Zip
ZipContainer
ZipDirectory
ZipReader
ZMQContext

Namespaces

AccessRights
Arrays
console
exception
History
Registry

Members

(static) LOG_DEBUG

Log level [DEBUG]

(static) LOG_ERROR

Log level [ERROR]

(static) LOG_NORMAL

Normal log level

(static) LOG_WARNING

Log level [WARNING]

(static) mapInstancesSymbol

Symbol for a class property that returns the mapped internal name. Objects of the type with this internal name will be mapped to the class. Equivalent to the expression $k.mapInstances(mappedInternalName, mappedClass)

The expression Symbol.for('$k.mapInstances') returns the same symbol

(static) mapSubtypesSymbol

Symbol for a class property that returns the mapped internal name. Subtypes of the type with this internal name will be mapped to the class. Equivalent to the expression $k.mapTypes(mappedInternalName, mappedClass)

The expression Symbol.for('$k.mapSubtypes') returns the same symbol

(static) out :$k.AbstractTextDocument

Returns the document that represents the output stream of some script environments. The kind of object depends on the environment, but is usually an instance of $k.TextDocument.

Example
$k.out.print("Name: ", this.name());

Methods

(static) abortTransaction()

Aborts the current transaction. All changes will be rolled back. Has no effect if not transaction is active. No error is thrown.

If the transaction function was called with a reject function, then this function is called before rolling back the transaction.

Since
  • 5.1.1

(static) checkAccessRight(context) → {Boolean}

Check access right

Parameters:
NameTypeDescription
contextobject

List of possible operation types and relevant keys of the context object:

createAttributeattributeType, element
createCompleteRelationrelationType, sourceElement, targetElement
createConceptsuperType
createInstancetype
createRelationrelationType, sourceElement, targetElement
deleteAttributeattribute, element
deleteConceptelement
deleteExtensionelement, object
deleteFolderfolder
deleteInstanceelement
deleteRelationrelation, element
modifyAttributeValueattribute
modifyFolderfolder
modifySchemaelement
readAttributeattribute, element
readConcepttype
readExtensionelement
readInstanceobject
readObjectsOfTypetype
validateAttributeValueattributeValue, language, attribute, element
Deprecated
  • Use $k.AccessRights.checkOperation()
Throws:
Returns:

The decision as boolean

Type: 
Boolean

(static) define(idopt, dependencies, factory)

Defines a module

Parameters:
NameTypeAttributesDescription
idstring<optional>

Optional module ID

dependenciesArray.<string>

IDs of required modules

factory

Factory that returns the value of the module

(static) elevatedDo(f)

Evaluates the function in an evelated context that does not check any access right. This function is only allowed in scripts that are controlled by administrators, otherwise an error is thrown.

Elevating the context does not grant administration rights, e.g. new users cannot be created by non-admin users.

Parameters:
NameTypeDescription
ffunction

Function that should be evaluated in a system context

Since
  • 4.1.0
Throws:

If an elevated context cannot be activated, e.g. in a script created by a user without administration rights

Type
$k.exception.AccessDenied
Returns:

The return value of the function

(static) filterWithAccessRights(operationType, elements, contextopt, decisionopt) → {Array.<$k.SemanticElement>}

Filter semantic elements in array with access rights

Parameters:
NameTypeAttributesDescription
operationTypestring

List of possible operation types and relevant keys of the context object:

createAttributeattributeType, element
createCompleteRelationrelationType, sourceElement, targetElement
createConceptsuperType
createInstancetype
createRelationrelationType, sourceElement, targetElement
deleteAttributeattribute, element
deleteConceptelement
deleteExtensionelement, object
deleteFolderfolder
deleteInstanceelement
deleteRelationrelation, element
modifyAttributeValueattribute
modifyFolderfolder
modifySchemaelement
readAttributeattribute, element
readConcepttype
readExtensionelement
readInstanceobject
readObjectsOfTypetype
validateAttributeValueattributeValue, language, attribute, element
elementsArray.<$k.SemanticElement>
contextobject<optional>

Object containing additional access context.

  • user: specifiy a user ($k.User) instead of the current user
decisionobject<optional>

Default is true

Deprecated
  • Use $k.AccessRights.filterElements()
Throws:
Returns:

Returns the filtered semantic elements

Type: 
Array.<$k.SemanticElement>

(static) getAccessRightDecision(context) → {$k.Decision}

Get access right decision

Parameters:
NameTypeDescription
contextobject

List of possible operation types: createAttribute { attributeType, element }, createCompleteRelation { relationType, sourceElement, targetElement }, createConcept { superType }, createInstance { type }, createRelation { relationType, sourceElement, targetElement }, delete { element }, deleteAttribute { attribute, element }, deleteConcept { element }, deleteExtension { element, object }, deleteInstance { element }, deleteRelation { relation, element }, modify { element }, modifyAttributeValue { attribute, element }, modifySchema { element }, read { element }, readAttribute { attribute, element }, readConcept { type }, readExtension { element }, readInstance { object }, readObjectsOfType { type }, validateAttributeValue { attributeValue, language, attribute, element }, optional can additionally set the user, e.g. $k.checkAccessRight("read", { "user" :, "element" :})

Since
  • 5.3.2
Deprecated
  • Use $k.AccessRights.getDecision()
Throws:
Returns:

The decision

Type: 
$k.Decision

(static) getClientContext(key)

Returns an object from the application client context. The application client context can be used to cache / transfer values across scripts. Use getTransactionContext(key) if possible. WARNING: do not use this function in REST scripts, "application client" refers to the entire bridge, thus the client context is shared by all users. The client context is resetted if

  • the client reconnects
  • client caches are flushed
Parameters:
NameTypeDescription
keystring

Key of the object

Since
  • 4.1.1
Returns:

The object with the given key

(static) getEnvironment(key) → {string}

Returns a value from the application environment. The application environment must be configured in the configuration file or by setting appropriate host environment variables

Example: Define a value with the key 'HOST'

[environment]
HOST=$(env:COMPUTERNAME)

IV_ENV_HOST=%COMPUTERNAME%

The value can then be accessed with $k.getEnvironment('HOST')

Parameters:
NameTypeDescription
keystring

Key of the value

Since
  • 5.4.0
Returns:

The environment value, or undefined if the key has not been configured.

Type: 
string

(static) getTransactionContext(key)

Returns an object from the transaction context. The client context can be used to cache / transfer values across scripts within the transaction.

Parameters:
NameTypeDescription
keystring

Key of the object

Since
  • 4.1.1
Throws:

If no transaction is active

Type
$k.exception.TransactionError
Returns:

The object with the given key

(static) isDebugEnabled() → {boolean}

Returns true if running in a debugger

Version
  • Experimental feature, might be removed at any time
Since
  • 5.1.1
Returns:
Type: 
boolean

(static) kscript(scriptName)

Return a wrappper for the specified KScript

Parameters:
NameTypeDescription
scriptNamestring

The registered name of the KScript

Version
  • Experimental feature, might be removed at any time
Since
  • 5.2.2
Throws:

If the script was not found or is not a KScript

Type
$k.exception.ModuleError

(static) language() → {string}

Returns the current language (ISO 639 2b)

Since
  • 4.1.1
Returns:

Current language, eg. "eng"

Type: 
string

(static) languageDo(language, f)

Evaluates the function with the given language as current language

Parameters:
NameTypeDescription
languagestring

Language to activate. Either ISO 639-1 (2-letter code, e.g. "en") or ISO 639-2B (3-letter code, e.g. "eng")

ffunction

Function that should be evaluated

Since
  • 4.1.1
Throws:

If an invalid language was specified

Type
$k.exception.InvalidLanguage
Returns:

The return value of the function

(static) locale() → {string}

Returns the current locale

Since
  • 4.1.1
Returns:

Current locale, eg. "en_US"

Type: 
string

(static) localeDo(locale, f)

Evaluates the function with the given locale as current locale

Parameters:
NameTypeDescription
localestring

Locale, e.g. "en_GB"

ffunction

Function that should be evaluated

Since
  • 4.1.1
Throws:

If an invalid locale was specified

Type
$k.exception.InvalidLanguage
Returns:

The return value of the function

(static) log(object, levelopt, channelopt)

Log an object on the current log stream (if available)

Parameters:
NameTypeAttributesDescription
object

Object to log. Will be converted with toString().

level<optional>

Log level. Either a number or a string ("debug", "normal", "warning", "error").

channelstring<optional>

Optional log channel.

Examples
$k.log("New instance created");
$k.log("The cake is a lie", $k.LOG_WARNING, "Portal");

(static) logData(data, messageopt, levelopt, channelopt)

Log an object and additional structured data on the current log stream (if available)

Parameters:
NameTypeAttributesDescription
dataobject

Data to log

message<optional>

Additional message. Will be converted with toString().

level<optional>

Log level. Either a number or a string ("debug", "normal", "warning", "error").

channelstring<optional>

Optional log channel.

Examples
$k.logData({"size":42}, "New instance created");
$k.logData({"companionCube":"dead"}, "The cake is a lie",  $k.LOG_WARNING, "Portal");

(static) mapInstances(internalName, proto)

Map the prototype of instances of the type with the internal name to the prototype object

Parameters:
NameTypeDescription
internalNamestring

Internal name of the type of instances to map

proto

Prototype object

Example
function Person() { }
Person.prototype.fullName = function() {
	return this.attributeValue("familyName").toUpperCase() 
		+ ", " + this.attributeValue("firstName");
};
$k.mapInstances("person", Person);
var persons =  $k.Registry.type("person").instances();
for (var p =0; persons.length>p; p++)
	$k.out.print(persons[p].fullName() + "\n");

(static) mapModule(moduleName, registryID)

Maps a module ID to the ID of a registered script. Allows to register scripts containing modules under a different ID

Parameters:
NameTypeDescription
moduleNamestring

The ID of the module

registryIDstring

The ID of the registered script

Deprecated
  • This feature is deprecated

(static) mapTypes(internalName, proto)

Map the prototype of types with the internal name to the prototype object

Parameters:
NameTypeDescription
internalNamestring

Internal name of the type to map

proto

Prototype object

(static) module(moduleName, isLocalopt)

Loads a module

Parameters:
NameTypeAttributesDescription
moduleNamestring

The registered name of the module

isLocalboolean<optional>

(Since 4.0.2) True if the module script should be evaluated in a local environment, false if it should be evaluated in the environment of the caller. Default is false"

Throws:

If the module was not found or defined more than once

Type
$k.exception.ModuleError
Returns:

The model exports

(static) noTriggersDo(f)

Evaluates the function without performing any triggers

Parameters:
NameTypeDescription
ffunction

Function that should be evaluated

Since
  • 4.1.0
Returns:

The return value of the function

(static) optimisticTransaction(f)

Evaluates the function in a transaction and returns its return value. Does not check if the transaction has been accepted or rejected. Allows to start a transaction within another transaction, the nested transaction will be a part of the outer transaction

Parameters:
NameTypeDescription
ffunction

Function that should be evaluated in a transaction

Throws:

If a read-only transaction is already active

Type
$k.exception.TransactionError
Returns:

The return value of the function

(static) require(dependencies, callback)

Calls a function with required modules. Passes the value of each required module

Parameters:
NameTypeDescription
dependenciesArray.<string>

IDs of required modules

callbackfunction

Callback function

Throws:

If a required module was not found or defined more than once

Type
$k.exception.ModuleError
Returns:

The return value of the callback function

(static) rootType() → {$k.Type}

Returns the root type of the Knowledge Graph

Deprecated
  • Use $k.Type.rootType()
Returns:
Type: 
$k.Type

(static) setClientContext(key, value)

Sets an object of the application client context. The application client context can be used to cache / transfer values across scripts. Use setTransactionContext(key, value) if possible. WARNING: do not use this function in REST scripts, "application client" refers to the entire bridge, thus the client context is shared by all users. The client context is resetted if

  • the client reconnects
  • client caches are flushed
Parameters:
NameTypeDescription
keystring

Key of the object

valueobject

The object to store

Since
  • 4.1.1

(static) setTransactionContext(key, value)

Sets an object of the transaction context. The client context can be used to cache / transfer values across scripts within the transaction.

Note: Plain objects are serialized, it is not possible to store function objects and other non-serializable properties.

Parameters:
NameTypeDescription
keystring

Key of the object

valueobject

The object to store

Since
  • 4.1.1

(static) shortcutRelationType() → {$k.Type}

Returns the parent type of all shortcut relation types

Deprecated
  • Use $k.Type.shortcutRelationType()
Returns:
Type: 
$k.Type

(static) sleep(delayMillis)

Suspends the current thread for a given number of milliseconds. Note: This blocks the whole execution of the current client.

Parameters:
NameTypeDescription
delayMillisnumber

The number of milliseconds to wait for. The function does not sleep if +-Infinity or NaN is set.

Since
  • 4.3.0

(static) softwareVersion() → {object}

Returns the core software version

Since
  • 4.4.0
Returns:

An object containing information about the core software version{major: 4, minor: 4, patch: 0, state: "Release"}

Type: 
object

(static) symmetricRelationProperties() → {boolean}

Returns true if symmetric relation properties are enabled

Returns:
Type: 
boolean

(static) systemRelationType() → {$k.Type}

Returns the parent type of all system relation types

Deprecated
  • Use $k.Type.systemRelationType()
Returns:
Type: 
$k.Type

(static) timeLimitedDo(timeout, f, timeoutFunctionopt)

Evaluates the function, but stops execution after the specified time and evaluates the (optional) timeout function.

If the evaluated function has started a transaction, then this transaction will be rolled back. Outer transaction will not be rolled back. To avoid incomplete write operations, an exception is raised if a write transaction is active when calling this function.

Parameters:
NameTypeAttributesDescription
timeoutnumber

Timeout in milliseconds

ffunction

Function that should be evaluated

timeoutFunctionfunction<optional>

Function that is evaluated when a timeout occurs.

Since
  • 4.2.0
Throws:

If a write transaction is active

Type
$k.exception.TransactionError
Returns:

The return value of the function, or the value of the timeout function when a timeout occurs, or undefined if no timout function is supplied

Example
$k.timeLimitedDo(1000, 
	function() { return $k.Registry.query("longRunningQuery").findElements() }, 
	function() { throw "Query did not finish" }
)

(static) topAttributeType() → {$k.Type}

Returns the parent type of all attribute types

Deprecated
  • Use $k.Type.topAttributeType()
Returns:
Type: 
$k.Type

(static) topRelationType() → {$k.Type}

Returns the parent type of all relation types

Deprecated
  • Use $k.Type.topRelationType()
Returns:
Type: 
$k.Type

(static) topTypes() → {Array.<$k.Type>}

Returns all top types except the top attribute and relation types

Deprecated
  • Use $k.Type.topTypes()
Returns:
Type: 
Array.<$k.Type>

(static) transaction(f, rejectFunctionopt)

Evaluates the function in a transaction and returns its return value if the transaction has been accepted. If the transaction is rejected due to concurrency conflicts, the optional reject function is performed. This function does not allow to start a transaction within an outer transaction, use optimisticTransaction() instead.

Parameters:
NameTypeAttributesDescription
ffunction

Function that should be evaluated in a transaction

rejectFunctionfunction<optional>

Optional function that is evaluated if the transaction is rejected.

Throws:

If another transaction is already active

Type
$k.exception.TransactionError
Returns:

The return value of the function. If the transaction is rejected, the return value of the reject function (if defined) or undefined is returned.

(static) transactionContext()

Deprecated
  • Use getTransactionContext(key) and setTransactionContext(key, value)
Throws:

If no transaction is active

Type
$k.exception.TransactionError
Returns:

The context object

(static) translatedMessage(message, messageParametersopt)

Returns a translated string for the message. Fills in the message parameters if present. Returns undefined if the message is unknown.

Parameters:
NameTypeAttributesDescription
messagestring

The internal message identifier.

messageParametersArray<optional>

Optional message parameters in case of a fill-in-the-blanks message.

Since
  • 5.4.0
Examples
$k.translatedMessage("wouldYouLikeToSaveTheFileMLS");
$k.translatedMessage("delete3MLS",[victim.name()]);

(static) user() → {$k.User}

Returns the current user

Returns:
Type: 
$k.User

(static) userDo(user, f)

Runs the function in an context bound to the user. This function is only allowed in scripts that are controlled by administrators, otherwise an error is thrown.

Access rights checking is enabled in the function, call $k.elevatedDo() to disable checks

Parameters:
NameTypeDescription
user$k.User

User or user instance

ffunction

Function that should be evaluated in the user context

Version
  • Experimental feature, might be removed at any time
Since
  • 5.1.0
Throws:

If a user context cannot be activated, e.g. in a script created by a user without administration rights

Type
$k.exception.AccessDenied
Returns:

The return value of the function

(static) userRelationType() → {$k.Type}

Returns the parent type of user-defined relation type

Returns:
Type: 
$k.Type

(static) uuid() → {string}

Generates a UUID

Returns:
Type: 
string

(static) volume() → {string}

Returns the name of the Knowledge Graph

Returns:
Type: 
string