@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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [21.8.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.7.4...sdk-codegen-v21.8.0) (2023-02-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* keep all body parameters toggle in API Explorer requests ([#1245](https://github.com/looker-open-source/sdk-codegen/issues/1245)) ([043ed3f](https://github.com/looker-open-source/sdk-codegen/commit/043ed3ff12cba4f821604b5b668d7301ed4aa6d1))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* The following workspace dependencies were updated
|
|
19
|
+
* dependencies
|
|
20
|
+
* @looker/sdk-rtl bumped from ^21.5.0 to ^21.6.0
|
|
21
|
+
|
|
22
|
+
### [21.7.4](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.7.3...sdk-codegen-v21.7.4) (2022-12-09)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @looker/sdk-rtl bumped from ^21.4.0 to ^21.5.0
|
|
30
|
+
|
|
8
31
|
### [21.7.3](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.7.2...sdk-codegen-v21.7.3) (2022-11-10)
|
|
9
32
|
|
|
10
33
|
|
package/lib/codeGen.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface IVersionInfo {
|
|
|
5
5
|
lookerVersion: string;
|
|
6
6
|
spec: SpecItem;
|
|
7
7
|
}
|
|
8
|
-
export declare const trimInputs: (inputs: any, depth?: number) => any;
|
|
8
|
+
export declare const trimInputs: (inputs: any, keepBody?: boolean, depth?: number) => any;
|
|
9
9
|
export declare type CodeAssignment = (indent: string, value: any) => string;
|
|
10
10
|
export interface IMappedType {
|
|
11
11
|
name: string;
|
package/lib/codeGen.js
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.trimInputs = exports.commentBlock = exports.CodeGen = void 0;
|
|
8
7
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
9
|
-
|
|
10
8
|
var _sdkModels = require("./sdkModels");
|
|
11
|
-
|
|
12
|
-
function
|
|
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
|
var commentBlock = function commentBlock(text) {
|
|
15
13
|
var indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
16
14
|
var commentStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '// ';
|
|
@@ -19,135 +17,89 @@ var commentBlock = function commentBlock(text) {
|
|
|
19
17
|
var lines = text.split('\n').map(x => "".concat(indentation).concat(x).trimRight());
|
|
20
18
|
return lines.join('\n');
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
exports.commentBlock = commentBlock;
|
|
24
|
-
|
|
25
21
|
var trimInputs = function trimInputs(inputs) {
|
|
26
|
-
var
|
|
27
|
-
|
|
22
|
+
var keepBody = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
23
|
+
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
28
24
|
function isEmpty(value, depth) {
|
|
29
25
|
if (Array.isArray(value)) return value.length === 0;
|
|
30
26
|
if (value === undefined) return true;
|
|
31
27
|
if (value === null) return true;
|
|
32
28
|
if (value === '') return true;
|
|
33
|
-
|
|
34
29
|
if (value instanceof Object) {
|
|
35
30
|
if (depth === 1) {
|
|
36
31
|
return false;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
return Object.keys(value).length === 0;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return false;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
var result;
|
|
46
38
|
if (inputs instanceof _sdkRtl.DelimArray) return inputs;
|
|
47
|
-
|
|
48
39
|
if (Array.isArray(inputs)) {
|
|
49
40
|
result = [];
|
|
50
|
-
Object.values(inputs).forEach(v => result.push(trimInputs(v, depth + 1)));
|
|
41
|
+
Object.values(inputs).forEach(v => result.push(trimInputs(v, keepBody, depth + 1)));
|
|
51
42
|
} else if (inputs instanceof Object) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
if (keepBody && depth > 0) {
|
|
44
|
+
result = inputs;
|
|
45
|
+
} else {
|
|
46
|
+
result = {};
|
|
47
|
+
Object.entries(inputs).forEach(_ref => {
|
|
48
|
+
var [key, value] = _ref;
|
|
49
|
+
var trimmed = trimInputs(value, keepBody, depth + 1);
|
|
50
|
+
if (!isEmpty(trimmed, depth + 1)) {
|
|
51
|
+
result[key] = trimmed;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
61
55
|
} else {
|
|
62
56
|
result = inputs;
|
|
63
57
|
}
|
|
64
|
-
|
|
65
58
|
return result;
|
|
66
59
|
};
|
|
67
|
-
|
|
68
60
|
exports.trimInputs = trimInputs;
|
|
69
|
-
|
|
70
61
|
class CodeGen {
|
|
71
62
|
constructor(api, versions) {
|
|
72
63
|
this.api = api;
|
|
73
64
|
this.versions = versions;
|
|
74
|
-
|
|
75
65
|
_defineProperty(this, "willItStream", false);
|
|
76
|
-
|
|
77
66
|
_defineProperty(this, "anyString", false);
|
|
78
|
-
|
|
79
67
|
_defineProperty(this, "codePath", './');
|
|
80
|
-
|
|
81
68
|
_defineProperty(this, "packagePath", 'looker');
|
|
82
|
-
|
|
83
69
|
_defineProperty(this, "sdkPath", 'sdk');
|
|
84
|
-
|
|
85
70
|
_defineProperty(this, "packageName", 'LookerSDK');
|
|
86
|
-
|
|
87
71
|
_defineProperty(this, "environmentPrefix", this.packageName.toUpperCase());
|
|
88
|
-
|
|
89
72
|
_defineProperty(this, "itself", '');
|
|
90
|
-
|
|
91
73
|
_defineProperty(this, "fileExtension", '.code');
|
|
92
|
-
|
|
93
74
|
_defineProperty(this, "argDelimiter", ', ');
|
|
94
|
-
|
|
95
75
|
_defineProperty(this, "paramDelimiter", ',\n');
|
|
96
|
-
|
|
97
76
|
_defineProperty(this, "propDelimiter", '\n');
|
|
98
|
-
|
|
99
77
|
_defineProperty(this, "enumDelimiter", ',\n');
|
|
100
|
-
|
|
101
78
|
_defineProperty(this, "codeQuote", "'");
|
|
102
|
-
|
|
103
79
|
_defineProperty(this, "useNamedParameters", true);
|
|
104
|
-
|
|
105
80
|
_defineProperty(this, "useNamedArguments", true);
|
|
106
|
-
|
|
107
81
|
_defineProperty(this, "useFunctions", false);
|
|
108
|
-
|
|
109
82
|
_defineProperty(this, "useInterfaces", false);
|
|
110
|
-
|
|
111
83
|
_defineProperty(this, "argSetSep", ': ');
|
|
112
|
-
|
|
113
84
|
_defineProperty(this, "hashSetSep", ': ');
|
|
114
|
-
|
|
115
85
|
_defineProperty(this, "arrayOpen", '[');
|
|
116
|
-
|
|
117
86
|
_defineProperty(this, "arrayClose", ']');
|
|
118
|
-
|
|
119
87
|
_defineProperty(this, "hashOpen", '{');
|
|
120
|
-
|
|
121
88
|
_defineProperty(this, "hashClose", '}');
|
|
122
|
-
|
|
123
89
|
_defineProperty(this, "hashKeyQuote", '');
|
|
124
|
-
|
|
125
90
|
_defineProperty(this, "typeOpen", '{');
|
|
126
|
-
|
|
127
91
|
_defineProperty(this, "typeClose", '}');
|
|
128
|
-
|
|
129
92
|
_defineProperty(this, "useModelClassForTypes", false);
|
|
130
|
-
|
|
131
93
|
_defineProperty(this, "indentStr", ' ');
|
|
132
|
-
|
|
133
94
|
_defineProperty(this, "commentStr", '// ');
|
|
134
|
-
|
|
135
95
|
_defineProperty(this, "noComment", false);
|
|
136
|
-
|
|
137
96
|
_defineProperty(this, "nullStr", 'null');
|
|
138
|
-
|
|
139
97
|
_defineProperty(this, "endTypeStr", '');
|
|
140
|
-
|
|
141
98
|
_defineProperty(this, "transport", 'rtl');
|
|
142
|
-
|
|
143
99
|
_defineProperty(this, "apiVersion", '');
|
|
144
|
-
|
|
145
100
|
_defineProperty(this, "apiRef", '');
|
|
146
|
-
|
|
147
101
|
_defineProperty(this, "apiPath", '');
|
|
148
|
-
|
|
149
102
|
_defineProperty(this, "defaultAsVal", (_, v) => v.toString());
|
|
150
|
-
|
|
151
103
|
if (versions && versions.spec) {
|
|
152
104
|
this.apiVersion = versions.spec.version;
|
|
153
105
|
this.apiPath = "/".concat(versions.spec.key);
|
|
@@ -156,76 +108,59 @@ class CodeGen {
|
|
|
156
108
|
this.packagePath += this.apiPath;
|
|
157
109
|
}
|
|
158
110
|
}
|
|
159
|
-
|
|
160
111
|
reset() {}
|
|
161
|
-
|
|
162
112
|
supportsMultiApi() {
|
|
163
113
|
return true;
|
|
164
114
|
}
|
|
165
|
-
|
|
166
115
|
functionsPrologue(_indent) {
|
|
167
116
|
return '';
|
|
168
117
|
}
|
|
169
|
-
|
|
170
118
|
functionsEpilogue(_indent) {
|
|
171
119
|
return '';
|
|
172
120
|
}
|
|
173
|
-
|
|
174
121
|
interfacesPrologue(_indent) {
|
|
175
122
|
return '';
|
|
176
123
|
}
|
|
177
|
-
|
|
178
124
|
reserve(name) {
|
|
179
125
|
return name;
|
|
180
126
|
}
|
|
181
|
-
|
|
182
127
|
streamsPrologue(_indent) {
|
|
183
128
|
return '';
|
|
184
129
|
}
|
|
185
|
-
|
|
186
130
|
quote(value) {
|
|
187
131
|
return "".concat(this.codeQuote).concat(value).concat(this.codeQuote);
|
|
188
132
|
}
|
|
189
|
-
|
|
190
133
|
declareEnumValue(indent, value) {
|
|
191
134
|
var quote = typeof value === 'string' ? this.codeQuote : '';
|
|
192
135
|
return "".concat(indent).concat((0, _sdkModels.mayQuote)(value), " = ").concat(quote).concat(value).concat(quote);
|
|
193
136
|
}
|
|
194
|
-
|
|
195
137
|
functionSignature(_indent, _method) {
|
|
196
138
|
return '';
|
|
197
139
|
}
|
|
198
|
-
|
|
199
140
|
declareFunction(_indent, _method) {
|
|
200
141
|
return '';
|
|
201
142
|
}
|
|
202
|
-
|
|
203
143
|
declareInterface(_indent, _method) {
|
|
204
144
|
return '';
|
|
205
145
|
}
|
|
206
|
-
|
|
207
146
|
argIndent(indent, args, opener, closer) {
|
|
208
147
|
var bump = this.bumper(indent);
|
|
209
148
|
var open = opener;
|
|
210
149
|
var close = closer;
|
|
211
150
|
var delim = this.argDelimiter;
|
|
212
|
-
|
|
213
151
|
if (args.length > 1) {
|
|
214
152
|
open = "".concat(opener, "\n").concat(bump);
|
|
215
153
|
close = "\n".concat(indent).concat(closer);
|
|
216
154
|
delim = "".concat(this.argDelimiter.trim(), "\n").concat(bump);
|
|
217
155
|
}
|
|
218
|
-
|
|
219
156
|
return "".concat(open).concat(args.join(delim)).concat(close);
|
|
220
157
|
}
|
|
221
|
-
|
|
222
158
|
argValue(indent, arg, inputs) {
|
|
223
159
|
if (!(arg.name in inputs)) return '';
|
|
224
160
|
var val = inputs[arg.name];
|
|
225
161
|
var argType = this.writeableType(arg.type) || arg.type;
|
|
226
162
|
var mt = this.typeMap(argType);
|
|
227
163
|
var argVal;
|
|
228
|
-
|
|
229
164
|
if (mt.asVal) {
|
|
230
165
|
argVal = mt.asVal(indent, val);
|
|
231
166
|
} else if (argType instanceof _sdkModels.ArrayType) {
|
|
@@ -237,29 +172,23 @@ class CodeGen {
|
|
|
237
172
|
} else {
|
|
238
173
|
argVal = this.defaultAsVal(indent, val);
|
|
239
174
|
}
|
|
240
|
-
|
|
241
175
|
return argVal;
|
|
242
176
|
}
|
|
243
|
-
|
|
244
177
|
assignParams(method, inputs) {
|
|
245
178
|
var args = [];
|
|
246
179
|
var hasComplexArg = false;
|
|
247
|
-
|
|
248
180
|
if (Object.keys(inputs).length > 0) {
|
|
249
181
|
var requestType;
|
|
250
|
-
|
|
251
182
|
if (!this.useNamedArguments && (requestType = this.api.getRequestType(method))) {
|
|
252
183
|
args.push(this.assignType(this.indentStr, requestType, inputs));
|
|
253
184
|
hasComplexArg = true;
|
|
254
185
|
} else {
|
|
255
|
-
method.allParams
|
|
186
|
+
var params = method.allParams;
|
|
187
|
+
params.forEach(p => {
|
|
256
188
|
var v = this.argValue(this.indentStr, p, inputs);
|
|
257
|
-
|
|
258
189
|
if (v !== '') {
|
|
259
190
|
var _arg = this.useNamedArguments ? "".concat(p.name, "=").concat(v) : v;
|
|
260
|
-
|
|
261
191
|
args.push(_arg);
|
|
262
|
-
|
|
263
192
|
if (!p.type.intrinsic) {
|
|
264
193
|
hasComplexArg = true;
|
|
265
194
|
}
|
|
@@ -267,34 +196,32 @@ class CodeGen {
|
|
|
267
196
|
});
|
|
268
197
|
}
|
|
269
198
|
}
|
|
270
|
-
|
|
271
199
|
var open = '';
|
|
272
|
-
|
|
273
200
|
if (args.length > 1 || hasComplexArg) {
|
|
274
201
|
open = "\n".concat(this.indentStr);
|
|
275
202
|
}
|
|
276
|
-
|
|
277
203
|
return args.length > 0 ? "".concat(open).concat(args.join(this.argDelimiter)) : '';
|
|
278
204
|
}
|
|
279
|
-
|
|
280
205
|
argSet(name, sep, exp) {
|
|
281
206
|
return "".concat(name).concat(sep).concat(exp);
|
|
282
207
|
}
|
|
283
|
-
|
|
284
208
|
assignType(indent, type, inputs) {
|
|
285
209
|
var mt = this.typeMap(type);
|
|
286
210
|
var args = [];
|
|
287
211
|
var bump = this.bumper(indent);
|
|
288
|
-
Object.values(type.properties)
|
|
212
|
+
var props = Object.values(type.properties);
|
|
213
|
+
props.forEach(p => {
|
|
289
214
|
var v = this.argValue(bump, p, inputs);
|
|
290
215
|
if (v) args.push(this.argSet(p.name, this.argSetSep, v));
|
|
291
216
|
});
|
|
292
|
-
if (args.length === 0) return '';
|
|
293
217
|
var open = this.useModelClassForTypes ? "".concat(mt.name).concat(this.typeOpen) : this.typeOpen;
|
|
294
218
|
var nl = ",\n".concat(bump);
|
|
295
|
-
|
|
219
|
+
var joined = "\n".concat(bump).concat(args.join(nl), "\n").concat(indent);
|
|
220
|
+
if (joined.trim().length === 0) {
|
|
221
|
+
joined = '';
|
|
222
|
+
}
|
|
223
|
+
return "".concat(open).concat(joined).concat(this.typeClose);
|
|
296
224
|
}
|
|
297
|
-
|
|
298
225
|
arrayValue(indent, type, val) {
|
|
299
226
|
var ra = type;
|
|
300
227
|
var et = ra.elementType;
|
|
@@ -302,47 +229,36 @@ class CodeGen {
|
|
|
302
229
|
var open = this.arrayOpen;
|
|
303
230
|
var close = this.arrayClose;
|
|
304
231
|
var arrayValDelimiter = this.argDelimiter;
|
|
305
|
-
|
|
306
232
|
if (val.length > 1 || !et.intrinsic) {
|
|
307
233
|
open = "".concat(open, "\n").concat(bump);
|
|
308
234
|
close = "\n".concat(indent).concat(close);
|
|
309
235
|
arrayValDelimiter = "".concat(arrayValDelimiter.trim(), "\n").concat(bump);
|
|
310
236
|
}
|
|
311
|
-
|
|
312
237
|
var args = [];
|
|
313
238
|
var asVal = this.defaultAsVal;
|
|
314
239
|
var mt = this.typeMap(et);
|
|
315
|
-
|
|
316
240
|
if (et.intrinsic) {
|
|
317
241
|
asVal = mt.asVal || asVal;
|
|
318
242
|
} else {
|
|
319
243
|
asVal = (i, v) => this.assignType(i, et, v);
|
|
320
244
|
}
|
|
321
|
-
|
|
322
245
|
val.forEach(v => args.push(asVal(bump, v)));
|
|
323
246
|
return open + args.join(arrayValDelimiter) + close;
|
|
324
247
|
}
|
|
325
|
-
|
|
326
248
|
anyValue(indent, val) {
|
|
327
249
|
if (val instanceof _sdkModels.Type) return this.assignType(indent, val, val);
|
|
328
|
-
|
|
329
250
|
switch (typeof val) {
|
|
330
251
|
case 'bigint':
|
|
331
252
|
case 'number':
|
|
332
253
|
return val.toString();
|
|
333
|
-
|
|
334
254
|
case 'boolean':
|
|
335
255
|
return val ? 'true' : 'false';
|
|
336
|
-
|
|
337
256
|
case 'string':
|
|
338
257
|
return this.quote(val);
|
|
339
|
-
|
|
340
258
|
case 'undefined':
|
|
341
259
|
return '';
|
|
342
|
-
|
|
343
260
|
case 'function':
|
|
344
261
|
return '';
|
|
345
|
-
|
|
346
262
|
case 'object':
|
|
347
263
|
{
|
|
348
264
|
if (Array.isArray(val)) {
|
|
@@ -355,14 +271,11 @@ class CodeGen {
|
|
|
355
271
|
return this.hashValue(indent, val);
|
|
356
272
|
}
|
|
357
273
|
}
|
|
358
|
-
|
|
359
274
|
case 'symbol':
|
|
360
275
|
return val.toString();
|
|
361
276
|
}
|
|
362
|
-
|
|
363
277
|
return val.toString();
|
|
364
278
|
}
|
|
365
|
-
|
|
366
279
|
hashValue(indent, val) {
|
|
367
280
|
var args = [];
|
|
368
281
|
var bump = this.bumper(indent);
|
|
@@ -374,94 +287,73 @@ class CodeGen {
|
|
|
374
287
|
});
|
|
375
288
|
return this.argIndent(indent, args, this.hashOpen, this.hashClose);
|
|
376
289
|
}
|
|
377
|
-
|
|
378
290
|
paramMappedType(param, method) {
|
|
379
291
|
var type = param.location === _sdkModels.strBody ? this.writeableType(param.type, method) || param.type : param.type;
|
|
380
292
|
return this.typeMap(type);
|
|
381
293
|
}
|
|
382
|
-
|
|
383
294
|
makeTheCall(_method, _inputs) {
|
|
384
295
|
return this.commentHeader('', "Not yet available");
|
|
385
296
|
}
|
|
386
|
-
|
|
387
297
|
beginRegion(indent, description) {
|
|
388
298
|
return "".concat(indent, "#region ").concat(description);
|
|
389
299
|
}
|
|
390
|
-
|
|
391
300
|
endRegion(indent, description) {
|
|
392
301
|
return "".concat(indent, "#endregion ").concat(description);
|
|
393
302
|
}
|
|
394
|
-
|
|
395
303
|
warnEditing() {
|
|
396
304
|
return 'NOTE: Do not edit this file generated by Looker SDK Codegen' + (this.apiVersion ? " for API ".concat(this.apiVersion) : '');
|
|
397
305
|
}
|
|
398
|
-
|
|
399
306
|
streamerSignature(_indent, _method) {
|
|
400
307
|
return '';
|
|
401
308
|
}
|
|
402
|
-
|
|
403
309
|
declareStreamer(_indent, _method) {
|
|
404
310
|
return '';
|
|
405
311
|
}
|
|
406
|
-
|
|
407
312
|
initArg(_indent, _property) {
|
|
408
313
|
return '';
|
|
409
314
|
}
|
|
410
|
-
|
|
411
315
|
construct(_indent, _type) {
|
|
412
316
|
return '';
|
|
413
317
|
}
|
|
414
|
-
|
|
415
318
|
bumper(indent) {
|
|
416
319
|
return indent + this.indentStr;
|
|
417
320
|
}
|
|
418
|
-
|
|
419
321
|
describeProperty(property) {
|
|
420
322
|
return "".concat(property.description).concat(property.readOnly ? ' (read-only)' : '');
|
|
421
323
|
}
|
|
422
|
-
|
|
423
324
|
sdkFileName(baseFileName) {
|
|
424
325
|
return this.fileName("".concat(this.sdkPath, "/").concat(this.apiVersion, "/").concat(baseFileName));
|
|
425
326
|
}
|
|
426
|
-
|
|
427
327
|
fileName(base) {
|
|
428
328
|
return "".concat(this.codePath).concat(this.packagePath, "/").concat(base).concat(this.fileExtension);
|
|
429
329
|
}
|
|
430
|
-
|
|
431
330
|
comment(indent, description) {
|
|
432
331
|
if (this.noComment) return '';
|
|
433
332
|
return commentBlock(description, indent, this.commentStr);
|
|
434
333
|
}
|
|
435
|
-
|
|
436
334
|
commentHeader(indent, text, _commentStr) {
|
|
437
335
|
if (this.noComment) return '';
|
|
438
336
|
return text ? "".concat(this.comment(indent, text), "\n") : '';
|
|
439
337
|
}
|
|
440
|
-
|
|
441
338
|
declareParameters(indent, method) {
|
|
442
339
|
var params = method.allParams;
|
|
443
340
|
var items = [];
|
|
444
341
|
if (params) params.forEach(p => items.push(this.declareParameter(indent, method, p)));
|
|
445
342
|
return items.join(this.paramDelimiter);
|
|
446
343
|
}
|
|
447
|
-
|
|
448
344
|
declareConstructorArg(indent, property) {
|
|
449
345
|
return "".concat(indent).concat(property.name).concat(property.nullable ? ' = ' + this.nullStr : '');
|
|
450
346
|
}
|
|
451
|
-
|
|
452
347
|
it(value) {
|
|
453
348
|
return this.itself ? "".concat(this.itself, ".").concat(value) : value;
|
|
454
349
|
}
|
|
455
|
-
|
|
456
350
|
typeProperties(type) {
|
|
457
351
|
return Object.values(type.properties);
|
|
458
352
|
}
|
|
459
|
-
|
|
460
353
|
declareType(indent, type) {
|
|
461
354
|
var bump = this.bumper(indent);
|
|
462
355
|
var props = [];
|
|
463
356
|
var propertyValues = '';
|
|
464
|
-
|
|
465
357
|
try {
|
|
466
358
|
if (type instanceof _sdkModels.EnumType) {
|
|
467
359
|
var num = type;
|
|
@@ -474,32 +366,25 @@ class CodeGen {
|
|
|
474
366
|
} catch (_unused) {
|
|
475
367
|
throw new Error(JSON.stringify(type, null, 2));
|
|
476
368
|
}
|
|
477
|
-
|
|
478
369
|
return this.typeSignature(indent, type) + propertyValues + this.construct(indent, type) + "".concat(this.endTypeStr ? indent : '').concat(this.endTypeStr);
|
|
479
370
|
}
|
|
480
|
-
|
|
481
371
|
argGroup(indent, args, prefix) {
|
|
482
372
|
prefix = prefix || '';
|
|
483
373
|
return args && args.length !== 0 ? "".concat(indent, "[").concat(prefix).concat(args.join(this.argDelimiter + prefix), "]") : this.nullStr;
|
|
484
374
|
}
|
|
485
|
-
|
|
486
375
|
argList(indent, args, prefix) {
|
|
487
376
|
prefix = prefix || '';
|
|
488
377
|
return args && args.length !== 0 ? "".concat(indent).concat(prefix).concat(args.join(this.argDelimiter + prefix)) : this.nullStr;
|
|
489
378
|
}
|
|
490
|
-
|
|
491
379
|
argFill(current, args) {
|
|
492
380
|
if (!current && args.trim() === this.nullStr) {
|
|
493
381
|
return '';
|
|
494
382
|
}
|
|
495
|
-
|
|
496
383
|
return "".concat(args).concat(current ? this.argDelimiter : '').concat(current);
|
|
497
384
|
}
|
|
498
|
-
|
|
499
385
|
httpPath(path, _prefix) {
|
|
500
386
|
return path;
|
|
501
387
|
}
|
|
502
|
-
|
|
503
388
|
httpArgs(indent, method) {
|
|
504
389
|
var result = this.argFill('', this.argGroup(indent, method.cookieArgs));
|
|
505
390
|
result = this.argFill(result, this.argGroup(indent, method.headerArgs));
|
|
@@ -507,28 +392,23 @@ class CodeGen {
|
|
|
507
392
|
result = this.argFill(result, this.argGroup(indent, method.queryArgs));
|
|
508
393
|
return result;
|
|
509
394
|
}
|
|
510
|
-
|
|
511
395
|
errorResponses(_indent, method) {
|
|
512
396
|
var results = method.errorResponses.map(r => "".concat(r.type.name));
|
|
513
397
|
return results.join(', ');
|
|
514
398
|
}
|
|
515
|
-
|
|
516
399
|
httpCall(indent, method) {
|
|
517
400
|
var bump = indent + this.indentStr;
|
|
518
401
|
var args = this.httpArgs(bump, method);
|
|
519
402
|
var errors = "(".concat(this.errorResponses(indent, method), ")");
|
|
520
403
|
return "".concat(indent, "return ").concat(this.it(this.transport), ".").concat(method.httpMethod.toLowerCase(), "(").concat(errors, ", \"").concat(method.endpoint, "\"").concat(args ? ', ' + args : '', ")");
|
|
521
404
|
}
|
|
522
|
-
|
|
523
405
|
streamCall(_indent, _method) {
|
|
524
406
|
return '';
|
|
525
407
|
}
|
|
526
|
-
|
|
527
408
|
useRequest(method) {
|
|
528
409
|
if (this.useNamedParameters) return false;
|
|
529
410
|
return method.eligibleForRequestType();
|
|
530
411
|
}
|
|
531
|
-
|
|
532
412
|
requestTypeName(method) {
|
|
533
413
|
if (!this.useRequest(method)) return '';
|
|
534
414
|
var request = this.api.getRequestType(method);
|
|
@@ -537,7 +417,6 @@ class CodeGen {
|
|
|
537
417
|
method.addType(this.api, request);
|
|
538
418
|
return request.name;
|
|
539
419
|
}
|
|
540
|
-
|
|
541
420
|
writeableType(type, method) {
|
|
542
421
|
if (!type) return undefined;
|
|
543
422
|
var writer = this.api.mayGetWriteableType(type);
|
|
@@ -546,16 +425,13 @@ class CodeGen {
|
|
|
546
425
|
if (method) method.addType(this.api, writer);
|
|
547
426
|
return writer;
|
|
548
427
|
}
|
|
549
|
-
|
|
550
428
|
typeNames() {
|
|
551
429
|
var _countError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
552
|
-
|
|
553
430
|
var items = [];
|
|
554
431
|
if (!this.api) return items;
|
|
555
432
|
Object.values(this.api.types).filter(type => type.refCount > 0 && !type.intrinsic).forEach(type => items.push(type.name));
|
|
556
433
|
return items;
|
|
557
434
|
}
|
|
558
|
-
|
|
559
435
|
typeMap(type) {
|
|
560
436
|
type.refCount++;
|
|
561
437
|
return {
|
|
@@ -563,8 +439,6 @@ class CodeGen {
|
|
|
563
439
|
name: type.name || ''
|
|
564
440
|
};
|
|
565
441
|
}
|
|
566
|
-
|
|
567
442
|
}
|
|
568
|
-
|
|
569
443
|
exports.CodeGen = CodeGen;
|
|
570
444
|
//# sourceMappingURL=codeGen.js.map
|