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