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