@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.
- package/CHANGELOG.md +14 -0
- package/lib/codeGen.d.ts +1 -1
- package/lib/codeGen.js +28 -154
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGenerators.js +0 -16
- package/lib/codeGenerators.js.map +1 -1
- package/lib/csharp.gen.js +3 -71
- package/lib/csharp.gen.js.map +1 -1
- package/lib/declarationInfo.js +0 -7
- package/lib/declarationInfo.js.map +1 -1
- package/lib/esm/codeGen.js +48 -157
- package/lib/esm/codeGen.js.map +1 -1
- package/lib/esm/codeGenerators.js +28 -20
- package/lib/esm/codeGenerators.js.map +1 -1
- package/lib/esm/csharp.gen.js +19 -75
- package/lib/esm/csharp.gen.js.map +1 -1
- package/lib/esm/declarationInfo.js +10 -7
- package/lib/esm/declarationInfo.js.map +1 -1
- package/lib/esm/exampleInfo.js +24 -23
- package/lib/esm/exampleInfo.js.map +1 -1
- package/lib/esm/go.gen.js +18 -92
- package/lib/esm/go.gen.js.map +1 -1
- package/lib/esm/index.js +148 -13
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/kotlin.gen.js +23 -118
- package/lib/esm/kotlin.gen.js.map +1 -1
- package/lib/esm/pseudo.gen.js +14 -24
- package/lib/esm/pseudo.gen.js.map +1 -1
- package/lib/esm/python.gen.js +19 -138
- package/lib/esm/python.gen.js.map +1 -1
- package/lib/esm/sdkModels.js +100 -432
- package/lib/esm/sdkModels.js.map +1 -1
- package/lib/esm/specConverter.js +58 -88
- package/lib/esm/specConverter.js.map +1 -1
- package/lib/esm/specDiff.js +36 -51
- package/lib/esm/specDiff.js.map +1 -1
- package/lib/esm/swift.gen.js +25 -137
- package/lib/esm/swift.gen.js.map +1 -1
- package/lib/esm/testUtils/index.js +17 -0
- package/lib/esm/testUtils/index.js.map +1 -0
- package/lib/esm/testUtils/testUtils.js +66 -0
- package/lib/esm/testUtils/testUtils.js.map +1 -0
- package/lib/esm/typescript.gen.js +24 -125
- package/lib/esm/typescript.gen.js.map +1 -1
- package/lib/exampleInfo.js +1 -31
- package/lib/exampleInfo.js.map +1 -1
- package/lib/go.gen.js +3 -87
- package/lib/go.gen.js.map +1 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +1 -1
- package/lib/kotlin.gen.js +7 -113
- package/lib/kotlin.gen.js.map +1 -1
- package/lib/pseudo.gen.js +3 -24
- package/lib/pseudo.gen.js.map +1 -1
- package/lib/python.gen.js +3 -133
- package/lib/python.gen.js.map +1 -1
- package/lib/sdkModels.js +8 -438
- package/lib/sdkModels.js.map +1 -1
- package/lib/specConverter.js +6 -106
- package/lib/specConverter.js.map +1 -1
- package/lib/specDiff.js +1 -56
- package/lib/specDiff.js.map +1 -1
- package/lib/swift.gen.js +3 -128
- package/lib/swift.gen.js.map +1 -1
- package/lib/testUtils/index.js +0 -2
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/testUtils.js +1 -17
- package/lib/testUtils/testUtils.js.map +1 -1
- package/lib/typescript.gen.js +5 -117
- package/lib/typescript.gen.js.map +1 -1
- package/package.json +3 -3
package/lib/sdkModels.js
CHANGED
|
@@ -3,26 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.typeRefs = exports.typeOfType = exports.titleCase = exports.tagTypes = exports.strWrite = exports.strRequest = exports.strBody = exports.setToCriteria = exports.safeName = exports.methodRefs = exports.mayQuote = exports.keyValues = exports.isSpecialName = exports.firstMethodRef = exports.firstCase = exports.describeParam = exports.criteriaToSet = exports.camelCase = exports.WriteType = exports.TypeOfType = exports.Type = exports.SearchCriterion = exports.SearchAll = exports.RequestType = exports.Property = exports.Parameter = exports.Method = exports.MetaType = exports.IntrinsicType = exports.HashType = exports.EnumType = exports.DelimArrayType = exports.ArrayType = exports.ApiModel = void 0;
|
|
8
7
|
var OAS = _interopRequireWildcard(require("openapi3-ts"));
|
|
9
|
-
|
|
10
8
|
var _blueimpMd = _interopRequireDefault(require("blueimp-md5"));
|
|
11
|
-
|
|
12
9
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
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); }
|
|
26
18
|
var strBody = 'body';
|
|
27
19
|
exports.strBody = strBody;
|
|
28
20
|
var strRequest = 'Request';
|
|
@@ -34,7 +26,6 @@ var enumTag = 'enum';
|
|
|
34
26
|
var simpleName = /^[a-z_][a-z_\d]*(\[])?$/im;
|
|
35
27
|
var TypeOfType;
|
|
36
28
|
exports.TypeOfType = TypeOfType;
|
|
37
|
-
|
|
38
29
|
(function (TypeOfType) {
|
|
39
30
|
TypeOfType[TypeOfType["Intrinsic"] = 0] = "Intrinsic";
|
|
40
31
|
TypeOfType[TypeOfType["Array"] = 1] = "Array";
|
|
@@ -43,108 +34,79 @@ exports.TypeOfType = TypeOfType;
|
|
|
43
34
|
TypeOfType[TypeOfType["Enum"] = 4] = "Enum";
|
|
44
35
|
TypeOfType[TypeOfType["Complex"] = 5] = "Complex";
|
|
45
36
|
})(TypeOfType || (exports.TypeOfType = TypeOfType = {}));
|
|
46
|
-
|
|
47
37
|
var typeOfType = type => {
|
|
48
38
|
if (type.intrinsic) return TypeOfType.Intrinsic;
|
|
49
|
-
|
|
50
39
|
switch (type.className) {
|
|
51
40
|
case 'ArrayType':
|
|
52
41
|
return TypeOfType.Array;
|
|
53
|
-
|
|
54
42
|
case 'HashType':
|
|
55
43
|
return TypeOfType.Hash;
|
|
56
|
-
|
|
57
44
|
case 'DelimArrayType':
|
|
58
45
|
return TypeOfType.DelimArray;
|
|
59
|
-
|
|
60
46
|
case 'EnumType':
|
|
61
47
|
return TypeOfType.Enum;
|
|
62
|
-
|
|
63
48
|
default:
|
|
64
49
|
{
|
|
65
50
|
return TypeOfType.Complex;
|
|
66
51
|
}
|
|
67
52
|
}
|
|
68
53
|
};
|
|
69
|
-
|
|
70
54
|
exports.typeOfType = typeOfType;
|
|
71
|
-
|
|
72
55
|
var isSpecialName = name => {
|
|
73
56
|
if (!name) return false;
|
|
74
57
|
var result = simpleName.test(name);
|
|
75
58
|
return !result;
|
|
76
59
|
};
|
|
77
|
-
|
|
78
60
|
exports.isSpecialName = isSpecialName;
|
|
79
|
-
|
|
80
61
|
var safeName = value => {
|
|
81
62
|
if (!value) return '';
|
|
82
63
|
return value.replace(/([-_ ]+)/g, '_');
|
|
83
64
|
};
|
|
84
|
-
|
|
85
65
|
exports.safeName = safeName;
|
|
86
|
-
|
|
87
66
|
var camelCase = value => {
|
|
88
67
|
if (!value) return '';
|
|
89
68
|
return value.replace(/(([-_ ]+)[a-z])|([-_ ]+)/gi, $1 => {
|
|
90
69
|
return $1.toLocaleUpperCase().replace(/([-_ ]+)/gi, '');
|
|
91
70
|
});
|
|
92
71
|
};
|
|
93
|
-
|
|
94
72
|
exports.camelCase = camelCase;
|
|
95
|
-
|
|
96
73
|
var titleCase = value => {
|
|
97
74
|
if (!value) return '';
|
|
98
75
|
value = camelCase(value);
|
|
99
76
|
return value[0].toLocaleUpperCase() + value.substr(1);
|
|
100
77
|
};
|
|
101
|
-
|
|
102
78
|
exports.titleCase = titleCase;
|
|
103
|
-
|
|
104
79
|
var firstCase = value => {
|
|
105
80
|
if (!value) return '';
|
|
106
81
|
value = camelCase(value);
|
|
107
82
|
return value[0].toLocaleUpperCase() + value.substr(1).toLocaleLowerCase();
|
|
108
83
|
};
|
|
109
|
-
|
|
110
84
|
exports.firstCase = firstCase;
|
|
111
|
-
|
|
112
85
|
var searchIt = value => value ? value + '\t' : '';
|
|
113
|
-
|
|
114
86
|
var localeSort = (a, b) => a.localeCompare(b);
|
|
115
|
-
|
|
116
87
|
var describeParam = param => {
|
|
117
88
|
var _param$type;
|
|
118
|
-
|
|
119
89
|
var desc = param.description || ((_param$type = param.type) === null || _param$type === void 0 ? void 0 : _param$type.description);
|
|
120
|
-
|
|
121
90
|
if (param.deprecated) {
|
|
122
91
|
if (!param.description.match(/deprecated/gi)) {
|
|
123
92
|
desc = "(DEPRECATED) ".concat(desc);
|
|
124
93
|
}
|
|
125
94
|
}
|
|
126
|
-
|
|
127
95
|
return desc;
|
|
128
96
|
};
|
|
129
|
-
|
|
130
97
|
exports.describeParam = describeParam;
|
|
131
|
-
|
|
132
98
|
var keyValues = list => {
|
|
133
99
|
if (!list) return [];
|
|
134
100
|
return Array.from(list.values()).sort();
|
|
135
101
|
};
|
|
136
|
-
|
|
137
102
|
exports.keyValues = keyValues;
|
|
138
|
-
|
|
139
103
|
var mayQuote = function mayQuote(value) {
|
|
140
104
|
var quoteChar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "'";
|
|
141
105
|
var str = value.toString();
|
|
142
106
|
if (!isSpecialName(str)) return str;
|
|
143
107
|
return "".concat(quoteChar).concat(str).concat(quoteChar);
|
|
144
108
|
};
|
|
145
|
-
|
|
146
109
|
exports.mayQuote = mayQuote;
|
|
147
|
-
|
|
148
110
|
var methodRefs = (api, refs) => {
|
|
149
111
|
var keys = keyValues(refs);
|
|
150
112
|
var result = [];
|
|
@@ -155,80 +117,62 @@ var methodRefs = (api, refs) => {
|
|
|
155
117
|
});
|
|
156
118
|
return result;
|
|
157
119
|
};
|
|
158
|
-
|
|
159
120
|
exports.methodRefs = methodRefs;
|
|
160
|
-
|
|
161
121
|
var typeRefs = (api, refs) => {
|
|
162
122
|
var keys = keyValues(refs);
|
|
163
123
|
var result = [];
|
|
164
124
|
keys.forEach(k => {
|
|
165
125
|
var ref = api.types[k];
|
|
166
|
-
|
|
167
126
|
if (ref) {
|
|
168
127
|
result.push(ref);
|
|
169
128
|
}
|
|
170
129
|
});
|
|
171
130
|
return result;
|
|
172
131
|
};
|
|
173
|
-
|
|
174
132
|
exports.typeRefs = typeRefs;
|
|
175
|
-
|
|
176
133
|
var firstMethodRef = function firstMethodRef(api, type) {
|
|
177
134
|
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
178
135
|
stack.add(type.name);
|
|
179
136
|
var method = methodRefs(api, type.methodRefs)[0];
|
|
180
|
-
|
|
181
137
|
if (!method) {
|
|
182
138
|
var parents = typeRefs(api, type.parentTypes);
|
|
183
|
-
|
|
184
139
|
for (var parent of parents) {
|
|
185
140
|
if (!stack.has(parent.name)) {
|
|
186
141
|
method = firstMethodRef(api, parent, stack);
|
|
187
142
|
}
|
|
188
|
-
|
|
189
143
|
if (method) break;
|
|
190
144
|
}
|
|
191
145
|
}
|
|
192
|
-
|
|
193
146
|
return method;
|
|
194
147
|
};
|
|
195
|
-
|
|
196
148
|
exports.firstMethodRef = firstMethodRef;
|
|
197
|
-
|
|
198
149
|
var anyWriter = function anyWriter(api, type) {
|
|
199
150
|
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
200
151
|
var result;
|
|
201
152
|
if (stack.has(type.name)) return undefined;
|
|
202
153
|
stack.add(type.name);
|
|
203
154
|
var methods = methodRefs(api, type.methodRefs);
|
|
204
|
-
|
|
205
155
|
for (var _method of methods) {
|
|
206
156
|
if (_method.httpMethod === 'POST' || _method.httpMethod === 'PUT' || _method.httpMethod === 'PATCH') {
|
|
207
157
|
result = _method;
|
|
208
158
|
break;
|
|
209
159
|
}
|
|
210
160
|
}
|
|
211
|
-
|
|
212
161
|
if (!result) {
|
|
213
162
|
var allTypes = new Set([...type.parentTypes, ...type.customTypes]);
|
|
214
163
|
allTypes.delete(type.name);
|
|
215
164
|
var refs = typeRefs(api, allTypes);
|
|
216
|
-
|
|
217
165
|
for (var ref of refs) {
|
|
218
166
|
result = anyWriter(api, ref, stack);
|
|
219
|
-
|
|
220
167
|
if (result) {
|
|
221
168
|
break;
|
|
222
169
|
}
|
|
223
170
|
}
|
|
224
171
|
}
|
|
225
|
-
|
|
226
172
|
return result;
|
|
227
173
|
};
|
|
228
|
-
|
|
229
174
|
var SearchCriterion;
|
|
230
175
|
exports.SearchCriterion = SearchCriterion;
|
|
231
|
-
|
|
232
176
|
(function (SearchCriterion) {
|
|
233
177
|
SearchCriterion[SearchCriterion["method"] = 0] = "method";
|
|
234
178
|
SearchCriterion[SearchCriterion["type"] = 1] = "type";
|
|
@@ -241,10 +185,8 @@ exports.SearchCriterion = SearchCriterion;
|
|
|
241
185
|
SearchCriterion[SearchCriterion["status"] = 8] = "status";
|
|
242
186
|
SearchCriterion[SearchCriterion["response"] = 9] = "response";
|
|
243
187
|
})(SearchCriterion || (exports.SearchCriterion = SearchCriterion = {}));
|
|
244
|
-
|
|
245
188
|
var SearchAll = new Set([SearchCriterion.method, SearchCriterion.type, SearchCriterion.name, SearchCriterion.description, SearchCriterion.argument, SearchCriterion.property, SearchCriterion.title, SearchCriterion.activityType, SearchCriterion.status, SearchCriterion.response]);
|
|
246
189
|
exports.SearchAll = SearchAll;
|
|
247
|
-
|
|
248
190
|
var criteriaToSet = criteria => {
|
|
249
191
|
var result = new Set();
|
|
250
192
|
criteria.forEach(name => {
|
|
@@ -253,19 +195,15 @@ var criteriaToSet = criteria => {
|
|
|
253
195
|
});
|
|
254
196
|
return result;
|
|
255
197
|
};
|
|
256
|
-
|
|
257
198
|
exports.criteriaToSet = criteriaToSet;
|
|
258
|
-
|
|
259
199
|
var setToCriteria = criteria => {
|
|
260
200
|
var result = [];
|
|
261
201
|
criteria.forEach(value => result.push(SearchCriterion[value]));
|
|
262
202
|
return result;
|
|
263
203
|
};
|
|
264
|
-
|
|
265
204
|
exports.setToCriteria = setToCriteria;
|
|
266
205
|
var MetaType;
|
|
267
206
|
exports.MetaType = MetaType;
|
|
268
|
-
|
|
269
207
|
(function (MetaType) {
|
|
270
208
|
MetaType["Intrinsic"] = "Intrinsic";
|
|
271
209
|
MetaType["Specification"] = "Specification";
|
|
@@ -273,7 +211,6 @@ exports.MetaType = MetaType;
|
|
|
273
211
|
MetaType["Request"] = "Request";
|
|
274
212
|
MetaType["Enumerated"] = "Enumerated";
|
|
275
213
|
})(MetaType || (exports.MetaType = MetaType = {}));
|
|
276
|
-
|
|
277
214
|
var tagTypes = (api, types) => {
|
|
278
215
|
var typeTags = {};
|
|
279
216
|
Object.entries(types).filter(_ref => {
|
|
@@ -282,30 +219,24 @@ var tagTypes = (api, types) => {
|
|
|
282
219
|
}).forEach(_ref2 => {
|
|
283
220
|
var [name, type] = _ref2;
|
|
284
221
|
var methods = methodRefs(api, type.methodRefs);
|
|
285
|
-
|
|
286
222
|
if (methods.length === 0) {
|
|
287
223
|
var first = firstMethodRef(api, type);
|
|
288
224
|
if (first) methods = [first];
|
|
289
225
|
}
|
|
290
|
-
|
|
291
226
|
methods.forEach(method => {
|
|
292
227
|
for (var tag of method.schema.tags) {
|
|
293
228
|
var _list = typeTags[tag];
|
|
294
|
-
|
|
295
229
|
if (!_list) {
|
|
296
230
|
_list = {};
|
|
297
231
|
typeTags[tag] = _list;
|
|
298
232
|
}
|
|
299
|
-
|
|
300
233
|
_list[name] = type;
|
|
301
234
|
}
|
|
302
235
|
});
|
|
303
236
|
});
|
|
304
237
|
return typeTags;
|
|
305
238
|
};
|
|
306
|
-
|
|
307
239
|
exports.tagTypes = tagTypes;
|
|
308
|
-
|
|
309
240
|
class MethodResponse {
|
|
310
241
|
constructor(statusCode, mediaType, type, description) {
|
|
311
242
|
this.statusCode = statusCode;
|
|
@@ -313,162 +244,118 @@ class MethodResponse {
|
|
|
313
244
|
this.type = type;
|
|
314
245
|
this.description = description;
|
|
315
246
|
}
|
|
316
|
-
|
|
317
247
|
get mode() {
|
|
318
248
|
return (0, _sdkRtl.responseMode)(this.mediaType);
|
|
319
249
|
}
|
|
320
|
-
|
|
321
250
|
search(rx, criteria) {
|
|
322
251
|
if (!criteria.has(SearchCriterion.response)) return false;
|
|
323
252
|
return rx.test(this.searchString(criteria)) || this.type.search(rx, criteria);
|
|
324
253
|
}
|
|
325
|
-
|
|
326
254
|
searchString(criteria) {
|
|
327
255
|
var result = searchIt("".concat(this.statusCode)) + searchIt("".concat(_sdkRtl.ResponseMode[this.mode]));
|
|
328
256
|
if (criteria.has(SearchCriterion.name)) result += searchIt(this.mediaType);
|
|
329
257
|
return result;
|
|
330
258
|
}
|
|
331
|
-
|
|
332
259
|
}
|
|
333
|
-
|
|
334
|
-
class Symbol {
|
|
260
|
+
class _Symbol {
|
|
335
261
|
constructor(name, type) {
|
|
336
262
|
var owner = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
337
263
|
this.name = name;
|
|
338
264
|
this.type = type;
|
|
339
265
|
this.owner = owner;
|
|
340
|
-
|
|
341
266
|
_defineProperty(this, "jsonName", '');
|
|
342
|
-
|
|
343
267
|
_defineProperty(this, "hasSpecialNeeds", false);
|
|
344
|
-
|
|
345
268
|
this.jsonName = name;
|
|
346
269
|
var snake = safeName(name);
|
|
347
|
-
|
|
348
270
|
if (snake !== name) {
|
|
349
271
|
this.name = snake;
|
|
350
272
|
this.hasSpecialNeeds = true;
|
|
351
273
|
}
|
|
352
274
|
}
|
|
353
|
-
|
|
354
275
|
get fullName() {
|
|
355
276
|
return "".concat(this.owner ? this.owner + '.' : '').concat(this.name);
|
|
356
277
|
}
|
|
357
|
-
|
|
358
278
|
asHashString() {
|
|
359
279
|
return "".concat(this.name, ":").concat(this.type.name);
|
|
360
280
|
}
|
|
361
|
-
|
|
362
281
|
search(rx, criteria) {
|
|
363
282
|
return rx.test(this.searchString(criteria)) || this.type.search(rx, criteria);
|
|
364
283
|
}
|
|
365
|
-
|
|
366
284
|
searchString(criteria) {
|
|
367
285
|
var result = '';
|
|
368
286
|
if (criteria.has(SearchCriterion.name) || criteria.has(SearchCriterion.method)) result += searchIt(this.name) + searchIt(this.jsonName);
|
|
369
287
|
return result;
|
|
370
288
|
}
|
|
371
|
-
|
|
372
289
|
}
|
|
373
|
-
|
|
374
|
-
class SchemadSymbol extends Symbol {
|
|
290
|
+
class SchemadSymbol extends _Symbol {
|
|
375
291
|
constructor(name, type, schema) {
|
|
376
292
|
var owner = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
377
293
|
super(name, type, owner);
|
|
378
|
-
|
|
379
294
|
_defineProperty(this, "schema", void 0);
|
|
380
|
-
|
|
381
295
|
_defineProperty(this, "description", void 0);
|
|
382
|
-
|
|
383
296
|
_defineProperty(this, "deprecated", false);
|
|
384
|
-
|
|
385
297
|
this.schema = schema;
|
|
386
298
|
this.description = schema.description || type.description || '';
|
|
387
299
|
this.deprecated = schema.deprecated || schema['x-looker-deprecated'] || false;
|
|
388
300
|
}
|
|
389
|
-
|
|
390
301
|
get status() {
|
|
391
302
|
return this.schema['x-looker-status'] || '';
|
|
392
303
|
}
|
|
393
|
-
|
|
394
304
|
get deprecation() {
|
|
395
305
|
return this.deprecated ? 'deprecated' : '';
|
|
396
306
|
}
|
|
397
|
-
|
|
398
307
|
}
|
|
399
|
-
|
|
400
308
|
class Property extends SchemadSymbol {
|
|
401
309
|
constructor(name, type, schema) {
|
|
402
310
|
var _schema$required;
|
|
403
|
-
|
|
404
311
|
var owner = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
405
312
|
var required = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
406
313
|
super(name, type, schema, owner);
|
|
407
|
-
|
|
408
314
|
_defineProperty(this, "required", false);
|
|
409
|
-
|
|
410
315
|
_defineProperty(this, "nullable", false);
|
|
411
|
-
|
|
412
316
|
_defineProperty(this, "readOnly", false);
|
|
413
|
-
|
|
414
317
|
_defineProperty(this, "writeOnly", false);
|
|
415
|
-
|
|
416
318
|
this.required = !!(required.includes(name) || (_schema$required = schema.required) !== null && _schema$required !== void 0 && _schema$required.includes(name));
|
|
417
319
|
this.nullable = this.schema.nullable || this.schema['x-looker-nullable'] || false;
|
|
418
320
|
this.readOnly = this.schema.readOnly || false;
|
|
419
321
|
this.writeOnly = this.schema.writeOnly || false;
|
|
420
322
|
}
|
|
421
|
-
|
|
422
323
|
tag(key) {
|
|
423
324
|
return this[key] ? " ".concat(key) : '';
|
|
424
325
|
}
|
|
425
|
-
|
|
426
326
|
summary() {
|
|
427
327
|
return "".concat(this.fullName, ":").concat(this.type.name).concat(this.tag('readOnly')).concat(this.tag('required')).concat(this.tag('nullable')).concat(this.tag('deprecated'));
|
|
428
328
|
}
|
|
429
|
-
|
|
430
329
|
asHashString() {
|
|
431
330
|
return super.asHashString() + this.tag('readOnly') + this.tag('required') + this.tag('nullable') + this.tag('deprecated');
|
|
432
331
|
}
|
|
433
|
-
|
|
434
332
|
searchString(criteria) {
|
|
435
333
|
var result = super.searchString(criteria);
|
|
436
334
|
if (criteria.has(SearchCriterion.description)) result += searchIt(this.description);
|
|
437
335
|
if (criteria.has(SearchCriterion.status)) result += searchIt(this.status) + searchIt(this.deprecation);
|
|
438
336
|
return result;
|
|
439
337
|
}
|
|
440
|
-
|
|
441
338
|
search(rx, criteria) {
|
|
442
339
|
return rx.test(this.searchString(criteria)) || this.type.search(rx, criteria);
|
|
443
340
|
}
|
|
444
|
-
|
|
445
341
|
}
|
|
446
|
-
|
|
447
342
|
exports.Property = Property;
|
|
448
|
-
|
|
449
343
|
class Parameter extends SchemadSymbol {
|
|
450
344
|
constructor(param, type) {
|
|
451
345
|
var owner = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
452
346
|
super(param.name || '', type, type.schema, owner);
|
|
453
|
-
|
|
454
347
|
_defineProperty(this, "description", '');
|
|
455
|
-
|
|
456
348
|
_defineProperty(this, "location", 'query');
|
|
457
|
-
|
|
458
349
|
_defineProperty(this, "required", false);
|
|
459
|
-
|
|
460
350
|
this.description = param.description || type.description || '';
|
|
461
|
-
|
|
462
351
|
if ('in' in param) {
|
|
463
352
|
this.location = param.in;
|
|
464
353
|
} else {
|
|
465
354
|
this.location = param.location || strBody;
|
|
466
355
|
}
|
|
467
|
-
|
|
468
356
|
this.deprecated = param.deprecated || this.deprecated;
|
|
469
357
|
this.required = param.required || false;
|
|
470
358
|
}
|
|
471
|
-
|
|
472
359
|
asSchemaObject() {
|
|
473
360
|
return {
|
|
474
361
|
deprecated: this.deprecated,
|
|
@@ -480,60 +367,46 @@ class Parameter extends SchemadSymbol {
|
|
|
480
367
|
writeOnly: false
|
|
481
368
|
};
|
|
482
369
|
}
|
|
483
|
-
|
|
484
370
|
asProperty() {
|
|
485
371
|
return new Property(this.name, this.type, this.asSchemaObject());
|
|
486
372
|
}
|
|
487
|
-
|
|
488
373
|
tag(key) {
|
|
489
374
|
return this[key] ? " ".concat(key) : '';
|
|
490
375
|
}
|
|
491
|
-
|
|
492
376
|
signature() {
|
|
493
377
|
return (this.required ? '' : '[') + this.name + ':' + this.type.name + (this.required ? '' : ']');
|
|
494
378
|
}
|
|
495
|
-
|
|
496
379
|
summary() {
|
|
497
380
|
return "".concat(this.fullName, ":").concat(this.type.name).concat(this.tag('readOnly')).concat(this.tag('required')).concat(this.tag('nullable')).concat(this.tag('deprecated'));
|
|
498
381
|
}
|
|
499
|
-
|
|
500
382
|
asHashString() {
|
|
501
383
|
return "".concat(this.name, ":").concat(this.type.name).concat(this.required ? '' : '?').concat(this.location);
|
|
502
384
|
}
|
|
503
|
-
|
|
504
385
|
doEncode() {
|
|
505
386
|
return this.type.name === 'string' || this.type.name === 'datetime' || this.type.name === 'date';
|
|
506
387
|
}
|
|
507
|
-
|
|
508
388
|
searchString(criteria) {
|
|
509
389
|
var result = '';
|
|
510
390
|
if (criteria.has(SearchCriterion.name)) result += searchIt(this.name);
|
|
511
391
|
if (criteria.has(SearchCriterion.description)) result += searchIt(this.description);
|
|
512
392
|
return result;
|
|
513
393
|
}
|
|
514
|
-
|
|
515
394
|
search(rx, criteria) {
|
|
516
395
|
return rx.test(this.searchString(criteria)) || this.type.search(rx, criteria);
|
|
517
396
|
}
|
|
518
|
-
|
|
519
397
|
}
|
|
520
|
-
|
|
521
398
|
exports.Parameter = Parameter;
|
|
522
|
-
|
|
523
399
|
class Method extends SchemadSymbol {
|
|
524
400
|
constructor(api, httpMethod, endpoint, schema, params, responses, body) {
|
|
525
401
|
if (!schema.operationId) {
|
|
526
402
|
throw new Error('Missing operationId');
|
|
527
403
|
}
|
|
528
|
-
|
|
529
404
|
var okays = responses.filter(response => {
|
|
530
405
|
return response.statusCode === _sdkRtl.StatusCode.OK || response.statusCode === _sdkRtl.StatusCode.NoContent;
|
|
531
406
|
});
|
|
532
|
-
|
|
533
407
|
if (!okays) {
|
|
534
408
|
throw new Error("Missing 2xx + application/json response in ".concat(endpoint));
|
|
535
409
|
}
|
|
536
|
-
|
|
537
410
|
var primaryResponse = okays.find(response => {
|
|
538
411
|
return response.statusCode === _sdkRtl.StatusCode.OK && response.mediaType === 'application/json';
|
|
539
412
|
}) || okays.find(response => {
|
|
@@ -541,45 +414,27 @@ class Method extends SchemadSymbol {
|
|
|
541
414
|
}) || okays.find(response => {
|
|
542
415
|
return response.statusCode === _sdkRtl.StatusCode.NoContent;
|
|
543
416
|
});
|
|
544
|
-
|
|
545
417
|
if (!primaryResponse) {
|
|
546
418
|
throw new Error("Missing 2xx + application/json response in ".concat(endpoint));
|
|
547
419
|
}
|
|
548
|
-
|
|
549
420
|
super(schema.operationId, primaryResponse.type, schema);
|
|
550
|
-
|
|
551
421
|
_defineProperty(this, "id", void 0);
|
|
552
|
-
|
|
553
422
|
_defineProperty(this, "httpMethod", void 0);
|
|
554
|
-
|
|
555
423
|
_defineProperty(this, "endpoint", void 0);
|
|
556
|
-
|
|
557
424
|
_defineProperty(this, "primaryResponse", void 0);
|
|
558
|
-
|
|
559
425
|
_defineProperty(this, "responses", void 0);
|
|
560
|
-
|
|
561
426
|
_defineProperty(this, "okResponses", void 0);
|
|
562
|
-
|
|
563
427
|
_defineProperty(this, "params", void 0);
|
|
564
|
-
|
|
565
428
|
_defineProperty(this, "responseModes", void 0);
|
|
566
|
-
|
|
567
429
|
_defineProperty(this, "activityType", void 0);
|
|
568
|
-
|
|
569
430
|
_defineProperty(this, "customTypes", void 0);
|
|
570
|
-
|
|
571
431
|
_defineProperty(this, "types", void 0);
|
|
572
|
-
|
|
573
432
|
_defineProperty(this, "rateLimited", void 0);
|
|
574
|
-
|
|
575
433
|
_defineProperty(this, "returnType", void 0);
|
|
576
|
-
|
|
577
434
|
this.okResponses = okays;
|
|
578
|
-
|
|
579
435
|
if (okays.length === 1) {
|
|
580
436
|
this.returnType = primaryResponse;
|
|
581
437
|
}
|
|
582
|
-
|
|
583
438
|
this.customTypes = new Set();
|
|
584
439
|
this.types = new Set();
|
|
585
440
|
this.httpMethod = httpMethod;
|
|
@@ -591,41 +446,32 @@ class Method extends SchemadSymbol {
|
|
|
591
446
|
this.params = [];
|
|
592
447
|
params.forEach(p => this.addParam(api, p));
|
|
593
448
|
responses.forEach(r => this.addType(api, r.type));
|
|
594
|
-
|
|
595
449
|
if (body) {
|
|
596
450
|
this.addParam(api, body);
|
|
597
451
|
}
|
|
598
|
-
|
|
599
452
|
this.activityType = schema['x-looker-activity-type'];
|
|
600
453
|
this.rateLimited = Method.isRateLimited(schema);
|
|
601
454
|
}
|
|
602
|
-
|
|
603
455
|
static isRateLimited(op) {
|
|
604
456
|
if (op['x-looker-rate-limited']) return true;
|
|
605
457
|
var many = ['X-RateLimit-Limit', 'X-RateLimit-Remaining', 'X-RateLimit-Reset', 'X-Rate-Limit-Limit', 'X-Rate-Limit-Remaining', 'X-Rate-Limit-Reset'];
|
|
606
|
-
|
|
607
458
|
for (var flag of many) {
|
|
608
459
|
if (flag in op) return true;
|
|
609
460
|
}
|
|
610
|
-
|
|
611
461
|
return false;
|
|
612
462
|
}
|
|
613
|
-
|
|
614
463
|
eligibleForRequestType() {
|
|
615
464
|
var [body] = this.bodyParams;
|
|
616
465
|
var offset = body && "required" in body && !body.required ? 1 : 0;
|
|
617
466
|
return this.optionalParams.length - offset > 1;
|
|
618
467
|
}
|
|
619
|
-
|
|
620
468
|
makeTypes(api) {
|
|
621
469
|
if (this.eligibleForRequestType()) {
|
|
622
470
|
api.getRequestType(this);
|
|
623
471
|
}
|
|
624
|
-
|
|
625
472
|
Object.entries(this.params).forEach(_ref3 => {
|
|
626
473
|
var [, param] = _ref3;
|
|
627
474
|
var writer = api.mayGetWriteableType(param.type);
|
|
628
|
-
|
|
629
475
|
if (writer) {
|
|
630
476
|
this.types.add(writer.name);
|
|
631
477
|
this.customTypes.add(writer.name);
|
|
@@ -633,246 +479,189 @@ class Method extends SchemadSymbol {
|
|
|
633
479
|
});
|
|
634
480
|
return this.types;
|
|
635
481
|
}
|
|
636
|
-
|
|
637
482
|
addParam(api, param) {
|
|
638
483
|
param.owner = this.name;
|
|
639
484
|
this.params.push(param);
|
|
640
485
|
this.addType(api, param.type);
|
|
641
486
|
return this;
|
|
642
487
|
}
|
|
643
|
-
|
|
644
488
|
addType(api, type) {
|
|
645
489
|
this.types.add(type.name);
|
|
646
490
|
type.methodRefs.add(this.name);
|
|
647
491
|
var custom = type.customType;
|
|
648
|
-
|
|
649
492
|
if (custom) {
|
|
650
493
|
this.customTypes.add(custom);
|
|
651
494
|
var customType = api.types[custom];
|
|
652
495
|
customType.methodRefs.add(this.name);
|
|
653
496
|
}
|
|
654
|
-
|
|
655
497
|
return this;
|
|
656
498
|
}
|
|
657
|
-
|
|
658
499
|
getResponseModes() {
|
|
659
500
|
var modes = new Set();
|
|
660
|
-
|
|
661
501
|
for (var resp of this.responses) {
|
|
662
502
|
var mode = resp.mode;
|
|
663
503
|
if (mode !== _sdkRtl.ResponseMode.unknown) modes.add(mode);
|
|
664
504
|
}
|
|
665
|
-
|
|
666
505
|
if (modes.size === 0) {
|
|
667
506
|
throw new Error("Is ".concat(this.operationId, " ").concat(JSON.stringify(this.responses), " binary or string?"));
|
|
668
507
|
}
|
|
669
|
-
|
|
670
508
|
return modes;
|
|
671
509
|
}
|
|
672
|
-
|
|
673
510
|
get operationId() {
|
|
674
511
|
return this.name;
|
|
675
512
|
}
|
|
676
|
-
|
|
677
513
|
get summary() {
|
|
678
514
|
return this.schema.summary || '';
|
|
679
515
|
}
|
|
680
|
-
|
|
681
516
|
signature() {
|
|
682
517
|
var result = this.operationId + '(';
|
|
683
518
|
var allParams = this.allParams;
|
|
684
|
-
|
|
685
519
|
if (allParams) {
|
|
686
520
|
allParams.forEach((param, index) => {
|
|
687
521
|
if (index > 0) result += ', ';
|
|
688
522
|
result += param.signature();
|
|
689
523
|
});
|
|
690
524
|
}
|
|
691
|
-
|
|
692
525
|
result += ')';
|
|
693
526
|
return result;
|
|
694
527
|
}
|
|
695
|
-
|
|
696
528
|
get requiredParams() {
|
|
697
529
|
return this.required('path').concat(this.required(strBody), this.required('query'), this.required('header'), this.required('cookie'));
|
|
698
530
|
}
|
|
699
|
-
|
|
700
531
|
get optionalParams() {
|
|
701
532
|
return this.optional('path').concat(this.optional(strBody), this.optional('query'), this.optional('header'), this.optional('cookie'));
|
|
702
533
|
}
|
|
703
|
-
|
|
704
534
|
get allParams() {
|
|
705
535
|
return this.requiredParams.concat(this.optionalParams);
|
|
706
536
|
}
|
|
707
|
-
|
|
708
537
|
get pathParams() {
|
|
709
538
|
return this.getParams('path');
|
|
710
539
|
}
|
|
711
|
-
|
|
712
540
|
get bodyParams() {
|
|
713
541
|
return this.getParams(strBody);
|
|
714
542
|
}
|
|
715
|
-
|
|
716
543
|
get queryParams() {
|
|
717
544
|
return this.getParams('query');
|
|
718
545
|
}
|
|
719
|
-
|
|
720
546
|
get headerParams() {
|
|
721
547
|
return this.getParams('header');
|
|
722
548
|
}
|
|
723
|
-
|
|
724
549
|
get cookieParams() {
|
|
725
550
|
return this.getParams('cookie');
|
|
726
551
|
}
|
|
727
|
-
|
|
728
552
|
get pathArgs() {
|
|
729
553
|
return this.argumentNames('path');
|
|
730
554
|
}
|
|
731
|
-
|
|
732
555
|
get bodyArg() {
|
|
733
556
|
var body = this.argumentNames(strBody);
|
|
734
557
|
if (body.length === 0) return '';
|
|
735
558
|
return body[0];
|
|
736
559
|
}
|
|
737
|
-
|
|
738
560
|
get queryArgs() {
|
|
739
561
|
return this.argumentNames('query');
|
|
740
562
|
}
|
|
741
|
-
|
|
742
563
|
get headerArgs() {
|
|
743
564
|
return this.argumentNames('header');
|
|
744
565
|
}
|
|
745
|
-
|
|
746
566
|
get cookieArgs() {
|
|
747
567
|
return this.argumentNames('cookie');
|
|
748
568
|
}
|
|
749
|
-
|
|
750
569
|
get errorResponses() {
|
|
751
570
|
var result = [];
|
|
752
571
|
var map = new Map();
|
|
753
|
-
|
|
754
572
|
for (var item of this.responses.filter(r => r.statusCode >= 400)) {
|
|
755
573
|
if (!map.has(item.type.name)) {
|
|
756
574
|
map.set(item.type.name, true);
|
|
757
575
|
result.push(item);
|
|
758
576
|
}
|
|
759
577
|
}
|
|
760
|
-
|
|
761
578
|
return result;
|
|
762
579
|
}
|
|
763
|
-
|
|
764
580
|
getParams(location) {
|
|
765
581
|
if (location) {
|
|
766
582
|
return this.params.filter(p => p.location === location);
|
|
767
583
|
}
|
|
768
|
-
|
|
769
584
|
return this.params;
|
|
770
585
|
}
|
|
771
|
-
|
|
772
586
|
responseIsBinary() {
|
|
773
587
|
return this.responseModes.has(_sdkRtl.ResponseMode.binary);
|
|
774
588
|
}
|
|
775
|
-
|
|
776
589
|
responseIsString() {
|
|
777
590
|
return this.responseModes.has(_sdkRtl.ResponseMode.string);
|
|
778
591
|
}
|
|
779
|
-
|
|
780
592
|
responseIsBoth() {
|
|
781
593
|
return this.responseIsBinary() && this.responseIsString();
|
|
782
594
|
}
|
|
783
|
-
|
|
784
595
|
static locationSorter(a, b) {
|
|
785
596
|
var remain = 0;
|
|
786
597
|
var before = -1;
|
|
787
598
|
var locations = ['path', strBody, 'query', 'header', 'cookie'];
|
|
788
599
|
if (a.location === b.location) return remain;
|
|
789
|
-
|
|
790
600
|
for (var _location of locations) {
|
|
791
601
|
if (a.location === _location) {
|
|
792
602
|
return remain;
|
|
793
603
|
}
|
|
794
|
-
|
|
795
604
|
if (b.location === _location) {
|
|
796
605
|
return before;
|
|
797
606
|
}
|
|
798
607
|
}
|
|
799
|
-
|
|
800
608
|
return remain;
|
|
801
609
|
}
|
|
802
|
-
|
|
803
610
|
sort(list) {
|
|
804
611
|
if (!list) list = this.params;
|
|
805
612
|
return list.sort((a, b) => Method.locationSorter(a, b));
|
|
806
613
|
}
|
|
807
|
-
|
|
808
614
|
required(location) {
|
|
809
615
|
var list = this.params.filter(i => i.required);
|
|
810
|
-
|
|
811
616
|
if (location) {
|
|
812
617
|
list = list.filter(i => i.location === location);
|
|
813
618
|
}
|
|
814
|
-
|
|
815
619
|
return list;
|
|
816
620
|
}
|
|
817
|
-
|
|
818
621
|
optional(location) {
|
|
819
622
|
var list = this.params.filter(i => !i.required);
|
|
820
|
-
|
|
821
623
|
if (location) {
|
|
822
624
|
list = list.filter(i => i.location === location);
|
|
823
625
|
}
|
|
824
|
-
|
|
825
626
|
return list;
|
|
826
627
|
}
|
|
827
|
-
|
|
828
628
|
hasOptionalParams() {
|
|
829
629
|
return this.optional().length > 0;
|
|
830
630
|
}
|
|
831
|
-
|
|
832
631
|
argumentNames(location) {
|
|
833
632
|
return this.getParams(location).map(p => p.name);
|
|
834
633
|
}
|
|
835
|
-
|
|
836
634
|
isMethodSearch(criteria) {
|
|
837
635
|
return criteria.has(SearchCriterion.method) || criteria.has(SearchCriterion.status) || criteria.has(SearchCriterion.activityType) || criteria.has(SearchCriterion.name) || criteria.has(SearchCriterion.argument);
|
|
838
636
|
}
|
|
839
|
-
|
|
840
637
|
searchString() {
|
|
841
638
|
var criteria = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SearchAll;
|
|
842
639
|
if (!this.isMethodSearch(criteria)) return '';
|
|
843
640
|
var result = super.searchString(criteria);
|
|
844
641
|
result += searchIt(this.summary) + searchIt(this.endpoint);
|
|
845
|
-
|
|
846
642
|
if (criteria.has(SearchCriterion.method)) {
|
|
847
643
|
if (criteria.has(SearchCriterion.description)) {
|
|
848
644
|
result += searchIt(this.description);
|
|
849
645
|
}
|
|
850
646
|
}
|
|
851
|
-
|
|
852
647
|
if (criteria.has(SearchCriterion.activityType)) {
|
|
853
648
|
if (this.rateLimited) {
|
|
854
649
|
result += searchIt('rate_limited');
|
|
855
650
|
}
|
|
856
|
-
|
|
857
651
|
result += searchIt(this.activityType);
|
|
858
652
|
}
|
|
859
|
-
|
|
860
653
|
if (criteria.has(SearchCriterion.status)) {
|
|
861
654
|
result += searchIt(this.status) + searchIt(this.deprecation);
|
|
862
655
|
}
|
|
863
|
-
|
|
864
656
|
if (criteria.has(SearchCriterion.argument)) {
|
|
865
657
|
this.params.forEach(p => {
|
|
866
658
|
result += p.searchString(criteria);
|
|
867
659
|
});
|
|
868
660
|
}
|
|
869
|
-
|
|
870
661
|
return result;
|
|
871
662
|
}
|
|
872
|
-
|
|
873
663
|
search(rx, criteria) {
|
|
874
664
|
var result = rx.test(this.searchString(criteria)) || this.type.search(rx, criteria);
|
|
875
|
-
|
|
876
665
|
if (!result && criteria.has(SearchCriterion.argument)) {
|
|
877
666
|
for (var a of this.params) {
|
|
878
667
|
if (a.search(rx, criteria)) {
|
|
@@ -881,7 +670,6 @@ class Method extends SchemadSymbol {
|
|
|
881
670
|
}
|
|
882
671
|
}
|
|
883
672
|
}
|
|
884
|
-
|
|
885
673
|
if (!result && criteria.has(SearchCriterion.response)) {
|
|
886
674
|
for (var r of this.responses) {
|
|
887
675
|
if (r.search(rx, criteria)) {
|
|
@@ -890,50 +678,32 @@ class Method extends SchemadSymbol {
|
|
|
890
678
|
}
|
|
891
679
|
}
|
|
892
680
|
}
|
|
893
|
-
|
|
894
681
|
return result;
|
|
895
682
|
}
|
|
896
|
-
|
|
897
683
|
}
|
|
898
|
-
|
|
899
684
|
exports.Method = Method;
|
|
900
|
-
|
|
901
685
|
class Type {
|
|
902
686
|
constructor(schema, name) {
|
|
903
687
|
this.schema = schema;
|
|
904
688
|
this.name = name;
|
|
905
|
-
|
|
906
689
|
_defineProperty(this, "properties", {});
|
|
907
|
-
|
|
908
690
|
_defineProperty(this, "methodRefs", new Set());
|
|
909
|
-
|
|
910
691
|
_defineProperty(this, "types", new Set());
|
|
911
|
-
|
|
912
692
|
_defineProperty(this, "customTypes", new Set());
|
|
913
|
-
|
|
914
693
|
_defineProperty(this, "parentTypes", new Set());
|
|
915
|
-
|
|
916
694
|
_defineProperty(this, "_writeable", []);
|
|
917
|
-
|
|
918
695
|
_defineProperty(this, "description", void 0);
|
|
919
|
-
|
|
920
696
|
_defineProperty(this, "customType", void 0);
|
|
921
|
-
|
|
922
697
|
_defineProperty(this, "jsonName", '');
|
|
923
|
-
|
|
924
698
|
_defineProperty(this, "refCount", 0);
|
|
925
|
-
|
|
926
699
|
this.jsonName = name;
|
|
927
700
|
var snake = safeName(name);
|
|
928
|
-
|
|
929
701
|
if (snake !== name) {
|
|
930
702
|
this.name = snake;
|
|
931
703
|
}
|
|
932
|
-
|
|
933
704
|
this.customType = name;
|
|
934
705
|
this.description = this.schema.description || '';
|
|
935
706
|
}
|
|
936
|
-
|
|
937
707
|
get metaType() {
|
|
938
708
|
if (this.intrinsic) return MetaType.Intrinsic;
|
|
939
709
|
if (this instanceof RequestType) return MetaType.Request;
|
|
@@ -941,30 +711,24 @@ class Type {
|
|
|
941
711
|
if (this instanceof EnumType) return MetaType.Enumerated;
|
|
942
712
|
return MetaType.Specification;
|
|
943
713
|
}
|
|
944
|
-
|
|
945
714
|
get fullName() {
|
|
946
715
|
return this.name;
|
|
947
716
|
}
|
|
948
|
-
|
|
949
717
|
get owner() {
|
|
950
718
|
return '';
|
|
951
719
|
}
|
|
952
|
-
|
|
953
720
|
get writeable() {
|
|
954
721
|
return this._writeable;
|
|
955
722
|
}
|
|
956
|
-
|
|
957
723
|
setWriteable(api) {
|
|
958
724
|
var result = [];
|
|
959
725
|
Object.values(this.properties).filter(prop => !(prop.readOnly || prop.type.readOnly)).forEach(prop => {
|
|
960
726
|
var type = prop.type;
|
|
961
727
|
var w = type.intrinsic ? undefined : api.mayGetWriteableType(type);
|
|
962
|
-
|
|
963
728
|
if (w) {
|
|
964
729
|
var writeProp = _objectSpread(_objectSpread({}, prop), {
|
|
965
730
|
type: w
|
|
966
731
|
});
|
|
967
|
-
|
|
968
732
|
result.push(writeProp);
|
|
969
733
|
} else {
|
|
970
734
|
result.push(prop);
|
|
@@ -973,104 +737,82 @@ class Type {
|
|
|
973
737
|
this._writeable = result;
|
|
974
738
|
return this._writeable;
|
|
975
739
|
}
|
|
976
|
-
|
|
977
740
|
maySetWriteable(api) {
|
|
978
741
|
if (this._writeable.length === 0) {
|
|
979
742
|
this.setWriteable(api);
|
|
980
743
|
}
|
|
981
|
-
|
|
982
744
|
return this._writeable;
|
|
983
745
|
}
|
|
984
|
-
|
|
985
746
|
get className() {
|
|
986
747
|
return this.name;
|
|
987
748
|
}
|
|
988
|
-
|
|
989
749
|
get intrinsic() {
|
|
990
750
|
return false;
|
|
991
751
|
}
|
|
992
|
-
|
|
993
752
|
get status() {
|
|
994
753
|
return this.schema['x-looker-status'] || '';
|
|
995
754
|
}
|
|
996
|
-
|
|
997
755
|
get deprecated() {
|
|
998
756
|
return this.schema.deprecated || this.schema['x-looker-deprecated'] || false;
|
|
999
757
|
}
|
|
1000
|
-
|
|
1001
758
|
get title() {
|
|
1002
759
|
return this.schema.title || '';
|
|
1003
760
|
}
|
|
1004
|
-
|
|
1005
761
|
get default() {
|
|
1006
762
|
return this.schema.default || '';
|
|
1007
763
|
}
|
|
1008
|
-
|
|
1009
764
|
get readOnly() {
|
|
1010
765
|
return Object.entries(this.properties).every(_ref4 => {
|
|
1011
766
|
var [, prop] = _ref4;
|
|
1012
767
|
return prop.readOnly;
|
|
1013
768
|
});
|
|
1014
769
|
}
|
|
1015
|
-
|
|
1016
770
|
filterRequiredProps(required) {
|
|
1017
771
|
var filteredProps = {};
|
|
1018
772
|
Object.entries(this.properties).forEach(_ref5 => {
|
|
1019
773
|
var [key, prop] = _ref5;
|
|
1020
774
|
var condition = required ? prop.required : !prop.required;
|
|
1021
|
-
|
|
1022
775
|
if (condition) {
|
|
1023
776
|
filteredProps[key] = prop;
|
|
1024
777
|
}
|
|
1025
778
|
});
|
|
1026
779
|
return filteredProps;
|
|
1027
780
|
}
|
|
1028
|
-
|
|
1029
781
|
get requiredProperties() {
|
|
1030
782
|
return this.filterRequiredProps(true);
|
|
1031
783
|
}
|
|
1032
|
-
|
|
1033
784
|
get optionalProperties() {
|
|
1034
785
|
return this.filterRequiredProps(false);
|
|
1035
786
|
}
|
|
1036
|
-
|
|
1037
787
|
get hasSpecialNeeds() {
|
|
1038
788
|
return !!Object.entries(this.properties).find(_ref6 => {
|
|
1039
789
|
var [, prop] = _ref6;
|
|
1040
790
|
return prop.hasSpecialNeeds;
|
|
1041
791
|
});
|
|
1042
792
|
}
|
|
1043
|
-
|
|
1044
793
|
load(api) {
|
|
1045
794
|
Object.entries(this.schema.properties || {}).forEach(_ref7 => {
|
|
1046
795
|
var [propName, propSchema] = _ref7;
|
|
1047
796
|
var propType = api.resolveType(propSchema, undefined, propName, this.name);
|
|
1048
|
-
|
|
1049
797
|
if (propType.instanceOf('EnumType')) {
|
|
1050
798
|
api.registerEnum(propType, propName);
|
|
1051
799
|
}
|
|
1052
|
-
|
|
1053
800
|
propType.parentTypes.add(this.name);
|
|
1054
|
-
|
|
1055
801
|
if (propType.instanceOf('ArrayType') || propType.instanceOf('HashType')) {
|
|
1056
802
|
var _propType$elementType, _propType$elementType2;
|
|
1057
|
-
|
|
1058
803
|
(_propType$elementType = propType.elementType) === null || _propType$elementType === void 0 ? void 0 : _propType$elementType.parentTypes.add(propType.name);
|
|
1059
804
|
(_propType$elementType2 = propType.elementType) === null || _propType$elementType2 === void 0 ? void 0 : _propType$elementType2.parentTypes.add(this.name);
|
|
1060
805
|
propType.parentTypes.add(this.name);
|
|
1061
806
|
}
|
|
1062
|
-
|
|
1063
807
|
this.types.add(propType.name);
|
|
1064
808
|
var customType = propType.customType;
|
|
1065
809
|
if (customType) this.customTypes.add(customType);
|
|
1066
810
|
this.properties[safeName(propName)] = new Property(propName, propType, propSchema, this.name, this.schema.required);
|
|
1067
811
|
});
|
|
1068
812
|
}
|
|
1069
|
-
|
|
1070
813
|
instanceOf(className) {
|
|
1071
814
|
return this.className === className;
|
|
1072
815
|
}
|
|
1073
|
-
|
|
1074
816
|
asHashString() {
|
|
1075
817
|
var result = "".concat(this.name, ":");
|
|
1076
818
|
Object.entries(this.properties).sort((_ref8, _ref9) => {
|
|
@@ -1083,7 +825,6 @@ class Type {
|
|
|
1083
825
|
});
|
|
1084
826
|
return result;
|
|
1085
827
|
}
|
|
1086
|
-
|
|
1087
828
|
isRecursive() {
|
|
1088
829
|
var selfType = this.name;
|
|
1089
830
|
return Object.entries(this.properties).some(_ref11 => {
|
|
@@ -1091,15 +832,12 @@ class Type {
|
|
|
1091
832
|
return prop.type.name === selfType;
|
|
1092
833
|
});
|
|
1093
834
|
}
|
|
1094
|
-
|
|
1095
835
|
static isPropSearch(criteria) {
|
|
1096
836
|
return criteria.has(SearchCriterion.status) || criteria.has(SearchCriterion.property);
|
|
1097
837
|
}
|
|
1098
|
-
|
|
1099
838
|
search(rx, criteria) {
|
|
1100
839
|
if (!criteria.has(SearchCriterion.type) && !criteria.has(SearchCriterion.status)) return false;
|
|
1101
840
|
var result = rx.test(this.searchString(criteria));
|
|
1102
|
-
|
|
1103
841
|
if (!result && Type.isPropSearch(criteria)) {
|
|
1104
842
|
for (var [, prop] of Object.entries(this.properties)) {
|
|
1105
843
|
if (this.name !== prop.type.name) {
|
|
@@ -1110,66 +848,49 @@ class Type {
|
|
|
1110
848
|
}
|
|
1111
849
|
}
|
|
1112
850
|
}
|
|
1113
|
-
|
|
1114
851
|
return result;
|
|
1115
852
|
}
|
|
1116
|
-
|
|
1117
853
|
searchString(criteria) {
|
|
1118
854
|
var result = '';
|
|
1119
855
|
if (criteria.has(SearchCriterion.name)) result += searchIt(this.name);
|
|
1120
856
|
if (criteria.has(SearchCriterion.description)) result += searchIt(this.description);
|
|
1121
857
|
if (criteria.has(SearchCriterion.title)) result += searchIt(this.title);
|
|
1122
|
-
|
|
1123
858
|
if (criteria.has(SearchCriterion.status)) {
|
|
1124
859
|
result += searchIt(this.status);
|
|
1125
860
|
if (this.deprecated) result += searchIt('deprecated');
|
|
1126
861
|
}
|
|
1127
|
-
|
|
1128
862
|
if (criteria.has(SearchCriterion.property)) {
|
|
1129
863
|
Object.entries(this.properties).forEach(_ref12 => {
|
|
1130
864
|
var [, prop] = _ref12;
|
|
1131
|
-
|
|
1132
865
|
if (this.name !== prop.type.name) {
|
|
1133
866
|
result += prop.searchString(criteria);
|
|
1134
867
|
}
|
|
1135
868
|
});
|
|
1136
869
|
}
|
|
1137
|
-
|
|
1138
870
|
return result;
|
|
1139
871
|
}
|
|
1140
|
-
|
|
1141
872
|
}
|
|
1142
|
-
|
|
1143
873
|
exports.Type = Type;
|
|
1144
|
-
|
|
1145
874
|
class ArrayType extends Type {
|
|
1146
875
|
constructor(elementType, schema) {
|
|
1147
876
|
super(schema, "".concat(elementType.name, "[]"));
|
|
1148
877
|
this.elementType = elementType;
|
|
1149
878
|
this.customType = elementType.customType;
|
|
1150
879
|
}
|
|
1151
|
-
|
|
1152
880
|
get className() {
|
|
1153
881
|
return 'ArrayType';
|
|
1154
882
|
}
|
|
1155
|
-
|
|
1156
883
|
get readOnly() {
|
|
1157
884
|
return this.elementType.readOnly;
|
|
1158
885
|
}
|
|
1159
|
-
|
|
1160
886
|
}
|
|
1161
|
-
|
|
1162
887
|
exports.ArrayType = ArrayType;
|
|
1163
|
-
|
|
1164
888
|
class EnumType extends Type {
|
|
1165
889
|
constructor(elementType, schema, api, typeName, methodName) {
|
|
1166
890
|
super(schema, schema.name);
|
|
1167
891
|
this.elementType = elementType;
|
|
1168
|
-
|
|
1169
892
|
_defineProperty(this, "values", void 0);
|
|
1170
|
-
|
|
1171
893
|
this.customType = elementType.customType;
|
|
1172
|
-
|
|
1173
894
|
if (lookerValuesTag in schema) {
|
|
1174
895
|
this.values = schema[lookerValuesTag];
|
|
1175
896
|
} else if (enumTag in schema) {
|
|
@@ -1177,69 +898,51 @@ class EnumType extends Type {
|
|
|
1177
898
|
} else {
|
|
1178
899
|
throw new Error("".concat(schema.name, " is an enum but has no defined enum values"));
|
|
1179
900
|
}
|
|
1180
|
-
|
|
1181
901
|
if (methodName) {
|
|
1182
902
|
this.description = "".concat(this.description).concat(this.description ? ' ' : '', "(Enum defined in ").concat(methodName, ")");
|
|
1183
903
|
}
|
|
1184
|
-
|
|
1185
904
|
this.name = this.findName(api, typeName, methodName);
|
|
1186
905
|
}
|
|
1187
|
-
|
|
1188
906
|
findName(api, typeName, methodName) {
|
|
1189
907
|
var hash = (0, _blueimpMd.default)(this.asHashString());
|
|
1190
908
|
var enums = api.getEnumList();
|
|
1191
909
|
var name = titleCase(this.name || typeName || 'Enum');
|
|
1192
|
-
|
|
1193
910
|
if (name in api.types) {
|
|
1194
911
|
var matched = enums[hash];
|
|
1195
|
-
|
|
1196
912
|
if ((matched === null || matched === void 0 ? void 0 : matched.name) === name) {
|
|
1197
913
|
return name;
|
|
1198
914
|
}
|
|
1199
|
-
|
|
1200
915
|
var baseName = methodName ? titleCase("".concat(methodName, "_").concat(name)) : name;
|
|
1201
916
|
var newName = baseName;
|
|
1202
917
|
var i = 0;
|
|
1203
|
-
|
|
1204
918
|
while (newName in api.types) {
|
|
1205
919
|
newName = "".concat(baseName).concat(++i);
|
|
1206
920
|
}
|
|
1207
|
-
|
|
1208
921
|
name = newName;
|
|
1209
922
|
}
|
|
1210
|
-
|
|
1211
923
|
enums[hash] = this;
|
|
1212
924
|
return name;
|
|
1213
925
|
}
|
|
1214
|
-
|
|
1215
926
|
searchString(criteria) {
|
|
1216
927
|
var result = super.searchString(criteria);
|
|
1217
|
-
|
|
1218
928
|
if (criteria.has(SearchCriterion.property)) {
|
|
1219
929
|
for (var val in this.values) {
|
|
1220
930
|
result += searchIt(val.toString());
|
|
1221
931
|
}
|
|
1222
932
|
}
|
|
1223
|
-
|
|
1224
933
|
return result;
|
|
1225
934
|
}
|
|
1226
|
-
|
|
1227
935
|
get className() {
|
|
1228
936
|
return 'EnumType';
|
|
1229
937
|
}
|
|
1230
|
-
|
|
1231
938
|
get readOnly() {
|
|
1232
939
|
return this.elementType.readOnly;
|
|
1233
940
|
}
|
|
1234
|
-
|
|
1235
941
|
asHashString() {
|
|
1236
942
|
return this.values.join();
|
|
1237
943
|
}
|
|
1238
|
-
|
|
1239
944
|
}
|
|
1240
|
-
|
|
1241
945
|
exports.EnumType = EnumType;
|
|
1242
|
-
|
|
1243
946
|
class DelimArrayType extends Type {
|
|
1244
947
|
constructor(elementType, schema) {
|
|
1245
948
|
super(schema, "DelimArray<".concat(elementType.name, ">"));
|
|
@@ -1247,69 +950,48 @@ class DelimArrayType extends Type {
|
|
|
1247
950
|
this.elementType = elementType;
|
|
1248
951
|
this.customType = elementType.customType;
|
|
1249
952
|
}
|
|
1250
|
-
|
|
1251
953
|
get className() {
|
|
1252
954
|
return 'DelimArrayType';
|
|
1253
955
|
}
|
|
1254
|
-
|
|
1255
956
|
get readOnly() {
|
|
1256
957
|
return this.elementType.readOnly;
|
|
1257
958
|
}
|
|
1258
|
-
|
|
1259
959
|
}
|
|
1260
|
-
|
|
1261
960
|
exports.DelimArrayType = DelimArrayType;
|
|
1262
|
-
|
|
1263
961
|
class HashType extends Type {
|
|
1264
962
|
constructor(elementType, schema) {
|
|
1265
963
|
super(schema, "Hash[".concat(elementType.name, "]"));
|
|
1266
|
-
|
|
1267
964
|
_defineProperty(this, "elementType", void 0);
|
|
1268
|
-
|
|
1269
965
|
this.elementType = elementType;
|
|
1270
966
|
this.customType = elementType.customType;
|
|
1271
967
|
}
|
|
1272
|
-
|
|
1273
968
|
get className() {
|
|
1274
969
|
return 'HashType';
|
|
1275
970
|
}
|
|
1276
|
-
|
|
1277
971
|
get readOnly() {
|
|
1278
972
|
return this.elementType.readOnly;
|
|
1279
973
|
}
|
|
1280
|
-
|
|
1281
974
|
}
|
|
1282
|
-
|
|
1283
975
|
exports.HashType = HashType;
|
|
1284
|
-
|
|
1285
976
|
class IntrinsicType extends Type {
|
|
1286
977
|
constructor(name) {
|
|
1287
978
|
super({}, name);
|
|
1288
|
-
|
|
1289
979
|
_defineProperty(this, "isString", false);
|
|
1290
|
-
|
|
1291
980
|
this.customType = '';
|
|
1292
981
|
this.isString = IntrinsicType.stringTypes.includes(name);
|
|
1293
982
|
}
|
|
1294
|
-
|
|
1295
983
|
get className() {
|
|
1296
984
|
return 'IntrinsicType';
|
|
1297
985
|
}
|
|
1298
|
-
|
|
1299
986
|
get intrinsic() {
|
|
1300
987
|
return true;
|
|
1301
988
|
}
|
|
1302
|
-
|
|
1303
989
|
get readOnly() {
|
|
1304
990
|
return false;
|
|
1305
991
|
}
|
|
1306
|
-
|
|
1307
992
|
}
|
|
1308
|
-
|
|
1309
993
|
exports.IntrinsicType = IntrinsicType;
|
|
1310
|
-
|
|
1311
994
|
_defineProperty(IntrinsicType, "stringTypes", ['string', 'uri', 'email', 'uuid', 'uri', 'hostname', 'ipv4', 'ipv6']);
|
|
1312
|
-
|
|
1313
995
|
class RequestType extends Type {
|
|
1314
996
|
constructor(api, name, params) {
|
|
1315
997
|
var description = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
@@ -1323,11 +1005,8 @@ class RequestType extends Type {
|
|
|
1323
1005
|
this.properties[p.name] = writeProp;
|
|
1324
1006
|
});
|
|
1325
1007
|
}
|
|
1326
|
-
|
|
1327
1008
|
}
|
|
1328
|
-
|
|
1329
1009
|
exports.RequestType = RequestType;
|
|
1330
|
-
|
|
1331
1010
|
class WriteType extends Type {
|
|
1332
1011
|
constructor(api, type) {
|
|
1333
1012
|
var name = "".concat(strWrite).concat(type.name);
|
|
@@ -1350,11 +1029,8 @@ class WriteType extends Type {
|
|
|
1350
1029
|
this.properties[safeName(p.name)] = writeProp;
|
|
1351
1030
|
});
|
|
1352
1031
|
}
|
|
1353
|
-
|
|
1354
1032
|
}
|
|
1355
|
-
|
|
1356
1033
|
exports.WriteType = WriteType;
|
|
1357
|
-
|
|
1358
1034
|
_defineProperty(WriteType, "readonlyProps", properties => {
|
|
1359
1035
|
var result = [];
|
|
1360
1036
|
Object.entries(properties).filter(_ref21 => {
|
|
@@ -1366,77 +1042,55 @@ _defineProperty(WriteType, "readonlyProps", properties => {
|
|
|
1366
1042
|
});
|
|
1367
1043
|
return result;
|
|
1368
1044
|
});
|
|
1369
|
-
|
|
1370
1045
|
class ApiModel {
|
|
1371
1046
|
constructor(spec) {
|
|
1372
1047
|
this.spec = spec;
|
|
1373
|
-
|
|
1374
1048
|
_defineProperty(this, "enumTypes", {});
|
|
1375
|
-
|
|
1376
1049
|
_defineProperty(this, "refs", {});
|
|
1377
|
-
|
|
1378
1050
|
_defineProperty(this, "methods", {});
|
|
1379
|
-
|
|
1380
1051
|
_defineProperty(this, "types", {});
|
|
1381
|
-
|
|
1382
1052
|
_defineProperty(this, "tags", {});
|
|
1383
|
-
|
|
1384
1053
|
_defineProperty(this, "typeTags", {});
|
|
1385
|
-
|
|
1386
1054
|
;
|
|
1387
1055
|
['string', 'integer', 'int64', 'boolean', 'object', 'uri', 'float', 'double', 'void', 'datetime', 'email', 'uuid', 'uri', 'hostname', 'ipv4', 'ipv6', 'any'].forEach(name => this.types[name] = new IntrinsicType(name));
|
|
1388
1056
|
this.load();
|
|
1389
1057
|
}
|
|
1390
|
-
|
|
1391
1058
|
get version() {
|
|
1392
1059
|
var _this$spec;
|
|
1393
|
-
|
|
1394
1060
|
return ((_this$spec = this.spec) === null || _this$spec === void 0 ? void 0 : _this$spec.info.version) || '';
|
|
1395
1061
|
}
|
|
1396
|
-
|
|
1397
1062
|
get description() {
|
|
1398
1063
|
var _this$spec2, _this$spec2$info, _this$spec2$info$desc;
|
|
1399
|
-
|
|
1400
1064
|
return ((_this$spec2 = this.spec) === null || _this$spec2 === void 0 ? void 0 : (_this$spec2$info = _this$spec2.info) === null || _this$spec2$info === void 0 ? void 0 : (_this$spec2$info$desc = _this$spec2$info.description) === null || _this$spec2$info$desc === void 0 ? void 0 : _this$spec2$info$desc.trim()) || '';
|
|
1401
1065
|
}
|
|
1402
|
-
|
|
1403
1066
|
static fromString(specContent) {
|
|
1404
1067
|
var json = JSON.parse(specContent);
|
|
1405
1068
|
return ApiModel.fromJson(json);
|
|
1406
1069
|
}
|
|
1407
|
-
|
|
1408
1070
|
static fromJson(json) {
|
|
1409
1071
|
var spec = new OAS.OpenApiBuilder(json).getSpec();
|
|
1410
1072
|
return new ApiModel(spec);
|
|
1411
1073
|
}
|
|
1412
|
-
|
|
1413
1074
|
static isMethodSearch(criteria) {
|
|
1414
1075
|
return criteria.has(SearchCriterion.method) || criteria.has(SearchCriterion.argument) || criteria.has(SearchCriterion.response) || criteria.has(SearchCriterion.status) || criteria.has(SearchCriterion.activityType);
|
|
1415
1076
|
}
|
|
1416
|
-
|
|
1417
1077
|
static isTypeSearch(criteria) {
|
|
1418
1078
|
return criteria.has(SearchCriterion.type) || criteria.has(SearchCriterion.title) || criteria.has(SearchCriterion.status);
|
|
1419
1079
|
}
|
|
1420
|
-
|
|
1421
1080
|
static addMethodToTags(tags, method) {
|
|
1422
1081
|
for (var tag of method.schema.tags) {
|
|
1423
1082
|
var _list2 = tags[tag];
|
|
1424
|
-
|
|
1425
1083
|
if (!_list2) {
|
|
1426
1084
|
_list2 = {};
|
|
1427
1085
|
tags[tag] = _list2;
|
|
1428
1086
|
}
|
|
1429
|
-
|
|
1430
1087
|
_list2[method.name] = method;
|
|
1431
1088
|
}
|
|
1432
|
-
|
|
1433
1089
|
return tags;
|
|
1434
1090
|
}
|
|
1435
|
-
|
|
1436
1091
|
tagMethod(method) {
|
|
1437
1092
|
return ApiModel.addMethodToTags(this.tags, method);
|
|
1438
1093
|
}
|
|
1439
|
-
|
|
1440
1094
|
search(expression) {
|
|
1441
1095
|
var criteria = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SearchAll;
|
|
1442
1096
|
var tags = {};
|
|
@@ -1450,7 +1104,6 @@ class ApiModel {
|
|
|
1450
1104
|
types
|
|
1451
1105
|
};
|
|
1452
1106
|
var rx;
|
|
1453
|
-
|
|
1454
1107
|
try {
|
|
1455
1108
|
rx = new RegExp(expression, 'mi');
|
|
1456
1109
|
} catch (e) {
|
|
@@ -1458,64 +1111,51 @@ class ApiModel {
|
|
|
1458
1111
|
result.ok = false;
|
|
1459
1112
|
return result;
|
|
1460
1113
|
}
|
|
1461
|
-
|
|
1462
1114
|
if (ApiModel.isMethodSearch(criteria)) {
|
|
1463
1115
|
Object.entries(this.methods).forEach(_ref13 => {
|
|
1464
1116
|
var [, method] = _ref13;
|
|
1465
|
-
|
|
1466
1117
|
if (method.search(rx, criteria)) {
|
|
1467
1118
|
methodCount++;
|
|
1468
1119
|
ApiModel.addMethodToTags(tags, method);
|
|
1469
1120
|
}
|
|
1470
1121
|
});
|
|
1471
1122
|
}
|
|
1472
|
-
|
|
1473
1123
|
if (ApiModel.isTypeSearch(criteria)) {
|
|
1474
1124
|
Object.entries(this.types).forEach(_ref14 => {
|
|
1475
1125
|
var [key, type] = _ref14;
|
|
1476
|
-
|
|
1477
1126
|
if (!rx) {
|
|
1478
1127
|
throw Error("".concat(key, " rx undefined"));
|
|
1479
1128
|
}
|
|
1480
|
-
|
|
1481
1129
|
if (type.search(rx, criteria)) {
|
|
1482
1130
|
typeCount++;
|
|
1483
1131
|
types[key] = type;
|
|
1484
1132
|
}
|
|
1485
1133
|
});
|
|
1486
1134
|
}
|
|
1487
|
-
|
|
1488
1135
|
result.message = "".concat(methodCount, " methods and ").concat(typeCount, " types found");
|
|
1489
1136
|
return result;
|
|
1490
1137
|
}
|
|
1491
|
-
|
|
1492
1138
|
jsonPath(path) {
|
|
1493
1139
|
var item = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.spec;
|
|
1494
1140
|
var splitter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '/';
|
|
1495
1141
|
var keys = path;
|
|
1496
|
-
|
|
1497
1142
|
if (!(path instanceof Array)) {
|
|
1498
1143
|
keys = path.split(splitter);
|
|
1499
1144
|
}
|
|
1500
|
-
|
|
1501
1145
|
for (var _key of keys) {
|
|
1502
1146
|
if (_key === '#') continue;
|
|
1503
1147
|
item = item[_key];
|
|
1504
1148
|
if (item == null) return null;
|
|
1505
1149
|
}
|
|
1506
|
-
|
|
1507
1150
|
return item;
|
|
1508
1151
|
}
|
|
1509
|
-
|
|
1510
1152
|
schemaHasEnums(schema) {
|
|
1511
1153
|
return lookerValuesTag in schema || enumTag in schema;
|
|
1512
1154
|
}
|
|
1513
|
-
|
|
1514
1155
|
resolveType(schema, style, typeName, methodName) {
|
|
1515
1156
|
var getRef = schema => {
|
|
1516
1157
|
var ref = schema.$ref;
|
|
1517
1158
|
var result = this.refs[ref];
|
|
1518
|
-
|
|
1519
1159
|
if (!result) {
|
|
1520
1160
|
var parts = ref.split('/');
|
|
1521
1161
|
var _name = parts[parts.length - 1];
|
|
@@ -1523,14 +1163,11 @@ class ApiModel {
|
|
|
1523
1163
|
this.refs[ref] = t;
|
|
1524
1164
|
result = t;
|
|
1525
1165
|
}
|
|
1526
|
-
|
|
1527
1166
|
return result;
|
|
1528
1167
|
};
|
|
1529
|
-
|
|
1530
1168
|
if (typeof schema === 'string') {
|
|
1531
1169
|
if (schema.indexOf('/requestBodies/') < 0) return this.types[schema.substr(schema.lastIndexOf('/') + 1)];
|
|
1532
1170
|
var deref = this.jsonPath(schema);
|
|
1533
|
-
|
|
1534
1171
|
if (deref) {
|
|
1535
1172
|
var ref = this.jsonPath(['content', 'application/json', 'schema', '$ref'], deref);
|
|
1536
1173
|
if (ref) return this.resolveType(ref, style, typeName, methodName);
|
|
@@ -1541,70 +1178,53 @@ class ApiModel {
|
|
|
1541
1178
|
if (schema.type === 'integer' && schema.format === 'int64') {
|
|
1542
1179
|
return this.types.int64;
|
|
1543
1180
|
}
|
|
1544
|
-
|
|
1545
1181
|
if (schema.type === 'number' && schema.format) {
|
|
1546
1182
|
return this.types[schema.format];
|
|
1547
1183
|
}
|
|
1548
|
-
|
|
1549
1184
|
if (schema.type === 'array' && schema.items) {
|
|
1550
1185
|
var resolved = this.resolveType(schema.items);
|
|
1551
|
-
|
|
1552
1186
|
if (!resolved) {
|
|
1553
1187
|
throw new Error("Could not resolve ".concat(JSON.stringify(schema)));
|
|
1554
1188
|
}
|
|
1555
|
-
|
|
1556
1189
|
if (style === 'simple' || style === 'form') {
|
|
1557
1190
|
return new DelimArrayType(resolved, schema);
|
|
1558
1191
|
}
|
|
1559
|
-
|
|
1560
1192
|
if (this.schemaHasEnums(schema)) {
|
|
1561
1193
|
var num = new EnumType(resolved, schema, this, typeName, methodName);
|
|
1562
1194
|
this.registerEnum(num, methodName);
|
|
1563
1195
|
var result = new ArrayType(num, schema);
|
|
1564
1196
|
return result;
|
|
1565
1197
|
}
|
|
1566
|
-
|
|
1567
1198
|
return new ArrayType(resolved, schema);
|
|
1568
1199
|
}
|
|
1569
|
-
|
|
1570
1200
|
if (this.schemaHasEnums(schema)) {
|
|
1571
1201
|
var _resolved = this.resolveType(schema.type, style, typeName, methodName);
|
|
1572
|
-
|
|
1573
1202
|
var _result = new EnumType(_resolved, schema, this, typeName, methodName);
|
|
1574
|
-
|
|
1575
1203
|
if (_result) {
|
|
1576
1204
|
return this.registerEnum(_result, methodName);
|
|
1577
1205
|
}
|
|
1578
|
-
|
|
1579
1206
|
return _result;
|
|
1580
1207
|
}
|
|
1581
|
-
|
|
1582
1208
|
if (schema.type === 'object' && schema.additionalProperties) {
|
|
1583
1209
|
if (schema.additionalProperties !== true) {
|
|
1584
1210
|
return new HashType(this.resolveType(schema.additionalProperties), schema);
|
|
1585
1211
|
}
|
|
1586
1212
|
}
|
|
1587
|
-
|
|
1588
1213
|
if (schema.format === 'date-time') {
|
|
1589
1214
|
return this.types.datetime;
|
|
1590
1215
|
}
|
|
1591
|
-
|
|
1592
1216
|
if (schema.format && this.types[schema.format]) {
|
|
1593
1217
|
return this.types[schema.format];
|
|
1594
1218
|
}
|
|
1595
|
-
|
|
1596
1219
|
if (this.types[schema.type]) {
|
|
1597
1220
|
return this.types[schema.type];
|
|
1598
1221
|
}
|
|
1599
1222
|
}
|
|
1600
|
-
|
|
1601
1223
|
throw new Error("Schema ".concat(typeof schema === 'string' ? schema : JSON.stringify(schema), " must have a ref or a type"));
|
|
1602
1224
|
}
|
|
1603
|
-
|
|
1604
1225
|
requestTypeName(method) {
|
|
1605
1226
|
return "".concat(strRequest).concat(camelCase('_' + method.name));
|
|
1606
1227
|
}
|
|
1607
|
-
|
|
1608
1228
|
makeRequestType(method) {
|
|
1609
1229
|
var name = this.requestTypeName(method);
|
|
1610
1230
|
var request = new RequestType(this, name, method.allParams, "Dynamically generated request type for ".concat(method.name));
|
|
@@ -1612,60 +1232,46 @@ class ApiModel {
|
|
|
1612
1232
|
method.addType(this, request);
|
|
1613
1233
|
return request;
|
|
1614
1234
|
}
|
|
1615
|
-
|
|
1616
1235
|
registerEnum(type, methodName) {
|
|
1617
1236
|
if (!(type instanceof EnumType)) return type;
|
|
1618
|
-
|
|
1619
1237
|
if (type.name in this.types) {
|
|
1620
1238
|
var hash = (0, _blueimpMd.default)(type.asHashString());
|
|
1621
1239
|
var matched = this.enumTypes[hash];
|
|
1622
|
-
|
|
1623
1240
|
if ((matched === null || matched === void 0 ? void 0 : matched.name) === type.name) {
|
|
1624
1241
|
return this.enumTypes[hash];
|
|
1625
1242
|
}
|
|
1626
1243
|
}
|
|
1627
|
-
|
|
1628
1244
|
if (methodName) {
|
|
1629
1245
|
var _method2 = this.methods[methodName];
|
|
1630
|
-
|
|
1631
1246
|
if (_method2) {
|
|
1632
1247
|
_method2.types.add(type.name);
|
|
1633
|
-
|
|
1634
1248
|
_method2.customTypes.add(type.name);
|
|
1635
1249
|
}
|
|
1636
1250
|
}
|
|
1637
|
-
|
|
1638
1251
|
this.types[type.name] = type;
|
|
1639
1252
|
return type;
|
|
1640
1253
|
}
|
|
1641
|
-
|
|
1642
1254
|
_getRequestType(method) {
|
|
1643
1255
|
if (method.optionalParams.length <= 1) return undefined;
|
|
1644
1256
|
var result = this.types[this.requestTypeName(method)];
|
|
1645
1257
|
if (!result) result = this.makeRequestType(method);
|
|
1646
1258
|
return result;
|
|
1647
1259
|
}
|
|
1648
|
-
|
|
1649
1260
|
getRequestType(method) {
|
|
1650
1261
|
var result = this._getRequestType(method);
|
|
1651
|
-
|
|
1652
1262
|
if (result) result.refCount++;
|
|
1653
1263
|
return result;
|
|
1654
1264
|
}
|
|
1655
|
-
|
|
1656
1265
|
getEnumList() {
|
|
1657
1266
|
return this.enumTypes;
|
|
1658
1267
|
}
|
|
1659
|
-
|
|
1660
1268
|
makeWriteableType(type) {
|
|
1661
1269
|
var writer = new WriteType(this, type);
|
|
1662
1270
|
this.types[writer.name] = writer;
|
|
1663
1271
|
return writer;
|
|
1664
1272
|
}
|
|
1665
|
-
|
|
1666
1273
|
mayGetWriteableType(type) {
|
|
1667
1274
|
var _type$elementType;
|
|
1668
|
-
|
|
1669
1275
|
if (type.intrinsic) return undefined;
|
|
1670
1276
|
if ((_type$elementType = type.elementType) !== null && _type$elementType !== void 0 && _type$elementType.intrinsic) return undefined;
|
|
1671
1277
|
if (type instanceof WriteType) return type;
|
|
@@ -1677,17 +1283,13 @@ class ApiModel {
|
|
|
1677
1283
|
if (props.length === 0) return undefined;
|
|
1678
1284
|
var obj = type;
|
|
1679
1285
|
var writes = obj.maySetWriteable(this);
|
|
1680
|
-
|
|
1681
1286
|
if (writes.length === 0) {
|
|
1682
1287
|
var immutable = 'WARNING: no writeable properties found for POST, PUT, or PATCH';
|
|
1683
|
-
|
|
1684
1288
|
if (type.description.indexOf(immutable) < 0) {
|
|
1685
1289
|
type.description += type.description.length > 0 ? '\n' : '' + immutable;
|
|
1686
1290
|
}
|
|
1687
|
-
|
|
1688
1291
|
return undefined;
|
|
1689
1292
|
}
|
|
1690
|
-
|
|
1691
1293
|
if (writes.length === props.length && JSON.stringify(writes) === JSON.stringify(props)) return undefined;
|
|
1692
1294
|
var result = this.makeWriteableType(type);
|
|
1693
1295
|
type.types.add(result.name);
|
|
@@ -1695,25 +1297,20 @@ class ApiModel {
|
|
|
1695
1297
|
result.parentTypes.add(type.name);
|
|
1696
1298
|
return result;
|
|
1697
1299
|
}
|
|
1698
|
-
|
|
1699
1300
|
loadDynamicTypes() {
|
|
1700
1301
|
Object.entries(this.methods).forEach(_ref16 => {
|
|
1701
1302
|
var [, method] = _ref16;
|
|
1702
1303
|
method.makeTypes(this);
|
|
1703
1304
|
});
|
|
1704
1305
|
}
|
|
1705
|
-
|
|
1706
1306
|
sortList(list) {
|
|
1707
1307
|
var result = {};
|
|
1708
1308
|
var sortedKeys = Object.keys(list).sort(localeSort);
|
|
1709
|
-
|
|
1710
1309
|
for (var _key2 of sortedKeys) {
|
|
1711
1310
|
result[_key2] = list[_key2];
|
|
1712
1311
|
}
|
|
1713
|
-
|
|
1714
1312
|
return result;
|
|
1715
1313
|
}
|
|
1716
|
-
|
|
1717
1314
|
sortLists() {
|
|
1718
1315
|
this.methods = this.sortList(this.methods);
|
|
1719
1316
|
this.types = this.sortList(this.types);
|
|
@@ -1724,10 +1321,8 @@ class ApiModel {
|
|
|
1724
1321
|
this.typeTags[key] = this.sortList(this.typeTags[key]);
|
|
1725
1322
|
});
|
|
1726
1323
|
}
|
|
1727
|
-
|
|
1728
1324
|
load() {
|
|
1729
1325
|
var _this$spec3, _this$spec3$component, _this$spec4;
|
|
1730
|
-
|
|
1731
1326
|
if ((_this$spec3 = this.spec) !== null && _this$spec3 !== void 0 && (_this$spec3$component = _this$spec3.components) !== null && _this$spec3$component !== void 0 && _this$spec3$component.schemas) {
|
|
1732
1327
|
Object.entries(this.spec.components.schemas).forEach(_ref17 => {
|
|
1733
1328
|
var [name, schema] = _ref17;
|
|
@@ -1744,7 +1339,6 @@ class ApiModel {
|
|
|
1744
1339
|
var nested = Object.values(type.properties).filter(p => !p.type.intrinsic);
|
|
1745
1340
|
nested.forEach(p => {
|
|
1746
1341
|
var ref = this.types[p.type.name];
|
|
1747
|
-
|
|
1748
1342
|
if (ref) {
|
|
1749
1343
|
p.type = ref;
|
|
1750
1344
|
p.description = p.description || p.type.description;
|
|
@@ -1752,7 +1346,6 @@ class ApiModel {
|
|
|
1752
1346
|
});
|
|
1753
1347
|
});
|
|
1754
1348
|
}
|
|
1755
|
-
|
|
1756
1349
|
if ((_this$spec4 = this.spec) !== null && _this$spec4 !== void 0 && _this$spec4.paths) {
|
|
1757
1350
|
Object.entries(this.spec.paths).forEach(_ref18 => {
|
|
1758
1351
|
var [path, schema] = _ref18;
|
|
@@ -1762,28 +1355,22 @@ class ApiModel {
|
|
|
1762
1355
|
});
|
|
1763
1356
|
});
|
|
1764
1357
|
}
|
|
1765
|
-
|
|
1766
1358
|
this.loadDynamicTypes();
|
|
1767
1359
|
this.typeTags = tagTypes(this, this.types);
|
|
1768
1360
|
this.sortLists();
|
|
1769
1361
|
}
|
|
1770
|
-
|
|
1771
1362
|
loadMethods(endpoint, schema) {
|
|
1772
1363
|
var methods = [];
|
|
1773
|
-
|
|
1774
1364
|
var addIfPresent = (httpMethod, opSchema) => {
|
|
1775
1365
|
if (opSchema) {
|
|
1776
1366
|
var responses = this.methodResponses(opSchema);
|
|
1777
1367
|
var params = this.methodParameters(opSchema);
|
|
1778
1368
|
var body = this.requestBody(opSchema.requestBody);
|
|
1779
|
-
|
|
1780
1369
|
var _method3 = new Method(this, httpMethod, endpoint, opSchema, params, responses, body);
|
|
1781
|
-
|
|
1782
1370
|
methods.push(_method3);
|
|
1783
1371
|
this.tagMethod(_method3);
|
|
1784
1372
|
}
|
|
1785
1373
|
};
|
|
1786
|
-
|
|
1787
1374
|
addIfPresent('GET', schema.get);
|
|
1788
1375
|
addIfPresent('PUT', schema.put);
|
|
1789
1376
|
addIfPresent('POST', schema.post);
|
|
@@ -1791,13 +1378,11 @@ class ApiModel {
|
|
|
1791
1378
|
addIfPresent('DELETE', schema.delete);
|
|
1792
1379
|
return methods;
|
|
1793
1380
|
}
|
|
1794
|
-
|
|
1795
1381
|
methodResponses(schema) {
|
|
1796
1382
|
var responses = [];
|
|
1797
1383
|
Object.entries(schema.responses).forEach(_ref19 => {
|
|
1798
1384
|
var [statusCode, contentSchema] = _ref19;
|
|
1799
1385
|
var desc = contentSchema.description || '';
|
|
1800
|
-
|
|
1801
1386
|
if (contentSchema.content) {
|
|
1802
1387
|
Object.entries(contentSchema.content).forEach(_ref20 => {
|
|
1803
1388
|
var [mediaType, response] = _ref20;
|
|
@@ -1809,16 +1394,12 @@ class ApiModel {
|
|
|
1809
1394
|
});
|
|
1810
1395
|
return responses;
|
|
1811
1396
|
}
|
|
1812
|
-
|
|
1813
1397
|
methodParameters(schema) {
|
|
1814
1398
|
var params = [];
|
|
1815
|
-
|
|
1816
1399
|
if (schema.parameters) {
|
|
1817
1400
|
for (var p of schema.parameters) {
|
|
1818
1401
|
var _type = void 0;
|
|
1819
|
-
|
|
1820
1402
|
var _param = void 0;
|
|
1821
|
-
|
|
1822
1403
|
if (OAS.isReferenceObject(p)) {
|
|
1823
1404
|
_type = this.resolveType(p);
|
|
1824
1405
|
_param = {
|
|
@@ -1829,27 +1410,21 @@ class ApiModel {
|
|
|
1829
1410
|
_type = this.resolveType(p.schema || {}, p.style);
|
|
1830
1411
|
_param = p;
|
|
1831
1412
|
}
|
|
1832
|
-
|
|
1833
1413
|
var mp = new Parameter(_param, _type);
|
|
1834
1414
|
params.push(mp);
|
|
1835
1415
|
}
|
|
1836
1416
|
}
|
|
1837
|
-
|
|
1838
1417
|
return params;
|
|
1839
1418
|
}
|
|
1840
|
-
|
|
1841
1419
|
requestBody(obj) {
|
|
1842
1420
|
if (!obj) return undefined;
|
|
1843
1421
|
var required = true;
|
|
1844
|
-
|
|
1845
1422
|
if (!OAS.isReferenceObject(obj)) {
|
|
1846
1423
|
var req = obj;
|
|
1847
|
-
|
|
1848
1424
|
if ('required' in req) {
|
|
1849
1425
|
required = req.required;
|
|
1850
1426
|
}
|
|
1851
1427
|
}
|
|
1852
|
-
|
|
1853
1428
|
var typeSchema = {
|
|
1854
1429
|
deprecated: false,
|
|
1855
1430
|
description: '',
|
|
@@ -1859,7 +1434,6 @@ class ApiModel {
|
|
|
1859
1434
|
writeOnly: false
|
|
1860
1435
|
};
|
|
1861
1436
|
var type = new Type(typeSchema, strBody);
|
|
1862
|
-
|
|
1863
1437
|
if (OAS.isReferenceObject(obj)) {
|
|
1864
1438
|
type = this.resolveType(obj.$ref);
|
|
1865
1439
|
} else if (obj.content) {
|
|
@@ -1867,7 +1441,6 @@ class ApiModel {
|
|
|
1867
1441
|
Object.keys(content).forEach(key => {
|
|
1868
1442
|
var media = content[key];
|
|
1869
1443
|
var schema = media.schema;
|
|
1870
|
-
|
|
1871
1444
|
if (OAS.isReferenceObject(schema)) {
|
|
1872
1445
|
type = this.resolveType(schema.$ref);
|
|
1873
1446
|
} else {
|
|
@@ -1875,7 +1448,6 @@ class ApiModel {
|
|
|
1875
1448
|
}
|
|
1876
1449
|
});
|
|
1877
1450
|
} else {}
|
|
1878
|
-
|
|
1879
1451
|
return new Parameter({
|
|
1880
1452
|
description: '',
|
|
1881
1453
|
location: strBody,
|
|
@@ -1883,8 +1455,6 @@ class ApiModel {
|
|
|
1883
1455
|
required: required
|
|
1884
1456
|
}, type);
|
|
1885
1457
|
}
|
|
1886
|
-
|
|
1887
1458
|
}
|
|
1888
|
-
|
|
1889
1459
|
exports.ApiModel = ApiModel;
|
|
1890
1460
|
//# sourceMappingURL=sdkModels.js.map
|