@darabonba/python-generator 1.2.19 → 2.0.1

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.
Files changed (152) hide show
  1. package/ChangeLog.md +0 -158
  2. package/lib/builtin.js +818 -0
  3. package/lib/generator.js +2708 -0
  4. package/lib/helper.js +422 -0
  5. package/package.json +6 -5
  6. package/tests/expected/alias/setup.py +79 -0
  7. package/tests/expected/alias/tea_python_tests/__init__.py +1 -0
  8. package/tests/expected/alias/tea_python_tests/client.py +35 -0
  9. package/tests/expected/annotation/tea_python_tests/__init__.py +1 -0
  10. package/tests/expected/annotation/tea_python_tests/client.py +93 -0
  11. package/tests/expected/annotation/tea_python_tests/models.py +37 -0
  12. package/tests/expected/api/tea_python_tests/__init__.py +1 -0
  13. package/tests/expected/api/tea_python_tests/client.py +106 -0
  14. package/tests/expected/builtin/tea_python_tests/client.py +685 -0
  15. package/tests/expected/comment/tea_python_tests/__init__.py +1 -0
  16. package/tests/expected/comment/tea_python_tests/client.py +288 -0
  17. package/tests/expected/comment/tea_python_tests/models.py +195 -0
  18. package/tests/expected/complex/tea_python_tests/__init__.py +1 -0
  19. package/tests/expected/complex/tea_python_tests/client.py +1169 -0
  20. package/tests/expected/complex/tea_python_tests/exceptions.py +39 -0
  21. package/tests/expected/complex/tea_python_tests/models.py +570 -0
  22. package/tests/expected/const/tea_python_tests/__init__.py +1 -0
  23. package/tests/expected/const/tea_python_tests/client.py +14 -0
  24. package/{src/langs/python/files/setup.py.tmpl → tests/expected/empty/setup.py} +11 -11
  25. package/tests/expected/empty/tea_python_tests/__init__.py +1 -0
  26. package/tests/expected/empty/tea_python_tests/client.py +10 -0
  27. package/tests/expected/exec/tea_python_tests/__init__.py +1 -0
  28. package/tests/expected/exec/tea_python_tests/exec_client.py +21 -0
  29. package/tests/expected/function/tea_python_tests/__init__.py +1 -0
  30. package/tests/expected/function/tea_python_tests/client.py +64 -0
  31. package/tests/expected/import/setup.py +78 -0
  32. package/tests/expected/import/tea_python_tests/__init__.py +1 -0
  33. package/tests/expected/import/tea_python_tests/client.py +29 -0
  34. package/tests/expected/map/tea_python_tests/__init__.py +1 -0
  35. package/tests/expected/map/tea_python_tests/client.py +39 -0
  36. package/tests/expected/model/tea_python_tests/__init__.py +1 -0
  37. package/tests/expected/model/tea_python_tests/client.py +10 -0
  38. package/tests/expected/model/tea_python_tests/exceptions.py +28 -0
  39. package/tests/expected/model/tea_python_tests/models.py +780 -0
  40. package/tests/expected/multi/tea_python_tests/api.py +95 -0
  41. package/tests/expected/multi/tea_python_tests/client.py +40 -0
  42. package/tests/expected/multi/tea_python_tests/lib/util.py +19 -0
  43. package/tests/expected/multi/tea_python_tests/model/user.py +26 -0
  44. package/tests/expected/multi/tea_python_tests/model/user_exceptions.py +83 -0
  45. package/tests/expected/multi/tea_python_tests/model/user_models.py +145 -0
  46. package/tests/expected/statements/tea_python_tests/__init__.py +1 -0
  47. package/tests/expected/statements/tea_python_tests/client.py +86 -0
  48. package/tests/expected/super/tea_python_tests/__init__.py +1 -0
  49. package/tests/expected/super/tea_python_tests/client.py +16 -0
  50. package/tests/expected/typedef/setup.py +77 -0
  51. package/tests/expected/typedef/tea_python_tests/__init__.py +1 -0
  52. package/tests/expected/typedef/tea_python_tests/client.py +74 -0
  53. package/tests/expected/typedef/tea_python_tests/models.py +42 -0
  54. package/tests/fixtures/alias/Darafile +11 -0
  55. package/tests/fixtures/alias/libraries/Alias/Darafile +11 -0
  56. package/tests/fixtures/alias/libraries/Alias-Symbol/Darafile +11 -0
  57. package/tests/fixtures/builtin/Darafile +6 -0
  58. package/tests/fixtures/builtin/main.dara +333 -0
  59. package/tests/fixtures/complex/libraries/import.dara +18 -11
  60. package/tests/fixtures/complex/main.dara +452 -103
  61. package/tests/fixtures/import/libraries/Darafile +1 -1
  62. package/tests/fixtures/import/pack/Darafile +3 -0
  63. package/tests/fixtures/map/libraries/Darafile +3 -0
  64. package/tests/fixtures/map/libraries/import.dara +4 -0
  65. package/tests/fixtures/map/main.dara +17 -2
  66. package/tests/fixtures/model/.libraries.json +3 -0
  67. package/tests/fixtures/model/Darafile +5 -2
  68. package/tests/fixtures/model/libraries/Darafile +20 -0
  69. package/tests/fixtures/model/libraries/import.dara +27 -0
  70. package/tests/fixtures/model/main.dara +60 -42
  71. package/tests/fixtures/multi/.libraries.json +3 -0
  72. package/tests/fixtures/multi/Darafile +12 -0
  73. package/tests/fixtures/multi/api.dara +20 -0
  74. package/tests/fixtures/multi/lib/util.dara +5 -0
  75. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +68 -0
  76. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/main.tea +244 -0
  77. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/util.tea +2 -0
  78. package/tests/fixtures/multi/main.dara +32 -0
  79. package/tests/fixtures/multi/model/user.dara +35 -0
  80. package/tests/{python3.tests.js → main.tests.js} +107 -65
  81. package/tests/output/alias/setup.py +79 -0
  82. package/tests/output/alias/tea_python_tests/client.py +35 -0
  83. package/{src/langs/python2/files/setup.py.tmpl → tests/output/annotation/setup.py} +19 -24
  84. package/tests/output/annotation/tea_python_tests/client.py +93 -0
  85. package/tests/output/annotation/tea_python_tests/models.py +37 -0
  86. package/tests/output/api/setup.py +77 -0
  87. package/tests/output/api/tea_python_tests/client.py +106 -0
  88. package/tests/output/builtin/setup.py +77 -0
  89. package/tests/output/builtin/tea_python_tests/client.py +685 -0
  90. package/tests/output/comment/setup.py +77 -0
  91. package/tests/output/comment/tea_python_tests/client.py +288 -0
  92. package/tests/output/comment/tea_python_tests/models.py +195 -0
  93. package/tests/output/complex/setup.py +77 -0
  94. package/tests/output/complex/tea_python_tests/client.py +1169 -0
  95. package/tests/output/complex/tea_python_tests/exceptions.py +39 -0
  96. package/tests/output/complex/tea_python_tests/models.py +570 -0
  97. package/tests/output/const/setup.py +77 -0
  98. package/tests/output/const/tea_python_tests/client.py +14 -0
  99. package/tests/output/empty/setup.py +77 -0
  100. package/tests/output/empty/tea_python_tests/client.py +10 -0
  101. package/tests/output/exec/setup.py +77 -0
  102. package/tests/output/exec/tea_python_tests/exec_client.py +21 -0
  103. package/tests/output/function/setup.py +77 -0
  104. package/tests/output/function/tea_python_tests/client.py +64 -0
  105. package/tests/output/import/setup.py +78 -0
  106. package/tests/output/import/tea_python_tests/client.py +29 -0
  107. package/tests/output/map/setup.py +77 -0
  108. package/tests/output/map/tea_python_tests/client.py +39 -0
  109. package/tests/output/model/setup.py +77 -0
  110. package/tests/output/model/tea_python_tests/client.py +10 -0
  111. package/tests/output/model/tea_python_tests/exceptions.py +28 -0
  112. package/tests/output/model/tea_python_tests/models.py +780 -0
  113. package/tests/output/multi/setup.py +77 -0
  114. package/tests/output/multi/tea_python_tests/api.py +95 -0
  115. package/tests/output/multi/tea_python_tests/client.py +40 -0
  116. package/tests/output/multi/tea_python_tests/lib/util.py +19 -0
  117. package/tests/output/multi/tea_python_tests/model/user.py +26 -0
  118. package/tests/output/multi/tea_python_tests/model/user_exceptions.py +83 -0
  119. package/tests/output/multi/tea_python_tests/model/user_models.py +145 -0
  120. package/tests/output/statements/setup.py +77 -0
  121. package/tests/output/statements/tea_python_tests/client.py +86 -0
  122. package/tests/output/super/setup.py +77 -0
  123. package/tests/output/super/tea_python_tests/client.py +16 -0
  124. package/tests/output/typedef/setup.py +78 -0
  125. package/tests/output/typedef/tea_python_tests/client.py +74 -0
  126. package/tests/output/typedef/tea_python_tests/models.py +42 -0
  127. package/src/generator.js +0 -231
  128. package/src/langs/common/combinator.js +0 -193
  129. package/src/langs/common/config.js +0 -60
  130. package/src/langs/common/enum.js +0 -179
  131. package/src/langs/common/items.js +0 -551
  132. package/src/langs/common/package_info.js +0 -53
  133. package/src/langs/python/combinator.js +0 -1898
  134. package/src/langs/python/config.js +0 -169
  135. package/src/langs/python/files/.gitignore.tmpl +0 -5
  136. package/src/langs/python/files/__init__.py.tmpl +0 -1
  137. package/src/langs/python/package_info.js +0 -78
  138. package/src/langs/python2/combinator.js +0 -1770
  139. package/src/langs/python2/config.js +0 -162
  140. package/src/langs/python2/files/.gitignore.tmpl +0 -5
  141. package/src/langs/python2/files/__init__.py.tmpl +0 -1
  142. package/src/langs/python2/package_info.js +0 -78
  143. package/src/lib/debug.js +0 -55
  144. package/src/lib/emitter.js +0 -95
  145. package/src/lib/helper.js +0 -207
  146. package/src/resolver/base.js +0 -282
  147. package/src/resolver/client.js +0 -1013
  148. package/src/resolver/model.js +0 -159
  149. package/tests/common.tests.js +0 -244
  150. package/tests/lib.tests.js +0 -269
  151. package/tests/python2.tests.js +0 -283
  152. package/tests/resolver.tests.js +0 -434
@@ -3,6 +3,9 @@
3
3
  "name": "import",
4
4
  "version": "0.0.1",
5
5
  "main": "./import.dara",
6
+ "releases": {
7
+ "ts": "@scope/name:*"
8
+ },
6
9
  "php": {
7
10
  "package": "Source",
8
11
  "clientName": "SourceClient",
@@ -5,3 +5,7 @@ init(config: Config);
5
5
  model Config = {
6
6
  strValue:string
7
7
  }
8
+
9
+ static function hello(): string {
10
+ return 'str';
11
+ }
@@ -4,10 +4,25 @@ extends Source;
4
4
 
5
5
  init(config: Source.Config){
6
6
  super(config);
7
+ var a = {
8
+ "test" = "test",
9
+ };
10
+ var c = {
11
+ "test" = "test",
12
+ };
7
13
  @endpointRule = 'central';
8
14
  @endpointMap = {
9
- ap-northeast-1 = 'cusanalytic.aliyuncs.com',
10
- ap-south-1 = 'cusanalytic.aliyuncs.com',
15
+ "ap-northeast-1" = 'cusanalytic.aliyuncs.com',
16
+ "ap-south-1" = 'cusanalytic.aliyuncs.com',
17
+ ...a,
18
+ ...c,
19
+ ap-south-2-test = Source.hello(),
20
+ };
21
+ var b = {
22
+ "ap-northeast-1" = {
23
+ "ap-south-1" = 'cusanalytic.aliyuncs.com',
24
+ },
25
+ "ap-south-2" = Source.hello(),
11
26
  };
12
27
  @endpointMap['ap-northeast-1'];
13
28
  @endpointMap['ap-northeast-1'] = "";
@@ -0,0 +1,3 @@
1
+ {
2
+ "darabonba:Import:*": "libraries"
3
+ }
@@ -1,6 +1,9 @@
1
1
  {
2
- "scope": "alibabacloud",
2
+ "scope": "darabonba",
3
3
  "name": "main",
4
4
  "version": "0.0.1",
5
- "main": "./main.dara"
5
+ "main": "./main.dara",
6
+ "libraries": {
7
+ "Source": "darabonba:Import:*"
8
+ }
6
9
  }
@@ -0,0 +1,20 @@
1
+ {
2
+ "scope": "darabonba",
3
+ "name": "import",
4
+ "version": "0.0.1",
5
+ "main": "./import.dara",
6
+ "java": {
7
+ "package": "com.import"
8
+ },
9
+ "csharp": {
10
+ "namespace": "Darabonba.import"
11
+ },
12
+ "python": {
13
+ "package": "Source",
14
+ "clientName": "client",
15
+ "modelDirName": "Models"
16
+ },
17
+ "releases": {
18
+ "php": "scope/name:1.0.0"
19
+ }
20
+ }
@@ -0,0 +1,27 @@
1
+ model RuntimeObject = {}
2
+
3
+ static function array(request: object, str: string): [ any ];
4
+
5
+ static function query(q: object): map[string]string;
6
+ static function body(): readable;
7
+ static function parse(c: class): void;
8
+ static async function asyncFunc(): void;
9
+
10
+ type @protocol = string
11
+ type @pathname = string
12
+ type @API = map[string]string
13
+
14
+ init(config: Config);
15
+ model Config = {}
16
+ function print(runtime: object, str: string): void {
17
+ return;
18
+ }
19
+
20
+ async function printAsync(runtime: object, str: string): void {
21
+ return;
22
+ }
23
+
24
+ model Request = {
25
+ accesskey?: string(name='accesskey', description='accesskey'),
26
+ region?: string(name='region', description='region'),
27
+ }
@@ -1,14 +1,33 @@
1
- model useBeforeDefineModel = {
2
- subModel: {
3
- useBeforeDefineModel: UseBeforeDefineModelOnSubModel
4
- }
1
+ import Source;
2
+
3
+ model M = {
4
+ subM: {}
5
5
  };
6
6
 
7
- model UseBeforeDefineModelOnSubModel = {
8
- m: MyModel,
7
+ model Class = {};
8
+
9
+ model model = {
10
+ str: string
11
+ }
12
+
13
+ exception MainFile extends $Error {
14
+ size: number,
15
+ data: map[string]model,
16
+ model: {
17
+ str: string,
18
+ model: {
19
+ str: string
20
+ },
21
+ }
9
22
  }
10
23
 
11
24
  model MyModel = {
25
+ model: {
26
+ str: string,
27
+ model: {
28
+ str: string
29
+ },
30
+ },
12
31
  stringfield: string,
13
32
  bytesfield: bytes,
14
33
  stringarrayfield: [ string ],
@@ -16,44 +35,43 @@ model MyModel = {
16
35
  name: string(name='realName'),
17
36
  submodel: {
18
37
  stringfield: string,
19
- } (name='SubModel'),
20
- subarray: [ M ] (name='SubArray'),
21
- maparray: [ map[string]any ] (name='MapArray'),
38
+ model: {
39
+ str: string
40
+ },
41
+ },
42
+ submodelMap: map[string]MyModel.submodel,
43
+ mapModel: map[string]M,
44
+ subarraymodel: [ {} ],
45
+ subarray: [ M ],
46
+ ssubarray: [[ M ]],
47
+ ssubmarray: [[ Source ]],
48
+ ssubmmarray: [[ Source.Request ]],
49
+ maparray: [ map[string]any ],
50
+ mapsubmarray: [ map[string]Source ],
51
+ moduleModelMap: map[string]Source.Request,
52
+ subModelMap: map[string]M.subM,
53
+ modelMap: map[string]M,
54
+ moduleMap: map[string]Source,
22
55
  object: object,
23
- numberfield: integer,
24
56
  readable: readable,
57
+ writable: writable,
25
58
  existModel: M,
26
- classEndTime?: string(description='结束时间', example='2018-10-10T10:10:00Z', pattern='\\\\d{4}[-]\\\\d{1,2}[-]\\\\d{1,2}(\\\\s\\\\d{2}:\\\\d{2}(:\\\\d{2})?)?', name='class_end_time'),
27
- maxLength?: string(description='最大长度', example='10000', maxLength='10', name='max-length'),
28
- minLength?: string(description='最小长度', example='10000', minLength='0', name='min-length'),
29
- maximum?: long(description='校验最大值', example='10000', maximum='99000000'),
30
- minimum?: long(description='校验最小值', example='10000', minimum='0'),
31
- test3: [[string]](description='test3 desc', name='test3'),
32
- arrayArrayModel: [[M]] (name='ArrayArrayModel'),
33
- arrayMapModel: [ map[string]M ] (name='ArrayMapModel'),
34
-
35
- mapModel: map[string]M (name='MapModel'),
36
- submodelMap: map[string]MyModel.submodel (name='SubmodelMap'),
37
-
38
- subModelModel: {
39
- subModel: [ M ]
40
- } (name='SubModelModel'),
41
- mapArrayMap?: map[string][ map[string]string ] (name='MapArrayMap'),
42
- mapArrayModel?: map[string][ M ] (name='MapArrayModel'),
43
- };
44
-
45
- model M = {
46
- oneself: M,
47
- selfArray: [M],
48
- selfMap: map[string]M,
49
- selfArrayMap: [ map[string]M ],
50
- selfArrayArray: [ [ M ] ]
59
+ request: $Request,
60
+ complexList: [ [ string ] ],
61
+ numberfield: number,
62
+ integerField: integer,
63
+ floatField: float,
64
+ doubleField: double,
65
+ longField: long,
66
+ ulongField: ulong,
67
+ int8Field: int8,
68
+ int16Field: int16,
69
+ int32Field: int32,
70
+ int64Field: int64,
71
+ uint8Field: uint8,
72
+ uint16Field: uint16,
73
+ uint32Field: uint32,
74
+ uint64Field: uint64,
75
+ link?: string(name='link', example='http://*/*.png'),
51
76
  };
52
77
 
53
- model Node {
54
- child?: {
55
- subChild?: {
56
- childNode?: Node(name='childNode'),
57
- }(name='subChild'),
58
- }(name='child'),
59
- }
@@ -0,0 +1,3 @@
1
+ {
2
+ "darabonba:Util:*": "libraries/darabonba_Util_0.2.11"
3
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "scope": "darabonba",
3
+ "name": "Util",
4
+ "version": "0.2.10",
5
+ "main": "./main.dara",
6
+ "releases": {
7
+ "go": "darabonba.com/multi/client:v1.0.0"
8
+ },
9
+ "libraries": {
10
+ "DARAUtil": "darabonba:Util:*"
11
+ }
12
+ }
@@ -0,0 +1,20 @@
1
+ import "./model/user" User;
2
+ import "./lib/util" Util;
3
+
4
+ init(){
5
+ }
6
+
7
+ api test3(): number {
8
+ __request.protocol = "https";
9
+ __request.method = 'DELETE';
10
+ __request.pathname = "/";
11
+ __request.headers = {
12
+ host = "test.aliyun.com",
13
+ accept = 'application/json',
14
+ };
15
+ __request.query = Util.getQuery();
16
+ } returns {
17
+ return __response.statusCode;
18
+ } runtime {
19
+ timeouted = 'retry'
20
+ }
@@ -0,0 +1,5 @@
1
+ @clientName("Util");
2
+
3
+ static function test1(): iterator[string];
4
+
5
+ static function getQuery(): map[string]string;
@@ -0,0 +1,68 @@
1
+ {
2
+ "scope": "darabonba",
3
+ "name": "Util",
4
+ "version": "0.2.11",
5
+ "main": "./main.tea",
6
+ "exports": {
7
+ "Util": "./util.tea"
8
+ },
9
+ "releases": {
10
+ "go": "github.com/alibabacloud-go/tea-utils/v2/service:v2.0.4",
11
+ "ts": "@alicloud/tea-util:^1.4.7",
12
+ "csharp": "AlibabaCloud.TeaUtil:0.1.17",
13
+ "java": "com.aliyun:tea-util:0.2.21",
14
+ "php": "alibabacloud/tea-utils:^0.2.19",
15
+ "python": "alibabacloud_tea_util:0.3.11",
16
+ "python2": "alibabacloud_tea_util_py2:0.0.9",
17
+ "swift": "alibabacloud-sdk-swift/tea-utils:1.0.3",
18
+ "cpp": "alibabacloud-sdk-cpp/dara-util:master"
19
+ },
20
+ "java": {
21
+ "package": "com.aliyun.teautil",
22
+ "className": "Common"
23
+ },
24
+ "csharp": {
25
+ "namespace": "AlibabaCloud.TeaUtil",
26
+ "className": "Common"
27
+ },
28
+ "php": {
29
+ "package": "AlibabaCloud.Tea.Utils",
30
+ "clientName": "Utils",
31
+ "modelDirName": "Utils"
32
+ },
33
+ "python": {
34
+ "package": "alibabacloud_tea_util",
35
+ "clientName": "client",
36
+ "exports": {
37
+ "Util": "Utils"
38
+ }
39
+ },
40
+ "python2": {
41
+ "package": "alibabacloud_tea_util",
42
+ "clientName": "client"
43
+ },
44
+ "cpp": {
45
+ "packageInfo": {
46
+ "git": {
47
+ "scope": "alibabacloud-sdk-cpp",
48
+ "project": "dara-util"
49
+ }
50
+ }
51
+ },
52
+ "swift": {
53
+ "clientName": "Client",
54
+ "packageInfo": {
55
+ "name": "TeaUtils",
56
+ "desc": "Alibaba Cloud Tea Util for Swift",
57
+ "github": "https://github.com/alibabacloud-sdk-swift/tea-utils",
58
+ "author": "Alibaba Cloud SDK",
59
+ "email": "sdk-team@alibabacloud.com"
60
+ }
61
+ },
62
+ "releaselog": {
63
+ "changelog": [
64
+ "[java]fix: enable getNonce() on Android platform."
65
+ ],
66
+ "compatible": true
67
+ }
68
+ }
@@ -0,0 +1,244 @@
1
+ /**
2
+ * This is a utility module
3
+ */
4
+
5
+ /**
6
+ * The common runtime options model
7
+ */
8
+ model RuntimeOptions {
9
+ autoretry?: boolean(description='whether to try again', name='autoretry'),
10
+ ignoreSSL?: boolean(description='ignore SSL validation', name='ignoreSSL'),
11
+ key?: string(description='privite key for client certificate', name='key'),
12
+ cert?: string(description='client certificate', name='cert'),
13
+ ca?: string(description='server certificate', name='ca'),
14
+ maxAttempts?: number(description='maximum number of retries', name='max_attempts'),
15
+ backoffPolicy?: string(description='backoff policy', name='backoff_policy'),
16
+ backoffPeriod?: number(description='backoff period', name='backoff_period'),
17
+ readTimeout?: number(description='read timeout', name='readTimeout'),
18
+ connectTimeout?: number(description='connect timeout', name='connectTimeout'),
19
+ httpProxy?: string(description='http proxy url', name='httpProxy'),
20
+ httpsProxy?: string(description='https Proxy url', name='httpsProxy'),
21
+ noProxy?: string(description='agent blacklist', name='noProxy'),
22
+ maxIdleConns?: number(description='maximum number of connections', name='maxIdleConns'),
23
+ localAddr?: string(description='local addr', name='localAddr'),
24
+ socks5Proxy?: string(description='SOCKS5 proxy', name='socks5Proxy'),
25
+ socks5NetWork?: string(description='SOCKS5 netWork', name='socks5NetWork'),
26
+ keepAlive?: boolean(description='whether to enable keep-alive', name='keepAlive'),
27
+ }
28
+
29
+ /**
30
+ * Convert a string(utf8) to bytes
31
+ * @return the return bytes
32
+ */
33
+ static function toBytes(val: string): bytes;
34
+
35
+ /**
36
+ * Convert a bytes to string(utf8)
37
+ * @return the return string
38
+ */
39
+ static function toString(val: bytes): string;
40
+
41
+ /**
42
+ * Parse it by JSON format
43
+ * @return the parsed result
44
+ */
45
+ static function parseJSON(val: string): any;
46
+
47
+ /**
48
+ * Read data from a readable stream, and compose it to a bytes
49
+ * @param stream the readable stream
50
+ * @return the bytes result
51
+ */
52
+ static async function readAsBytes(stream: readable): bytes;
53
+
54
+ /**
55
+ * Read data from a readable stream, and compose it to a string
56
+ * @param stream the readable stream
57
+ * @return the string result
58
+ */
59
+ static async function readAsString(stream: readable): string {
60
+ var buff = readAsBytes(stream);
61
+ return toString(buff);
62
+ }
63
+
64
+ /**
65
+ * Read data from a readable stream, and parse it by JSON format
66
+ * @param stream the readable stream
67
+ * @return the parsed result
68
+ */
69
+ static async function readAsJSON(stream: readable): any {
70
+ return parseJSON(readAsString(stream));
71
+ }
72
+
73
+ /**
74
+ * Generate a nonce string
75
+ * @return the nonce string
76
+ */
77
+ static function getNonce(): string;
78
+
79
+ /**
80
+ * Get an UTC format string by current date, e.g. 'Thu, 06 Feb 2020 07:32:54 GMT'
81
+ * @return the UTC format string
82
+ */
83
+ static function getDateUTCString(): string;
84
+
85
+ /**
86
+ * If not set the real, use default value
87
+ * @return the return string
88
+ */
89
+ static function defaultString(real: string, default: string): string;
90
+
91
+ /**
92
+ * If not set the real, use default value
93
+ * @return the return number
94
+ */
95
+ static function defaultNumber(real: number, default: number): number;
96
+
97
+ /**
98
+ * Format a map to form string, like a=a%20b%20c
99
+ * @return the form string
100
+ */
101
+ static function toFormString(val: object): string;
102
+
103
+ /**
104
+ * Stringify a value by JSON format
105
+ * @return the JSON format string
106
+ */
107
+ static function toJSONString(val: any): string;
108
+
109
+ /**
110
+ * Check the string is empty?
111
+ * @return if string is null or zero length, return true
112
+ */
113
+ static function empty(val: string): boolean;
114
+
115
+ /**
116
+ * Check one string equals another one?
117
+ * @return if equals, return true
118
+ */
119
+ static function equalString(val1: string, val2: string): boolean;
120
+
121
+ /**
122
+ * Check one number equals another one?
123
+ * @return if equals, return true
124
+ */
125
+ static function equalNumber(val1: number, val2: number): boolean;
126
+
127
+ /**
128
+ * Check one value is unset
129
+ * @return if unset, return true
130
+ */
131
+ static function isUnset(value: any): boolean;
132
+
133
+ /**
134
+ * Stringify the value of map
135
+ * @return the new stringified map
136
+ */
137
+ static function stringifyMapValue(m: map[string]any): map[string]string;
138
+
139
+ /**
140
+ * Anyify the value of map
141
+ * @return the new anyfied map
142
+ */
143
+ static function anyifyMapValue(m: map[string]string): map[string]any;
144
+
145
+ /**
146
+ * Assert a value, if it is a boolean, return it, otherwise throws
147
+ * @return the boolean value
148
+ */
149
+ static function assertAsBoolean(value: any)throws : boolean;
150
+
151
+ /**
152
+ * Assert a value, if it is a string, return it, otherwise throws
153
+ * @return the string value
154
+ */
155
+ static function assertAsString(value: any)throws : string;
156
+
157
+ /**
158
+ * Assert a value, if it is a bytes, return it, otherwise throws
159
+ * @return the bytes value
160
+ */
161
+ static function assertAsBytes(value: any)throws : bytes;
162
+
163
+ /**
164
+ * Assert a value, if it is a number, return it, otherwise throws
165
+ * @return the number value
166
+ */
167
+ static function assertAsNumber(value: any)throws : number;
168
+
169
+ /**
170
+ * Assert a value, if it is a integer, return it, otherwise throws
171
+ * @return the integer value
172
+ */
173
+ static function assertAsInteger(value: any)throws : integer;
174
+
175
+ /**
176
+ * Assert a value, if it is a map, return it, otherwise throws
177
+ * @return the map value
178
+ */
179
+ static function assertAsMap(value: any)throws : map[string]any;
180
+
181
+ /**
182
+ * Assert a value, if it is a array, return it, otherwise throws
183
+ * @return the array value
184
+ */
185
+ static function assertAsArray(value: any)throws : [ any ];
186
+
187
+ /**
188
+ * Get user agent, if it userAgent is not null, splice it with defaultUserAgent and return, otherwise return defaultUserAgent
189
+ * @return the string value
190
+ */
191
+ static function getUserAgent(userAgent: string): string;
192
+
193
+ /**
194
+ * If the code between 200 and 300, return true, or return false
195
+ * @return boolean
196
+ */
197
+ static function is2xx(code: number): boolean;
198
+
199
+ /**
200
+ * If the code between 300 and 400, return true, or return false
201
+ * @return boolean
202
+ */
203
+ static function is3xx(code: number): boolean;
204
+
205
+ /**
206
+ * If the code between 400 and 500, return true, or return false
207
+ * @return boolean
208
+ */
209
+ static function is4xx(code: number): boolean;
210
+
211
+ /**
212
+ * If the code between 500 and 600, return true, or return false
213
+ * @return boolean
214
+ */
215
+ static function is5xx(code: number): boolean;
216
+
217
+ /**
218
+ * Validate model
219
+ * @return void
220
+ */
221
+ static function validateModel(m: $Model) throws: void;
222
+
223
+ /**
224
+ * Model transforms to map[string]any
225
+ * @return map[string]any
226
+ */
227
+ static function toMap(in: $Model): map[string]any;
228
+
229
+
230
+ /**
231
+ * Suspends the current thread for the specified number of milliseconds.
232
+ */
233
+ static async function sleep(millisecond: number): void;
234
+
235
+ /**
236
+ * Transform input as array.
237
+ */
238
+ static function toArray(input: any): [ map[string]any ];
239
+
240
+ /**
241
+ * Assert a value, if it is a readable, return it, otherwise throws
242
+ * @return the readable value
243
+ */
244
+ static function assertAsReadable(value: any)throws : readable;
@@ -0,0 +1,2 @@
1
+ @clientName("Utils")
2
+ static function test(): void;
@@ -0,0 +1,32 @@
1
+ import "./model/user" User;
2
+ import "./lib/util" Util;
3
+ import "./api" API;
4
+
5
+ type @user = User.Info
6
+
7
+ init(){
8
+ @user = new User.Info{
9
+ name = 'test',
10
+ age = 124,
11
+ maxAttemp = 3,
12
+ autoretry = true,
13
+ };
14
+
15
+ }
16
+
17
+ async function test3(): asyncIterator[string]{
18
+ var it:iterator[string] = Util.test1();
19
+ for(var test : it) {
20
+ yield test;
21
+ }
22
+ }
23
+
24
+
25
+ async function test4(): number{
26
+ var api = new API();
27
+ var status = api.test3();
28
+ return status;
29
+ }
30
+
31
+
32
+
@@ -0,0 +1,35 @@
1
+ import DARAUtil;
2
+ import DARAUtil.Util as Utils;
3
+ import "../lib/util" Util;
4
+
5
+
6
+ model BaseInfo extends DARAUtil.RuntimeOptions {
7
+ maxAttemp: number,
8
+ }
9
+
10
+ model Info extends BaseInfo {
11
+ name: string,
12
+ age: integer,
13
+ }
14
+
15
+
16
+ static async function test(): asyncIterator[string]{
17
+ Utils.test();
18
+ var it:iterator[string] = Util.test1();
19
+ for(var test : it) {
20
+ yield test;
21
+ }
22
+
23
+ }
24
+
25
+ exception Err {
26
+ msg: string,
27
+ }
28
+
29
+ exception Err1 extends BaseInfo {
30
+ msg: string,
31
+ }
32
+
33
+ exception Err2 extends Err {
34
+ msg2: string,
35
+ }