Updated on 2025-03-21 GMT+08:00

Preset APIs in the Script

The script engine of Huawei Cloud Astro Zero uses the TypeScript language. During script execution, the TypeScript language is translated into the JavaScript language and executed by the JavaScript engine.

In addition to the official standard libraries of JavaScript ES5, Huawei Cloud Astro Zero provides more than 10 preset standard libraries (that is, preset APIs) to help you develop scripts more efficiently. Table 1 describes the standard libraries.

The following is an example of using a library:

import * as http from 'http';
Table 1 Standard library description

Standard Library Name

Description

sys

Provides system-level operations, such as obtaining system parameter values and providing the alarm script library to set tracing points in scripts to report alarms.

context

Provides script execution context, for example, obtains the current tenant ID or current login user ID.

action

Defines the input and output methods of the script and the method of invoking the script.

buffer

Operates the binary buffer, for example, converts the content of the buffer to a string.

setup

Adds, deletes, modifies, and queries standard objects.

db

Adds, deletes, modifies, and queries the custom objects.

sql

Executes SQL statements. Currently, only "select" statements can be executed.

bo

Adds, deletes, modifies, and queries business objects.

meta

Operates object metadata, for example, obtains the field name or length.

http

HTTP or HTTPS operation.

iconv

Converts a string into the GBK, GB18030, GB2132, or ISO8859_1 encoding format, or decodes a string.

crypto

Performs encryption operation, including the encapsulation of hash, HMAC, encryption, decryption, signature, and verification.

decimal

Converts the value of the number type queried from the HTTP request or database to a decimal value and perform mathematical operations such as addition, subtraction, multiplication, and division.

excel

Operates an Excel file, for example, generates an Excel file.

text

Operates text, for example, converts text to binary.

xml

Operates XML files, for example, reading XML files.

uuid

Generates a globally unique ID.