Skip to main content

App

App (i.e., application), each application in JitNode corresponds to an App object. Developers can directly use the app keyword to call the App object in backend code.

app is a global object that points to the current application's App object, requiring no imports and can be used directly.

Properties

NameTypeDescription
appIdstrApplication ID, e.g.: wanyun.MyApp
appKeystrUnique identifier of the runtime application, composed of appId and version, e.g.: wanyun.MyApp@1.0.0
versionstrApplication version, three-segment dot-separated version number, e.g.: 1.0.0
titlestrApplication title, e.g.: My Application
initboolWhether the application is initialized, e.g.: True
debugboolWhether the application is in debug mode, e.g.: True
updateTimeintApplication update time, millisecond timestamp, e.g.: 1717987200000
envIdstrRuntime environment ID, e.g.: JRE_MWcVmUZjEq
nodeIdstrNode ID, e.g.: JN_c1tqsCN7Q5
envEnvironRuntime environment object that the application belongs to
nodeNodeJit node object
domainstrApplication domain, e.g.: http://127.0.0.1:8080
entrystrApplication access address, e.g.: http://127.0.0.1:8080/whwy/testjitai
endpointstrApplication API endpoint root path, e.g.: http://127.0.0.1:8080/api/whwy/testjitai
jitDictConfiguration manifest after application packaging
initDataDict[str, Any]Application initialization data
envVarsDict[str, Any]Application environment variable list, key is variable name, value is variable value. Example: {'DB_HOST': '127.0.0.1', 'DB_PORT': 3306}
app_hierarchyList[App]Application inheritance chain (including current application itself), accessing this property triggers loading of all applications in the inheritance chain (if not yet loaded)
requirementsList[str]Dependency list from the current application's requirements.txt
reqsSet[str]List of installed dependency libraries, key is dependency library name, value is dependency library version
librariesPathstrPython library installation root directory
libPathListList[str]Library path list
namespacesList[str]Application element namespace list, e.g.: ['models', 'services', 'databases']
globalsDict[str, Any]Dictionary of set global variables, key is variable name, value is variable value
codeAppCodeSource code manager, operates application source code
resourceAppResourceResource manager, operates application resources
Danger

Developers can read the above properties, but should not forcibly modify property values, as it will cause unpredictable errors.

Methods

getElement

Get the specified element object, which will match precisely based on fullName. This is the most commonly used method in daily development.

Parameters:

  • fullName (str): Element fullName, e.g. "models.UserModel"

Return Value:

Element object.

Return Type:

Element

Element Call Syntax Sugar
# Regular element call syntax
msgSvc = app.getElement("services.MsgSvc")
msgSvc.sendMsg("Hello, World!")
# Element call syntax sugar
app.services.OpenMsgSvc.sendMsg("Hello, World!")

findElements

Find elements, supports selector syntax, may return multiple element objects.

Parameters:

  • selector (str): Element selector, supports SELECTOR syntax

Return Value:

List of element objects.

Return Type:

List[Element]

SELECTOR Syntax
Selector TypeSyntaxExampleDescription
Default SelectorfullNamemodels.UserModelExact match element full name
Type Selector.type.models.NormalTypeSelect all elements of specified type
Attribute Selector#attr=value#title=User ModelSupports >, <, !=, =
Parent Selector*fullName*models.UserModelFind all parent elements of specified element
Child SelectorfullName*models.NormalType*Find all child elements of specified element
Filter Selectorselector:filter.models.NormalType:#title=UserFurther filter previous results
Union Selectorselector1,selector2models.UserModel,services.UserServiceMerge results from multiple selectors

getElementDefine

Find element definition information precisely by fullName.

Parameters:

  • fullName (str): Element fullName

Returns:

Element attribute dictionary object.

Return Type:

ElementAttrDict

findElementsDefine

Find element definition information using SELECTOR syntax.

Parameters:

  • selector (str): Element selector, supports SELECTOR syntax

Returns:

List of element attribute dictionaries.

Return Type:

List[ElementAttrDict]

getAllElementsDefine

Get complete application element information, including definition information for all elements. Calling this function will not trigger element loading.

Returns:

Element definition dictionary, where key is element fullName and value is Dict[str, Any].

Return Type:

Dict[str, Dict[str, Any]]

getEnvVarsDefine

Get application environment variable definition information, including those inherited from parent applications.

Returns:

List of environment variable definitions.

Return Type:

List[Dict[str, Any]]

getParentsMetadata

Get parent application metadata information, excluding the current application itself.

Returns:

Parent application metadata, where key is appKey and value is Dict (containing fields: appId, version).

Return Type:

OrderedDict[str, Dict]

newVariable

Create a variable object that complies with JitAi data type specifications.

Parameters:

  • config (Dict[str, Any]): Variable configuration dictionary, must contain dataType field specifying JitAi data type
  • value (Any): Initial value of the variable, type must be compatible with the specified data type

Returns:

Variable object instance that complies with JitAi specifications.

Return Type:

Variable object

Example:

text_var = app.newVariable({'dataType': 'Stext'}, 'Hello, World!')

registerGlobalVar

Register a global variable, which can be accessed through builtins after setting.

Parameters:

  • name (str): Variable name
  • value (Any): Variable value
Note

Developers should use global variables with caution to avoid polluting the global namespace.

JitAI AssistantBeta
Powered by JitAI