@looker/sdk-codegen 21.7.3 → 21.8.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 +23 -0
- package/lib/codeGen.d.ts +1 -1
- package/lib/codeGen.js +28 -154
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGenerators.js +0 -16
- package/lib/codeGenerators.js.map +1 -1
- package/lib/csharp.gen.js +3 -71
- package/lib/csharp.gen.js.map +1 -1
- package/lib/declarationInfo.js +0 -7
- package/lib/declarationInfo.js.map +1 -1
- package/lib/esm/codeGen.js +48 -157
- package/lib/esm/codeGen.js.map +1 -1
- package/lib/esm/codeGenerators.js +28 -20
- package/lib/esm/codeGenerators.js.map +1 -1
- package/lib/esm/csharp.gen.js +19 -75
- package/lib/esm/csharp.gen.js.map +1 -1
- package/lib/esm/declarationInfo.js +10 -7
- package/lib/esm/declarationInfo.js.map +1 -1
- package/lib/esm/exampleInfo.js +24 -23
- package/lib/esm/exampleInfo.js.map +1 -1
- package/lib/esm/go.gen.js +18 -92
- package/lib/esm/go.gen.js.map +1 -1
- package/lib/esm/index.js +148 -13
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/kotlin.gen.js +23 -118
- package/lib/esm/kotlin.gen.js.map +1 -1
- package/lib/esm/pseudo.gen.js +14 -24
- package/lib/esm/pseudo.gen.js.map +1 -1
- package/lib/esm/python.gen.js +19 -138
- package/lib/esm/python.gen.js.map +1 -1
- package/lib/esm/sdkModels.js +100 -432
- package/lib/esm/sdkModels.js.map +1 -1
- package/lib/esm/specConverter.js +58 -88
- package/lib/esm/specConverter.js.map +1 -1
- package/lib/esm/specDiff.js +36 -51
- package/lib/esm/specDiff.js.map +1 -1
- package/lib/esm/swift.gen.js +25 -137
- package/lib/esm/swift.gen.js.map +1 -1
- package/lib/esm/testUtils/index.js +17 -0
- package/lib/esm/testUtils/index.js.map +1 -0
- package/lib/esm/testUtils/testUtils.js +66 -0
- package/lib/esm/testUtils/testUtils.js.map +1 -0
- package/lib/esm/typescript.gen.js +24 -125
- package/lib/esm/typescript.gen.js.map +1 -1
- package/lib/exampleInfo.js +1 -31
- package/lib/exampleInfo.js.map +1 -1
- package/lib/go.gen.js +3 -87
- package/lib/go.gen.js.map +1 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +1 -1
- package/lib/kotlin.gen.js +7 -113
- package/lib/kotlin.gen.js.map +1 -1
- package/lib/pseudo.gen.js +3 -24
- package/lib/pseudo.gen.js.map +1 -1
- package/lib/python.gen.js +3 -133
- package/lib/python.gen.js.map +1 -1
- package/lib/sdkModels.js +8 -438
- package/lib/sdkModels.js.map +1 -1
- package/lib/specConverter.js +6 -106
- package/lib/specConverter.js.map +1 -1
- package/lib/specDiff.js +1 -56
- package/lib/specDiff.js.map +1 -1
- package/lib/swift.gen.js +3 -128
- package/lib/swift.gen.js.map +1 -1
- package/lib/testUtils/index.js +0 -2
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/testUtils.js +1 -17
- package/lib/testUtils/testUtils.js.map +1 -1
- package/lib/typescript.gen.js +5 -117
- package/lib/typescript.gen.js.map +1 -1
- package/package.json +3 -3
package/lib/esm/index.js
CHANGED
|
@@ -1,14 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _codeGen = require("./codeGen");
|
|
7
|
+
Object.keys(_codeGen).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _codeGen[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _codeGen[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _sdkModels = require("./sdkModels");
|
|
18
|
+
Object.keys(_sdkModels).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _sdkModels[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _sdkModels[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _kotlin = require("./kotlin.gen");
|
|
29
|
+
Object.keys(_kotlin).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _kotlin[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _kotlin[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _pseudo = require("./pseudo.gen");
|
|
40
|
+
Object.keys(_pseudo).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _pseudo[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _pseudo[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _python = require("./python.gen");
|
|
51
|
+
Object.keys(_python).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _python[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _python[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _swift = require("./swift.gen");
|
|
62
|
+
Object.keys(_swift).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _swift[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function get() {
|
|
68
|
+
return _swift[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _typescript = require("./typescript.gen");
|
|
73
|
+
Object.keys(_typescript).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _typescript[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function get() {
|
|
79
|
+
return _typescript[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _csharp = require("./csharp.gen");
|
|
84
|
+
Object.keys(_csharp).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _csharp[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function get() {
|
|
90
|
+
return _csharp[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _codeGenerators = require("./codeGenerators");
|
|
95
|
+
Object.keys(_codeGenerators).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _codeGenerators[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function get() {
|
|
101
|
+
return _codeGenerators[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _exampleInfo = require("./exampleInfo");
|
|
106
|
+
Object.keys(_exampleInfo).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _exampleInfo[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _exampleInfo[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _declarationInfo = require("./declarationInfo");
|
|
117
|
+
Object.keys(_declarationInfo).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _declarationInfo[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function get() {
|
|
123
|
+
return _declarationInfo[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _specDiff = require("./specDiff");
|
|
128
|
+
Object.keys(_specDiff).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _specDiff[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function get() {
|
|
134
|
+
return _specDiff[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
var _specConverter = require("./specConverter");
|
|
139
|
+
Object.keys(_specConverter).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _specConverter[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function get() {
|
|
145
|
+
return _specConverter[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
14
149
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport * from './codeGen'\nexport * from './sdkModels'\nexport * from './kotlin.gen'\nexport * from './pseudo.gen'\nexport * from './python.gen'\nexport * from './swift.gen'\nexport * from './typescript.gen'\nexport * from './csharp.gen'\nexport * from './codeGenerators'\nexport * from './exampleInfo'\nexport * from './declarationInfo'\nexport * from './specDiff'\nexport * from './specConverter'\n"],"mappings":";;;;;AA0BA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/lib/esm/kotlin.gen.js
CHANGED
|
@@ -1,122 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KotlinGen = void 0;
|
|
7
|
+
var _sdkModels = require("./sdkModels");
|
|
8
|
+
var _codeGen = require("./codeGen");
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
class KotlinGen extends _codeGen.CodeGen {
|
|
6
13
|
constructor() {
|
|
7
14
|
super(...arguments);
|
|
8
|
-
|
|
9
15
|
_defineProperty(this, "codePath", './kotlin/src/main/com/');
|
|
10
|
-
|
|
11
16
|
_defineProperty(this, "packagePath", 'looker');
|
|
12
|
-
|
|
13
17
|
_defineProperty(this, "itself", 'this');
|
|
14
|
-
|
|
15
18
|
_defineProperty(this, "fileExtension", '.kt');
|
|
16
|
-
|
|
17
19
|
_defineProperty(this, "commentStr", '// ');
|
|
18
|
-
|
|
19
20
|
_defineProperty(this, "nullStr", 'null');
|
|
20
|
-
|
|
21
21
|
_defineProperty(this, "transport", 'transport');
|
|
22
|
-
|
|
23
22
|
_defineProperty(this, "argDelimiter", ', ');
|
|
24
|
-
|
|
25
23
|
_defineProperty(this, "argSetSep", ' = ');
|
|
26
|
-
|
|
27
24
|
_defineProperty(this, "hashSetSep", ' to ');
|
|
28
|
-
|
|
29
25
|
_defineProperty(this, "arrayOpen", 'arrayOf(');
|
|
30
|
-
|
|
31
26
|
_defineProperty(this, "arrayClose", ')');
|
|
32
|
-
|
|
33
27
|
_defineProperty(this, "hashOpen", 'mapOf(');
|
|
34
|
-
|
|
35
28
|
_defineProperty(this, "hashClose", ')');
|
|
36
|
-
|
|
37
29
|
_defineProperty(this, "hashKeyQuote", '"');
|
|
38
|
-
|
|
39
30
|
_defineProperty(this, "typeOpen", '(');
|
|
40
|
-
|
|
41
31
|
_defineProperty(this, "typeClose", ')');
|
|
42
|
-
|
|
43
32
|
_defineProperty(this, "useModelClassForTypes", true);
|
|
44
|
-
|
|
45
33
|
_defineProperty(this, "paramDelimiter", ',\n');
|
|
46
|
-
|
|
47
34
|
_defineProperty(this, "propDelimiter", ',\n');
|
|
48
|
-
|
|
49
35
|
_defineProperty(this, "codeQuote", '"');
|
|
50
|
-
|
|
51
36
|
_defineProperty(this, "enumDelimiter", ',\n');
|
|
52
|
-
|
|
53
37
|
_defineProperty(this, "indentStr", ' ');
|
|
54
|
-
|
|
55
38
|
_defineProperty(this, "endTypeStr", '\n) : Serializable');
|
|
56
|
-
|
|
57
39
|
_defineProperty(this, "needsRequestTypes", false);
|
|
58
|
-
|
|
59
40
|
_defineProperty(this, "willItStream", true);
|
|
60
|
-
|
|
61
41
|
_defineProperty(this, "defaultApi", '4.0');
|
|
62
42
|
}
|
|
63
|
-
|
|
64
43
|
supportsMultiApi() {
|
|
65
44
|
return false;
|
|
66
45
|
}
|
|
67
|
-
|
|
68
46
|
isDefaultApi() {
|
|
69
47
|
return this.apiVersion === this.defaultApi;
|
|
70
48
|
}
|
|
71
|
-
|
|
72
49
|
sdkClassName() {
|
|
73
50
|
return this.isDefaultApi() ? 'LookerSDK' : "Looker".concat(this.apiRef, "SDK");
|
|
74
51
|
}
|
|
75
|
-
|
|
76
52
|
apiNamespace() {
|
|
77
53
|
if (this.apiVersion === this.defaultApi) return '';
|
|
78
54
|
return ".api".concat(this.apiRef);
|
|
79
55
|
}
|
|
80
|
-
|
|
81
56
|
methodsPrologue(_indent) {
|
|
82
57
|
return "\n// ".concat(this.warnEditing(), "\npackage com.looker.sdk").concat(this.apiNamespace(), "\n\nimport com.looker.rtl.*\nimport java.util.*\n\nclass ").concat(this.sdkClassName(), "(authSession: AuthSession) : APIMethods(authSession) {\n\n val stream by lazy { ").concat(this.sdkClassName(), "Stream(this.authSession) }\n");
|
|
83
58
|
}
|
|
84
|
-
|
|
85
59
|
streamsPrologue(_indent) {
|
|
86
60
|
return "\n// ".concat(this.warnEditing(), "\npackage com.looker.sdk").concat(this.apiNamespace(), "\n\nimport com.looker.rtl.*\nimport java.util.*\n\nclass ").concat(this.sdkClassName(), "Stream(authSession: AuthSession) : APIMethods(authSession) {\n\n");
|
|
87
61
|
}
|
|
88
|
-
|
|
89
62
|
methodsEpilogue(_indent) {
|
|
90
63
|
return '\n}';
|
|
91
64
|
}
|
|
92
|
-
|
|
93
65
|
modelsPrologue(_indent) {
|
|
94
66
|
return "\n// ".concat(this.warnEditing(), "\n\npackage com.looker.sdk").concat(this.apiNamespace(), "\n\nimport com.looker.rtl.*\nimport java.io.Serializable\nimport java.util.*\n");
|
|
95
67
|
}
|
|
96
|
-
|
|
97
68
|
modelsEpilogue(_indent) {
|
|
98
69
|
return '';
|
|
99
70
|
}
|
|
100
|
-
|
|
101
71
|
commentHeader(indent, text) {
|
|
102
72
|
var commentStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' * ';
|
|
103
73
|
if (this.noComment || !text) return '';
|
|
104
|
-
|
|
105
74
|
if (commentStr === ' ') {
|
|
106
|
-
return "".concat(indent, "/**\n\n").concat(commentBlock(text, indent, commentStr), "\n").concat(indent, " */\n");
|
|
75
|
+
return "".concat(indent, "/**\n\n").concat((0, _codeGen.commentBlock)(text, indent, commentStr), "\n").concat(indent, " */\n");
|
|
107
76
|
}
|
|
108
|
-
|
|
109
|
-
return "".concat(indent, "/**\n").concat(commentBlock(text, indent, commentStr), "\n").concat(indent, " */\n");
|
|
77
|
+
return "".concat(indent, "/**\n").concat((0, _codeGen.commentBlock)(text, indent, commentStr), "\n").concat(indent, " */\n");
|
|
110
78
|
}
|
|
111
|
-
|
|
112
79
|
beginRegion(indent, description) {
|
|
113
80
|
return "".concat(indent, "//region ").concat(description);
|
|
114
81
|
}
|
|
115
|
-
|
|
116
82
|
endRegion(indent, description) {
|
|
117
83
|
return "".concat(indent, "//endregion ").concat(description);
|
|
118
84
|
}
|
|
119
|
-
|
|
120
85
|
declareProperty(indent, property) {
|
|
121
86
|
var optional = !property.required ? '? = null' : '';
|
|
122
87
|
var type = this.typeMap(property.type);
|
|
@@ -124,22 +89,17 @@ export class KotlinGen extends CodeGen {
|
|
|
124
89
|
var result = "".concat(attr).concat(indent, "var ").concat(property.name, ": ").concat(type.name).concat(optional);
|
|
125
90
|
return result;
|
|
126
91
|
}
|
|
127
|
-
|
|
128
92
|
paramComment(param, mapped) {
|
|
129
|
-
return "@param {".concat(mapped.name, "} ").concat(param.name, " ").concat(describeParam(param));
|
|
93
|
+
return "@param {".concat(mapped.name, "} ").concat(param.name, " ").concat((0, _sdkModels.describeParam)(param));
|
|
130
94
|
}
|
|
131
|
-
|
|
132
95
|
declareParameter(indent, method, param) {
|
|
133
96
|
var mapped = this.paramMappedType(param, method);
|
|
134
97
|
var pOpt = '';
|
|
135
|
-
|
|
136
98
|
if (!param.required) {
|
|
137
99
|
pOpt = '?';
|
|
138
100
|
}
|
|
139
|
-
|
|
140
101
|
return "".concat(indent).concat(param.name, ": ").concat(mapped.name).concat(pOpt) + (param.required ? '' : mapped.default ? " = ".concat(mapped.default) : '');
|
|
141
102
|
}
|
|
142
|
-
|
|
143
103
|
assignType(indent, type, inputs) {
|
|
144
104
|
var result = super.assignType(indent, type, inputs);
|
|
145
105
|
if (result || type.className !== 'DelimArrayType') return result;
|
|
@@ -152,61 +112,47 @@ export class KotlinGen extends CodeGen {
|
|
|
152
112
|
var nl = ",\n".concat(bump);
|
|
153
113
|
return "".concat(open, "\n").concat(bump).concat(args.join(nl), "\n").concat(indent).concat(this.typeClose);
|
|
154
114
|
}
|
|
155
|
-
|
|
156
115
|
assignParams(method, inputs) {
|
|
157
116
|
var args = [];
|
|
158
117
|
var hasComplexArg = false;
|
|
159
|
-
|
|
160
118
|
if (Object.keys(inputs).length > 0) {
|
|
161
|
-
method.allParams
|
|
119
|
+
var params = method.allParams;
|
|
120
|
+
params.forEach(p => {
|
|
162
121
|
var v = this.argValue(this.indentStr, p, inputs);
|
|
163
|
-
|
|
164
122
|
if (v !== '') {
|
|
165
123
|
var arg = !p.required ? "".concat(p.name).concat(this.argSetSep).concat(v) : v;
|
|
166
124
|
args.push(arg);
|
|
167
|
-
|
|
168
125
|
if (!p.type.intrinsic) {
|
|
169
126
|
hasComplexArg = true;
|
|
170
127
|
}
|
|
171
128
|
}
|
|
172
129
|
});
|
|
173
130
|
}
|
|
174
|
-
|
|
175
131
|
var open = '';
|
|
176
|
-
|
|
177
132
|
if (args.length > 1 || hasComplexArg) {
|
|
178
133
|
open = "\n".concat(this.indentStr);
|
|
179
134
|
}
|
|
180
|
-
|
|
181
135
|
return args.length > 0 ? "".concat(open).concat(args.join(this.argDelimiter)) : '';
|
|
182
136
|
}
|
|
183
|
-
|
|
184
137
|
makeTheCall(method, inputs) {
|
|
185
138
|
var _method$returnType;
|
|
186
|
-
|
|
187
|
-
inputs = trimInputs(inputs);
|
|
188
139
|
var typeName = (_method$returnType = method.returnType) !== null && _method$returnType !== void 0 && _method$returnType.type ? this.typeMap(method.returnType.type).name : 'String';
|
|
189
140
|
var resp = "val response = await sdk.ok<".concat(typeName, ">(sdk.").concat(method.name, "(");
|
|
190
141
|
var args = this.assignParams(method, inputs);
|
|
191
142
|
return "".concat(resp).concat(args, "))");
|
|
192
143
|
}
|
|
193
|
-
|
|
194
144
|
methodHeaderComment(method) {
|
|
195
145
|
var _method$description;
|
|
196
|
-
|
|
197
146
|
var streamer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
198
147
|
var lines = [];
|
|
199
148
|
lines.push((_method$description = method.description) === null || _method$description === void 0 ? void 0 : _method$description.trim());
|
|
200
|
-
|
|
201
149
|
if (method.allParams.length) {
|
|
202
150
|
lines.push('');
|
|
203
151
|
method.allParams.forEach(p => lines.push(this.paramComment(p, this.paramMappedType(p, method))));
|
|
204
152
|
}
|
|
205
|
-
|
|
206
153
|
var resultType = streamer ? 'ByteArray' : this.typeMap(method.type).name;
|
|
207
154
|
lines.push('');
|
|
208
155
|
lines.push("".concat(method.httpMethod, " ").concat(method.endpoint, " -> ").concat(resultType));
|
|
209
|
-
|
|
210
156
|
if (method.responseIsBoth()) {
|
|
211
157
|
lines.push('');
|
|
212
158
|
lines.push('**Note**: Binary content may be returned by this method.');
|
|
@@ -214,10 +160,8 @@ export class KotlinGen extends CodeGen {
|
|
|
214
160
|
lines.push('');
|
|
215
161
|
lines.push('**Note**: Binary content is returned by this method.');
|
|
216
162
|
}
|
|
217
|
-
|
|
218
163
|
return lines.join('\n');
|
|
219
164
|
}
|
|
220
|
-
|
|
221
165
|
methodHeaderDeclaration(indent, method) {
|
|
222
166
|
var streamer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
223
167
|
var bump = indent + this.indentStr;
|
|
@@ -226,55 +170,43 @@ export class KotlinGen extends CodeGen {
|
|
|
226
170
|
if (args && args.length > 0) args.forEach(p => params.push(this.declareParameter(bump, method, p)));
|
|
227
171
|
return "\n".concat(this.commentHeader(indent, this.methodHeaderComment(method, streamer)).trimEnd(), "\n").concat(this.deprecated(indent, method)).concat(indent).concat(this.jvmOverloads(method), "fun ").concat(method.name, "(\n").concat(params.join(this.paramDelimiter), "\n").concat(indent, ") : SDKResponse {\n");
|
|
228
172
|
}
|
|
229
|
-
|
|
230
173
|
deprecated(indent, method) {
|
|
231
174
|
return method.deprecated ? "".concat(indent, "@Deprecated(message = \"Deprecated method\")\n") : '';
|
|
232
175
|
}
|
|
233
|
-
|
|
234
176
|
jvmOverloads(method) {
|
|
235
177
|
return method.optionalParams.length > 0 ? '@JvmOverloads ' : '';
|
|
236
178
|
}
|
|
237
|
-
|
|
238
179
|
methodSignature(indent, method) {
|
|
239
180
|
return this.methodHeaderDeclaration(indent, method, false);
|
|
240
181
|
}
|
|
241
|
-
|
|
242
182
|
encodePathParams(indent, method) {
|
|
243
183
|
var encodings = '';
|
|
244
|
-
|
|
245
184
|
if (method.pathParams.length > 0) {
|
|
246
185
|
for (var param of method.pathParams) {
|
|
247
186
|
encodings += "".concat(indent, "val path_").concat(param.name, " = encodeParam(").concat(param.name, ")\n");
|
|
248
187
|
}
|
|
249
188
|
}
|
|
250
|
-
|
|
251
189
|
return encodings;
|
|
252
190
|
}
|
|
253
|
-
|
|
254
191
|
declareMethod(indent, method) {
|
|
255
192
|
var bump = this.bumper(indent);
|
|
256
193
|
return this.methodSignature(indent, method) + this.encodePathParams(bump, method) + this.httpCall(bump, method) + "\n".concat(indent, "}");
|
|
257
194
|
}
|
|
258
|
-
|
|
259
195
|
streamerSignature(indent, method) {
|
|
260
196
|
return this.methodHeaderDeclaration(indent, method, true);
|
|
261
197
|
}
|
|
262
|
-
|
|
263
198
|
declareStreamer(indent, method) {
|
|
264
199
|
var bump = this.bumper(indent);
|
|
265
200
|
return this.streamerSignature(indent, method) + this.encodePathParams(bump, method) + this.streamCall(bump, method) + "\n".concat(indent, "}");
|
|
266
201
|
}
|
|
267
|
-
|
|
268
202
|
declareEnumValue(indent, value) {
|
|
269
|
-
return "".concat(indent).concat(mayQuote(value));
|
|
203
|
+
return "".concat(indent).concat((0, _sdkModels.mayQuote)(value));
|
|
270
204
|
}
|
|
271
|
-
|
|
272
205
|
describeProperty(property) {
|
|
273
206
|
return "@property ".concat(property.name, " ").concat(super.describeProperty(property));
|
|
274
207
|
}
|
|
275
|
-
|
|
276
208
|
typeSignature(indent, type) {
|
|
277
|
-
if (type instanceof EnumType) {
|
|
209
|
+
if (type instanceof _sdkModels.EnumType) {
|
|
278
210
|
return "\n".concat(this.commentHeader(indent, type.description).trim(), "\n").concat(indent, "enum class ").concat(type.name, " : Serializable {\n").trim();
|
|
279
211
|
} else {
|
|
280
212
|
var props = Object.values(type.properties).map(prop => this.describeProperty(prop));
|
|
@@ -282,35 +214,28 @@ export class KotlinGen extends CodeGen {
|
|
|
282
214
|
return "\n".concat(this.commentHeader(indent, header).trim(), "\n").concat(indent, "data class ").concat(type.name, " (\n").trim();
|
|
283
215
|
}
|
|
284
216
|
}
|
|
285
|
-
|
|
286
217
|
declareType(indent, type) {
|
|
287
218
|
var bump = this.bumper(indent);
|
|
288
|
-
|
|
289
|
-
if (type instanceof EnumType) {
|
|
219
|
+
if (type instanceof _sdkModels.EnumType) {
|
|
290
220
|
var num = type;
|
|
291
221
|
var props = num.values.map(value => this.declareEnumValue(bump, value));
|
|
292
222
|
return "\n".concat(this.typeSignature(indent, type), "\n").concat(props.join(this.enumDelimiter), "\n}\n").trim();
|
|
293
223
|
} else {
|
|
294
224
|
var _props = Object.values(type.properties).map(prop => this.declareProperty(bump, prop));
|
|
295
|
-
|
|
296
225
|
return "\n".concat(this.typeSignature(indent, type), "\n").concat(_props.join(this.propDelimiter), "\n) : Serializable\n").trim();
|
|
297
226
|
}
|
|
298
227
|
}
|
|
299
|
-
|
|
300
228
|
errorResponses(_indent, _method) {
|
|
301
229
|
return '';
|
|
302
230
|
}
|
|
303
|
-
|
|
304
231
|
httpPath(path, prefix) {
|
|
305
232
|
prefix = prefix || '';
|
|
306
233
|
if (path.indexOf('{') >= 0) return '"' + path.replace(/{/gi, '${path_' + prefix) + '"';
|
|
307
234
|
return "\"".concat(path, "\"");
|
|
308
235
|
}
|
|
309
|
-
|
|
310
236
|
argGroup(indent, args, prefix) {
|
|
311
237
|
if (!args || args.length === 0) return 'mapOf()';
|
|
312
238
|
var hash = [];
|
|
313
|
-
|
|
314
239
|
for (var arg of args) {
|
|
315
240
|
if (prefix) {
|
|
316
241
|
hash.push("\"".concat(arg, "\" to ").concat(prefix).concat(arg));
|
|
@@ -318,73 +243,59 @@ export class KotlinGen extends CodeGen {
|
|
|
318
243
|
hash.push("\"".concat(arg, "\" to ").concat(arg));
|
|
319
244
|
}
|
|
320
245
|
}
|
|
321
|
-
|
|
322
246
|
var bump = this.bumper(indent);
|
|
323
247
|
var argBump = this.bumper(bump);
|
|
324
248
|
var argWrapper = ",\n ".concat(argBump);
|
|
325
249
|
return "\n".concat(bump, "mapOf(").concat(hash.join(argWrapper), ")");
|
|
326
250
|
}
|
|
327
|
-
|
|
328
251
|
argList(indent, args, prefix) {
|
|
329
252
|
prefix = prefix || '';
|
|
330
253
|
return args && args.length !== 0 ? "\n".concat(indent).concat(prefix).concat(args.join(this.argDelimiter + prefix)) : this.nullStr;
|
|
331
254
|
}
|
|
332
|
-
|
|
333
255
|
argFill(current, args) {
|
|
334
256
|
if (!current && args.trim() === this.nullStr) {
|
|
335
257
|
return '';
|
|
336
258
|
}
|
|
337
|
-
|
|
338
259
|
return "".concat(args).concat(current ? this.argDelimiter : '').concat(current);
|
|
339
260
|
}
|
|
340
|
-
|
|
341
261
|
httpArgs(indent, method) {
|
|
342
262
|
var request = this.useRequest(method) ? 'request.' : '';
|
|
343
263
|
var result = this.argFill('', method.bodyArg ? "".concat(request).concat(method.bodyArg) : this.nullStr);
|
|
344
264
|
result = this.argFill(result, this.argGroup(indent, method.queryArgs, request));
|
|
345
265
|
return result;
|
|
346
266
|
}
|
|
347
|
-
|
|
348
267
|
httpCall(indent, method) {
|
|
349
268
|
var request = this.useRequest(method) ? 'request.' : '';
|
|
350
269
|
var type = this.typeMap(method.type);
|
|
351
270
|
var args = this.httpArgs(indent, method);
|
|
352
271
|
return "".concat(indent, "return ").concat(this.it(method.httpMethod.toLowerCase()), "<").concat(type.name, ">(").concat(this.httpPath(method.endpoint, request)).concat(args ? ', ' + args : '', ")");
|
|
353
272
|
}
|
|
354
|
-
|
|
355
273
|
streamCall(indent, method) {
|
|
356
274
|
var request = this.useRequest(method) ? 'request.' : '';
|
|
357
275
|
var bump = indent + this.indentStr;
|
|
358
276
|
var args = this.httpArgs(bump, method);
|
|
359
277
|
return "".concat(bump, "return ").concat(this.it(method.httpMethod.toLowerCase()), "<ByteArray>(").concat(this.httpPath(method.endpoint, request)).concat(args ? ', ' + args : '', ")");
|
|
360
278
|
}
|
|
361
|
-
|
|
362
279
|
summary(indent, text) {
|
|
363
280
|
return this.commentHeader(indent, text);
|
|
364
281
|
}
|
|
365
|
-
|
|
366
282
|
typeNames() {
|
|
367
283
|
var countError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
368
284
|
var names = [];
|
|
369
285
|
if (!this.api) return names;
|
|
370
|
-
|
|
371
286
|
if (countError) {
|
|
372
287
|
this.api.types.Error.refCount++;
|
|
373
288
|
} else {
|
|
374
289
|
this.api.types.Error.refCount = 0;
|
|
375
290
|
}
|
|
376
|
-
|
|
377
291
|
var types = this.api.types;
|
|
378
292
|
Object.values(types).filter(type => type.refCount > 0 && !type.intrinsic).forEach(type => names.push("I".concat(type.name)));
|
|
379
293
|
return names;
|
|
380
294
|
}
|
|
381
|
-
|
|
382
295
|
typeMap(type) {
|
|
383
296
|
super.typeMap(type);
|
|
384
297
|
var mt = this.nullStr;
|
|
385
|
-
|
|
386
298
|
var asString = (_, v) => "\"".concat(v, "\"");
|
|
387
|
-
|
|
388
299
|
var ktTypes = {
|
|
389
300
|
any: {
|
|
390
301
|
default: mt,
|
|
@@ -460,17 +371,14 @@ export class KotlinGen extends CodeGen {
|
|
|
460
371
|
asVal: (_i, _v) => 'String'
|
|
461
372
|
}
|
|
462
373
|
};
|
|
463
|
-
|
|
464
374
|
if (type.elementType) {
|
|
465
375
|
var map = this.typeMap(type.elementType);
|
|
466
|
-
|
|
467
376
|
switch (type.className) {
|
|
468
377
|
case 'ArrayType':
|
|
469
378
|
return {
|
|
470
379
|
default: this.nullStr,
|
|
471
380
|
name: "Array<".concat(map.name, ">")
|
|
472
381
|
};
|
|
473
|
-
|
|
474
382
|
case 'HashType':
|
|
475
383
|
{
|
|
476
384
|
var mapName = type.elementType.name === 'string' ? 'Any' : map.name;
|
|
@@ -479,13 +387,12 @@ export class KotlinGen extends CodeGen {
|
|
|
479
387
|
name: 'Map<String' + ",".concat(mapName, ">")
|
|
480
388
|
};
|
|
481
389
|
}
|
|
482
|
-
|
|
483
390
|
case 'DelimArrayType':
|
|
484
391
|
return {
|
|
485
392
|
default: this.nullStr,
|
|
486
|
-
name: "DelimArray<".concat(map.name, ">")
|
|
393
|
+
name: "DelimArray<".concat(map.name, ">"),
|
|
394
|
+
asVal: (_, v) => "DelimArray<".concat(map.name, ">(arrayOf(").concat(v, "))")
|
|
487
395
|
};
|
|
488
|
-
|
|
489
396
|
case 'EnumType':
|
|
490
397
|
return {
|
|
491
398
|
default: '',
|
|
@@ -493,10 +400,8 @@ export class KotlinGen extends CodeGen {
|
|
|
493
400
|
asVal: (_, v) => "".concat(type.name, ".").concat(v)
|
|
494
401
|
};
|
|
495
402
|
}
|
|
496
|
-
|
|
497
403
|
throw new Error("Don't know how to handle: ".concat(JSON.stringify(type)));
|
|
498
404
|
}
|
|
499
|
-
|
|
500
405
|
if (type.name) {
|
|
501
406
|
return ktTypes[type.name] || {
|
|
502
407
|
default: this.nullStr,
|
|
@@ -506,6 +411,6 @@ export class KotlinGen extends CodeGen {
|
|
|
506
411
|
throw new Error('Cannot output a nameless type.');
|
|
507
412
|
}
|
|
508
413
|
}
|
|
509
|
-
|
|
510
414
|
}
|
|
415
|
+
exports.KotlinGen = KotlinGen;
|
|
511
416
|
//# sourceMappingURL=kotlin.gen.js.map
|