@lcap/nasl 3.9.1-beta.13 → 3.9.1-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcap/nasl",
3
3
  "description": "NetEase Application Specific Language",
4
- "version": "3.9.1-beta.13",
4
+ "version": "3.9.1-beta.15",
5
5
  "author": "Forrest <rainforest92@126.com>",
6
6
  "main": "./out",
7
7
  "types": "./out/index.d.ts",
@@ -70,16 +70,16 @@
70
70
  "socket.io-client": "2.4.0",
71
71
  "uuid": "8.3.2",
72
72
  "vue-template-compiler": "2.6.14",
73
- "@lcap/nasl-breakpoint": "3.9.1-beta.13",
74
- "@lcap/nasl-concepts": "3.9.1-beta.13",
75
- "@lcap/nasl-language-server-core": "3.9.1-beta.13",
76
- "@lcap/nasl-log": "3.9.1-beta.13",
77
- "@lcap/nasl-sentry": "3.9.1-beta.13",
78
- "@lcap/nasl-translator": "3.9.1-beta.13",
79
- "@lcap/nasl-types": "3.9.1-beta.13",
80
- "@lcap/nasl-typescript-worker": "3.9.1-beta.13",
81
- "@lcap/nasl-unified-frontend-generator": "3.9.1-beta.13",
82
- "@lcap/nasl-utils": "3.9.1-beta.13"
73
+ "@lcap/nasl-language-server-core": "3.9.1-beta.15",
74
+ "@lcap/nasl-concepts": "3.9.1-beta.15",
75
+ "@lcap/nasl-sentry": "3.9.1-beta.15",
76
+ "@lcap/nasl-breakpoint": "3.9.1-beta.15",
77
+ "@lcap/nasl-log": "3.9.1-beta.15",
78
+ "@lcap/nasl-translator": "3.9.1-beta.15",
79
+ "@lcap/nasl-types": "3.9.1-beta.15",
80
+ "@lcap/nasl-typescript-worker": "3.9.1-beta.15",
81
+ "@lcap/nasl-unified-frontend-generator": "3.9.1-beta.15",
82
+ "@lcap/nasl-utils": "3.9.1-beta.15"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@types/babel__core": "7.20.1",
@@ -91,8 +91,8 @@
91
91
  "rimraf": "3.0.2",
92
92
  "typedoc": "0.25.13",
93
93
  "typescript": "5.4.4",
94
- "@lcap/nasl-test-toolkit": "1.0.0",
95
- "@lcap/nasl-tsconfig": "1.0.1"
94
+ "@lcap/nasl-tsconfig": "1.0.1",
95
+ "@lcap/nasl-test-toolkit": "1.0.0"
96
96
  },
97
97
  "scripts": {
98
98
  "clear": "rimraf ./out",
@@ -1,13 +1,12 @@
1
- /* 基本类型定义 */
1
+ // 基本类型定义
2
2
  type Any = any;
3
3
  type Long = number;
4
- type Integer = number;
5
4
  type Decimal = number;
6
5
  type Boolean = boolean;
7
6
  type String = string;
8
- type List<T> = Array<T>;
9
-
7
+ /* 日期类型 */
10
8
  type Date = globalThis.Date;
9
+ /* 时间类型 */
11
10
  class Time {
12
11
  accept: 'Time';
13
12
  }
@@ -15,25 +14,39 @@ class Time {
15
14
  class DateTime {
16
15
  accept: 'DateTime';
17
16
  }
17
+ type List<T> = Array<T>;
18
+
19
+ /*
20
+ * 循环函数ForEach
21
+ * 这是唯一一个可以在逻辑中使用的循环函数,用于遍历列表中的元素,禁止使用for、while等其他循环语句。
22
+ */
23
+ declare function ForEach<T>(list: List<T>, start: Long, end: Long, fn: (item: T, index: Long) => void): void;
24
+
25
+ // 基本运算函数,用于数学计算
26
+ declare function plus(left: Decimal, right: Decimal): Decimal;
27
+ declare function minus(left: Decimal, right: Decimal): Decimal;
28
+ declare function multiply(left: Decimal, right: Decimal): Decimal;
29
+ declare function divide(left: Decimal, right: Decimal): Decimal;
30
+ declare function remainder(left: Decimal, right: Decimal): Decimal;
18
31
 
19
32
  /**
20
33
  * 数据实体接口
21
- * 作用:创建、更新和删除数据表中的数据
34
+ * 作用:查询、创建、更新和删除数据表中的数据
22
35
  */
23
36
  interface Entity<T> {
24
37
  /* 根据主键ID获取一条数据 */
25
- get(id: Integer): T;
38
+ get(id: Long): T;
26
39
  /**
27
40
  * 将传入的数据实体插入到数据表中
28
41
  * @param entity 数据实体,T类型。不包含id, createTime, updateTime, createdBy, updatedBy字段
29
42
  * @returns 返回插入的数据实体,T类型。已自动生成id, createTime, updateTime, createdBy, updatedBy字段, 可以通过返回值获取插入数据在数据库中的id
30
- * @example const person = nasl.util.NewEntity<app.dataSources.defaultDS.entities.Person>({name: 'test', age: 18}; insertPerson = app.dataSources.defaultDS.entities.PersonEntity.create(person); // 可以根据insertPerson.id获取插入数据在数据库中的id
43
+ * @example const person = nasl.util.NewEntity<Person>({name: 'test', age: 18}; insertPerson = PersonEntity.create(person); // 可以根据insertPerson.id获取插入数据在数据库中的id
31
44
  */
32
45
  create(entity: T): T;
33
46
  /* 根据传入的数据对象更新数据表中的数据 */
34
47
  update(entity: T): T;
35
48
  /* 根据主键ID删除数据表中的数据 */
36
- delete(id: Integer): void;
49
+ delete(id: Long): void;
37
50
  /* 根据传入的数据对象创建或更新数据表中的数据 */
38
51
  createOrUpdate(body: T): T;
39
52
  /* 根据主键ID列表批量删除数据表中的数据 */
@@ -41,14 +54,37 @@ interface Entity<T> {
41
54
  /* 根据传入的数据对象列表批量更新数据表中的数据 */
42
55
  batchUpdate(list: List<T>): List<T>;
43
56
  /* 根据主键ID列表批量删除数据表中的数据 */
44
- batchDelete(list: List<Integer>): void;
57
+ batchDelete(list: List<Long>): void;
45
58
  }
46
-
47
59
  /*
48
60
  * createEntity函数:根据数据表类型创建一个数据实体接口,然后通过该接口调用数据表中的数据。
49
- * @example const LCAPUserEntity = createEntity<app.dataSources.defaultDS.entities.LCAPUser>(); app.dataSources.defaultDS.entities.LCAPUserEntity.delete(id);
61
+ * @example const LCAPUserEntity = createEntity<LCAPUser>(); LCAPUserEntity.delete(id);
50
62
  * 注意:对应接口已经在下面的实体列表中定义好了,不需要重新定义。
51
63
  */
52
64
  declare const createEntity: <T>() => Entity<T>;
53
65
  /* EntityRelation函数:用于定义数据表内的外键关联关系。*/
54
- declare function EntityRelation(property: any): any;
66
+ declare function EntityRelation(property: any): any;
67
+
68
+ /* 系统逻辑: 认证与权限 */
69
+ declare namespace nasl.auth {
70
+ /* 判断当前登录用户是否拥有该资源路径的访问权限 */
71
+ export function hasAuth(authPath: String): Boolean;
72
+ /* 退出当前登录状态,无输出参数 */
73
+ export function logout(): void;
74
+ /* 将输入的字符串使用AES算法进行加密, 输出参数为一个加密后的字符串 */
75
+ export function encryptByAES(rawStr: String): String;
76
+ /* 对加密的字符串使用AES算法进行解密, 输出参数为一个解密后的字符串 */
77
+ export function decryptByAES(encryptedStr: String): String;
78
+ /* 当前登录用户信息 */
79
+ export const userInfo: {
80
+ Status: String;
81
+ UserName: String;
82
+ Email: String;
83
+ UserId: String;
84
+ Phone: String;
85
+ CreateTime: Long;
86
+ UpdateTime: Long;
87
+ LoginCount: Long;
88
+ Source: String;
89
+ };
90
+ }
@@ -0,0 +1,99 @@
1
+ // 基本类型定义
2
+ type Any = any;
3
+ type Long = number;
4
+ type Decimal = number;
5
+ type Boolean = boolean;
6
+ type String = string;
7
+ /* 日期类型 */
8
+ type Date = globalThis.Date;
9
+ /* 时间类型 */
10
+ class Time {
11
+ accept: 'Time';
12
+ }
13
+ /* 日期时间类型 */
14
+ class DateTime {
15
+ accept: 'DateTime';
16
+ }
17
+ type List<T> = Array<T>;
18
+
19
+ /*
20
+ * 循环函数ForEach
21
+ * 这是唯一一个可以在逻辑中使用的循环函数,用于遍历列表中的元素,禁止使用for、while等其他循环语句。
22
+ */
23
+ declare function ForEach<T>(list: List<T>, start: Long, end: Long, fn: (item: T, index: Long) => void): void;
24
+
25
+ /* 基本运算函数,用于数学计算 */
26
+ declare function plus(left: Decimal, right: Decimal): Decimal;
27
+ declare function minus(left: Decimal, right: Decimal): Decimal;
28
+ declare function multiply(left: Decimal, right: Decimal): Decimal;
29
+ declare function divide(left: Decimal, right: Decimal): Decimal;
30
+ declare function remainder(left: Decimal, right: Decimal): Decimal;
31
+
32
+ /* 分页组件函数,用于分页 */
33
+ declare function PAGINATE<T>(list: List<T>, page: Long, size: Long): { list: List<T>, total: Long; };
34
+
35
+ /**
36
+ * 数据库操作函数系列
37
+ * 平台提供两种数据库操作方式:SQL语言和数据实体接口。二者分别适用于不同的场景:
38
+ * 使用SQL语言进行查询操作,使用数据实体接口进行增删改操作。
39
+ */
40
+
41
+ /**
42
+ * SQL数据查询, 只使用该方法进行数据查询
43
+ * @param sql 数据查询需要的 SQL
44
+ * @returns 返回查询结果列表
45
+ *
46
+ * 关于T的类型说明:
47
+ * 1. 如果查询字段均来自一个数据表,T为该数据表的类型
48
+ * 2. 如果查询字段来自多个数据表,那么T为匿名类型,包含所有查询字段, 如:{name: string, age: number}
49
+ * 在调用时,T可以不指定,平台会自动进行推断
50
+ *
51
+ * 优先使用数据库的查询和数据操纵能力,例如 JOIN、SUM、GROUP_BY 等
52
+ * 所有变量格式为:${variable},不能用''包裹,不能用函数处理。
53
+ * @example `SELECT * FROM Student WHERE id = ${id}`
54
+ * @example `SELECT OrderProduct.*, Product.price as price FROM OrderProduct JOIN Product ON OrderProduct.productId = Product.id WHERE orderId = ${id}`
55
+ *
56
+ * 关于返回值类型, 可能是列表或单个值, 根据具体的SQL语句来确定。
57
+ * @example `SELECT SUM(price) FROM Goods` -> T
58
+ * @example `SELECT SUM(price) FROM Goods GROUP BY user` -> List<T>
59
+ * @example `SELECT * FROM Goods` -> List<T>
60
+ */
61
+ declare namespace nasl.oql {
62
+ export function query<T>(sql: string): List<T> | T;
63
+ }
64
+
65
+ /**
66
+ * 数据实体接口
67
+ * 作用:数据库增删改操作
68
+ */
69
+ interface Entity<T> {
70
+ /* 根据主键获取一条数据。注意:该方法仅支持使用主键进行查询, 且只返回一条数据 */
71
+ get(id: Long): T;
72
+ /**
73
+ * 将传入的数据实体插入到数据表中
74
+ * @param entity 数据实体,T类型。不包含id, createTime, updateTime, createdBy, updatedBy字段
75
+ * @returns 返回插入的数据实体,T类型。已自动生成id, createTime, updateTime, createdBy, updatedBy字段, 可以通过返回值获取插入数据在数据库中的id
76
+ * @example const person = nasl.util.NewEntity<Person>({name: 'test', age: 18}; insertPerson = PersonEntity.create(person); // 可以根据insertPerson.id获取插入数据在数据库中的id
77
+ */
78
+ create(entity: T): T;
79
+ /* 根据传入的数据对象更新数据表中的数据 */
80
+ update(entity: T): T;
81
+ /* 根据主键删除数据表中的数据 */
82
+ delete(id: Long): void;
83
+ /* 根据传入的数据对象创建或更新数据表中的数据 */
84
+ createOrUpdate(body: T): T;
85
+ /* 根据主键列表批量删除数据表中的数据 */
86
+ batchCreate(list: List<T>): List<T>;
87
+ /* 根据传入的数据对象列表批量更新数据表中的数据 */
88
+ batchUpdate(list: List<T>): List<T>;
89
+ /* 根据主键列表批量删除数据表中的数据 */
90
+ batchDelete(list: List<Long>): void;
91
+ }
92
+ /*
93
+ * createEntity函数:根据数据表类型创建一个数据实体接口,然后通过该接口调用数据表中的数据。
94
+ * @example const LCAPUserEntity = createEntity<LCAPUser>(); LCAPUserEntity.delete(id);
95
+ * 注意:对应接口已经在下面的实体列表中定义好了,不需要重新定义。
96
+ */
97
+ declare const createEntity: <T>() => Entity<T>;
98
+ /* EntityRelation函数:用于定义数据表内的外键关联关系。*/
99
+ declare function EntityRelation(property: any): any;
@@ -1,5 +1,8 @@
1
+ /* UI组件基础库 */
1
2
  declare namespace nasl.ui {
2
- /* 校验类型 */
3
+ /* 表单检验类型,用于表单校验函数
4
+ * @example let formValidate: ValidateResult = $refs.form2.validate();
5
+ */
3
6
  export interface ValidateResult { valid: Boolean; }
4
7
  /* current: 推导类型 */
5
8
  export class Current<T> {
@@ -57,34 +60,11 @@ declare namespace nasl.ui {
57
60
  getPropValue<K extends ViewComponentOptionGetKeys>(key: K): ViewComponentOptions[K];
58
61
  }
59
62
 
60
- // 在页面上弹出消息
63
+ /* 在页面上弹出消息 */
61
64
  export function showMessage(text: Any): void;
62
65
  /** 跳转到指定页面
63
66
  * @example nasl.ui.destination('pageType.some_view.sub1_view', { param1, param2, ... });
64
67
  * pageType 为 namespace,如 pc 或者 m,必填
65
68
  */
66
69
  export function destination(path: String, args: object): void;
67
- }
68
-
69
- declare namespace nasl.auth {
70
- // 检查当前用户是否有当前资源的权限
71
- export function hasAuth(authPath: String): Boolean;
72
- // 退出当前登录状态
73
- export function logout(): void;
74
- // 对字符串 实现aes加密,返回加密后的字符串
75
- export function encryptByAES(authPath: String): String;
76
- // 对字符串 实现aes解密,返回解密后的字符串
77
- export function decryptByAES(authPath: String): String;
78
- // 获取用户信息
79
- export const userInfo: {
80
- Status: String;
81
- UserName: String;
82
- Email: String;
83
- UserId: String;
84
- Phone: String;
85
- CreateTime: Long;
86
- UpdateTime: Long;
87
- LoginCount: Long;
88
- Source: String;
89
- };
90
- }
70
+ }
@@ -1,30 +1,27 @@
1
- /** 循环函数ForEach
2
- * 这是唯一一个可以在逻辑中使用的循环函数,用于遍历列表中的元素,禁止使用for、forEach等其他循环语句。
3
- */
4
- declare function ForEach<T>(list: List<T>, start: Integer, end: Integer, fn: (item: T, index: Integer) => void): void;
5
-
6
- /* 基本运算函数,用于数学计算 */
7
- declare function plus(left: Decimal, right: Decimal): Decimal;
8
- declare function minus(left: Decimal, right: Decimal): Decimal;
9
- declare function multiply(left: Decimal, right: Decimal): Decimal;
10
- declare function divide(left: Decimal, right: Decimal): Decimal;
11
- declare function remainder(left: Decimal, right: Decimal): Decimal;
12
-
1
+ // 内置函数库
13
2
  declare namespace nasl.util {
14
3
  /* 类型转换与格式化函数 */
4
+ /* 各基础数据类型之间转换 */
15
5
  export function Convert(value: null): <T extends never>() => T;
6
+ /* 返回格式化的数字字符串 */
16
7
  export function FormatNumber(doubleValue: Decimal | Long, digits: Long, showGroups: Boolean): String;
17
- // @example nasl.util.FormatDateTime(dataTime1, 'yyyy-MM-dd HH:mm:ss', 'global')
8
+ /* 返回格式化日期时间字符串 */
9
+ /* @example nasl.util.FormatDateTime(nasl.util.CurrDateTime(), 'yyyy-MM-dd HH:mm:ss', 'global') */
18
10
  export function FormatDateTime(dateTime: DateTime, formatter: String, timeZone: string): String;
11
+ /* 返回格式化日期字符串 */
12
+ /* @example nasl.util.FormatDate(nasl.util.CurrDate(), 'yyyy-MM-dd') */
19
13
  export function FormatDate(date: Date, formatter: String): String;
20
- // @example nasl.util.FromString<Date>(variable1)
14
+ /* 字符串转换成其他类型 */
15
+ /* @example nasl.util.FromString<Date>('2021-01-01') */
21
16
  export function FromString<T extends Decimal | Date | Time | DateTime | Long | Boolean>(value: String): T;
17
+ /* 各类型转换成字符串 */
22
18
  export function ToString(value: Any): String;
23
19
 
24
20
  /* 字符串函数 */
25
21
  export function Length(str1: String): Decimal;
26
22
  export function Length<K, V>(str1: Map<K, V>): Decimal;
27
23
  export function Length<T>(str1: List<T>): Decimal;
24
+ /* 用于查找字符串中指定字段所在位置,常用的场景包括字符串匹配、字符串替换、数据校验等 */
28
25
  export function IndexOf(str: String, search: String, formIndex: Decimal, ignoreCase: Boolean): Decimal;
29
26
  export function Join(list: List<Any>, seperator: String): String;
30
27
  export function LastIndexOf(str: String, search: String, ignoreCase: Boolean): Decimal;
@@ -39,23 +36,38 @@ declare namespace nasl.util {
39
36
  export function CurrDate(): Date;
40
37
  export function CurrDateTime(): DateTime;
41
38
  export function CurrTime(): Time;
42
- // 计算两个日期时间之间的差值,calcType 支持年、季度、月、周、天、时分秒,默认为 'd'
43
- export function DateDiff<T extends Date | Time | DateTime>(dateTime1: T, dateTime2: T, calcType: 'y' | 'q' | 'M' | 'w' | 'd' | 'h' | 'm' | 's', isAbs: Boolean): Decimal;
44
- // 为指定日期时间调整增加(减少)时间
39
+ /**
40
+ * 返回日期比较结果
41
+ * @param date1: 日期1
42
+ * @param date2: 日期2
43
+ * @param calcType: 计算类型。计算两个日期时间之间的差值,支持年数('y')、季度数('q')、月数('m')、周数('w')、天数('d')、小时数('h')、分钟数('m')、秒数('s')。默认为天数。
44
+ * @param isAbs: 是否返回绝对值,默认为 true
45
+ * @returns 根据计算类型返回对应的差值
46
+ */
47
+ export function DateDiff<T extends Date | Time | DateTime>(dateTime1: T, dateTime2: T, calcType: 'y' | 'q' | 'm' | 'w' | 'd' | 'h' | 'm' | 's', isAbs: Boolean): Decimal;
48
+ /* 为指定日期时间调整增加(减少)时间 */
45
49
  export function AlterDateTime<T extends Date | DateTime>(dateTime: T, option: 'Increase' | 'Decrease', amount: Long, unit: 'day' | 'week' | 'month' | 'quarter' | 'year'): T;
46
- /** 按指定维度计算日期的序号。当输入为 DateTime 类型时,会把数据转到提供的时区的当地时间进行计算
50
+ /**
51
+ * 按指定维度计算日期的序号。当输入为 DateTime 类型时,会把数据转到提供的时区的当地时间进行计算
47
52
  * @param dateTime: 日期或日期时间
48
53
  * @param metric: 计算维度,格式为'小日期单位-大日期单位'。日期单位包括:'year'、'quarter'、'month'、'week'、'day'。如设置 'week-year',则返回当前日期是所在年的第几周, 'day-week',则返回当前日期是所在周的第几天。
54
+ * @param timeZone: 时区,也可填写 'global',表示全局配置的时区
55
+ */
56
+ export function GetDateCount<T extends Date | DateTime>(dateTime: T, metric: String, timeZone: String): Time;
57
+ /**
58
+ * 按“星期几”获取指定日期范围内的日子。当输入为 DateTime 类型时,会把数据转到提供的时区的当地时间进行计算。
59
+ * @param startDate: 开始日期/日期时间
60
+ * @param endDate: 结束日期/日期时间
61
+ * @param target: 目标星期几,1-7分别代表周一到周日
62
+ * @param timeZone: 时区,也可填写 'global',表示全局配置的时区
49
63
  */
50
- export function GetDateCount<T extends Date | DateTime>(dateTime: T, metric: 'week-year'): Time;
51
- // 按“星期几”获取指定日期范围内的日子。当输入为 DateTime 类型时,会把数据转到提供的时区的当地时间进行计算。target 取值范围 [1,2,3,4,5,6,7]
52
- export function GetSpecificDaysOfWeek<T extends Date | DateTime>(startDate: T, endDate: T, target: List<Long>): List<T>;
64
+ export function GetSpecificDaysOfWeek<T extends Date | DateTime>(startDate: T, endDate: T, target: List<Long>, timeZone?: String): List<T>;
53
65
 
54
- /* 列表(List)函数 */
55
- export function Add<T, K extends T>(list: List<T>, item: K): void;
56
- export function AddAll<T>(list: List<T>, addList: List<T>): Decimal;
57
- export function Contains<T, K extends T>(list: List<T>, item: K): Boolean;
58
- export function Insert<T, K extends T>(list: List<T>, index: Decimal, item: K): void;
66
+ // 列表(List)函数
67
+ export function ListAdd<T, K extends T>(list: List<T>, item: K): void;
68
+ export function ListAddAll<T>(list: List<T>, addList: List<T>): Decimal;
69
+ export function ListContains<T, K extends T>(list: List<T>, item: K): Boolean;
70
+ export function ListInsert<T, K extends T>(list: List<T>, index: Decimal, item: K): void;
59
71
  export function ListDistinct<T>(list: List<T>): void;
60
72
  export function ListDistinctBy<A>(list: List<A>, by: List<{ items: Array<(elem: A) => any>; }>): List<A>;
61
73
  export function ListFilter<T>(list: List<T>, by: (item: T) => Boolean): List<T>;
@@ -73,10 +85,10 @@ declare namespace nasl.util {
73
85
  export function ListSum<T extends Long | Decimal>(list: List<T>): T;
74
86
  export function ListToMap<T, K extends Boolean | Decimal | Decimal | String, V>(map: List<T>, byKey: (elem: T) => K, byVal: (elem: T) => V): Map<K, V>;
75
87
  export function ListTransform<T0, T>(list: List<T0>, by: (elem: T0) => T): List<T>;
76
- export function Get<T>(list: List<T>, index: Decimal): T;
77
- export function Remove<T, K extends T>(list: List<T>, item: K): void;
78
- export function RemoveAt<T>(list: List<T>, index: Long): T;
79
- export function Set<T, K extends T>(list: List<T>, index: Decimal, item: K): T;
88
+ export function ListGet<T>(list: List<T>, index: Decimal): T;
89
+ export function ListRemove<T, K extends T>(list: List<T>, item: K): void;
90
+ export function ListRemoveAt<T>(list: List<T>, index: Long): T;
91
+ export function ListSet<T, K extends T>(list: List<T>, index: Decimal, item: K): T;
80
92
 
81
93
  /* 映射(Map)函数 */
82
94
  export function MapContains<K, V>(map: Map<K, V>, key: K): Boolean;
@@ -86,56 +98,65 @@ declare namespace nasl.util {
86
98
  export function MapRemove<K, V>(map: Map<K, V>, key: K): void;
87
99
  export function MapValues<K, V>(map: Map<K, V>): List<V>;
88
100
 
89
- /* 枚举函数,项目中可使用的枚举类型均定义在 app.enums 中 */
90
- /** 将指定枚举转换枚举value和text的List集合
91
- * @example nasl.util.EnumToList<app.enums.UserSourceEnum>();
92
- */
101
+ /* 枚举函数。项目中的枚举类型均定义在 app.enums 中 */
102
+ /* 返回枚举value和text的List集合 */
103
+ /* @example nasl.util.EnumToList<app.enums.UserSourceEnum>() */
93
104
  export function EnumToList<T extends Enums>(): List<{ text: String, value: String; }>;
94
- // 返回枚举指定value的标题字符串
105
+ /* 返回枚举指定value的标题字符串 */
95
106
  export function EnumItemToText(value: Enums<Long | String>): String;
96
- // 在指定枚举中找到与参数相同的枚举值并返回
107
+ /* 在指定枚举中找到与参数相同的枚举值并返回 */
97
108
  export function StringToEnumValue<T extends Enums>(value: String): T;
98
109
 
99
110
  /* 数学函数 */
100
- /** 整数/小数 操作
101
- * @param mode: 'HalfUp' | 'TowardsZero' | 'TowardsInfinity' === '四舍五入' | '截断、向零取整,如 -2.6 取整为 -2' | '进位、向正负无穷取整,如 -1.1 取整为 -2'
102
- */
111
+ /**
112
+ * 整数/小数 操作
113
+ * @param mode: 'HalfUp' | 'TowardsZero' | 'TowardsInfinity' === '四舍五入' | '截断、向零取整,如 -2.6 取整为 -2' | '进位、向正负无穷取整,如 -1.1 取整为 -2'
114
+ */
103
115
  export function Round(value: Decimal, mode: 'HalfUp' | 'TowardsZero' | 'TowardsInfinity'): Decimal;
104
- /* 其他函数 */
116
+
117
+ // 其他函数
118
+ /* (修改原数据)清除复杂对象中每个属性的数据(若输入是单个基础类型如 Integer 的值,则不做处理) */
105
119
  export function Clear<T>(struct: T): T;
106
120
  export function Clone<T>(struct: T): T;
107
- // 判断参数是否为有效值,null、空字符串、纯空格、长度为0的集合均不被视为有效值,传入多个参数时,判断是否全部都是有效值 */
121
+ /* 判断参数是否为有效值,null、空字符串、纯空格、长度为0的集合均不被视为有效值,传入多个参数时,判断是否全部都是有效值 */
108
122
  export function HasValue(...args: Any[]): Boolean;
109
- // RandomInt 生成的数字为整数,如果需要指定位数的随机数,需要在数字前按照位数要求补 0
123
+ /* RandomInt 生成的数字为整数,如果需要指定位数的随机数,需要在数字前按照位数要求补 0 */
110
124
  export function RandomInt(start: Long, end: Long): Long;
111
125
 
112
126
  // New 系列函数使用
113
- /** 生成新的列表,T 类型必填
114
- * @example const variable1 = nasl.util.NewList<Boolean | Long>([true, false, 1])
115
- */
127
+ /**
128
+ * 生成新的列表,T 类型必填
129
+ * @example const variable1 = nasl.util.NewList<Boolean | Long>([true, false, 1])
130
+ */
116
131
  export function NewList<T>(args: T[]): List<T>;
117
- /** 生成新的映射,K、T 类型必填
118
- * @example const variable1 = nasl.util.NewMap<String, Long>({'123': 456})
119
- */
132
+ /**
133
+ * 生成新的映射,K、T 类型必填
134
+ * @example const variable1 = nasl.util.NewMap<String, Long>({'123': 456})
135
+ */
120
136
  export function NewMap<K, T>(args: any): Map<K, T>;
121
- /** 生成新的数据实体,T 类型必填
122
- * class Entity1 { id: Long; property1: String; property2: String;}
123
- * @example const variable1 = nasl.util.NewEntity<Entity1>({id: 123, property1: '123', property2: '456'})
124
- */
137
+ /**
138
+ * 生成新的数据实体,T 类型必填
139
+ * class Entity1 { id: Long; property1: String; property2: String;}
140
+ * @example const variable1 = nasl.util.NewEntity<Entity1>({id: 123, property1: '123', property2: '456'})
141
+ */
125
142
  export function NewEntity<T>(arg: T): T;
126
- /** 生成新的结构体,T 类型必填
127
- * class Structure1 { id: Long; property1: String; property2: String;}
128
- * @example const variable1 = nasl.util.NewStructure<Structure1>({id: 123, property1: '123', property2: '456'})
129
- */
143
+ /**
144
+ * 生成新的结构体,T 类型必填
145
+ * class Structure1 { id: Long; property1: String; property2: String;}
146
+ * @example const variable1 = nasl.util.NewStructure<Structure1>({id: 123, property1: '123', property2: '456'})
147
+ */
130
148
  export function NewStructure<T>(arg: T): T;
131
- /** 生成新的匿名结构体, 无需定义类型
132
- * @example const variable1 = nasl.util.NewAnonymousStructure({property1: '123', property2: '456'})
133
- */
149
+ /**
150
+ * 生成新的匿名结构体, 无需定义类型
151
+ * @example const variable1 = nasl.util.NewAnonymousStructure({property1: '123', property2: '456'})
152
+ */
134
153
  export function NewAnonymousStructure(arg: Any): Any;
135
154
 
155
+ export function consoleLog(arg: Any): void;
136
156
  export function jsonSerialize(arg: Any): String;
137
- /** JSON 反序列化, T 为返回值类型,必填
138
- * @example nasl.util.jsonDeserialize<Boolean>(variable1);
139
- */
157
+ /**
158
+ * JSON 反序列化, T 为返回值类型,必填
159
+ * @example nasl.util.jsonDeserialize<Boolean>(variable1);
160
+ */
140
161
  export function jsonDeserialize<T>(arg: String): T;
141
- }
162
+ }