@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
@@ -4,204 +4,145 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TypescriptGen = void 0;
7
-
8
7
  var _sdkModels = require("./sdkModels");
9
-
10
8
  var _codeGen = require("./codeGen");
11
-
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13
-
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
-
16
- 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; }
17
-
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
+ 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; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ 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); }
18
14
  class TypescriptGen extends _codeGen.CodeGen {
19
15
  constructor() {
20
16
  super(...arguments);
21
-
22
17
  _defineProperty(this, "codePath", './packages/');
23
-
24
18
  _defineProperty(this, "useFunctions", true);
25
-
26
19
  _defineProperty(this, "useInterfaces", true);
27
-
28
20
  _defineProperty(this, "packagePath", 'sdk/src');
29
-
30
21
  _defineProperty(this, "itself", 'this');
31
-
32
22
  _defineProperty(this, "fileExtension", '.ts');
33
-
34
23
  _defineProperty(this, "commentStr", '// ');
35
-
36
24
  _defineProperty(this, "nullStr", 'null');
37
-
38
25
  _defineProperty(this, "transport", 'transport');
39
-
40
26
  _defineProperty(this, "argDelimiter", ', ');
41
-
42
27
  _defineProperty(this, "paramDelimiter", ',\n');
43
-
44
28
  _defineProperty(this, "propDelimiter", '\n');
45
-
46
29
  _defineProperty(this, "indentStr", ' ');
47
-
48
30
  _defineProperty(this, "endTypeStr", '\n}');
49
-
50
31
  _defineProperty(this, "willItStream", true);
51
-
52
32
  _defineProperty(this, "useNamedParameters", false);
53
-
54
33
  _defineProperty(this, "useNamedArguments", false);
55
-
56
34
  _defineProperty(this, "rtlNeeds", new Set());
57
35
  }
58
-
59
36
  reset() {
60
37
  this.rtlNeeds = new Set();
61
38
  }
62
-
63
39
  sdkFileName(baseFileName) {
64
40
  var _this$versions;
65
-
66
41
  return this.fileName("".concat((_this$versions = this.versions) === null || _this$versions === void 0 ? void 0 : _this$versions.spec.key, "/").concat(baseFileName));
67
42
  }
68
-
69
43
  rtlImports() {
70
44
  var rtl = Array.from(this.rtlNeeds).join(', ');
71
-
72
45
  if (rtl) {
73
46
  rtl += ', ';
74
47
  }
75
-
76
48
  return rtl;
77
49
  }
78
-
79
50
  rtlImportStatement() {
80
51
  var rtl = this.rtlImports();
81
52
  return rtl ? "\nimport type { ".concat(rtl, " } from '@looker/sdk-rtl'\n") : '';
82
53
  }
83
-
84
54
  methodsPrologue(_indent) {
85
55
  return "\nimport type { ".concat(this.rtlImports(), "IAuthSession, ITransportSettings, SDKResponse } from '@looker/sdk-rtl'\nimport { APIMethods, encodeParam } from '@looker/sdk-rtl'\n/**\n * ").concat(this.warnEditing(), "\n *\n */\nimport { sdkVersion } from '../constants'\nimport type { I").concat(this.packageName, " } from './methodsInterface'\nimport type { ").concat(this.typeNames().join(', '), " } from './models'\n\nexport class ").concat(this.packageName, " extends APIMethods implements I").concat(this.packageName, " {\n static readonly ApiVersion = '").concat(this.apiVersion, "'\n constructor(authSession: IAuthSession) {\n super(authSession, sdkVersion)\n this.apiVersion = ").concat(this.packageName, ".ApiVersion\n this.apiPath =\n authSession.settings.base_url === ''\n ? ''\n : authSession.settings.base_url + '/api/' + this.apiVersion\n }\n\n");
86
56
  }
87
-
88
57
  functionsPrologue(_indent) {
89
58
  return "\nimport type { ".concat(this.rtlImports(), "IAPIMethods, IAuthSession, ITransportSettings, SDKResponse } from '@looker/sdk-rtl'\nimport { encodeParam, functionalSdk } from '@looker/sdk-rtl'\n\n/**\n * ").concat(this.warnEditing(), "\n *\n */\n\nimport { sdkVersion } from '../constants'\nimport type { ").concat(this.typeNames().join(', '), " } from './models'\n\n/**\n * Creates a \"functional sdk\" that knows the API and Looker release version\n * @param authSession authentication session\n */\nexport const functionalSdk").concat(this.apiRef, " = (\n authSession: IAuthSession,\n) => {\n return functionalSdk(authSession, '").concat(this.apiVersion, "', sdkVersion)\n}\n\n");
90
59
  }
91
-
92
60
  interfacesPrologue(_indent) {
93
61
  return "\nimport type { ".concat(this.rtlImports(), " IAPIMethods, ITransportSettings, SDKResponse } from '@looker/sdk-rtl'\n/**\n * ").concat(this.warnEditing(), "\n *\n */\nimport type { ").concat(this.typeNames().join(', '), " } from './models'\n\nexport interface I").concat(this.packageName, " extends IAPIMethods {\n\n");
94
62
  }
95
-
96
63
  streamsPrologue(_indent) {
97
64
  return "\nimport type { Readable } from 'readable-stream'\nimport type { ".concat(this.rtlImports(), "IAuthSession, ITransportSettings } from '@looker/sdk-rtl'\nimport { APIMethods, encodeParam } from '@looker/sdk-rtl'\n\n/**\n * ").concat(this.warnEditing(), "\n *\n */\nimport { sdkVersion } from '../constants'\nimport type { ").concat(this.typeNames().join(', '), " } from './models'\n\nexport class ").concat(this.packageName, "Stream extends APIMethods {\n static readonly ApiVersion = '").concat(this.apiVersion, "'\n constructor(authSession: IAuthSession) {\n super(authSession, sdkVersion)\n this.apiVersion = ").concat(this.packageName, "Stream.ApiVersion\n this.apiPath =\n authSession.settings.base_url === ''\n ? ''\n : authSession.settings.base_url + '/api/' + this.apiVersion\n }\n");
98
65
  }
99
-
100
66
  methodsEpilogue(_indent) {
101
67
  return '\n}';
102
68
  }
103
-
104
69
  modelsPrologue(_indent) {
105
70
  return "".concat(this.rtlImportStatement(), "\n/*\n * ").concat(this.warnEditing(), "\n */\n\n");
106
71
  }
107
-
108
72
  modelsEpilogue(_indent) {
109
73
  return '';
110
74
  }
111
-
112
75
  commentHeader(indent, text) {
113
76
  var commentStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' * ';
114
77
  if (this.noComment || !text) return '';
115
78
  var commentPrefix = text.includes(' License') && text.includes('Copyright (c)') ? '/*' : '/**';
116
-
117
79
  if (commentStr === ' ') {
118
80
  return "".concat(indent).concat(commentPrefix, "\n\n").concat((0, _codeGen.commentBlock)(text, indent, commentStr), "\n").concat(indent, " */\n");
119
81
  }
120
-
121
82
  return "".concat(indent).concat(commentPrefix, "\n").concat((0, _codeGen.commentBlock)(text, indent, commentStr), "\n").concat(indent, " */\n");
122
83
  }
123
-
124
84
  beginRegion(indent, description) {
125
85
  return "".concat(indent, "//#region ").concat(description);
126
86
  }
127
-
128
87
  endRegion(indent, description) {
129
88
  return "".concat(indent, "//#endregion ").concat(description);
130
89
  }
131
-
132
90
  declareProperty(indent, property) {
133
91
  var optional = !property.required ? '?' : '';
134
92
  var nullify = property.nullable ? ' | null' : '';
135
-
136
93
  if (property.name === _sdkModels.strBody) {
137
94
  property.type.refCount++;
138
95
  return this.commentHeader(indent, property.description || 'body parameter for dynamically created request type') + "".concat(indent).concat(property.name).concat(optional, ": ").concat(this.typeName(property.type)).concat(nullify);
139
96
  }
140
-
141
97
  var mapped = this.typeMap(property.type);
142
98
  return this.commentHeader(indent, this.describeProperty(property)) + "".concat(indent).concat(this.reserve(property.name)).concat(optional, ": ").concat(mapped.name).concat(nullify);
143
99
  }
144
-
145
100
  impartial(param, mapped) {
146
101
  if (param.type.intrinsic || param.location !== _sdkModels.strBody) return mapped.name;
147
102
  return "Partial<".concat(mapped.name, ">");
148
103
  }
149
-
150
104
  paramComment(param, mapped) {
151
105
  var desc = param.description || param.type.description;
152
-
153
106
  if (!desc) {
154
107
  desc = this.impartial(param, mapped);
155
108
  }
156
-
157
109
  return "@param ".concat(param.name, " ").concat((0, _sdkModels.describeParam)(_objectSpread(_objectSpread({}, param), {
158
110
  description: desc
159
111
  })));
160
112
  }
161
-
162
113
  declareParameter(indent, method, param) {
163
114
  var type = param.location === _sdkModels.strBody ? this.writeableType(param.type, method) || param.type : param.type;
164
115
  var mapped = this.typeMap(type);
165
116
  var pOpt = '';
166
117
  mapped.name = this.impartial(param, mapped);
167
-
168
118
  if (!param.required) {
169
119
  pOpt = mapped.default ? '' : '?';
170
120
  }
171
-
172
121
  return "".concat(indent).concat(this.reserve(param.name)).concat(pOpt, ": ").concat(mapped.name) + (param.required ? '' : mapped.default ? " = ".concat(mapped.default) : '');
173
122
  }
174
-
175
123
  makeTheCall(method, inputs) {
176
- inputs = (0, _codeGen.trimInputs)(inputs);
177
124
  var args = this.assignParams(method, inputs);
178
125
  var fun = "// functional SDK syntax is recommended for minimizing browser payloads\nlet response = await sdk.ok(".concat(method.name, "(sdk").concat(args ? ',' : '');
179
126
  var mono = "// monolithic SDK syntax can also be used for Node apps\nlet response = await sdk.ok(sdk.".concat(method.name, "(");
180
127
  return "".concat(fun).concat(args, "))\n").concat(mono).concat(args, "))");
181
128
  }
182
-
183
129
  methodHeaderComment(method) {
184
130
  var _method$description;
185
-
186
131
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
187
132
  if (this.noComment) return '';
188
133
  var lines = [];
189
134
  var desc = (_method$description = method.description) === null || _method$description === void 0 ? void 0 : _method$description.trim();
190
-
191
135
  if (desc) {
192
136
  lines.push(desc);
193
137
  lines.push('');
194
138
  }
195
-
196
139
  var resultType = this.typeMap(method.type).name;
197
140
  lines.push("".concat(method.httpMethod, " ").concat(method.endpoint, " -> ").concat(resultType));
198
141
  lines.push('');
199
-
200
142
  if (method.deprecated) {
201
143
  lines.push('@deprecated');
202
144
  lines.push('');
203
145
  }
204
-
205
146
  if (method.responseIsBoth()) {
206
147
  lines.push('@remarks');
207
148
  lines.push('**NOTE**: Binary content may be returned by this function.');
@@ -211,13 +152,10 @@ class TypescriptGen extends _codeGen.CodeGen {
211
152
  lines.push('**NOTE**: Binary content is returned by this function.');
212
153
  lines.push('');
213
154
  }
214
-
215
155
  params.forEach(p => lines.push("@param ".concat(p)));
216
156
  var args = method.allParams;
217
-
218
157
  if (args.length) {
219
158
  var requestType = this.requestTypeName(method);
220
-
221
159
  if (requestType) {
222
160
  requestType = method.httpMethod === 'PATCH' ? "Partial<I".concat(requestType, ">") : "I".concat(requestType);
223
161
  lines.push("@param request composed interface \"".concat(requestType, "\" for complex method parameters"));
@@ -225,12 +163,10 @@ class TypescriptGen extends _codeGen.CodeGen {
225
163
  args.forEach(p => lines.push(this.paramComment(p, this.paramMappedType(p, method))));
226
164
  }
227
165
  }
228
-
229
166
  lines.push('@param options one-time API call overrides');
230
167
  lines.push('');
231
168
  return lines.join('\n');
232
169
  }
233
-
234
170
  methodHeaderDeclaration(indent, method) {
235
171
  var streamer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
236
172
  var params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
@@ -239,7 +175,6 @@ class TypescriptGen extends _codeGen.CodeGen {
239
175
  var requestType = this.requestTypeName(method);
240
176
  var bump = this.bumper(indent);
241
177
  var headComment = streamer ? this.methodHeaderComment(method, ['callback streaming output function']) : this.methodHeaderComment(method, params);
242
-
243
178
  if (requestType) {
244
179
  fragment = method.httpMethod === 'PATCH' ? "request: Partial<I".concat(requestType, ">") : "request: I".concat(requestType);
245
180
  params.push(fragment);
@@ -249,24 +184,19 @@ class TypescriptGen extends _codeGen.CodeGen {
249
184
  if (args && args.length > 0) args.forEach(p => params.push(this.declareParameter(bump, method, p)));
250
185
  fragment = params.length > 0 ? "\n".concat(params.join(this.paramDelimiter)) : '';
251
186
  }
252
-
253
187
  var callback = "callback: (readable: Readable) => Promise<".concat(mapped.name, ">,");
254
188
  var header = this.commentHeader(indent, headComment) + "".concat(indent, "async ").concat(method.name, "(") + (streamer ? "\n".concat(bump).concat(callback) : '');
255
189
  var returns = streamer ? '' : ": ".concat(this.returnType(indent, method));
256
190
  return header + fragment + (fragment ? ', ' : '') + "options?: Partial<ITransportSettings>)".concat(returns, " {\n");
257
191
  }
258
-
259
192
  methodSignature(indent, method) {
260
193
  return this.methodHeaderDeclaration(indent, method, false);
261
194
  }
262
-
263
195
  encodePathParams(indent, method) {
264
196
  var bump = indent + this.indentStr;
265
197
  var encodings = '';
266
-
267
198
  if (method.pathParams.length > 0) {
268
199
  var prefix = this.useRequest(method) ? 'request' : '';
269
-
270
200
  for (var param of method.pathParams) {
271
201
  if (param.doEncode()) {
272
202
  var name = this.accessor(param.name, prefix);
@@ -274,28 +204,23 @@ class TypescriptGen extends _codeGen.CodeGen {
274
204
  }
275
205
  }
276
206
  }
277
-
278
207
  return encodings;
279
208
  }
280
-
281
209
  declareMethod(indent, method) {
282
210
  var bump = this.bumper(indent);
283
211
  return this.methodSignature(indent, method) + this.encodePathParams(indent, method) + this.httpCall(bump, method) + "\n".concat(indent, "}");
284
212
  }
285
-
286
213
  returnType(indent, method) {
287
214
  var mapped = this.typeMap(method.type);
288
215
  var errors = this.errorResponses(indent, method);
289
216
  return "Promise<SDKResponse<".concat(mapped.name, ", ").concat(errors, ">>");
290
217
  }
291
-
292
218
  functionSignature(indent, method) {
293
219
  var fragment;
294
220
  var requestType = this.requestTypeName(method);
295
221
  var bump = this.bumper(indent);
296
222
  var params = ['sdk: IAPIMethods'];
297
223
  var headComment = this.methodHeaderComment(method, ['sdk IAPIMethods implementation']);
298
-
299
224
  if (requestType) {
300
225
  fragment = method.httpMethod === 'PATCH' ? "request: Partial<I".concat(requestType, ">") : "request: I".concat(requestType);
301
226
  params.push(fragment);
@@ -305,12 +230,10 @@ class TypescriptGen extends _codeGen.CodeGen {
305
230
  if (args && args.length > 0) args.forEach(p => params.push(this.declareParameter(bump, method, p)));
306
231
  fragment = params.length > 0 ? "\n".concat(params.join(this.paramDelimiter)) : '';
307
232
  }
308
-
309
233
  var header = this.commentHeader(indent, headComment) + "".concat(indent, "export const ").concat(method.name, " = async (");
310
234
  var returns = this.returnType(indent, method);
311
235
  return header + fragment + (fragment ? ', ' : '') + "options?: Partial<ITransportSettings>): ".concat(returns, " => {\n");
312
236
  }
313
-
314
237
  declareFunction(indent, method) {
315
238
  var bump = this.bumper(indent);
316
239
  this.itself = 'sdk';
@@ -318,92 +241,73 @@ class TypescriptGen extends _codeGen.CodeGen {
318
241
  this.itself = 'this';
319
242
  return result;
320
243
  }
321
-
322
244
  declareInterface(indent, method) {
323
245
  var sig = this.methodSignature(indent, method).trimRight();
324
246
  sig = sig.replace(/^\s*async /gm, '');
325
247
  sig = sig.substr(0, sig.length - 2);
326
248
  return "".concat(sig, "\n");
327
249
  }
328
-
329
250
  streamerSignature(indent, method) {
330
251
  return this.methodHeaderDeclaration(indent, method, true);
331
252
  }
332
-
333
253
  declareStreamer(indent, method) {
334
254
  var bump = this.bumper(indent);
335
255
  return this.streamerSignature(indent, method) + this.encodePathParams(bump, method) + this.streamCall(bump, method) + "\n".concat(indent, "}");
336
256
  }
337
-
338
257
  reserve(name) {
339
258
  if (!(0, _sdkModels.isSpecialName)(name)) return name;
340
259
  return "'".concat(name, "'");
341
260
  }
342
-
343
261
  typeName(type) {
344
262
  type.refCount++;
345
-
346
263
  if (type.customType && !(type instanceof _sdkModels.EnumType)) {
347
264
  return this.reserve("I".concat(type.name));
348
265
  }
349
-
350
266
  return this.reserve(type.name);
351
267
  }
352
-
353
268
  typeSignature(indent, type) {
354
269
  var meta = type instanceof _sdkModels.EnumType ? 'enum' : 'interface';
355
270
  return this.commentHeader(indent, type.description) + "".concat(indent, "export ").concat(meta, " ").concat(this.typeName(type), " ").concat(this.typeOpen, "\n");
356
271
  }
357
-
358
272
  errorResponses(_indent, method) {
359
273
  var results = method.errorResponses.map(r => "".concat(this.typeName(r.type)));
360
274
  return results.join(' | ');
361
275
  }
362
-
363
276
  httpPath(path, prefix) {
364
277
  prefix = prefix || '';
365
278
  if (path.indexOf('{') >= 0) return "`".concat(path.replace(/{/gi, '${' + prefix), "`");
366
279
  return "'".concat(path, "'");
367
280
  }
368
-
369
281
  argGroup(_indent, args, prefix) {
370
282
  if (!args || args.length === 0) return this.nullStr;
371
283
  var hash = [];
372
-
373
284
  for (var arg of args) {
374
285
  var reserved = this.reserve(arg);
375
-
376
286
  if (prefix) {
377
287
  hash.push("".concat(reserved, ": ").concat(this.accessor(arg, prefix)));
378
288
  } else {
379
289
  hash.push(reserved);
380
290
  }
381
291
  }
382
-
383
292
  return "{".concat(hash.join(this.argDelimiter), "}");
384
293
  }
385
-
386
294
  accessor(name, prefix) {
387
295
  var reserved = this.reserve(name);
388
296
  if (!prefix) return reserved;
389
297
  if (reserved === name) return "".concat(prefix, ".").concat(name);
390
298
  return "".concat(prefix, "[").concat(reserved, "]");
391
299
  }
392
-
393
300
  argList(indent, args, prefix) {
394
301
  prefix = prefix || '';
395
302
  var bits = args.map(a => this.accessor(a, prefix));
396
303
  return args && args.length !== 0 ? "\n".concat(indent).concat(bits.join(this.argDelimiter)) : this.nullStr;
397
304
  }
398
-
399
305
  argFill(current, args) {
400
306
  if (!current && args.trim() === this.nullStr) {
401
307
  return '';
402
308
  }
403
-
404
309
  return "".concat(args).concat(current ? this.argDelimiter : '').concat(current);
405
310
  }
406
-
407
311
  httpArgs(indent, method) {
408
312
  var request = this.useRequest(method) ? 'request' : '';
409
313
  var result = this.argFill('', 'options');
@@ -411,7 +315,6 @@ class TypescriptGen extends _codeGen.CodeGen {
411
315
  result = this.argFill(result, this.argGroup(indent, method.queryArgs, request));
412
316
  return result;
413
317
  }
414
-
415
318
  httpCall(indent, method) {
416
319
  var request = this.useRequest(method) ? 'request.' : '';
417
320
  var mapped = this.typeMap(method.type);
@@ -420,7 +323,6 @@ class TypescriptGen extends _codeGen.CodeGen {
420
323
  var errors = this.errorResponses(indent, method);
421
324
  return "".concat(indent, "return ").concat(this.it(method.httpMethod.toLowerCase())) + "<".concat(mapped.name, ", ").concat(errors, ">(") + this.httpPath(method.endpoint, request) + "".concat(args ? ', ' + args : '', ")");
422
325
  }
423
-
424
326
  streamCall(indent, method) {
425
327
  var request = this.useRequest(method) ? 'request.' : '';
426
328
  var mapped = this.typeMap(method.type);
@@ -428,11 +330,9 @@ class TypescriptGen extends _codeGen.CodeGen {
428
330
  var args = this.httpArgs(bump, method);
429
331
  return "".concat(indent, "return ").concat(this.it('authStream'), "<").concat(mapped.name, ">(callback, '").concat(method.httpMethod.toUpperCase(), "', ").concat(this.httpPath(method.endpoint, request)).concat(args ? ', ' + args : '', ")");
430
332
  }
431
-
432
333
  summary(indent, text) {
433
334
  return this.commentHeader(indent, text);
434
335
  }
435
-
436
336
  typeNames() {
437
337
  var names = [];
438
338
  if (!this.api) return names;
@@ -440,13 +340,10 @@ class TypescriptGen extends _codeGen.CodeGen {
440
340
  Object.values(types).filter(type => type.refCount > 0 && !type.intrinsic).forEach(type => names.push(this.typeName(type)));
441
341
  return names;
442
342
  }
443
-
444
343
  typeMap(type) {
445
344
  super.typeMap(type);
446
345
  var mt = '';
447
-
448
346
  var asString = (_, v) => "'".concat(v, "'");
449
-
450
347
  var tsTypes = {
451
348
  any: {
452
349
  default: mt,
@@ -522,24 +419,20 @@ class TypescriptGen extends _codeGen.CodeGen {
522
419
  asVal: (_i, _v) => ''
523
420
  }
524
421
  };
525
-
526
422
  if (type.elementType) {
527
423
  var map = this.typeMap(type.elementType);
528
-
529
424
  switch (type.className) {
530
425
  case 'ArrayType':
531
426
  return {
532
427
  default: '[]',
533
428
  name: "".concat(map.name, "[]")
534
429
  };
535
-
536
430
  case 'HashType':
537
431
  this.rtlNeeds.add('IDictionary');
538
432
  return {
539
433
  default: '',
540
434
  name: "IDictionary<".concat(map.name, ">")
541
435
  };
542
-
543
436
  case 'DelimArrayType':
544
437
  this.rtlNeeds.add('DelimArray');
545
438
  return {
@@ -547,7 +440,6 @@ class TypescriptGen extends _codeGen.CodeGen {
547
440
  name: "DelimArray<".concat(map.name, ">"),
548
441
  asVal: (_, v) => "new DelimArray<".concat(map.name, ">([").concat(v, "])")
549
442
  };
550
-
551
443
  case 'EnumType':
552
444
  return {
553
445
  default: '',
@@ -555,10 +447,8 @@ class TypescriptGen extends _codeGen.CodeGen {
555
447
  asVal: (_, v) => "".concat(type.name, ".").concat(v)
556
448
  };
557
449
  }
558
-
559
450
  throw new Error("Don't know how to handle: ".concat(JSON.stringify(type)));
560
451
  }
561
-
562
452
  if (type.name) {
563
453
  var mapped = tsTypes[type.name];
564
454
  if (mapped && mapped.name === 'Url') this.rtlNeeds.add(mapped.name);
@@ -570,8 +460,6 @@ class TypescriptGen extends _codeGen.CodeGen {
570
460
  throw new Error('Cannot output a nameless type.');
571
461
  }
572
462
  }
573
-
574
463
  }
575
-
576
464
  exports.TypescriptGen = TypescriptGen;
577
465
  //# sourceMappingURL=typescript.gen.js.map