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