@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.
Files changed (71) hide show
  1. package/CHANGELOG.md +23 -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/swift.gen.js CHANGED
@@ -4,155 +4,109 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.SwiftGen = 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 SwiftGen extends _codeGen.CodeGen {
15
13
  constructor() {
16
14
  super(...arguments);
17
-
18
15
  _defineProperty(this, "anyString", true);
19
-
20
16
  _defineProperty(this, "codePath", './swift/');
21
-
22
17
  _defineProperty(this, "packagePath", 'looker');
23
-
24
18
  _defineProperty(this, "itself", 'self');
25
-
26
19
  _defineProperty(this, "fileExtension", '.swift');
27
-
28
20
  _defineProperty(this, "commentStr", '// ');
29
-
30
21
  _defineProperty(this, "nullStr", 'nil');
31
-
32
22
  _defineProperty(this, "transport", 'transport');
33
-
34
23
  _defineProperty(this, "argDelimiter", ', ');
35
-
36
24
  _defineProperty(this, "paramDelimiter", ',\n');
37
-
38
25
  _defineProperty(this, "propDelimiter", '\n');
39
-
40
26
  _defineProperty(this, "enumDelimiter", '\n');
41
-
42
27
  _defineProperty(this, "codeQuote", '"');
43
-
44
28
  _defineProperty(this, "indentStr", ' ');
45
-
46
29
  _defineProperty(this, "endTypeStr", "\n}");
47
-
48
30
  _defineProperty(this, "needsRequestTypes", false);
49
-
50
31
  _defineProperty(this, "willItStream", true);
51
-
52
32
  _defineProperty(this, "keywords", new Set(['associatedtype', 'class', 'deinit', 'enum', 'extension', 'fileprivate', 'func', 'import', 'init', 'inout', 'internal', 'let', 'open', 'operator', 'private', 'protocol', 'public', 'static', 'struct', 'subscript', 'typealias', 'var', 'break', 'case', 'continue', 'default', 'defer', 'do', 'else', 'fallthrough', 'for', 'guard', 'if', 'in', 'repeat', 'return', 'switch', 'where', 'while', 'as', 'Any', 'catch', 'false', 'is', 'nil', 'rethrows', 'super', 'self', 'Self', 'throw', 'throws', 'true', 'try', '_', '#available', '#colorLiteral', '#column', '#else', '#elseif', '#endif', '#file', '#fileLiteral', '#function', '#if', '#imageLiteral', '#line', '#selector', 'and #sourceLocation', 'associativity', 'convenience', 'dynamic', 'didSet', 'final', 'get', 'infix', 'indirect', 'lazy', 'left', 'mutating', 'none', 'nonmutating', 'optional', 'override', 'postfix', 'precedence', 'prefix', 'Protocol', 'right', 'set', 'Type', 'unowned', 'weak', 'willSet']));
53
33
  }
54
-
55
34
  supportsMultiApi() {
56
35
  return false;
57
36
  }
58
-
59
37
  methodsPrologue(_indent) {
60
38
  return "\n/// ".concat(this.warnEditing(), "\n\nimport Foundation\n\n@available(OSX 10.15, *)\nopen class ").concat(this.packageName, ": APIMethods {\n\n").concat(this.indentStr, "public lazy var stream = ").concat(this.packageName, "Stream(authSession)\n");
61
39
  }
62
-
63
40
  streamsPrologue(_indent) {
64
41
  return "\n/// ".concat(this.warnEditing(), "\n\nimport Foundation\n\n@available(OSX 10.15, *)\nopen class ").concat(this.packageName, "Stream: APIMethods {\n");
65
42
  }
66
-
67
43
  methodsEpilogue(_indent) {
68
44
  return '\n}';
69
45
  }
70
-
71
46
  modelsPrologue(_indent) {
72
47
  return "\n/// ".concat(this.warnEditing(), "\n\nimport Foundation\n");
73
48
  }
74
-
75
49
  modelsEpilogue(_indent) {
76
50
  return '\n';
77
51
  }
78
-
79
52
  reserve(name) {
80
53
  if (this.keywords.has(name)) {
81
54
  return "`".concat(name, "`");
82
55
  }
83
-
84
56
  return name;
85
57
  }
86
-
87
58
  sdkFileName(baseFileName) {
88
59
  return this.fileName("sdk/".concat(baseFileName));
89
60
  }
90
-
91
61
  commentHeader(indent, text) {
92
62
  var commentStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' * ';
93
63
  if (this.noComment || !text) return '';
94
-
95
64
  if (commentStr === ' ') {
96
65
  return "".concat(indent, "/**\n\n").concat((0, _codeGen.commentBlock)(text, indent, commentStr), "\n").concat(indent, " */\n");
97
66
  }
98
-
99
67
  return "".concat(indent, "/**\n").concat((0, _codeGen.commentBlock)(text, indent, commentStr), "\n").concat(indent, " */\n");
100
68
  }
101
-
102
69
  beginRegion(indent, description) {
103
70
  return "".concat(indent, "// MARK ").concat(description);
104
71
  }
105
-
106
72
  endRegion(_indent, _description) {
107
73
  return '';
108
74
  }
109
-
110
75
  isIdProp(_property) {
111
76
  return true;
112
77
  }
113
-
114
78
  itemType(property) {
115
79
  if ((0, _sdkModels.typeOfType)(property.type) === _sdkModels.TypeOfType.Array && property.type.elementType) {
116
80
  return property.type.elementType;
117
81
  }
118
-
119
82
  return property.type;
120
83
  }
121
-
122
84
  useAnyString(property) {
123
85
  var typeCheck = this.itemType(property).name.toLowerCase();
124
86
  return this.anyString && typeCheck === 'string' && this.isIdProp(property);
125
87
  }
126
-
127
88
  useAnyInt(property) {
128
89
  var typeCheck = this.itemType(property).name.toLowerCase();
129
90
  return this.anyString && (typeCheck === 'integer' || typeCheck === 'int64') && this.isIdProp(property);
130
91
  }
131
-
132
92
  privy(name) {
133
93
  return this.reserve('_' + name.replace(/`/g, ''));
134
94
  }
135
-
136
95
  getSpecialHandling(property) {
137
96
  return this.useAnyString(property) ? 'AnyString' : this.useAnyInt(property) ? 'AnyInt' : '';
138
97
  }
139
-
140
98
  declareProperty(indent, property) {
141
99
  var optional = property.required ? '' : '?';
142
-
143
100
  if (property.name === _sdkModels.strBody) {
144
101
  property.type.refCount++;
145
102
  return this.commentHeader(indent, property.description || 'body parameter for dynamically created request type') + "".concat(indent, "var ").concat(this.reserve(property.name), ": ").concat(property.type.name).concat(optional);
146
103
  }
147
-
148
104
  var type = this.typeMap(property.type);
149
105
  var specialHandling = this.getSpecialHandling(property);
150
106
  var munge = '';
151
107
  var declaration = "".concat(indent, "public var ").concat(this.reserve(property.name), ": ").concat(type.name).concat(optional, "\n");
152
-
153
108
  if (specialHandling) {
154
109
  var ra = (0, _sdkModels.typeOfType)(property.type) === _sdkModels.TypeOfType.Array;
155
-
156
110
  var privy = this.reserve('_' + property.name);
157
111
  var bump = this.bumper(indent);
158
112
  var setter = property.required ? ra ? "".concat(privy, " = newValue.map { ").concat(specialHandling, ".init($0) }") : "".concat(privy, " = ").concat(specialHandling, ".init(newValue)") : ra ? "if let v = newValue { ".concat(privy, " = v.map { ").concat(specialHandling, ".init($0) } } else { ").concat(privy, " = nil }") : "".concat(privy, " = newValue.map(").concat(specialHandling, ".init)");
@@ -160,60 +114,46 @@ class SwiftGen extends _codeGen.CodeGen {
160
114
  munge = ra ? "".concat(indent, "private var ").concat(privy, ": [").concat(specialHandling, "]").concat(optional, "\n") : "".concat(indent, "private var ").concat(privy, ": ").concat(specialHandling).concat(optional, "\n");
161
115
  declaration = "".concat(indent, "public var ").concat(this.reserve(property.name), ": ").concat(type.name).concat(optional, " {\n").concat(bump, "get { ").concat(getter, " }\n").concat(bump, "set { ").concat(setter, " }\n").concat(indent, "}\n");
162
116
  }
163
-
164
117
  return munge + this.commentHeader(indent, this.describeProperty(property)) + declaration;
165
118
  }
166
-
167
119
  paramComment(param, mapped) {
168
120
  return "@param {".concat(mapped.name, "} ").concat(param.name, " ").concat((0, _sdkModels.describeParam)(param));
169
121
  }
170
-
171
122
  declareParameter(indent, method, param) {
172
123
  var type = param.location === _sdkModels.strBody ? this.writeableType(param.type, method) || param.type : param.type;
173
124
  var mapped = this.typeMap(type);
174
125
  var pOpt = '';
175
126
  var line = '';
176
-
177
127
  if (param.location === _sdkModels.strBody) {
178
128
  mapped.name = "".concat(mapped.name);
179
129
  }
180
-
181
130
  if (!param.required) {
182
131
  pOpt = '?';
183
132
  } else {
184
133
  line = '_ ';
185
134
  }
186
-
187
135
  return this.commentHeader(indent, this.paramComment(param, mapped)) + "".concat(indent).concat(line).concat(this.reserve(param.name), ": ").concat(mapped.name).concat(pOpt) + (param.required ? '' : mapped.default ? " = ".concat(mapped.default) : '');
188
136
  }
189
-
190
137
  initProp(prop) {
191
138
  var propName = this.reserve(prop.name);
192
139
  var specialHandling = this.getSpecialHandling(prop);
193
-
194
140
  if (specialHandling) {
195
141
  var ra = (0, _sdkModels.typeOfType)(prop.type) === _sdkModels.TypeOfType.Array;
196
-
197
142
  var varName = this.privy(propName);
198
-
199
143
  if (prop.required) {
200
144
  if (ra) {
201
145
  return "".concat(this.it(varName), " = ").concat(propName, ".map { ").concat(specialHandling, ".init($0) }");
202
146
  }
203
-
204
147
  return "".concat(this.it(varName), " = ").concat(specialHandling, ".init(").concat(propName, ")");
205
148
  } else {
206
149
  if (ra) {
207
150
  return "if let v = ".concat(propName, " { ").concat(varName, " = v.map { ").concat(specialHandling, ".init($0) } } else { ").concat(varName, " = nil }");
208
151
  }
209
-
210
152
  return "".concat(this.it(varName), " = ").concat(propName, ".map(").concat(specialHandling, ".init)");
211
153
  }
212
154
  }
213
-
214
155
  return "".concat(this.it(propName), " = ").concat(propName);
215
156
  }
216
-
217
157
  construct(indent, type) {
218
158
  if (type instanceof _sdkModels.EnumType) return '';
219
159
  indent = this.bumper(indent);
@@ -232,47 +172,37 @@ class SwiftGen extends _codeGen.CodeGen {
232
172
  });
233
173
  var namedInit = "".concat(indent, "public init(") + "".concat(args.join(this.argDelimiter), ") {\n") + inits.join('\n') + "\n".concat(indent, "}");
234
174
  var posInit = '';
235
-
236
175
  if (props.some(p => p.required)) {
237
176
  posInit = "\n".concat(indent, "public init(") + "".concat(posArgs.join(this.argDelimiter), ") {\n") + "".concat(bump).concat(this.it('init'), "(").concat(posInits.join(', '), ")") + "\n".concat(indent, "}\n");
238
177
  }
239
-
240
178
  return "\n".concat(namedInit, "\n").concat(posInit);
241
179
  }
242
-
243
180
  declarePositionalArg(indent, property) {
244
181
  var mappedType = this.typeMap(property.type);
245
182
  var propType;
246
183
  var line = '_ ';
247
-
248
184
  if (property.required) {
249
185
  propType = mappedType.name;
250
186
  } else {
251
187
  line = '';
252
188
  propType = "".concat(mappedType.name, "? = ").concat(this.nullStr);
253
189
  }
254
-
255
190
  var propName = this.reserve(property.name);
256
191
  return "".concat(indent).concat(line).concat(propName, ": ").concat(propType);
257
192
  }
258
-
259
193
  declareConstructorArg(indent, property) {
260
194
  var mappedType = this.typeMap(property.type);
261
195
  var propType;
262
-
263
196
  if (property.required) {
264
197
  propType = mappedType.name;
265
198
  } else {
266
199
  propType = "".concat(mappedType.name, "? = ").concat(this.nullStr);
267
200
  }
268
-
269
201
  var propName = this.reserve(property.name);
270
202
  return "".concat(indent).concat(propName, ": ").concat(propType);
271
203
  }
272
-
273
204
  methodHeaderDeclaration(indent, method) {
274
205
  var _method$description;
275
-
276
206
  var streamer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
277
207
  var type = this.typeMap(method.type);
278
208
  var resultType = streamer ? 'Data' : type.name;
@@ -282,7 +212,6 @@ class SwiftGen extends _codeGen.CodeGen {
282
212
  var fragment;
283
213
  var requestType = this.requestTypeName(method);
284
214
  var bump = indent + this.indentStr;
285
-
286
215
  if (requestType) {
287
216
  fragment = "request: I".concat(requestType);
288
217
  } else {
@@ -291,55 +220,44 @@ class SwiftGen extends _codeGen.CodeGen {
291
220
  if (args && args.length > 0) args.forEach(p => params.push(this.declareParameter(bump, method, p)));
292
221
  fragment = params.length > 0 ? "\n".concat(params.join(this.paramDelimiter)) : '';
293
222
  }
294
-
295
223
  if (method.responseIsBoth()) {
296
224
  headComment += "\n\n**Note**: Binary content may be returned by this method.";
297
225
  } else if (method.responseIsBinary()) {
298
226
  headComment += "\n\n**Note**: Binary content is returned by this method.\n";
299
227
  }
300
-
301
228
  var dep = method.deprecated ? "".concat(indent, "@available(*, deprecated)\n") : '';
302
229
  var header = this.commentHeader(indent, headComment) + dep + "".concat(indent, "public func ").concat(method.name, "(");
303
230
  return header + fragment + "".concat(fragment ? ',' : '', "\n").concat(bump, "options: ITransportSettings? = nil\n").concat(indent, ") -> ").concat(returnType, " {\n");
304
231
  }
305
-
306
232
  methodSignature(indent, method) {
307
233
  return this.methodHeaderDeclaration(indent, method, false);
308
234
  }
309
-
310
235
  encodePathParams(indent, method) {
311
236
  var encodings = '';
312
-
313
237
  if (method.pathParams.length > 0) {
314
238
  for (var param of method.pathParams) {
315
239
  encodings += "".concat(indent, "let path_").concat(param.name, " = encodeParam(").concat(param.name, ")\n");
316
240
  }
317
241
  }
318
-
319
242
  return encodings;
320
243
  }
321
-
322
244
  declareMethod(indent, method) {
323
245
  var bump = this.bumper(indent);
324
246
  return this.methodSignature(indent, method) + this.encodePathParams(bump, method) + this.httpCall(bump, method) + "\n".concat(indent, "}");
325
247
  }
326
-
327
248
  streamerSignature(indent, method) {
328
249
  return this.methodHeaderDeclaration(indent, method, true);
329
250
  }
330
-
331
251
  declareStreamer(indent, method) {
332
252
  var bump = this.bumper(indent);
333
253
  return this.streamerSignature(indent, method) + this.encodePathParams(bump, method) + this.streamCall(bump, method) + "\n".concat(indent, "}");
334
254
  }
335
-
336
255
  codingKeys(indent, type) {
337
256
  var special = false;
338
257
  var keys = Object.values(type.properties).map(p => {
339
258
  var name = this.reserve(p.name);
340
259
  var alias = '';
341
260
  var useIt = this.useAnyString(p) || this.useAnyInt(p);
342
-
343
261
  if (useIt) {
344
262
  name = this.privy(name);
345
263
  special = true;
@@ -348,7 +266,6 @@ class SwiftGen extends _codeGen.CodeGen {
348
266
  special = true;
349
267
  alias = p.jsonName;
350
268
  }
351
-
352
269
  return name + (alias ? " = \"".concat(alias, "\"") : '');
353
270
  });
354
271
  if (!special) return '';
@@ -357,54 +274,42 @@ class SwiftGen extends _codeGen.CodeGen {
357
274
  var cases = keys.join("\n".concat(bump2, "case "));
358
275
  return "\n".concat(bump, "private enum CodingKeys : String, CodingKey {") + "\n".concat(bump2, "case ").concat(cases) + "\n".concat(bump, "}\n");
359
276
  }
360
-
361
277
  declareEnumValue(indent, value) {
362
278
  var quote = typeof value === 'string' ? this.codeQuote : '';
363
279
  return "".concat(indent, "case ").concat((0, _sdkModels.mayQuote)(value), " = ").concat(quote).concat(value).concat(quote);
364
280
  }
365
-
366
281
  typeSignature(indent, type) {
367
282
  var recursive = type.isRecursive();
368
283
  var typeName = recursive ? 'class' : 'struct';
369
284
  var access = recursive ? 'open' : 'public';
370
285
  var baseClass = 'SDKModel';
371
286
  var isEnum = type instanceof _sdkModels.EnumType;
372
-
373
287
  if (isEnum) {
374
288
  typeName = 'enum';
375
289
  var num = type;
376
-
377
290
  var _mapped = this.typeMap(num.elementType);
378
-
379
291
  baseClass = "".concat(_mapped.name, ", Codable");
380
292
  }
381
-
382
293
  var keys = this.codingKeys(indent, type);
383
294
  var needClass = recursive ? '\nRecursive type references must use Class instead of Struct' : '';
384
295
  var mapped = this.typeMap(type);
385
296
  return this.commentHeader(indent, type.description + needClass) + "".concat(indent).concat(access, " ").concat(typeName, " ").concat(mapped.name, ": ").concat(baseClass, " {\n").concat(keys);
386
297
  }
387
-
388
298
  errorResponses(_indent, _method) {
389
299
  return 'SDKError';
390
300
  }
391
-
392
301
  httpPath(path, prefix) {
393
302
  prefix = prefix || '';
394
-
395
303
  if (path.indexOf('{') >= 0) {
396
304
  var tweak = path.replace(/{/gi, '\\(path_' + prefix);
397
305
  tweak = tweak.replace(/}/gi, ')');
398
306
  return "\"".concat(tweak, "\"");
399
307
  }
400
-
401
308
  return "\"".concat(path, "\"");
402
309
  }
403
-
404
310
  argGroup(indent, args, prefix) {
405
311
  if (!args || args.length === 0) return this.nullStr;
406
312
  var hash = [];
407
-
408
313
  for (var arg of args) {
409
314
  if (prefix) {
410
315
  hash.push("\"".concat(arg, "\": ").concat(prefix).concat(arg));
@@ -412,36 +317,28 @@ class SwiftGen extends _codeGen.CodeGen {
412
317
  hash.push("\"".concat(arg, "\": ").concat(arg));
413
318
  }
414
319
  }
415
-
416
320
  return "\n".concat(indent, "[").concat(hash.join(this.argDelimiter), "]");
417
321
  }
418
-
419
322
  queryGroup(indent, method, prefix) {
420
323
  var params = method.getParams('query');
421
324
  if (!params || params.length === 0) return this.nullStr;
422
325
  var hash = [];
423
-
424
326
  for (var param of params) {
425
327
  var arg = this.asAny(param);
426
-
427
328
  if (prefix) {
428
329
  hash.push("\"".concat(param.name, "\": ").concat(prefix).concat(arg));
429
330
  } else {
430
331
  hash.push("\"".concat(param.name, "\": ").concat(arg));
431
332
  }
432
333
  }
433
-
434
334
  return "\n".concat(indent, "[").concat(hash.join(this.argDelimiter), "]");
435
335
  }
436
-
437
336
  asAny(param) {
438
337
  var castIt;
439
-
440
338
  if (param.type.elementType) {
441
339
  castIt = true;
442
340
  } else {
443
341
  var mapped = this.typeMap(param.type);
444
-
445
342
  switch (mapped.name.toLowerCase()) {
446
343
  case 'date':
447
344
  case 'datetime':
@@ -449,29 +346,23 @@ class SwiftGen extends _codeGen.CodeGen {
449
346
  case 'bool':
450
347
  castIt = true;
451
348
  break;
452
-
453
349
  default:
454
350
  castIt = false;
455
351
  break;
456
352
  }
457
353
  }
458
-
459
354
  return param.name + (castIt ? ' as Any?' : '');
460
355
  }
461
-
462
356
  argList(indent, args, prefix) {
463
357
  prefix = prefix || '';
464
358
  return args && args.length !== 0 ? "\n".concat(indent).concat(prefix).concat(args.join(this.argDelimiter + prefix)) : this.nullStr;
465
359
  }
466
-
467
360
  argFill(current, args) {
468
361
  if (!current && args.trim() === this.nullStr) {
469
362
  return '';
470
363
  }
471
-
472
364
  return "".concat(args).concat(current ? this.argDelimiter : '').concat(current);
473
365
  }
474
-
475
366
  httpArgs(indent, method) {
476
367
  var request = this.useRequest(method) ? 'request.' : '';
477
368
  var result = this.argFill('', 'options');
@@ -479,7 +370,6 @@ class SwiftGen extends _codeGen.CodeGen {
479
370
  result = this.argFill(result, this.queryGroup(indent, method, request));
480
371
  return result;
481
372
  }
482
-
483
373
  httpCall(indent, method) {
484
374
  var request = this.useRequest(method) ? 'request.' : '';
485
375
  var type = this.typeMap(method.type);
@@ -488,7 +378,6 @@ class SwiftGen extends _codeGen.CodeGen {
488
378
  var errors = this.errorResponses(indent, method);
489
379
  return "".concat(indent, "let result: SDKResponse<").concat(type.name, ", ").concat(errors, "> = ").concat(this.it(method.httpMethod.toLowerCase()), "(").concat(this.httpPath(method.endpoint, request)).concat(args ? ', ' + args : '', ")\n").concat(indent, "return result");
490
380
  }
491
-
492
381
  streamCall(indent, method) {
493
382
  var request = this.useRequest(method) ? 'request.' : '';
494
383
  var bump = indent + this.indentStr;
@@ -496,27 +385,22 @@ class SwiftGen extends _codeGen.CodeGen {
496
385
  var errors = this.errorResponses(indent, method);
497
386
  return "".concat(indent, "let result: SDKResponse<Data, ").concat(errors, "> = ").concat(this.it(method.httpMethod.toLowerCase()), "(").concat(this.httpPath(method.endpoint, request)).concat(args ? ', ' + args : '', ")\n").concat(indent, "return result");
498
387
  }
499
-
500
388
  summary(indent, text) {
501
389
  return this.commentHeader(indent, text);
502
390
  }
503
-
504
391
  typeNames() {
505
392
  var countError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
506
393
  var names = [];
507
394
  if (!this.api) return names;
508
-
509
395
  if (countError) {
510
396
  this.api.types.Error.refCount++;
511
397
  } else {
512
398
  this.api.types.Error.refCount = 0;
513
399
  }
514
-
515
400
  var types = this.api.types;
516
401
  Object.values(types).filter(type => type.refCount > 0 && !type.intrinsic).forEach(type => names.push("I".concat(type.name)));
517
402
  return names;
518
403
  }
519
-
520
404
  typeMap(type) {
521
405
  super.typeMap(type);
522
406
  var ns = 'Lk';
@@ -602,17 +486,14 @@ class SwiftGen extends _codeGen.CodeGen {
602
486
  name: 'Voidable'
603
487
  }
604
488
  };
605
-
606
489
  if (type.elementType) {
607
490
  var map = this.typeMap(type.elementType);
608
-
609
491
  switch (type.className) {
610
492
  case 'ArrayType':
611
493
  return {
612
494
  default: '[]',
613
495
  name: "[".concat(map.name, "]")
614
496
  };
615
-
616
497
  case 'HashType':
617
498
  {
618
499
  var mapName = type.elementType.name === 'string' ? 'AnyCodable' : map.name;
@@ -621,23 +502,19 @@ class SwiftGen extends _codeGen.CodeGen {
621
502
  name: "StringDictionary<".concat(mapName, ">")
622
503
  };
623
504
  }
624
-
625
505
  case 'DelimArrayType':
626
506
  return {
627
507
  default: 'nil',
628
508
  name: "DelimArray<".concat(map.name, ">")
629
509
  };
630
-
631
510
  case 'EnumType':
632
511
  return {
633
512
  default: 'nil',
634
513
  name: type.name
635
514
  };
636
515
  }
637
-
638
516
  throw new Error("Don't know how to handle: ".concat(JSON.stringify(type)));
639
517
  }
640
-
641
518
  if (type.name) {
642
519
  return swiftTypes[type.name] || {
643
520
  default: '',
@@ -647,8 +524,6 @@ class SwiftGen extends _codeGen.CodeGen {
647
524
  throw new Error('Cannot output a nameless type.');
648
525
  }
649
526
  }
650
-
651
527
  }
652
-
653
528
  exports.SwiftGen = SwiftGen;
654
529
  //# sourceMappingURL=swift.gen.js.map