@darabonba/python-generator 1.2.18 → 2.0.0
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/ChangeLog.md +0 -155
- package/lib/builtin.js +818 -0
- package/lib/generator.js +2704 -0
- package/lib/helper.js +422 -0
- package/package.json +6 -5
- package/src/lib/helper.js +11 -1
- package/src/resolver/base.js +3 -1
- package/src/resolver/client.js +7 -4
- package/src/resolver/model.js +5 -3
- package/tests/expected/alias/setup.py +79 -0
- package/tests/expected/alias/tea_python_tests/__init__.py +1 -0
- package/tests/expected/alias/tea_python_tests/client.py +35 -0
- package/tests/expected/annotation/tea_python_tests/__init__.py +1 -0
- package/tests/expected/annotation/tea_python_tests/client.py +93 -0
- package/tests/expected/annotation/tea_python_tests/models.py +37 -0
- package/tests/expected/api/tea_python_tests/__init__.py +1 -0
- package/tests/expected/api/tea_python_tests/client.py +106 -0
- package/tests/expected/builtin/tea_python_tests/client.py +685 -0
- package/tests/expected/comment/tea_python_tests/__init__.py +1 -0
- package/tests/expected/comment/tea_python_tests/client.py +288 -0
- package/tests/expected/comment/tea_python_tests/models.py +195 -0
- package/tests/expected/complex/tea_python_tests/__init__.py +1 -0
- package/tests/expected/complex/tea_python_tests/client.py +1168 -0
- package/tests/expected/complex/tea_python_tests/exceptions.py +39 -0
- package/tests/expected/complex/tea_python_tests/models.py +570 -0
- package/tests/expected/const/tea_python_tests/__init__.py +1 -0
- package/tests/expected/const/tea_python_tests/client.py +14 -0
- package/tests/expected/empty/setup.py +74 -0
- package/tests/expected/empty/tea_python_tests/__init__.py +1 -0
- package/tests/expected/empty/tea_python_tests/client.py +10 -0
- package/tests/expected/exec/tea_python_tests/__init__.py +1 -0
- package/tests/expected/exec/tea_python_tests/exec_client.py +21 -0
- package/tests/expected/function/tea_python_tests/__init__.py +1 -0
- package/tests/expected/function/tea_python_tests/client.py +64 -0
- package/tests/expected/import/setup.py +78 -0
- package/tests/expected/import/tea_python_tests/__init__.py +1 -0
- package/tests/expected/import/tea_python_tests/client.py +29 -0
- package/tests/expected/map/tea_python_tests/__init__.py +1 -0
- package/tests/expected/map/tea_python_tests/client.py +39 -0
- package/tests/expected/model/tea_python_tests/__init__.py +1 -0
- package/tests/expected/model/tea_python_tests/client.py +10 -0
- package/tests/expected/model/tea_python_tests/exceptions.py +28 -0
- package/tests/expected/model/tea_python_tests/models.py +780 -0
- package/tests/expected/multi/tea_python_tests/api.py +95 -0
- package/tests/expected/multi/tea_python_tests/client.py +40 -0
- package/tests/expected/multi/tea_python_tests/lib/util.py +19 -0
- package/tests/expected/multi/tea_python_tests/model/user.py +23 -0
- package/tests/expected/multi/tea_python_tests/model/user_exceptions.py +83 -0
- package/tests/expected/multi/tea_python_tests/model/user_models.py +145 -0
- package/tests/expected/python2/function/tea_python_tests/client.py +3 -1
- package/tests/expected/python2/model/tea_python_tests/models.py +57 -30
- package/tests/expected/python3/function/tea_python_tests/client.py +3 -1
- package/tests/expected/python3/model/tea_python_tests/models.py +57 -29
- package/tests/expected/statements/tea_python_tests/__init__.py +1 -0
- package/tests/expected/statements/tea_python_tests/client.py +86 -0
- package/tests/expected/super/tea_python_tests/__init__.py +1 -0
- package/tests/expected/super/tea_python_tests/client.py +16 -0
- package/tests/expected/typedef/setup.py +77 -0
- package/tests/expected/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/typedef/tea_python_tests/client.py +74 -0
- package/tests/expected/typedef/tea_python_tests/models.py +42 -0
- package/tests/fixtures/alias/Darafile +11 -0
- package/tests/fixtures/alias/libraries/Alias/Darafile +11 -0
- package/tests/fixtures/alias/libraries/Alias-Symbol/Darafile +11 -0
- package/tests/fixtures/builtin/Darafile +6 -0
- package/tests/fixtures/builtin/main.dara +333 -0
- package/tests/fixtures/complex/libraries/import.dara +18 -11
- package/tests/fixtures/complex/main.dara +451 -103
- package/tests/fixtures/function/main.dara +2 -0
- package/tests/fixtures/import/libraries/Darafile +1 -1
- package/tests/fixtures/import/pack/Darafile +3 -0
- package/tests/fixtures/map/libraries/Darafile +3 -0
- package/tests/fixtures/map/libraries/import.dara +4 -0
- package/tests/fixtures/map/main.dara +17 -2
- package/tests/fixtures/model/.libraries.json +3 -0
- package/tests/fixtures/model/Darafile +5 -2
- package/tests/fixtures/model/libraries/Darafile +20 -0
- package/tests/fixtures/model/libraries/import.dara +27 -0
- package/tests/fixtures/model/main.dara +57 -37
- package/tests/fixtures/multi/.libraries.json +3 -0
- package/tests/fixtures/multi/Darafile +12 -0
- package/tests/fixtures/multi/api.dara +20 -0
- package/tests/fixtures/multi/lib/util.dara +5 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +62 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/main.tea +244 -0
- package/tests/fixtures/multi/main.dara +32 -0
- package/tests/fixtures/multi/model/user.dara +33 -0
- package/tests/{python3.tests.js → main.tests.js} +107 -65
- package/tests/output/alias/setup.py +79 -0
- package/tests/output/alias/tea_python_tests/client.py +35 -0
- package/tests/output/annotation/setup.py +77 -0
- package/tests/output/annotation/tea_python_tests/client.py +93 -0
- package/tests/output/annotation/tea_python_tests/models.py +37 -0
- package/tests/output/api/setup.py +77 -0
- package/tests/output/api/tea_python_tests/client.py +106 -0
- package/tests/output/builtin/setup.py +77 -0
- package/tests/output/builtin/tea_python_tests/client.py +685 -0
- package/tests/output/comment/setup.py +77 -0
- package/tests/output/comment/tea_python_tests/client.py +288 -0
- package/tests/output/comment/tea_python_tests/models.py +195 -0
- package/tests/output/complex/setup.py +77 -0
- package/tests/output/complex/tea_python_tests/client.py +1168 -0
- package/tests/output/complex/tea_python_tests/exceptions.py +39 -0
- package/tests/output/complex/tea_python_tests/models.py +570 -0
- package/tests/output/const/setup.py +77 -0
- package/tests/output/const/tea_python_tests/client.py +14 -0
- package/tests/output/empty/setup.py +77 -0
- package/tests/output/empty/tea_python_tests/client.py +10 -0
- package/tests/output/exec/setup.py +77 -0
- package/tests/output/exec/tea_python_tests/exec_client.py +21 -0
- package/tests/output/function/setup.py +77 -0
- package/tests/output/function/tea_python_tests/client.py +64 -0
- package/tests/output/import/setup.py +78 -0
- package/tests/output/import/tea_python_tests/client.py +29 -0
- package/tests/output/map/setup.py +77 -0
- package/tests/output/map/tea_python_tests/client.py +39 -0
- package/tests/output/model/setup.py +77 -0
- package/tests/output/model/tea_python_tests/client.py +10 -0
- package/tests/output/model/tea_python_tests/exceptions.py +28 -0
- package/tests/output/model/tea_python_tests/models.py +780 -0
- package/tests/output/multi/setup.py +77 -0
- package/tests/output/multi/tea_python_tests/api.py +95 -0
- package/tests/output/multi/tea_python_tests/client.py +40 -0
- package/tests/output/multi/tea_python_tests/lib/util.py +19 -0
- package/tests/output/multi/tea_python_tests/model/user.py +23 -0
- package/tests/output/multi/tea_python_tests/model/user_exceptions.py +83 -0
- package/tests/output/multi/tea_python_tests/model/user_models.py +145 -0
- package/tests/output/statements/setup.py +77 -0
- package/tests/output/statements/tea_python_tests/client.py +86 -0
- package/tests/output/super/setup.py +77 -0
- package/tests/output/super/tea_python_tests/client.py +16 -0
- package/tests/output/typedef/setup.py +78 -0
- package/tests/output/typedef/tea_python_tests/client.py +74 -0
- package/tests/output/typedef/tea_python_tests/models.py +42 -0
- package/tests/common.tests.js +0 -244
- package/tests/lib.tests.js +0 -269
- package/tests/python2.tests.js +0 -283
- package/tests/resolver.tests.js +0 -434
|
@@ -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,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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
import Source;
|
|
2
|
+
|
|
3
|
+
model M = {
|
|
4
|
+
subM: {}
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
model
|
|
8
|
-
|
|
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,42 +35,43 @@ model MyModel = {
|
|
|
16
35
|
name: string(name='realName'),
|
|
17
36
|
submodel: {
|
|
18
37
|
stringfield: string,
|
|
38
|
+
model: {
|
|
39
|
+
str: string
|
|
40
|
+
},
|
|
19
41
|
},
|
|
42
|
+
submodelMap: map[string]MyModel.submodel,
|
|
43
|
+
mapModel: map[string]M,
|
|
44
|
+
subarraymodel: [ {} ],
|
|
20
45
|
subarray: [ M ],
|
|
46
|
+
ssubarray: [[ M ]],
|
|
47
|
+
ssubmarray: [[ Source ]],
|
|
48
|
+
ssubmmarray: [[ Source.Request ]],
|
|
21
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
model M = {
|
|
44
|
-
oneself: M,
|
|
45
|
-
selfArray: [M],
|
|
46
|
-
selfMap: map[string]M,
|
|
47
|
-
selfArrayMap: [ map[string]M ],
|
|
48
|
-
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'),
|
|
49
76
|
};
|
|
50
77
|
|
|
51
|
-
model Node {
|
|
52
|
-
child?: {
|
|
53
|
-
subChild?: {
|
|
54
|
-
childNode?: Node(name='childNode'),
|
|
55
|
-
}(name='subChild'),
|
|
56
|
-
}(name='child'),
|
|
57
|
-
}
|
|
@@ -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,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scope": "darabonba",
|
|
3
|
+
"name": "Util",
|
|
4
|
+
"version": "0.2.11",
|
|
5
|
+
"main": "./main.tea",
|
|
6
|
+
"releases": {
|
|
7
|
+
"go": "github.com/alibabacloud-go/tea-utils/v2/service:v2.0.4",
|
|
8
|
+
"ts": "@alicloud/tea-util:^1.4.7",
|
|
9
|
+
"csharp": "AlibabaCloud.TeaUtil:0.1.17",
|
|
10
|
+
"java": "com.aliyun:tea-util:0.2.21",
|
|
11
|
+
"php": "alibabacloud/tea-utils:^0.2.19",
|
|
12
|
+
"python": "alibabacloud_tea_util:0.3.11",
|
|
13
|
+
"python2": "alibabacloud_tea_util_py2:0.0.9",
|
|
14
|
+
"swift": "alibabacloud-sdk-swift/tea-utils:1.0.3",
|
|
15
|
+
"cpp": "alibabacloud-sdk-cpp/dara-util:master"
|
|
16
|
+
},
|
|
17
|
+
"java": {
|
|
18
|
+
"package": "com.aliyun.teautil",
|
|
19
|
+
"className": "Common"
|
|
20
|
+
},
|
|
21
|
+
"csharp": {
|
|
22
|
+
"namespace": "AlibabaCloud.TeaUtil",
|
|
23
|
+
"className": "Common"
|
|
24
|
+
},
|
|
25
|
+
"php": {
|
|
26
|
+
"package": "AlibabaCloud.Tea.Utils",
|
|
27
|
+
"clientName": "Utils",
|
|
28
|
+
"modelDirName": "Utils"
|
|
29
|
+
},
|
|
30
|
+
"python": {
|
|
31
|
+
"package": "alibabacloud_tea_util",
|
|
32
|
+
"clientName": "client"
|
|
33
|
+
},
|
|
34
|
+
"python2": {
|
|
35
|
+
"package": "alibabacloud_tea_util",
|
|
36
|
+
"clientName": "client"
|
|
37
|
+
},
|
|
38
|
+
"cpp": {
|
|
39
|
+
"packageInfo": {
|
|
40
|
+
"git": {
|
|
41
|
+
"scope": "alibabacloud-sdk-cpp",
|
|
42
|
+
"project": "dara-util"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"swift": {
|
|
47
|
+
"clientName": "Client",
|
|
48
|
+
"packageInfo": {
|
|
49
|
+
"name": "TeaUtils",
|
|
50
|
+
"desc": "Alibaba Cloud Tea Util for Swift",
|
|
51
|
+
"github": "https://github.com/alibabacloud-sdk-swift/tea-utils",
|
|
52
|
+
"author": "Alibaba Cloud SDK",
|
|
53
|
+
"email": "sdk-team@alibabacloud.com"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"releaselog": {
|
|
57
|
+
"changelog": [
|
|
58
|
+
"[java]fix: enable getNonce() on Android platform."
|
|
59
|
+
],
|
|
60
|
+
"compatible": true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -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,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,33 @@
|
|
|
1
|
+
import DARAUtil;
|
|
2
|
+
import "../lib/util" Util;
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
model BaseInfo extends DARAUtil.RuntimeOptions {
|
|
6
|
+
maxAttemp: number,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
model Info extends BaseInfo {
|
|
10
|
+
name: string,
|
|
11
|
+
age: integer,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static async function test(): asyncIterator[string]{
|
|
16
|
+
var it:iterator[string] = Util.test1();
|
|
17
|
+
for(var test : it) {
|
|
18
|
+
yield test;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exception Err {
|
|
24
|
+
msg: string,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exception Err1 extends BaseInfo {
|
|
28
|
+
msg: string,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exception Err2 extends Err {
|
|
32
|
+
msg2: string,
|
|
33
|
+
}
|