Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

alarm

  • alarm(alarmCode: string, attachment: string, filename: string, line: number): void
  • 脚本主动告警。

    请使用 sys.alarm('命名空间__9位告警码',...) 的形式调用,否则将影响编译打包

    since

    AppCube 1.3.10

    example
    import * as sys from 'sys'
    sys.alarm('NS_123456789', '备注信息', filename(), line()) // filename()、line()为内置方法
    

    Parameters

    • alarmCode: string

      告警码,形如“命名空间 + __ + 9位告警码”

    • attachment: string

      备注信息

    • filename: string

      文件名,通过filename()方法获取

    • line: number

      行号,通过line()方法获取

    Returns void

formatError

  • formatError(name: string, ...args: any[]): string
  • Format i18n error

    Parameters

    • name: string

      the error no

    • Rest ...args: any[]

      the error format's placeholder parameters

    Returns string

getCustomResource

  • getCustomResource(labelId: string, language: string): string
  • 获取自定义多语言资源。

    Parameters

    • labelId: string

      标签id

    • language: string

      语言

    Returns string

getCustomTranslation

  • getCustomTranslation(picklistId: string, elementId: string, language: string): string
  • 获取多语言资源翻译内容

    Parameters

    • picklistId: string

      picklist id

    • elementId: string

      emement id

    • language: string

      语言类型

    Returns string

getFieldPicklistID

  • getFieldPicklistID(objectName: string, fieldName: string): string
  • 获取字段的picklist id

    Parameters

    • objectName: string

      对象名称

    • fieldName: string

      字段名称

    Returns string

getLicense

  • getLicense(): Object[]
  • 获取当前租户的许可证

    在开启安全配置情况下,需要 '管理系统设置' 权限

    example
    
    import  * as sys from 'sys';
    
    let result = sys.getLicense();
    

    Returns Object[]

    license info of current tenant

getNonEncryptionParameter

  • getNonEncryptionParameter(name: string): string | Decimal | boolean
  • 获取系统参数值, 同getTypeParameter的区别在于: 在开启安全配置情况下,需要 '管理系统设置' 权限或者拥有该系统参数的读权限才可以访问。 如果系统参数的值是加密内容,则会抛出异常。

    example
    
    import { getParameterWithoutDecrypt } from 'sys';
    let email = getParameterWithoutDecrypt('ipaddress');
    

    Parameters

    • name: string

      系统参数名称

    Returns string | Decimal | boolean

    系统参数值

getOrganization

  • 获取组织信息,

    在开启安全配置情况下,需要 '管理系统设置' 权限

    example
    
    import  * as sys from 'sys';
    
    let org = sys.getOrganization();
    

    Returns Organization | null

getParameter

  • getParameter(name: string): string
  • 获取系统参数值,以字符串形式返回

    在开启安全配置情况下,需要 '管理系统设置' 权限或者拥有该系统参数的读权限才可以访问。 同时只要有访问权限,不管系统参数是否加密,都是以明文的方式获取。

    example
    
    import { getParameter } from 'sys';
    let email = getParameter('ipaddress');
    

    Parameters

    • name: string

      系统参数名称

    Returns string

    系统参数字符串值

getPickList

  • getPickList(id: string): PickList | null
  • example
    
    import  * as sys from 'sys';
    
    let flag = sys.getPickList(id);
    

    Parameters

    • id: string

      the PickList id

    Returns PickList | null

    PickList info

getTypeParameter

  • getTypeParameter(name: string): string | Decimal | boolean
  • 获取系统参数值,与getParameter方法不同之处是,该函数返回具体的类型变量,类型映射关系如下:

    Text => string Time => string Number => decimal.Decimal Boolean => boolean

    在开启安全配置情况下,需要 '管理系统设置' 权限或者拥有该系统参数的读权限才可以访问。 同时只要有访问权限,不管系统参数是否加密,都是以明文的方式获取。

    example
    
    import { getTypeParameter } from 'sys';
    
    let email = getTypeParameter('ipaddress');
    

    Parameters

    • name: string

      系统参数名称

    Returns string | Decimal | boolean

    系统参数值

getVersion

  • getVersion(): string
  • 获取appcube核心引擎版本号.

    Returns string

invokeFlow

  • 调用服务编排 在启用租户级别安全模式下, 需要有运行服务编排权限才能操作

    example
    
    import * as sys from 'sys';
    
    let result = sys.invokeFlow('sum', {a: 1, b: 2}); // result = {c: 3}
    

    Parameters

    • flowName: string

      flow名称

    • param: Object

      flow调用参数

    • Optional flag: TransactionFlag

      事件标识,不建议使用

    Returns any

    flow输出参数

invokeSimpleBO

  • invokeSimpleBO(boName: string, operationName: string, param: Object, version: string): any
  • 调用BO的操作,与custom api不同,此处的调用是进程内调用,所以需要相应的BO已经安装了

    example
    import * as sys from 'sys';
    
    let result = sys.invokeSimpleBO('calculator', 'sum', {a: 1, b: 2}, '1.0.0'); // result = {c: 3}
    

    Parameters

    • boName: string

      bo名称

    • operationName: string

      bo的操作名

    • param: Object

      bo的操作的输入参数

    • version: string

      bo版本号

    Returns any

    bo操作的输出参数内容

isValidCurrencyCode

  • example
    
    import  * as sys from 'sys';
    
    let flag = sys.isValidCurrencyCode(sys.CurrencyCode.USD);
    

    Parameters

    Returns boolean

    true|false

sendCustomEmail

  • sendCustomEmail(userName: string, password: string, sender: string, template: string, input: Dict, smtpHost?: string): Dict
  • Send a custom email with specified sender and email server

    example
    
    import * as sys from 'sys';
    function testSend() {
       let map = {
           "body":"email content",
           "subject": "email subject",
           "address": "receiver@xxx.com",
           "cc": "cc@xxx.com", //optional
           "bcc": "bcc@xxx.com" //optional
           }
       let password = sys.getParameter('your_sysparam_of_password');
       sys.sendCustomEmail('user', password, 'xx@xx.com', '', map) // send without template
    }
    

    Parameters

    • userName: string

      email user name

    • password: string

      user password(请勿在代码中使用明文密码,推荐通过系统参数加密配置)

    • sender: string

      email sender

    • template: string

      email template name

    • input: Dict

      the request input parameters.

    • Optional smtpHost: string

      email SMTP server ip:port (optional)

    Returns Dict

sendDelayEvent

  • sendDelayEvent(topic: string, eventName: string, input: Dict, routeKey?: string): void
  • 延时发送kafka事件,与sendEvent的立即发生事件消息不同,sendDelayEvent会等到脚本执行完,事务结束后,再发送事件消息给kafka

    Parameters

    • topic: string

      topic决事件发给哪个kafka, 请使用自定义kafka连接器的topic,如果为"", 使用系统内置的kafka.

    • eventName: string

      事件名称

    • input: Dict

      事件的内容

    • Optional routeKey: string

      事件消息的分区路由key, 同一个key,事件消息会发送kakfa的同一个分区

    Returns void

sendEmail

  • sendEmail(template: string, input: Dict): Dict
  • 发送系统邮件

    example
    
    import * as sys from 'sys';
    
    function testSend() {
       let map = {
           "body":"email content",
           "subject": "email subject",
           "address": "receiver@xxx.com",
           "cc": "cc@xxx.com", //optional
           "bcc": "bcc@xxx.com" //optional
           }
       sys.sendEmail('template-name', map) // send with template
    }
    

    Parameters

    • template: string

      邮箱模板名

    • input: Dict

      邮件发送参数,如cc, bcc, body, subject, address等

    Returns Dict

sendEvent

  • sendEvent(topic: string, eventName: string, input: Dict, routeKey?: string): void
  • 发送kafka事件

    Parameters

    • topic: string

      topic决事件发给哪个kafka, 请使用自定义kafka连接器的topic,如果为"", 使用系统内置的kafka.

    • eventName: string

      事件名称

    • input: Dict

      事件的内容

    • Optional routeKey: string

      事件消息的分区路由key, 同一个key,事件消息会发送kakfa的同一个分区

    Returns void

sendRest

  • sendRest(name: string, input: Dict): Dict
  • 发送rest action

    example
    
    import * as sys from 'sys';
    let res = sys.sendRest("actiontest", {name:'hello, bingo', age: 1});
    

    Parameters

    • name: string

      rest action名称

    • input: Dict

      rest action请求参数

    Returns Dict

sendSyncEmail

  • sendSyncEmail(template: string, input: Dict): Dict
  • Send a system email and wait for response

    example
    
    import * as sys from 'sys';
    function testSend() {
       let map = {
           "body":"email content",
           "subject": "email subject",
           "address": "receiver@xxx.com",
           "cc": "cc@xxx.com", //optional
           "bcc": "bcc@xxx.com" //optional
           }
       sys.sendSyncEmail('template-name', map) // send with template
    }
    

    Parameters

    • template: string

      email template name

    • input: Dict

      the request input parameters.

    Returns Dict

setParameter

  • setParameter(name: string, value: any): void
  • 设置系统参数值.

    Parameters

    • name: string

      系统参数名字.

    • value: any

      系统参数值.

    Returns void

verifyExecuteAPIProfile

  • verifyExecuteAPIProfile(): boolean
  • example
    
    import  * as sys from 'sys';
    
    let flg = sys.verifyExecuteAPIProfile();
    if (flg){ // 如果为真,表示用户有请求自定义接口的业务权限,默认传上下文的method和URL,如 POST /service/.../test
        ...
    }
    

    Returns boolean

    Boolean