@blues-inc/notehub-js 1.0.24 → 1.0.25-beta.2
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/README.md +198 -189
- package/dist/ApiClient.js +160 -159
- package/dist/api/AlertApi.js +22 -22
- package/dist/api/AuthorizationApi.js +16 -16
- package/dist/api/BillingAccountApi.js +14 -14
- package/dist/api/DeviceApi.js +351 -351
- package/dist/api/EventApi.js +118 -130
- package/dist/api/MonitorApi.js +52 -52
- package/dist/api/ProjectApi.js +326 -326
- package/dist/api/RouteApi.js +74 -74
- package/dist/model/Alert.js +76 -74
- package/dist/model/AlertDataInner.js +35 -35
- package/dist/model/AlertNotificationsInner.js +18 -18
- package/dist/model/Aws.js +65 -65
- package/dist/model/Azure.js +43 -43
- package/dist/model/BillingAccount.js +21 -21
- package/dist/model/BillingAccountRole.js +9 -9
- package/dist/model/Body.js +5 -5
- package/dist/model/CloneProjectRequest.js +20 -20
- package/dist/model/Contact.js +22 -22
- package/dist/model/CreateFleetRequest.js +7 -7
- package/dist/model/CreateMonitor.js +126 -125
- package/dist/model/CreateProductRequest.js +22 -22
- package/dist/model/CreateProjectRequest.js +16 -16
- package/dist/model/CurrentFirmware.js +12 -12
- package/dist/model/DFUEnv.js +12 -12
- package/dist/model/DFUState.js +65 -65
- package/dist/model/DeleteDeviceFleetsRequest.js +8 -8
- package/dist/model/Device.js +84 -84
- package/dist/model/DeviceDfuHistory.js +20 -19
- package/dist/model/DeviceDfuHistoryPage.js +13 -12
- package/dist/model/DeviceDfuStateMachine.js +25 -24
- package/dist/model/DeviceDfuStateMachineNode.js +22 -22
- package/dist/model/DeviceDfuStatus.js +20 -20
- package/dist/model/DeviceDfuStatusCurrent.js +32 -32
- package/dist/model/DeviceDfuStatusPage.js +13 -12
- package/dist/model/DeviceSession.js +182 -182
- package/dist/model/DeviceTowerInfo.js +14 -14
- package/dist/model/DeviceUsage.js +32 -32
- package/dist/model/DfuActionRequest.js +7 -7
- package/dist/model/EmailNotification.js +7 -7
- package/dist/model/EnvironmentVariables.js +8 -8
- package/dist/model/Error.js +31 -31
- package/dist/model/Event.js +223 -223
- package/dist/model/Firmware.js +49 -49
- package/dist/model/FirmwareInfo.js +60 -60
- package/dist/model/Fleet.js +21 -21
- package/dist/model/GetAlerts200Response.js +15 -14
- package/dist/model/GetBillingAccounts200Response.js +10 -9
- package/dist/model/GetDeviceEnvironmentVariables200Response.js +12 -12
- package/dist/model/GetDeviceHealthLog200Response.js +12 -11
- package/dist/model/GetDeviceHealthLog200ResponseHealthLogInner.js +19 -19
- package/dist/model/GetDeviceLatest200Response.js +10 -9
- package/dist/model/GetDevicePublicKey200Response.js +16 -16
- package/dist/model/GetDeviceSessions200Response.js +17 -16
- package/dist/model/GetProjectDevicePublicKeys200Response.js +17 -16
- package/dist/model/GetProjectDevicePublicKeys200ResponseDevicePublicKeysInner.js +12 -12
- package/dist/model/GetProjectDevices200Response.js +17 -16
- package/dist/model/GetProjectEvents200Response.js +21 -20
- package/dist/model/GetProjectEventsByCursor200Response.js +24 -23
- package/dist/model/GetProjectFleets200Response.js +12 -11
- package/dist/model/GetProjectMembers200Response.js +12 -11
- package/dist/model/GetProjectProducts200Response.js +10 -9
- package/dist/model/GetProjects200Response.js +10 -9
- package/dist/model/GetRouteLogsByRoute200ResponseInner.js +35 -35
- package/dist/model/Google.js +33 -33
- package/dist/model/HandleNoteChanges200Response.js +11 -11
- package/dist/model/HandleNoteGet200Response.js +13 -13
- package/dist/model/HandleNoteSignal200Response.js +5 -5
- package/dist/model/HandleNotefileChanges200Response.js +11 -11
- package/dist/model/HandleNotefileChangesPending200Response.js +14 -14
- package/dist/model/HandleNotefileDeleteRequest.js +7 -7
- package/dist/model/Http.js +35 -35
- package/dist/model/HttpFilter.js +19 -19
- package/dist/model/HttpTransform.js +20 -20
- package/dist/model/Location.js +40 -40
- package/dist/model/Login200Response.js +7 -7
- package/dist/model/LoginRequest.js +12 -12
- package/dist/model/Monitor.js +100 -99
- package/dist/model/MonitorAlertRoutesInner.js +9 -10
- package/dist/model/Mqtt.js +66 -66
- package/dist/model/Note.js +10 -10
- package/dist/model/NotehubRoute.js +36 -36
- package/dist/model/NotehubRouteSchema.js +45 -46
- package/dist/model/PostProvisionProjectDeviceRequest.js +26 -13
- package/dist/model/Product.js +26 -26
- package/dist/model/Project.js +34 -34
- package/dist/model/ProjectMember.js +22 -22
- package/dist/model/Proxy.js +24 -24
- package/dist/model/PutDeviceFleetsRequest.js +8 -8
- package/dist/model/Radresponder.js +25 -25
- package/dist/model/Role.js +9 -9
- package/dist/model/Slack.js +53 -53
- package/dist/model/SlackBearerNotification.js +25 -25
- package/dist/model/SlackWebHookNotification.js +20 -20
- package/dist/model/Snowflake.js +45 -45
- package/dist/model/SnowflakeTransform.js +12 -12
- package/dist/model/Thingworx.js +33 -33
- package/dist/model/TowerLocation.js +52 -52
- package/dist/model/Twilio.js +43 -43
- package/dist/model/UpdateFleetRequest.js +17 -17
- package/dist/model/UploadMetadata.js +59 -59
- package/dist/model/UserDbRoute.js +25 -25
- package/dist/model/UserDfuStateMachine.js +20 -20
- package/dist/model/UserDfuStateMachineStatus.js +20 -20
- package/dist/model/UserFirmwareInfo.js +12 -12
- package/package.json +3 -3
package/dist/ApiClient.js
CHANGED
|
@@ -14,7 +14,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
14
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
15
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
|
|
16
16
|
* Notehub API
|
|
17
|
-
* The OpenAPI definition for the Notehub.io API.
|
|
17
|
+
* The OpenAPI definition for the Notehub.io API.
|
|
18
18
|
*
|
|
19
19
|
* The version of the OpenAPI document: 1.2.0
|
|
20
20
|
* Contact: engineering@blues.io
|
|
@@ -25,16 +25,16 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
* @module ApiClient
|
|
29
|
+
* @version 1.0.25-beta.2
|
|
30
|
+
*/
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
|
|
33
|
+
* application to use this class directly - the *Api and model classes provide the public API for the service. The
|
|
34
|
+
* contents of this file should be regarded as internal but are documented for completeness.
|
|
35
|
+
* @alias module:ApiClient
|
|
36
|
+
* @class
|
|
37
|
+
*/
|
|
38
38
|
var ApiClient = /*#__PURE__*/function () {
|
|
39
39
|
/**
|
|
40
40
|
* The base URL against which to resolve every API call's (relative) path.
|
|
@@ -42,29 +42,29 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
42
42
|
* @param {String} basePath
|
|
43
43
|
*/
|
|
44
44
|
function ApiClient() {
|
|
45
|
-
var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
45
|
+
var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'https://api.notefile.net';
|
|
46
46
|
_classCallCheck(this, ApiClient);
|
|
47
47
|
/**
|
|
48
48
|
* The base URL against which to resolve every API call's (relative) path.
|
|
49
49
|
* @type {String}
|
|
50
50
|
* @default https://api.notefile.net
|
|
51
51
|
*/
|
|
52
|
-
this.basePath = basePath.replace(/\/+$/,
|
|
52
|
+
this.basePath = basePath.replace(/\/+$/, '');
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* The authentication methods to be included for all API calls.
|
|
56
56
|
* @type {Array.<String>}
|
|
57
57
|
*/
|
|
58
58
|
this.authentications = {
|
|
59
|
-
api_key: {
|
|
60
|
-
type:
|
|
61
|
-
|
|
62
|
-
name:
|
|
59
|
+
'api_key': {
|
|
60
|
+
type: 'apiKey',
|
|
61
|
+
'in': 'header',
|
|
62
|
+
name: 'X-Session-Token'
|
|
63
63
|
},
|
|
64
|
-
pin: {
|
|
65
|
-
type:
|
|
66
|
-
|
|
67
|
-
name:
|
|
64
|
+
'pin': {
|
|
65
|
+
type: 'apiKey',
|
|
66
|
+
'in': 'header',
|
|
67
|
+
name: 'X-Auth-Token'
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -73,9 +73,10 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
73
73
|
* @type {Array.<String>}
|
|
74
74
|
* @default {}
|
|
75
75
|
*/
|
|
76
|
-
this.defaultHeaders = {
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
this.defaultHeaders = {};
|
|
77
|
+
if (typeof window === 'undefined') {
|
|
78
|
+
this.defaultHeaders['User-Agent'] = 'OpenAPI-Generator/1.0.25-beta.2/Javascript';
|
|
79
|
+
}
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
82
|
* The default HTTP timeout for all API calls.
|
|
@@ -97,13 +98,13 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
97
98
|
* response, and return them in the next request.
|
|
98
99
|
* @default false
|
|
99
100
|
*/
|
|
100
|
-
this.enableCookies =
|
|
101
|
+
this.enableCookies = true;
|
|
101
102
|
|
|
102
103
|
/*
|
|
103
104
|
* Used to save and return cookies in a node.js (non-browser) setting,
|
|
104
105
|
* if this.enableCookies is set to true.
|
|
105
106
|
*/
|
|
106
|
-
if (typeof window ===
|
|
107
|
+
if (typeof window === 'undefined') {
|
|
107
108
|
this.agent = new _superagent["default"].agent();
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -119,15 +120,15 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
* Returns a string representation for an actual parameter.
|
|
124
|
+
* @param param The actual parameter.
|
|
125
|
+
* @returns {String} The string representation of <code>param</code>.
|
|
126
|
+
*/
|
|
126
127
|
return _createClass(ApiClient, [{
|
|
127
128
|
key: "paramToString",
|
|
128
129
|
value: function paramToString(param) {
|
|
129
130
|
if (param == undefined || param == null) {
|
|
130
|
-
return
|
|
131
|
+
return '';
|
|
131
132
|
}
|
|
132
133
|
if (param instanceof Date) {
|
|
133
134
|
return param.toJSON();
|
|
@@ -139,10 +140,10 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
* Returns a boolean indicating if the parameter could be JSON.stringified
|
|
144
|
+
* @param param The actual parameter
|
|
145
|
+
* @returns {Boolean} Flag indicating if <code>param</code> can be JSON.stringified
|
|
146
|
+
*/
|
|
146
147
|
}, {
|
|
147
148
|
key: "buildUrl",
|
|
148
149
|
value:
|
|
@@ -157,7 +158,7 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
157
158
|
function buildUrl(path, pathParams, apiBasePath) {
|
|
158
159
|
var _this = this;
|
|
159
160
|
if (!path.match(/^\//)) {
|
|
160
|
-
path =
|
|
161
|
+
path = '/' + path;
|
|
161
162
|
}
|
|
162
163
|
var url = this.basePath + path;
|
|
163
164
|
|
|
@@ -178,16 +179,16 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
* Checks whether the given content type represents JSON.<br>
|
|
183
|
+
* JSON content type examples:<br>
|
|
184
|
+
* <ul>
|
|
185
|
+
* <li>application/json</li>
|
|
186
|
+
* <li>application/json; charset=UTF8</li>
|
|
187
|
+
* <li>APPLICATION/JSON</li>
|
|
188
|
+
* </ul>
|
|
189
|
+
* @param {String} contentType The MIME content type to check.
|
|
190
|
+
* @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
|
|
191
|
+
*/
|
|
191
192
|
}, {
|
|
192
193
|
key: "isJsonMime",
|
|
193
194
|
value: function isJsonMime(contentType) {
|
|
@@ -195,10 +196,10 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
|
|
200
|
+
* @param {Array.<String>} contentTypes
|
|
201
|
+
* @returns {String} The chosen content type, preferring JSON.
|
|
202
|
+
*/
|
|
202
203
|
}, {
|
|
203
204
|
key: "jsonPreferredMime",
|
|
204
205
|
value: function jsonPreferredMime(contentTypes) {
|
|
@@ -211,18 +212,18 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
* Checks whether the given parameter value represents file-like content.
|
|
216
|
+
* @param param The parameter to check.
|
|
217
|
+
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
|
|
218
|
+
*/
|
|
218
219
|
}, {
|
|
219
220
|
key: "isFileParam",
|
|
220
221
|
value: function isFileParam(param) {
|
|
221
222
|
// fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
|
|
222
|
-
if (typeof require ===
|
|
223
|
+
if (typeof require === 'function') {
|
|
223
224
|
var fs;
|
|
224
225
|
try {
|
|
225
|
-
fs = require(
|
|
226
|
+
fs = require('fs');
|
|
226
227
|
} catch (err) {}
|
|
227
228
|
if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
|
|
228
229
|
return true;
|
|
@@ -230,32 +231,32 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
// Buffer in Node.js
|
|
233
|
-
if (typeof Buffer ===
|
|
234
|
+
if (typeof Buffer === 'function' && param instanceof Buffer) {
|
|
234
235
|
return true;
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
// Blob in browser
|
|
238
|
-
if (typeof Blob ===
|
|
239
|
+
if (typeof Blob === 'function' && param instanceof Blob) {
|
|
239
240
|
return true;
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
// File in browser (it seems File object is also instance of Blob, but keep this for safe)
|
|
243
|
-
if (typeof File ===
|
|
244
|
+
if (typeof File === 'function' && param instanceof File) {
|
|
244
245
|
return true;
|
|
245
246
|
}
|
|
246
247
|
return false;
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
251
|
+
* Normalizes parameter values:
|
|
252
|
+
* <ul>
|
|
253
|
+
* <li>remove nils</li>
|
|
254
|
+
* <li>keep files and arrays</li>
|
|
255
|
+
* <li>format to string with `paramToString` for other cases</li>
|
|
256
|
+
* </ul>
|
|
257
|
+
* @param {Object.<String, Object>} params The parameters as object properties.
|
|
258
|
+
* @returns {Object.<String, Object>} normalized parameters.
|
|
259
|
+
*/
|
|
259
260
|
}, {
|
|
260
261
|
key: "normalizeParams",
|
|
261
262
|
value: function normalizeParams(params) {
|
|
@@ -274,12 +275,12 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
* Builds a string representation of an array-type actual parameter, according to the given collection format.
|
|
279
|
+
* @param {Array} param An array parameter.
|
|
280
|
+
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
|
|
281
|
+
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
|
|
282
|
+
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
|
|
283
|
+
*/
|
|
283
284
|
}, {
|
|
284
285
|
key: "buildCollectionParam",
|
|
285
286
|
value: function buildCollectionParam(param, collectionFormat) {
|
|
@@ -287,29 +288,29 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
287
288
|
return null;
|
|
288
289
|
}
|
|
289
290
|
switch (collectionFormat) {
|
|
290
|
-
case
|
|
291
|
-
return param.map(this.paramToString, this).join(
|
|
292
|
-
case
|
|
293
|
-
return param.map(this.paramToString, this).join(
|
|
294
|
-
case
|
|
295
|
-
return param.map(this.paramToString, this).join(
|
|
296
|
-
case
|
|
297
|
-
return param.map(this.paramToString, this).join(
|
|
298
|
-
case
|
|
291
|
+
case 'csv':
|
|
292
|
+
return param.map(this.paramToString, this).join(',');
|
|
293
|
+
case 'ssv':
|
|
294
|
+
return param.map(this.paramToString, this).join(' ');
|
|
295
|
+
case 'tsv':
|
|
296
|
+
return param.map(this.paramToString, this).join('\t');
|
|
297
|
+
case 'pipes':
|
|
298
|
+
return param.map(this.paramToString, this).join('|');
|
|
299
|
+
case 'multi':
|
|
299
300
|
//return the array directly as SuperAgent will handle it as expected
|
|
300
301
|
return param.map(this.paramToString, this);
|
|
301
|
-
case
|
|
302
|
+
case 'passthrough':
|
|
302
303
|
return param;
|
|
303
304
|
default:
|
|
304
|
-
throw new Error(
|
|
305
|
+
throw new Error('Unknown collection format: ' + collectionFormat);
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
|
|
308
309
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
310
|
+
* Applies authentication headers to the request.
|
|
311
|
+
* @param {Object} request The request object created by a <code>superagent()</code> call.
|
|
312
|
+
* @param {Array.<String>} authNames An array of authentication method names.
|
|
313
|
+
*/
|
|
313
314
|
}, {
|
|
314
315
|
key: "applyAuthToRequest",
|
|
315
316
|
value: function applyAuthToRequest(request, authNames) {
|
|
@@ -317,39 +318,39 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
317
318
|
authNames.forEach(function (authName) {
|
|
318
319
|
var auth = _this2.authentications[authName];
|
|
319
320
|
switch (auth.type) {
|
|
320
|
-
case
|
|
321
|
+
case 'basic':
|
|
321
322
|
if (auth.username || auth.password) {
|
|
322
|
-
request.auth(auth.username ||
|
|
323
|
+
request.auth(auth.username || '', auth.password || '');
|
|
323
324
|
}
|
|
324
325
|
break;
|
|
325
|
-
case
|
|
326
|
+
case 'bearer':
|
|
326
327
|
if (auth.accessToken) {
|
|
327
|
-
var localVarBearerToken = typeof auth.accessToken ===
|
|
328
|
+
var localVarBearerToken = typeof auth.accessToken === 'function' ? auth.accessToken() : auth.accessToken;
|
|
328
329
|
request.set({
|
|
329
|
-
Authorization:
|
|
330
|
+
'Authorization': 'Bearer ' + localVarBearerToken
|
|
330
331
|
});
|
|
331
332
|
}
|
|
332
333
|
break;
|
|
333
|
-
case
|
|
334
|
+
case 'apiKey':
|
|
334
335
|
if (auth.apiKey) {
|
|
335
336
|
var data = {};
|
|
336
337
|
data[auth.name] = auth.apiKey;
|
|
337
|
-
if (auth[
|
|
338
|
+
if (auth['in'] === 'header') {
|
|
338
339
|
request.set(data);
|
|
339
340
|
} else {
|
|
340
341
|
request.query(data);
|
|
341
342
|
}
|
|
342
343
|
}
|
|
343
344
|
break;
|
|
344
|
-
case
|
|
345
|
+
case 'oauth2':
|
|
345
346
|
if (auth.accessToken) {
|
|
346
347
|
request.set({
|
|
347
|
-
Authorization:
|
|
348
|
+
'Authorization': 'Bearer ' + auth.accessToken
|
|
348
349
|
});
|
|
349
350
|
}
|
|
350
351
|
break;
|
|
351
352
|
default:
|
|
352
|
-
throw new Error(
|
|
353
|
+
throw new Error('Unknown authentication type: ' + auth.type);
|
|
353
354
|
}
|
|
354
355
|
});
|
|
355
356
|
}
|
|
@@ -373,7 +374,7 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
373
374
|
// Rely on SuperAgent for parsing response body.
|
|
374
375
|
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
|
|
375
376
|
var data = response.body;
|
|
376
|
-
if (data == null || _typeof(data) ===
|
|
377
|
+
if (data == null || _typeof(data) === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length) {
|
|
377
378
|
// SuperAgent does not always produce a body; use the unparsed response as a fallback
|
|
378
379
|
data = response.text;
|
|
379
380
|
}
|
|
@@ -415,8 +416,8 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
415
416
|
this.applyAuthToRequest(request, authNames);
|
|
416
417
|
|
|
417
418
|
// set query parameters
|
|
418
|
-
if (httpMethod.toUpperCase() ===
|
|
419
|
-
queryParams[
|
|
419
|
+
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
|
420
|
+
queryParams['_'] = new Date().getTime();
|
|
420
421
|
}
|
|
421
422
|
request.query(this.normalizeParams(queryParams));
|
|
422
423
|
|
|
@@ -433,13 +434,13 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
433
434
|
var contentType = this.jsonPreferredMime(contentTypes);
|
|
434
435
|
if (contentType) {
|
|
435
436
|
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
|
|
436
|
-
if (contentType !=
|
|
437
|
+
if (contentType != 'multipart/form-data') {
|
|
437
438
|
request.type(contentType);
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
|
-
if (contentType ===
|
|
441
|
+
if (contentType === 'application/x-www-form-urlencoded') {
|
|
441
442
|
request.send(_querystring["default"].stringify(this.normalizeParams(formParams)));
|
|
442
|
-
} else if (contentType ==
|
|
443
|
+
} else if (contentType == 'multipart/form-data') {
|
|
443
444
|
var _formParams = this.normalizeParams(formParams);
|
|
444
445
|
for (var key in _formParams) {
|
|
445
446
|
if (_formParams.hasOwnProperty(key)) {
|
|
@@ -458,8 +459,8 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
458
459
|
}
|
|
459
460
|
}
|
|
460
461
|
} else if (bodyParam !== null && bodyParam !== undefined) {
|
|
461
|
-
if (!request.header[
|
|
462
|
-
request.type(
|
|
462
|
+
if (!request.header['Content-Type']) {
|
|
463
|
+
request.type('application/json');
|
|
463
464
|
}
|
|
464
465
|
request.send(bodyParam);
|
|
465
466
|
}
|
|
@@ -467,18 +468,18 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
467
468
|
if (accept) {
|
|
468
469
|
request.accept(accept);
|
|
469
470
|
}
|
|
470
|
-
if (returnType ===
|
|
471
|
-
request.responseType(
|
|
472
|
-
} else if (returnType ===
|
|
473
|
-
request.responseType(
|
|
471
|
+
if (returnType === 'Blob') {
|
|
472
|
+
request.responseType('blob');
|
|
473
|
+
} else if (returnType === 'String') {
|
|
474
|
+
request.responseType('text');
|
|
474
475
|
}
|
|
475
476
|
|
|
476
477
|
// Attach previously saved cookies, if enabled
|
|
477
478
|
if (this.enableCookies) {
|
|
478
|
-
if (typeof window ===
|
|
479
|
+
if (typeof window === 'undefined') {
|
|
479
480
|
this.agent._attachCookies(request);
|
|
480
481
|
} else {
|
|
481
|
-
request.withCredentials();
|
|
482
|
+
request.withCredentials(); // Allows credentials to be sent with cross-origin requests in the browser
|
|
482
483
|
}
|
|
483
484
|
}
|
|
484
485
|
return new Promise(function (resolve, reject) {
|
|
@@ -496,7 +497,7 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
496
497
|
} else {
|
|
497
498
|
try {
|
|
498
499
|
var data = _this3.deserialize(response, returnType);
|
|
499
|
-
if (_this3.enableCookies && typeof window ===
|
|
500
|
+
if (_this3.enableCookies && typeof window === 'undefined') {
|
|
500
501
|
_this3.agent._saveCookies(response);
|
|
501
502
|
}
|
|
502
503
|
resolve({
|
|
@@ -512,21 +513,21 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
512
513
|
}
|
|
513
514
|
|
|
514
515
|
/**
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
516
|
+
* Parses an ISO-8601 string representation or epoch representation of a date value.
|
|
517
|
+
* @param {String} str The date value as a string.
|
|
518
|
+
* @returns {Date} The parsed date object.
|
|
519
|
+
*/
|
|
519
520
|
}, {
|
|
520
521
|
key: "hostSettings",
|
|
521
522
|
value:
|
|
522
523
|
/**
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
524
|
+
* Gets an array of host settings
|
|
525
|
+
* @returns An array of host settings
|
|
526
|
+
*/
|
|
526
527
|
function hostSettings() {
|
|
527
528
|
return [{
|
|
528
|
-
url: "https://api.notefile.net",
|
|
529
|
-
description: "Production server"
|
|
529
|
+
'url': "https://api.notefile.net",
|
|
530
|
+
'description': "Production server"
|
|
530
531
|
}];
|
|
531
532
|
}
|
|
532
533
|
}, {
|
|
@@ -540,37 +541,37 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
540
541
|
throw new Error("Invalid index " + index + " when selecting the host settings. Must be less than " + servers.length);
|
|
541
542
|
}
|
|
542
543
|
var server = servers[index];
|
|
543
|
-
var url = server[
|
|
544
|
+
var url = server['url'];
|
|
544
545
|
|
|
545
546
|
// go through variable and assign a value
|
|
546
|
-
for (var variable_name in server[
|
|
547
|
+
for (var variable_name in server['variables']) {
|
|
547
548
|
if (variable_name in variables) {
|
|
548
|
-
var variable = server[
|
|
549
|
-
if (!(
|
|
549
|
+
var variable = server['variables'][variable_name];
|
|
550
|
+
if (!('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name])) {
|
|
550
551
|
url = url.replace("{" + variable_name + "}", variables[variable_name]);
|
|
551
552
|
} else {
|
|
552
|
-
throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server[
|
|
553
|
+
throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + ".");
|
|
553
554
|
}
|
|
554
555
|
} else {
|
|
555
556
|
// use default value
|
|
556
|
-
url = url.replace("{" + variable_name + "}", server[
|
|
557
|
+
url = url.replace("{" + variable_name + "}", server['variables'][variable_name]['default_value']);
|
|
557
558
|
}
|
|
558
559
|
}
|
|
559
560
|
return url;
|
|
560
561
|
}
|
|
561
562
|
|
|
562
563
|
/**
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
* Constructs a new map or array model from REST data.
|
|
565
|
+
* @param data {Object|Array} The REST data.
|
|
566
|
+
* @param obj {Object|Array} The target object or array.
|
|
567
|
+
*/
|
|
567
568
|
}], [{
|
|
568
569
|
key: "canBeJsonified",
|
|
569
570
|
value: function canBeJsonified(str) {
|
|
570
|
-
if (typeof str !==
|
|
571
|
+
if (typeof str !== 'string' && _typeof(str) !== 'object') return false;
|
|
571
572
|
try {
|
|
572
573
|
var type = str.toString();
|
|
573
|
-
return type ===
|
|
574
|
+
return type === '[object Object]' || type === '[object Array]';
|
|
574
575
|
} catch (err) {
|
|
575
576
|
return false;
|
|
576
577
|
}
|
|
@@ -579,42 +580,42 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
579
580
|
key: "parseDate",
|
|
580
581
|
value: function parseDate(str) {
|
|
581
582
|
if (isNaN(str)) {
|
|
582
|
-
return new Date(str.replace(/(\d)(T)(\d)/i,
|
|
583
|
+
return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
|
|
583
584
|
}
|
|
584
585
|
return new Date(+str);
|
|
585
586
|
}
|
|
586
587
|
|
|
587
588
|
/**
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
589
|
+
* Converts a value to the specified type.
|
|
590
|
+
* @param {(String|Object)} data The data to convert, as a string or object.
|
|
591
|
+
* @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
|
|
592
|
+
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
|
593
|
+
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
|
594
|
+
* all properties on <code>data<code> will be converted to this type.
|
|
595
|
+
* @returns An instance of the specified type or null or undefined if data is null or undefined.
|
|
596
|
+
*/
|
|
596
597
|
}, {
|
|
597
598
|
key: "convertToType",
|
|
598
599
|
value: function convertToType(data, type) {
|
|
599
600
|
if (data === null || data === undefined) return data;
|
|
600
601
|
switch (type) {
|
|
601
|
-
case
|
|
602
|
+
case 'Boolean':
|
|
602
603
|
return Boolean(data);
|
|
603
|
-
case
|
|
604
|
+
case 'Integer':
|
|
604
605
|
return parseInt(data, 10);
|
|
605
|
-
case
|
|
606
|
+
case 'Number':
|
|
606
607
|
return parseFloat(data);
|
|
607
|
-
case
|
|
608
|
+
case 'String':
|
|
608
609
|
return String(data);
|
|
609
|
-
case
|
|
610
|
+
case 'Date':
|
|
610
611
|
return String(data);
|
|
611
|
-
case
|
|
612
|
+
case 'Blob':
|
|
612
613
|
return data;
|
|
613
614
|
default:
|
|
614
615
|
if (type === Object) {
|
|
615
616
|
// generic object, return directly
|
|
616
617
|
return data;
|
|
617
|
-
} else if (typeof type.constructFromObject ===
|
|
618
|
+
} else if (typeof type.constructFromObject === 'function') {
|
|
618
619
|
// for model type like User and enum class
|
|
619
620
|
return type.constructFromObject(data);
|
|
620
621
|
} else if (Array.isArray(type)) {
|
|
@@ -623,7 +624,7 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
623
624
|
return data.map(function (item) {
|
|
624
625
|
return ApiClient.convertToType(item, itemType);
|
|
625
626
|
});
|
|
626
|
-
} else if (_typeof(type) ===
|
|
627
|
+
} else if (_typeof(type) === 'object') {
|
|
627
628
|
// for plain object type like: {'String': 'Integer'}
|
|
628
629
|
var keyType, valueType;
|
|
629
630
|
for (var k in type) {
|
|
@@ -673,32 +674,32 @@ ApiClient.CollectionFormatEnum = {
|
|
|
673
674
|
* Comma-separated values. Value: <code>csv</code>
|
|
674
675
|
* @const
|
|
675
676
|
*/
|
|
676
|
-
CSV:
|
|
677
|
+
CSV: ',',
|
|
677
678
|
/**
|
|
678
679
|
* Space-separated values. Value: <code>ssv</code>
|
|
679
680
|
* @const
|
|
680
681
|
*/
|
|
681
|
-
SSV:
|
|
682
|
+
SSV: ' ',
|
|
682
683
|
/**
|
|
683
684
|
* Tab-separated values. Value: <code>tsv</code>
|
|
684
685
|
* @const
|
|
685
686
|
*/
|
|
686
|
-
TSV:
|
|
687
|
+
TSV: '\t',
|
|
687
688
|
/**
|
|
688
689
|
* Pipe(|)-separated values. Value: <code>pipes</code>
|
|
689
690
|
* @const
|
|
690
691
|
*/
|
|
691
|
-
PIPES:
|
|
692
|
+
PIPES: '|',
|
|
692
693
|
/**
|
|
693
694
|
* Native array. Value: <code>multi</code>
|
|
694
695
|
* @const
|
|
695
696
|
*/
|
|
696
|
-
MULTI:
|
|
697
|
+
MULTI: 'multi'
|
|
697
698
|
};
|
|
698
699
|
|
|
699
700
|
/**
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
* The default API client implementation.
|
|
702
|
+
* @type {module:ApiClient}
|
|
703
|
+
*/
|
|
703
704
|
ApiClient.instance = new ApiClient();
|
|
704
705
|
var _default = exports["default"] = ApiClient;
|