roboto-js 1.8.4 → 1.8.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.
@@ -84,7 +84,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
84
84
  // Asynchronous browser hydration: set auth header and in-memory user
85
85
  // Use storage adaptor if available, otherwise fallback to localStorage
86
86
  this._initializeFromStorage()["catch"](function (e) {
87
- return console.warn('[RbtApi] Storage initialization failed:', e);
87
+ return void 0;
88
88
  });
89
89
  this.localDb = null;
90
90
  this.iac_session = null;
@@ -95,6 +95,13 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
95
95
 
96
96
  // Use the storageAdaptor to get the authToken, if available
97
97
  this.initAuthToken(authtoken);
98
+
99
+ // Set apiKey synchronously if provided (don't wait for async initApiKey)
100
+ if (apikey) {
101
+ this.apikey = apikey;
102
+ this.axios.defaults.headers.common['apikey'] = this.apikey;
103
+ // ADD THIS LINE
104
+ }
98
105
  this.initApiKey(apikey);
99
106
  }
100
107
 
@@ -158,19 +165,17 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
158
165
  if (token) {
159
166
  this.authtoken = token;
160
167
  this.axios.defaults.headers.common['authtoken'] = token;
161
- console.log('[RbtApi] Loaded authtoken from storage adaptor');
162
168
  }
163
- _context.next = 33;
169
+ _context.next = 32;
164
170
  break;
165
171
  case 30:
166
172
  _context.prev = 30;
167
173
  _context.t1 = _context["catch"](2);
168
- console.warn('[RbtApi] Failed to load authtoken from storage adaptor:', _context.t1);
169
- case 33:
170
- _context.prev = 33;
171
- _context.next = 36;
174
+ case 32:
175
+ _context.prev = 32;
176
+ _context.next = 35;
172
177
  return this.localStorageAdaptor.getItem('rbtUser');
173
- case 36:
178
+ case 35:
174
179
  cachedUser = _context.sent;
175
180
  if (cachedUser) {
176
181
  parsed = typeof cachedUser === 'string' ? JSON.parse(cachedUser) : cachedUser;
@@ -179,20 +184,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
179
184
  id: parsed.id
180
185
  }, this.axios);
181
186
  this.currentUser.setData(parsed);
182
- console.log('[RbtApi] Loaded user from storage adaptor');
183
187
  }
184
188
  }
185
- _context.next = 43;
189
+ _context.next = 41;
186
190
  break;
187
- case 40:
188
- _context.prev = 40;
189
- _context.t2 = _context["catch"](33);
190
- console.warn('[RbtApi] Failed to load user from storage adaptor:', _context.t2);
191
- case 43:
191
+ case 39:
192
+ _context.prev = 39;
193
+ _context.t2 = _context["catch"](32);
194
+ case 41:
192
195
  case "end":
193
196
  return _context.stop();
194
197
  }
195
- }, _callee, this, [[2, 30], [9, 21, 24, 27], [33, 40]]);
198
+ }, _callee, this, [[2, 30], [9, 21, 24, 27], [32, 39]]);
196
199
  }));
197
200
  function _initializeFromStorage() {
198
201
  return _initializeFromStorage2.apply(this, arguments);
@@ -209,7 +212,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
209
212
  var baseUrl = this.axios.defaults.baseURL;
210
213
  var wsProtocol = baseUrl.startsWith('https') ? 'wss://' : 'ws://';
211
214
  var wsUrl = baseUrl.replace(/^https?:\/\//, wsProtocol);
212
- console.log('[RbtApi] Creating new WebSocket connection to:', wsUrl + '/realtime');
213
215
  this.websocketClient = new WebSocket("".concat(wsUrl, "/realtime"));
214
216
  this._setupWebSocketHandlers(this.websocketClient);
215
217
  return this.websocketClient;
@@ -219,7 +221,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
219
221
  value: function _setupWebSocketHandlers(ws) {
220
222
  var _this = this;
221
223
  ws.onopen = function () {
222
- console.log('[RbtApi] WebSocket connected.');
223
224
  _this._wsReconnectAttempts = 0;
224
225
  _this._wsConnected = true;
225
226
 
@@ -243,13 +244,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
243
244
  }
244
245
  };
245
246
  ws.onclose = function (event) {
246
- console.warn('[RbtApi] WebSocket closed:', event.code, event.reason);
247
247
  _this._wsConnected = false;
248
248
 
249
249
  // Attempt reconnection with exponential backoff
250
250
  if (!_this._wsManualClose && _this._wsReconnectAttempts < 5) {
251
251
  var delay = Math.min(1000 * Math.pow(2, _this._wsReconnectAttempts), 30000);
252
- console.log("[RbtApi] Attempting reconnection in ".concat(delay, "ms (attempt ").concat(_this._wsReconnectAttempts + 1, "/5)"));
253
252
  setTimeout(function () {
254
253
  _this._wsReconnectAttempts++;
255
254
  _this.websocketClient = null; // Clear the old connection
@@ -883,28 +882,27 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
883
882
  while (1) switch (_context16.prev = _context16.next) {
884
883
  case 0:
885
884
  if (this.appServiceHost) {
886
- _context16.next = 3;
885
+ _context16.next = 2;
887
886
  break;
888
887
  }
889
- console.warn('RBTTOK not initialized');
890
888
  return _context16.abrupt("return", false);
891
- case 3:
889
+ case 2:
892
890
  if (!this.requestCache[authtoken]) {
893
- _context16.next = 5;
891
+ _context16.next = 4;
894
892
  break;
895
893
  }
896
894
  return _context16.abrupt("return", this.requestCache[authtoken]);
897
- case 5:
898
- _context16.prev = 5;
895
+ case 4:
896
+ _context16.prev = 4;
899
897
  //console.log('RBTTOK Req', authtoken);
900
898
  // Create a new promise for the token refresh and store it in the cache
901
899
  promise = this.axios.post('/user_service/refreshAuthToken', [authtoken]);
902
900
  this.requestCache[authtoken] = promise;
903
901
 
904
902
  // Await the promise to get the response
905
- _context16.next = 10;
903
+ _context16.next = 9;
906
904
  return promise;
907
- case 10:
905
+ case 9:
908
906
  response = _context16.sent;
909
907
  //console.log('RBTTOK Response ',response);
910
908
  // Once the promise resolves, delete it from the cache to allow future refreshes
@@ -912,17 +910,17 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
912
910
 
913
911
  // Return the response data
914
912
  return _context16.abrupt("return", response.data);
915
- case 15:
916
- _context16.prev = 15;
917
- _context16.t0 = _context16["catch"](5);
913
+ case 14:
914
+ _context16.prev = 14;
915
+ _context16.t0 = _context16["catch"](4);
918
916
  // On error, remove the cached promise to allow retries
919
917
  delete this.requestCache[authtoken];
920
918
  this._handleError(_context16.t0);
921
- case 19:
919
+ case 18:
922
920
  case "end":
923
921
  return _context16.stop();
924
922
  }
925
- }, _callee16, this, [[5, 15]]);
923
+ }, _callee16, this, [[4, 14]]);
926
924
  }));
927
925
  function refreshAuthToken(_x8) {
928
926
  return _refreshAuthToken.apply(this, arguments);
@@ -1223,9 +1221,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1223
1221
  throw new Error("Invalid query parameter(s): ".concat(invalidParams.join(', '), ". Valid parameters are: ").concat(validParams.join(', ')));
1224
1222
  case 6:
1225
1223
  // Warn if enableRealtime is passed to query() - it should only be used by load()
1226
- if (params.enableRealtime) {
1227
- console.warn('[roboto-js] enableRealtime should not be passed to query(), only to load(). This parameter will be ignored.');
1228
- }
1224
+ if (params.enableRealtime) {}
1229
1225
  params.type = type;
1230
1226
 
1231
1227
  // Default ordering and pagination
@@ -1301,14 +1297,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1301
1297
  // Ensure WebSocket client is available if realtime is requested
1302
1298
  var websocketClient = this.websocketClient;
1303
1299
  if (options.enableRealtime && !websocketClient) {
1304
- console.log('[AgentProviderSync] Creating WebSocket client for realtime objects');
1305
1300
  websocketClient = this.getWebSocketClient();
1306
1301
  }
1307
- console.log('[AgentProviderSync] _processResponseData creating objects with:', {
1308
- enableRealtime: options.enableRealtime || false,
1309
- hasWebSocketClient: !!websocketClient,
1310
- itemCount: response.data.items.length
1311
- });
1312
1302
  response.data.items = response.data.items.map(function (record) {
1313
1303
  return new _rbt_object["default"](record, _this7.axios, {
1314
1304
  websocketClient: websocketClient,
@@ -1391,21 +1381,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1391
1381
  // Only log cache hits once per object to reduce spam
1392
1382
  hitLogKey = "hit:".concat(_cacheKey);
1393
1383
  if (!this._loggedCacheEvents.has(hitLogKey)) {
1394
- console.log('[AgentProviderSync] 🎯 roboto.load cache HIT:', {
1395
- type: type,
1396
- id: id,
1397
- hasRealtime: !!cached._realtime,
1398
- requestedRealtime: !!params.enableRealtime
1399
- });
1400
1384
  this._loggedCacheEvents.add(hitLogKey);
1401
1385
  }
1402
1386
 
1403
1387
  // If realtime is requested but cached object doesn't have it, upgrade it
1404
1388
  if (params.enableRealtime && !cached._realtime) {
1405
- console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', {
1406
- type: type,
1407
- id: id
1408
- });
1409
1389
  cached._initRealtime();
1410
1390
  }
1411
1391
  cachedObjects.push(cached);
@@ -1428,10 +1408,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1428
1408
  // Only log bulk cache miss once
1429
1409
  bulkMissLogKey = "bulk-miss:".concat(type, ":").concat(missingIds.join(','));
1430
1410
  if (!this._loggedCacheEvents.has(bulkMissLogKey)) {
1431
- console.log('[AgentProviderSync] 📦 roboto.load cache MISS, loading:', {
1432
- type: type,
1433
- ids: missingIds
1434
- });
1435
1411
  this._loggedCacheEvents.add(bulkMissLogKey);
1436
1412
  }
1437
1413
 
@@ -1455,10 +1431,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1455
1431
  // Only log cache set once per object to reduce spam
1456
1432
  setLogKey = "set:".concat(cacheKey);
1457
1433
  if (!this._loggedCacheEvents.has(setLogKey)) {
1458
- console.log('[AgentProviderSync] 💾 roboto.load cached object:', {
1459
- type: type,
1460
- id: obj.id
1461
- });
1462
1434
  this._loggedCacheEvents.add(setLogKey);
1463
1435
  }
1464
1436
  }
@@ -1500,21 +1472,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1500
1472
  }
1501
1473
  // Only log cache hits once per object to reduce spam
1502
1474
  _hitLogKey = "hit:".concat(_cacheKey3);
1503
- if (!this._loggedCacheEvents.has(_hitLogKey) || console.log('[AgentProviderSync] 🎯 roboto.load cache HIT:', {
1504
- type: type,
1505
- id: ids,
1506
- hasRealtime: !!_cached._realtime,
1507
- requestedRealtime: !!params.enableRealtime
1508
- })) {
1475
+ if (!this._loggedCacheEvents.has(_hitLogKey) || void 0) {
1509
1476
  this._loggedCacheEvents.add(_hitLogKey);
1510
1477
  }
1511
1478
 
1512
1479
  // If realtime is requested but cached object doesn't have it, upgrade it
1513
1480
  if (params.enableRealtime && !_cached._realtime) {
1514
- console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', {
1515
- type: type,
1516
- id: ids
1517
- });
1518
1481
  _cached._initRealtime();
1519
1482
  }
1520
1483
  return _context24.abrupt("return", _cached);
@@ -1533,10 +1496,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1533
1496
  // Only log cache miss once per object to reduce spam
1534
1497
  missLogKey = "miss:".concat(_cacheKey3);
1535
1498
  if (!this._loggedCacheEvents.has(missLogKey)) {
1536
- console.log('[AgentProviderSync] 📦 roboto.load cache MISS, loading:', {
1537
- type: type,
1538
- id: ids
1539
- });
1540
1499
  this._loggedCacheEvents.add(missLogKey);
1541
1500
  }
1542
1501
 
@@ -1564,10 +1523,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1564
1523
  // Only log cache set once per object to reduce spam
1565
1524
  _setLogKey = "set:".concat(_cacheKey3);
1566
1525
  if (!_this8._loggedCacheEvents.has(_setLogKey)) {
1567
- console.log('[AgentProviderSync] 💾 roboto.load cached object:', {
1568
- type: type,
1569
- id: ids
1570
- });
1571
1526
  _this8._loggedCacheEvents.add(_setLogKey);
1572
1527
  }
1573
1528
  }
@@ -1626,11 +1581,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1626
1581
  this._loggedCacheEvents["delete"]("hit:".concat(cacheKey));
1627
1582
  this._loggedCacheEvents["delete"]("miss:".concat(cacheKey));
1628
1583
  this._loggedCacheEvents["delete"]("set:".concat(cacheKey));
1629
- console.log('[AgentProviderSync] 🗑️ roboto.clearCache specific object:', {
1630
- type: type,
1631
- id: id,
1632
- removed: removed
1633
- });
1634
1584
  } else if (type) {
1635
1585
  // Clear all objects of a specific type
1636
1586
  var removedCount = 0;
@@ -1666,19 +1616,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1666
1616
  } finally {
1667
1617
  _iterator7.f();
1668
1618
  }
1669
- console.log('[AgentProviderSync] 🗑️ roboto.clearCache by type:', {
1670
- type: type,
1671
- removedCount: removedCount
1672
- });
1673
1619
  } else {
1674
1620
  // Clear all cached objects
1675
1621
  var size = this._objectCache.size;
1676
1622
  this._objectCache.clear();
1677
1623
  this._loggedCacheEvents.clear();
1678
1624
  this._pendingLoads.clear();
1679
- console.log('[AgentProviderSync] 🗑️ roboto.clearCache all objects:', {
1680
- clearedCount: size
1681
- });
1682
1625
  }
1683
1626
  }
1684
1627
 
@@ -2122,13 +2065,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2122
2065
  if (res) return;
2123
2066
  }
2124
2067
  if (_lodash["default"].isObject(err) && _lodash["default"].get(err, 'response')) {
2125
- if (err.response) {
2126
- console.log('Error response:', {
2127
- data: err.response.data,
2128
- status: err.response.status,
2129
- headers: err.response.headers
2130
- });
2131
- }
2068
+ if (err.response) {}
2132
2069
  var msg = _lodash["default"].get(err, 'response.data.message', 'Error in API response');
2133
2070
  if (msg.key) {
2134
2071
  //throw new Error(msg.key);
@@ -357,7 +357,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
357
357
  key: "save",
358
358
  value: function () {
359
359
  var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
360
- var _response$data, _response$data2, record, response, _e$response;
360
+ var _response$data, _response$data2, record, response;
361
361
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
362
362
  while (1) switch (_context3.prev = _context3.next) {
363
363
  case 0:
@@ -402,11 +402,10 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
402
402
  case 20:
403
403
  _context3.prev = 20;
404
404
  _context3.t0 = _context3["catch"](2);
405
- console.log('RbtObject.save.error:', _context3.t0 === null || _context3.t0 === void 0 || (_e$response = _context3.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.data);
406
405
  this._error = _context3.t0;
407
406
  //console.log(e.response.data);
408
407
  throw _context3.t0;
409
- case 25:
408
+ case 24:
410
409
  case "end":
411
410
  return _context3.stop();
412
411
  }
@@ -908,10 +907,8 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
908
907
  case 13:
909
908
  _context8.prev = 13;
910
909
  _context8.t0 = _context8["catch"](2);
911
- console.log('RbtObject.delete.error:');
912
- console.log(_context8.t0.response.data);
913
910
  throw _context8.t0;
914
- case 18:
911
+ case 16:
915
912
  case "end":
916
913
  return _context8.stop();
917
914
  }
@@ -1009,12 +1006,8 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
1009
1006
  userId: msg.userId || msg.delta.userId || null
1010
1007
  });
1011
1008
  _this3._trigger('change', changeData);
1012
- if (msg.isStateSync) {
1013
- console.log('[RbtObject] Applied state sync:', msg.delta.path, '=', msg.delta.value);
1014
- }
1015
- } else {
1016
- console.warn('[RbtObject] Received update message without valid delta:', msg);
1017
- }
1009
+ if (msg.isStateSync) {}
1010
+ } else {}
1018
1011
  } else if (msg.type === 'save') {
1019
1012
  _this3._trigger('save', msg.revision || {});
1020
1013
  }
@@ -1045,8 +1038,6 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
1045
1038
  }, {
1046
1039
  key: "_trigger",
1047
1040
  value: function _trigger(type, data) {
1048
- var _this$_eventHandlers$;
1049
- console.log('[AgentProviderSync] _trigger called:', type, 'handlers:', (_this$_eventHandlers$ = this._eventHandlers[type]) === null || _this$_eventHandlers$ === void 0 ? void 0 : _this$_eventHandlers$.length, 'data:', data);
1050
1041
  var _iterator = _createForOfIteratorHelper(this._eventHandlers[type] || []),
1051
1042
  _step;
1052
1043
  try {
@@ -176,10 +176,8 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
176
176
  case 17:
177
177
  _context.prev = 17;
178
178
  _context.t0 = _context["catch"](0);
179
- console.log('RbtUser.save.error:', _context.t0);
180
- //console.log(e.response.data);
181
179
  throw _context.t0;
182
- case 21:
180
+ case 20:
183
181
  case "end":
184
182
  return _context.stop();
185
183
  }