backendless 7.4.5 → 7.4.6

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/es/index.js CHANGED
@@ -291,7 +291,10 @@ var Backendless = /*#__PURE__*/function () {
291
291
  if (this.domain) {
292
292
  return this.domain + this.apiURI;
293
293
  }
294
- return [this.serverURL, this.appId, this.apiKey].join('/');
294
+ if (this.appId && this.apiKey) {
295
+ return [this.serverURL, this.appId, this.apiKey].join('/');
296
+ }
297
+ return null;
295
298
  },
296
299
  set: function set(appPath) {
297
300
  throw new Error("Setting '".concat(appPath, "' value to Backendless.appPath directly is not possible, ") + 'instead you must use Backendless.initApp(APP_ID, API_KEY) for setup the value');
@@ -89,13 +89,15 @@ var Logging = /*#__PURE__*/function () {
89
89
  this.stopFlushInterval();
90
90
  messages = (0, _toConsumableArray2["default"])(this.messages);
91
91
  this.messages = [];
92
- this.flushRequest = this.app.request.put({
93
- url: this.app.urls.logging(),
94
- data: messages
95
- })["catch"](function (error) {
96
- _this2.messages = [].concat((0, _toConsumableArray2["default"])(messages), (0, _toConsumableArray2["default"])(_this2.messages));
97
- _this2.checkMessagesLimit();
98
- throw error;
92
+ this.flushRequest = Promise.resolve().then(function () {
93
+ return _this2.app.request.put({
94
+ url: _this2.app.urls.logging(),
95
+ data: messages
96
+ })["catch"](function (error) {
97
+ _this2.messages = [].concat((0, _toConsumableArray2["default"])(messages), (0, _toConsumableArray2["default"])(_this2.messages));
98
+ _this2.checkMessagesLimit();
99
+ throw error;
100
+ });
99
101
  })["finally"](function () {
100
102
  return delete _this2.flushRequest;
101
103
  });
@@ -133,7 +135,10 @@ var Logging = /*#__PURE__*/function () {
133
135
  }
134
136
  this.checkMessagesLenTimer = setTimeout(function () {
135
137
  if (_this3.messages.length >= _this3.numOfMessages) {
136
- _this3.flush();
138
+ _this3.flush()["catch"](function (error) {
139
+ // eslint-disable-next-line no-console
140
+ console.error('Could not flush log messages immediately: ', error);
141
+ });
137
142
  } else {
138
143
  _this3.startFlushInterval();
139
144
  }
@@ -152,7 +157,10 @@ var Logging = /*#__PURE__*/function () {
152
157
  var _this4 = this;
153
158
  if (!this.flushInterval) {
154
159
  this.flushInterval = setTimeout(function () {
155
- return _this4.flush();
160
+ _this4.flush()["catch"](function (error) {
161
+ // eslint-disable-next-line no-console
162
+ console.error('Could not flush log messages with timer: ', error);
163
+ });
156
164
  }, this.timeFrequency * 1000);
157
165
  }
158
166
  }
package/es/urls.js CHANGED
@@ -15,6 +15,9 @@ var Urls = /*#__PURE__*/function () {
15
15
  (0, _createClass2["default"])(Urls, [{
16
16
  key: "root",
17
17
  value: function root() {
18
+ if (!this.app.appPath) {
19
+ throw new Error('Backendless API is not configured, make sure you run Backendless.initApp(...) ' + 'before the operation');
20
+ }
18
21
  return this.app.appPath;
19
22
  }
20
23
 
package/lib/index.js CHANGED
@@ -291,7 +291,10 @@ var Backendless = /*#__PURE__*/function () {
291
291
  if (this.domain) {
292
292
  return this.domain + this.apiURI;
293
293
  }
294
- return [this.serverURL, this.appId, this.apiKey].join('/');
294
+ if (this.appId && this.apiKey) {
295
+ return [this.serverURL, this.appId, this.apiKey].join('/');
296
+ }
297
+ return null;
295
298
  },
296
299
  set: function set(appPath) {
297
300
  throw new Error("Setting '".concat(appPath, "' value to Backendless.appPath directly is not possible, ") + 'instead you must use Backendless.initApp(APP_ID, API_KEY) for setup the value');
@@ -89,13 +89,15 @@ var Logging = /*#__PURE__*/function () {
89
89
  this.stopFlushInterval();
90
90
  messages = (0, _toConsumableArray2["default"])(this.messages);
91
91
  this.messages = [];
92
- this.flushRequest = this.app.request.put({
93
- url: this.app.urls.logging(),
94
- data: messages
95
- })["catch"](function (error) {
96
- _this2.messages = [].concat((0, _toConsumableArray2["default"])(messages), (0, _toConsumableArray2["default"])(_this2.messages));
97
- _this2.checkMessagesLimit();
98
- throw error;
92
+ this.flushRequest = Promise.resolve().then(function () {
93
+ return _this2.app.request.put({
94
+ url: _this2.app.urls.logging(),
95
+ data: messages
96
+ })["catch"](function (error) {
97
+ _this2.messages = [].concat((0, _toConsumableArray2["default"])(messages), (0, _toConsumableArray2["default"])(_this2.messages));
98
+ _this2.checkMessagesLimit();
99
+ throw error;
100
+ });
99
101
  })["finally"](function () {
100
102
  return delete _this2.flushRequest;
101
103
  });
@@ -133,7 +135,10 @@ var Logging = /*#__PURE__*/function () {
133
135
  }
134
136
  this.checkMessagesLenTimer = setTimeout(function () {
135
137
  if (_this3.messages.length >= _this3.numOfMessages) {
136
- _this3.flush();
138
+ _this3.flush()["catch"](function (error) {
139
+ // eslint-disable-next-line no-console
140
+ console.error('Could not flush log messages immediately: ', error);
141
+ });
137
142
  } else {
138
143
  _this3.startFlushInterval();
139
144
  }
@@ -152,7 +157,10 @@ var Logging = /*#__PURE__*/function () {
152
157
  var _this4 = this;
153
158
  if (!this.flushInterval) {
154
159
  this.flushInterval = setTimeout(function () {
155
- return _this4.flush();
160
+ _this4.flush()["catch"](function (error) {
161
+ // eslint-disable-next-line no-console
162
+ console.error('Could not flush log messages with timer: ', error);
163
+ });
156
164
  }, this.timeFrequency * 1000);
157
165
  }
158
166
  }
package/lib/urls.js CHANGED
@@ -15,6 +15,9 @@ var Urls = /*#__PURE__*/function () {
15
15
  (0, _createClass2["default"])(Urls, [{
16
16
  key: "root",
17
17
  value: function root() {
18
+ if (!this.app.appPath) {
19
+ throw new Error('Backendless API is not configured, make sure you run Backendless.initApp(...) ' + 'before the operation');
20
+ }
18
21
  return this.app.appPath;
19
22
  }
20
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backendless",
3
- "version": "7.4.5",
3
+ "version": "7.4.6",
4
4
  "description": "Backendless JavaScript SDK for Node.js and the browser",
5
5
  "browser": "dist/backendless.js",
6
6
  "main": "lib/index.js",
package/src/index.js CHANGED
@@ -278,7 +278,11 @@ class Backendless {
278
278
  return this.domain + this.apiURI
279
279
  }
280
280
 
281
- return [this.serverURL, this.appId, this.apiKey].join('/')
281
+ if (this.appId && this.apiKey) {
282
+ return [this.serverURL, this.appId, this.apiKey].join('/')
283
+ }
284
+
285
+ return null
282
286
  }
283
287
 
284
288
  set appPath(appPath) {
@@ -78,17 +78,20 @@ export default class Logging {
78
78
 
79
79
  this.messages = []
80
80
 
81
- this.flushRequest = this.app.request
82
- .put({
83
- url : this.app.urls.logging(),
84
- data: messages
85
- })
86
- .catch(error => {
87
- this.messages = [...messages, ...this.messages]
88
-
89
- this.checkMessagesLimit()
90
-
91
- throw error
81
+ this.flushRequest = Promise.resolve()
82
+ .then(() => {
83
+ return this.app.request
84
+ .put({
85
+ url : this.app.urls.logging(),
86
+ data: messages
87
+ })
88
+ .catch(error => {
89
+ this.messages = [...messages, ...this.messages]
90
+
91
+ this.checkMessagesLimit()
92
+
93
+ throw error
94
+ })
92
95
  })
93
96
  .finally(() => delete this.flushRequest)
94
97
  }
@@ -116,6 +119,10 @@ export default class Logging {
116
119
  this.checkMessagesLenTimer = setTimeout(() => {
117
120
  if (this.messages.length >= this.numOfMessages) {
118
121
  this.flush()
122
+ .catch(error => {
123
+ // eslint-disable-next-line no-console
124
+ console.error('Could not flush log messages immediately: ', error)
125
+ })
119
126
  } else {
120
127
  this.startFlushInterval()
121
128
  }
@@ -130,7 +137,13 @@ export default class Logging {
130
137
 
131
138
  startFlushInterval() {
132
139
  if (!this.flushInterval) {
133
- this.flushInterval = setTimeout(() => this.flush(), this.timeFrequency * 1000)
140
+ this.flushInterval = setTimeout(() => {
141
+ this.flush()
142
+ .catch(error => {
143
+ // eslint-disable-next-line no-console
144
+ console.error('Could not flush log messages with timer: ', error)
145
+ })
146
+ }, this.timeFrequency * 1000)
134
147
  }
135
148
  }
136
149
 
package/src/urls.js CHANGED
@@ -4,6 +4,13 @@ export default class Urls {
4
4
  }
5
5
 
6
6
  root() {
7
+ if (!this.app.appPath) {
8
+ throw new Error(
9
+ 'Backendless API is not configured, make sure you run Backendless.initApp(...) ' +
10
+ 'before the operation'
11
+ )
12
+ }
13
+
7
14
  return this.app.appPath
8
15
  }
9
16