roboto-js 1.9.14 → 3.0.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/.last-build +1 -1
- package/dist/cjs/rbt_api.cjs +40 -9
- package/dist/cjs/rbt_object.cjs +13 -1
- package/dist/cjs/rbt_user.cjs +1 -1
- package/dist/cjs/version.cjs +2 -2
- package/dist/esm/rbt_api.js +40 -9
- package/dist/esm/rbt_object.js +13 -1
- package/dist/esm/rbt_user.js +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/rbt_api.js +47 -86
- package/dist/rbt_object.js +10 -8
- package/dist/version.js +2 -2
- package/package.json +1 -1
- package/src/rbt_api.js +41 -41
- package/src/rbt_object.js +8 -8
- package/src/rbt_user.js +1 -1
- package/src/version.js +2 -2
package/.last-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2026-
|
|
1
|
+
2026-04-05T01:06:26.330Z
|
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -48,6 +48,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
48
48
|
_ref$withCredentials = _ref.withCredentials,
|
|
49
49
|
withCredentials = _ref$withCredentials === void 0 ? true : _ref$withCredentials;
|
|
50
50
|
_classCallCheck(this, RbtApi);
|
|
51
|
+
//console.log('[RbtApi] constructor received:', { baseUrl, accesskey, authtoken, apikey, withCredentials });
|
|
52
|
+
|
|
51
53
|
this.websocketClient = null;
|
|
52
54
|
|
|
53
55
|
// Object cache for sharing instances across multiple load() calls
|
|
@@ -105,7 +107,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
105
107
|
if (apikey) {
|
|
106
108
|
this.apikey = apikey;
|
|
107
109
|
this.axios.defaults.headers.common['apikey'] = this.apikey;
|
|
108
|
-
// ADD THIS LINE
|
|
110
|
+
//console.log('[RbtApi] Set apikey header:', this.axios.defaults.headers.common['apikey']); // ADD THIS LINE
|
|
109
111
|
}
|
|
110
112
|
this.initApiKey(apikey);
|
|
111
113
|
}
|
|
@@ -170,6 +172,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
170
172
|
if (token) {
|
|
171
173
|
this.authtoken = token;
|
|
172
174
|
this.axios.defaults.headers.common['authtoken'] = token;
|
|
175
|
+
//console.log('[RbtApi] Loaded authtoken from storage adaptor');
|
|
173
176
|
}
|
|
174
177
|
_context.next = 32;
|
|
175
178
|
break;
|
|
@@ -189,6 +192,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
189
192
|
id: parsed.id
|
|
190
193
|
}, this.axios);
|
|
191
194
|
this.currentUser.setData(parsed);
|
|
195
|
+
//console.log('[RbtApi] Loaded user from storage adaptor');
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
198
|
_context.next = 41;
|
|
@@ -217,6 +221,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
217
221
|
var baseUrl = this.axios.defaults.baseURL;
|
|
218
222
|
var wsProtocol = baseUrl.startsWith('https') ? 'wss://' : 'ws://';
|
|
219
223
|
var wsUrl = baseUrl.replace(/^https?:\/\//, wsProtocol);
|
|
224
|
+
|
|
225
|
+
//console.log('[RbtApi] Creating new WebSocket connection to:', wsUrl + '/realtime');
|
|
220
226
|
this.websocketClient = new WebSocket("".concat(wsUrl, "/realtime"));
|
|
221
227
|
this._setupWebSocketHandlers(this.websocketClient);
|
|
222
228
|
return this.websocketClient;
|
|
@@ -226,6 +232,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
226
232
|
value: function _setupWebSocketHandlers(ws) {
|
|
227
233
|
var _this = this;
|
|
228
234
|
ws.onopen = function () {
|
|
235
|
+
//console.log('[RbtApi] WebSocket connected.');
|
|
229
236
|
_this._wsReconnectAttempts = 0;
|
|
230
237
|
_this._wsConnected = true;
|
|
231
238
|
|
|
@@ -254,6 +261,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
254
261
|
// Attempt reconnection with exponential backoff
|
|
255
262
|
if (!_this._wsManualClose && _this._wsReconnectAttempts < 5) {
|
|
256
263
|
var delay = Math.min(1000 * Math.pow(2, _this._wsReconnectAttempts), 30000);
|
|
264
|
+
//console.log(`[RbtApi] Attempting reconnection in ${delay}ms (attempt ${this._wsReconnectAttempts + 1}/5)`);
|
|
265
|
+
|
|
257
266
|
setTimeout(function () {
|
|
258
267
|
_this._wsReconnectAttempts++;
|
|
259
268
|
_this.websocketClient = null; // Clear the old connection
|
|
@@ -467,7 +476,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
467
476
|
case 0:
|
|
468
477
|
_context6.prev = 0;
|
|
469
478
|
_context6.next = 3;
|
|
470
|
-
return this.axios.post('/
|
|
479
|
+
return this.axios.post('/api/iac/loginUser', [{
|
|
471
480
|
email: params.email,
|
|
472
481
|
password: params.password ? _cryptoJs["default"].MD5(params.password).toString(_cryptoJs["default"].enc.Hex) : null,
|
|
473
482
|
// legacy hash password (md5)
|
|
@@ -586,7 +595,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
586
595
|
case 0:
|
|
587
596
|
_context8.prev = 0;
|
|
588
597
|
_context8.next = 3;
|
|
589
|
-
return this.axios.post('/
|
|
598
|
+
return this.axios.post('/api/iac/logoutUser');
|
|
590
599
|
case 3:
|
|
591
600
|
response = _context8.sent;
|
|
592
601
|
if (!(response.data.ok === false)) {
|
|
@@ -748,7 +757,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
748
757
|
};
|
|
749
758
|
_context11.prev = 1;
|
|
750
759
|
_context11.next = 4;
|
|
751
|
-
return this.axios.post('/
|
|
760
|
+
return this.axios.post('/api/iac/confirmUserEmail', [params]);
|
|
752
761
|
case 4:
|
|
753
762
|
response = _context11.sent;
|
|
754
763
|
if (!(response.data.ok === false)) {
|
|
@@ -909,6 +918,9 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
909
918
|
break;
|
|
910
919
|
}
|
|
911
920
|
_this4.currentOrganization = org; // Already an RbtObject
|
|
921
|
+
//console.log('[RbtApi] Current organization loaded:', org.get('name'));
|
|
922
|
+
|
|
923
|
+
// Cache in storage if available
|
|
912
924
|
if (!_this4.localStorageAdaptor) {
|
|
913
925
|
_context14.next = 24;
|
|
914
926
|
break;
|
|
@@ -1099,18 +1111,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1099
1111
|
}
|
|
1100
1112
|
throw new Error('Failed to load user object');
|
|
1101
1113
|
case 17:
|
|
1114
|
+
//console.log('[RbtApi] User loaded:', user.id);
|
|
1102
1115
|
// Update user's organizations array
|
|
1103
1116
|
userOrgs = user.get('organizations') || [];
|
|
1104
1117
|
orgExists = userOrgs.some(function (o) {
|
|
1105
1118
|
return (o === null || o === void 0 ? void 0 : o.id) === orgId;
|
|
1106
1119
|
});
|
|
1107
1120
|
if (!orgExists) {
|
|
1121
|
+
//console.log('[RbtApi] Adding organization to user organizations array');
|
|
1108
1122
|
userOrgs.unshift({
|
|
1109
1123
|
id: orgId,
|
|
1110
1124
|
roles: [role]
|
|
1111
1125
|
});
|
|
1112
1126
|
user.set('organizations', userOrgs);
|
|
1113
|
-
} else {
|
|
1127
|
+
} else {
|
|
1128
|
+
//console.log('[RbtApi] Organization already in user organizations array');
|
|
1129
|
+
}
|
|
1114
1130
|
|
|
1115
1131
|
// Set as current organization preference - handle both nested path formats
|
|
1116
1132
|
modData = user.get('mod') || {};
|
|
@@ -1118,9 +1134,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1118
1134
|
user.set('mod', modData);
|
|
1119
1135
|
|
|
1120
1136
|
// Save user record
|
|
1137
|
+
//console.log('[RbtApi] Saving user with organization:', orgId);
|
|
1121
1138
|
_context17.next = 25;
|
|
1122
1139
|
return user.save();
|
|
1123
1140
|
case 25:
|
|
1141
|
+
//console.log('[RbtApi] User saved successfully');
|
|
1142
|
+
|
|
1124
1143
|
// Clear cached organization to force reload
|
|
1125
1144
|
this.currentOrganization = null;
|
|
1126
1145
|
|
|
@@ -1184,7 +1203,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1184
1203
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1185
1204
|
case 0:
|
|
1186
1205
|
_context18.next = 2;
|
|
1187
|
-
return _this5.axios.post('/
|
|
1206
|
+
return _this5.axios.post('/api/iac/loadUser', [params]);
|
|
1188
1207
|
case 2:
|
|
1189
1208
|
response = _context18.sent;
|
|
1190
1209
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
@@ -1245,7 +1264,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1245
1264
|
_context20.prev = 4;
|
|
1246
1265
|
//console.log('RBTTOK Req', authtoken);
|
|
1247
1266
|
// Create a new promise for the token refresh and store it in the cache
|
|
1248
|
-
promise = this.axios.post('/
|
|
1267
|
+
promise = this.axios.post('/api/iac/refreshAuthToken', [authtoken]);
|
|
1249
1268
|
this.requestCache[authtoken] = promise;
|
|
1250
1269
|
|
|
1251
1270
|
// Await the promise to get the response
|
|
@@ -1284,7 +1303,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1284
1303
|
//
|
|
1285
1304
|
// try {
|
|
1286
1305
|
//
|
|
1287
|
-
// const response = await this.axios.post('/
|
|
1306
|
+
// const response = await this.axios.post('/api/iac/refreshAuthToken', [authtoken]);
|
|
1288
1307
|
// return response.data;
|
|
1289
1308
|
//
|
|
1290
1309
|
// } catch (e) {
|
|
@@ -1313,7 +1332,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1313
1332
|
dataHash = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
1314
1333
|
_context21.prev = 1;
|
|
1315
1334
|
_context21.next = 4;
|
|
1316
|
-
return this.axios.post('/
|
|
1335
|
+
return this.axios.post('/api/iac/registerUser', [dataHash]);
|
|
1317
1336
|
case 4:
|
|
1318
1337
|
response = _context21.sent;
|
|
1319
1338
|
record = response.data;
|
|
@@ -1740,11 +1759,13 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1740
1759
|
// Only log cache hits once per object to reduce spam
|
|
1741
1760
|
hitLogKey = "hit:".concat(_cacheKey);
|
|
1742
1761
|
if (!this._loggedCacheEvents.has(hitLogKey)) {
|
|
1762
|
+
//console.log('[AgentProviderSync] 🎯 roboto.load cache HIT:', { type, id, hasRealtime: !!cached._realtime, requestedRealtime: !!params.enableRealtime });
|
|
1743
1763
|
this._loggedCacheEvents.add(hitLogKey);
|
|
1744
1764
|
}
|
|
1745
1765
|
|
|
1746
1766
|
// If realtime is requested but cached object doesn't have it, upgrade it
|
|
1747
1767
|
if (params.enableRealtime && !cached._realtime) {
|
|
1768
|
+
//console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', { type, id });
|
|
1748
1769
|
cached._initRealtime();
|
|
1749
1770
|
}
|
|
1750
1771
|
cachedObjects.push(cached);
|
|
@@ -1767,6 +1788,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1767
1788
|
// Only log bulk cache miss once
|
|
1768
1789
|
bulkMissLogKey = "bulk-miss:".concat(type, ":").concat(missingIds.join(','));
|
|
1769
1790
|
if (!this._loggedCacheEvents.has(bulkMissLogKey)) {
|
|
1791
|
+
//console.log('[AgentProviderSync] 📦 roboto.load cache MISS, loading:', { type, ids: missingIds });
|
|
1770
1792
|
this._loggedCacheEvents.add(bulkMissLogKey);
|
|
1771
1793
|
}
|
|
1772
1794
|
|
|
@@ -1790,6 +1812,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1790
1812
|
// Only log cache set once per object to reduce spam
|
|
1791
1813
|
setLogKey = "set:".concat(cacheKey);
|
|
1792
1814
|
if (!this._loggedCacheEvents.has(setLogKey)) {
|
|
1815
|
+
//console.log('[AgentProviderSync] 💾 roboto.load cached object:', { type, id: obj.id });
|
|
1793
1816
|
this._loggedCacheEvents.add(setLogKey);
|
|
1794
1817
|
}
|
|
1795
1818
|
}
|
|
@@ -1837,6 +1860,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1837
1860
|
|
|
1838
1861
|
// If realtime is requested but cached object doesn't have it, upgrade it
|
|
1839
1862
|
if (params.enableRealtime && !_cached._realtime) {
|
|
1863
|
+
//console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', { type, id: ids });
|
|
1840
1864
|
_cached._initRealtime();
|
|
1841
1865
|
}
|
|
1842
1866
|
return _context28.abrupt("return", _cached);
|
|
@@ -1855,6 +1879,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1855
1879
|
// Only log cache miss once per object to reduce spam
|
|
1856
1880
|
missLogKey = "miss:".concat(_cacheKey3);
|
|
1857
1881
|
if (!this._loggedCacheEvents.has(missLogKey)) {
|
|
1882
|
+
//console.log('[AgentProviderSync] 📦 roboto.load cache MISS, loading:', { type, id: ids });
|
|
1858
1883
|
this._loggedCacheEvents.add(missLogKey);
|
|
1859
1884
|
}
|
|
1860
1885
|
|
|
@@ -1882,6 +1907,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1882
1907
|
// Only log cache set once per object to reduce spam
|
|
1883
1908
|
_setLogKey = "set:".concat(_cacheKey3);
|
|
1884
1909
|
if (!_this9._loggedCacheEvents.has(_setLogKey)) {
|
|
1910
|
+
//console.log('[AgentProviderSync] 💾 roboto.load cached object:', { type, id: ids });
|
|
1885
1911
|
_this9._loggedCacheEvents.add(_setLogKey);
|
|
1886
1912
|
}
|
|
1887
1913
|
}
|
|
@@ -1940,6 +1966,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1940
1966
|
this._loggedCacheEvents["delete"]("hit:".concat(cacheKey));
|
|
1941
1967
|
this._loggedCacheEvents["delete"]("miss:".concat(cacheKey));
|
|
1942
1968
|
this._loggedCacheEvents["delete"]("set:".concat(cacheKey));
|
|
1969
|
+
|
|
1970
|
+
//console.log('[AgentProviderSync] 🗑️ roboto.clearCache specific object:', { type, id, removed });
|
|
1943
1971
|
} else if (type) {
|
|
1944
1972
|
// Clear all objects of a specific type
|
|
1945
1973
|
var removedCount = 0;
|
|
@@ -1970,6 +1998,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1970
1998
|
this._loggedCacheEvents["delete"](logKey);
|
|
1971
1999
|
}
|
|
1972
2000
|
}
|
|
2001
|
+
|
|
2002
|
+
//console.log('[AgentProviderSync] 🗑️ roboto.clearCache by type:', { type, removedCount });
|
|
1973
2003
|
} catch (err) {
|
|
1974
2004
|
_iterator7.e(err);
|
|
1975
2005
|
} finally {
|
|
@@ -1981,6 +2011,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1981
2011
|
this._objectCache.clear();
|
|
1982
2012
|
this._loggedCacheEvents.clear();
|
|
1983
2013
|
this._pendingLoads.clear();
|
|
2014
|
+
//console.log('[AgentProviderSync] 🗑️ roboto.clearCache all objects:', { clearedCount: size });
|
|
1984
2015
|
}
|
|
1985
2016
|
}
|
|
1986
2017
|
|
package/dist/cjs/rbt_object.cjs
CHANGED
|
@@ -1053,7 +1053,9 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
1053
1053
|
userId: msg.userId || msg.delta.userId || null
|
|
1054
1054
|
});
|
|
1055
1055
|
_this3._trigger('change', changeData);
|
|
1056
|
-
if (msg.isStateSync) {
|
|
1056
|
+
if (msg.isStateSync) {
|
|
1057
|
+
//console.log('[RbtObject] Applied state sync:', msg.delta.path, '=', msg.delta.value);
|
|
1058
|
+
}
|
|
1057
1059
|
} else {}
|
|
1058
1060
|
} else if (msg.type === 'save') {
|
|
1059
1061
|
_this3._trigger('save', msg.revision || {});
|
|
@@ -1072,12 +1074,15 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
1072
1074
|
this._eventHandlers.change.push(cb);
|
|
1073
1075
|
|
|
1074
1076
|
// Log registration with stack trace to identify duplicates
|
|
1077
|
+
//console.log(`[AgentProviderSync] 📝 onChange handler registered #${handlerCount + 1}`);
|
|
1075
1078
|
|
|
1076
1079
|
// Get stack trace to see who registered this handler
|
|
1077
1080
|
var stack = new Error().stack;
|
|
1078
1081
|
var stackLines = stack.split('\n');
|
|
1079
1082
|
// Skip the first 3 lines (Error, onChange, and the immediate caller)
|
|
1080
1083
|
var relevantStack = stackLines.slice(3, 8).join('\n');
|
|
1084
|
+
//console.log('[AgentProviderSync] Registration stack:', relevantStack);
|
|
1085
|
+
|
|
1081
1086
|
// Auto-initialize realtime if this object has WebSocket capability
|
|
1082
1087
|
if (this._ws && !this._realtime) {
|
|
1083
1088
|
this._initRealtime();
|
|
@@ -1091,6 +1096,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
1091
1096
|
var index = this._eventHandlers.change.indexOf(cb);
|
|
1092
1097
|
if (index > -1) {
|
|
1093
1098
|
this._eventHandlers.change.splice(index, 1);
|
|
1099
|
+
//console.log(`[AgentProviderSync] 🗑️ onChange handler removed. Remaining:`, this._eventHandlers.change.length);
|
|
1094
1100
|
return true;
|
|
1095
1101
|
} else {
|
|
1096
1102
|
return false;
|
|
@@ -1120,16 +1126,22 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
1120
1126
|
key: "_trigger",
|
|
1121
1127
|
value: function _trigger(type, data) {
|
|
1122
1128
|
var handlers = this._eventHandlers[type] || [];
|
|
1129
|
+
//console.log('[AgentProviderSync] _trigger called:', type, 'handlers:', handlers.length, 'data:', data)
|
|
1130
|
+
|
|
1123
1131
|
for (var i = 0; i < handlers.length; i++) {
|
|
1124
1132
|
var fn = handlers[i];
|
|
1125
1133
|
try {
|
|
1134
|
+
//console.log(`[AgentProviderSync] 🔄 Calling handler ${i+1}/${handlers.length}`);
|
|
1126
1135
|
fn(data);
|
|
1136
|
+
//console.log(`[AgentProviderSync] ✅ Handler ${i+1} succeeded`);
|
|
1127
1137
|
} catch (error) {
|
|
1128
1138
|
console.error("[AgentProviderSync] \u274C Handler ".concat(i + 1, "/").concat(handlers.length, " threw error:"), error);
|
|
1129
1139
|
console.error('[AgentProviderSync] Error stack:', error.stack);
|
|
1130
1140
|
// Continue to next handler instead of breaking the loop
|
|
1131
1141
|
}
|
|
1132
1142
|
}
|
|
1143
|
+
|
|
1144
|
+
// ✓ Completed calling ${handlers.length} handlers`);
|
|
1133
1145
|
}
|
|
1134
1146
|
}, {
|
|
1135
1147
|
key: "_broadcastChange",
|
package/dist/cjs/rbt_user.cjs
CHANGED
|
@@ -158,7 +158,7 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
|
|
|
158
158
|
record = this.toRecord();
|
|
159
159
|
record.type = '<@iac.user>';
|
|
160
160
|
_context.next = 6;
|
|
161
|
-
return this._axios.post('/
|
|
161
|
+
return this._axios.post('/api/iac/saveUser', [record]);
|
|
162
162
|
case 6:
|
|
163
163
|
response = _context.sent;
|
|
164
164
|
if (!(response.data.ok === false)) {
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = void 0;
|
|
7
7
|
// Auto-generated version file
|
|
8
8
|
// DO NOT EDIT - This file is automatically updated from package.cjson
|
|
9
|
-
// Version:
|
|
10
|
-
var version = exports.version = '
|
|
9
|
+
// Version: 3.0.0
|
|
10
|
+
var version = exports.version = '3.0.0';
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -41,6 +41,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
41
41
|
_ref$withCredentials = _ref.withCredentials,
|
|
42
42
|
withCredentials = _ref$withCredentials === void 0 ? true : _ref$withCredentials;
|
|
43
43
|
_classCallCheck(this, RbtApi);
|
|
44
|
+
//console.log('[RbtApi] constructor received:', { baseUrl, accesskey, authtoken, apikey, withCredentials });
|
|
45
|
+
|
|
44
46
|
this.websocketClient = null;
|
|
45
47
|
|
|
46
48
|
// Object cache for sharing instances across multiple load() calls
|
|
@@ -98,7 +100,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
98
100
|
if (apikey) {
|
|
99
101
|
this.apikey = apikey;
|
|
100
102
|
this.axios.defaults.headers.common['apikey'] = this.apikey;
|
|
101
|
-
// ADD THIS LINE
|
|
103
|
+
//console.log('[RbtApi] Set apikey header:', this.axios.defaults.headers.common['apikey']); // ADD THIS LINE
|
|
102
104
|
}
|
|
103
105
|
this.initApiKey(apikey);
|
|
104
106
|
}
|
|
@@ -163,6 +165,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
163
165
|
if (token) {
|
|
164
166
|
this.authtoken = token;
|
|
165
167
|
this.axios.defaults.headers.common['authtoken'] = token;
|
|
168
|
+
//console.log('[RbtApi] Loaded authtoken from storage adaptor');
|
|
166
169
|
}
|
|
167
170
|
_context.next = 32;
|
|
168
171
|
break;
|
|
@@ -182,6 +185,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
182
185
|
id: parsed.id
|
|
183
186
|
}, this.axios);
|
|
184
187
|
this.currentUser.setData(parsed);
|
|
188
|
+
//console.log('[RbtApi] Loaded user from storage adaptor');
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
_context.next = 41;
|
|
@@ -210,6 +214,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
210
214
|
var baseUrl = this.axios.defaults.baseURL;
|
|
211
215
|
var wsProtocol = baseUrl.startsWith('https') ? 'wss://' : 'ws://';
|
|
212
216
|
var wsUrl = baseUrl.replace(/^https?:\/\//, wsProtocol);
|
|
217
|
+
|
|
218
|
+
//console.log('[RbtApi] Creating new WebSocket connection to:', wsUrl + '/realtime');
|
|
213
219
|
this.websocketClient = new WebSocket("".concat(wsUrl, "/realtime"));
|
|
214
220
|
this._setupWebSocketHandlers(this.websocketClient);
|
|
215
221
|
return this.websocketClient;
|
|
@@ -219,6 +225,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
219
225
|
value: function _setupWebSocketHandlers(ws) {
|
|
220
226
|
var _this = this;
|
|
221
227
|
ws.onopen = function () {
|
|
228
|
+
//console.log('[RbtApi] WebSocket connected.');
|
|
222
229
|
_this._wsReconnectAttempts = 0;
|
|
223
230
|
_this._wsConnected = true;
|
|
224
231
|
|
|
@@ -247,6 +254,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
247
254
|
// Attempt reconnection with exponential backoff
|
|
248
255
|
if (!_this._wsManualClose && _this._wsReconnectAttempts < 5) {
|
|
249
256
|
var delay = Math.min(1000 * Math.pow(2, _this._wsReconnectAttempts), 30000);
|
|
257
|
+
//console.log(`[RbtApi] Attempting reconnection in ${delay}ms (attempt ${this._wsReconnectAttempts + 1}/5)`);
|
|
258
|
+
|
|
250
259
|
setTimeout(function () {
|
|
251
260
|
_this._wsReconnectAttempts++;
|
|
252
261
|
_this.websocketClient = null; // Clear the old connection
|
|
@@ -460,7 +469,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
460
469
|
case 0:
|
|
461
470
|
_context6.prev = 0;
|
|
462
471
|
_context6.next = 3;
|
|
463
|
-
return this.axios.post('/
|
|
472
|
+
return this.axios.post('/api/iac/loginUser', [{
|
|
464
473
|
email: params.email,
|
|
465
474
|
password: params.password ? CryptoJS.MD5(params.password).toString(CryptoJS.enc.Hex) : null,
|
|
466
475
|
// legacy hash password (md5)
|
|
@@ -579,7 +588,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
579
588
|
case 0:
|
|
580
589
|
_context8.prev = 0;
|
|
581
590
|
_context8.next = 3;
|
|
582
|
-
return this.axios.post('/
|
|
591
|
+
return this.axios.post('/api/iac/logoutUser');
|
|
583
592
|
case 3:
|
|
584
593
|
response = _context8.sent;
|
|
585
594
|
if (!(response.data.ok === false)) {
|
|
@@ -741,7 +750,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
741
750
|
};
|
|
742
751
|
_context11.prev = 1;
|
|
743
752
|
_context11.next = 4;
|
|
744
|
-
return this.axios.post('/
|
|
753
|
+
return this.axios.post('/api/iac/confirmUserEmail', [params]);
|
|
745
754
|
case 4:
|
|
746
755
|
response = _context11.sent;
|
|
747
756
|
if (!(response.data.ok === false)) {
|
|
@@ -902,6 +911,9 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
902
911
|
break;
|
|
903
912
|
}
|
|
904
913
|
_this4.currentOrganization = org; // Already an RbtObject
|
|
914
|
+
//console.log('[RbtApi] Current organization loaded:', org.get('name'));
|
|
915
|
+
|
|
916
|
+
// Cache in storage if available
|
|
905
917
|
if (!_this4.localStorageAdaptor) {
|
|
906
918
|
_context14.next = 24;
|
|
907
919
|
break;
|
|
@@ -1092,18 +1104,22 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1092
1104
|
}
|
|
1093
1105
|
throw new Error('Failed to load user object');
|
|
1094
1106
|
case 17:
|
|
1107
|
+
//console.log('[RbtApi] User loaded:', user.id);
|
|
1095
1108
|
// Update user's organizations array
|
|
1096
1109
|
userOrgs = user.get('organizations') || [];
|
|
1097
1110
|
orgExists = userOrgs.some(function (o) {
|
|
1098
1111
|
return (o === null || o === void 0 ? void 0 : o.id) === orgId;
|
|
1099
1112
|
});
|
|
1100
1113
|
if (!orgExists) {
|
|
1114
|
+
//console.log('[RbtApi] Adding organization to user organizations array');
|
|
1101
1115
|
userOrgs.unshift({
|
|
1102
1116
|
id: orgId,
|
|
1103
1117
|
roles: [role]
|
|
1104
1118
|
});
|
|
1105
1119
|
user.set('organizations', userOrgs);
|
|
1106
|
-
} else {
|
|
1120
|
+
} else {
|
|
1121
|
+
//console.log('[RbtApi] Organization already in user organizations array');
|
|
1122
|
+
}
|
|
1107
1123
|
|
|
1108
1124
|
// Set as current organization preference - handle both nested path formats
|
|
1109
1125
|
modData = user.get('mod') || {};
|
|
@@ -1111,9 +1127,12 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1111
1127
|
user.set('mod', modData);
|
|
1112
1128
|
|
|
1113
1129
|
// Save user record
|
|
1130
|
+
//console.log('[RbtApi] Saving user with organization:', orgId);
|
|
1114
1131
|
_context17.next = 25;
|
|
1115
1132
|
return user.save();
|
|
1116
1133
|
case 25:
|
|
1134
|
+
//console.log('[RbtApi] User saved successfully');
|
|
1135
|
+
|
|
1117
1136
|
// Clear cached organization to force reload
|
|
1118
1137
|
this.currentOrganization = null;
|
|
1119
1138
|
|
|
@@ -1177,7 +1196,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1177
1196
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1178
1197
|
case 0:
|
|
1179
1198
|
_context18.next = 2;
|
|
1180
|
-
return _this5.axios.post('/
|
|
1199
|
+
return _this5.axios.post('/api/iac/loadUser', [params]);
|
|
1181
1200
|
case 2:
|
|
1182
1201
|
response = _context18.sent;
|
|
1183
1202
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
@@ -1238,7 +1257,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1238
1257
|
_context20.prev = 4;
|
|
1239
1258
|
//console.log('RBTTOK Req', authtoken);
|
|
1240
1259
|
// Create a new promise for the token refresh and store it in the cache
|
|
1241
|
-
promise = this.axios.post('/
|
|
1260
|
+
promise = this.axios.post('/api/iac/refreshAuthToken', [authtoken]);
|
|
1242
1261
|
this.requestCache[authtoken] = promise;
|
|
1243
1262
|
|
|
1244
1263
|
// Await the promise to get the response
|
|
@@ -1277,7 +1296,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1277
1296
|
//
|
|
1278
1297
|
// try {
|
|
1279
1298
|
//
|
|
1280
|
-
// const response = await this.axios.post('/
|
|
1299
|
+
// const response = await this.axios.post('/api/iac/refreshAuthToken', [authtoken]);
|
|
1281
1300
|
// return response.data;
|
|
1282
1301
|
//
|
|
1283
1302
|
// } catch (e) {
|
|
@@ -1306,7 +1325,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1306
1325
|
dataHash = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
1307
1326
|
_context21.prev = 1;
|
|
1308
1327
|
_context21.next = 4;
|
|
1309
|
-
return this.axios.post('/
|
|
1328
|
+
return this.axios.post('/api/iac/registerUser', [dataHash]);
|
|
1310
1329
|
case 4:
|
|
1311
1330
|
response = _context21.sent;
|
|
1312
1331
|
record = response.data;
|
|
@@ -1733,11 +1752,13 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1733
1752
|
// Only log cache hits once per object to reduce spam
|
|
1734
1753
|
hitLogKey = "hit:".concat(_cacheKey);
|
|
1735
1754
|
if (!this._loggedCacheEvents.has(hitLogKey)) {
|
|
1755
|
+
//console.log('[AgentProviderSync] 🎯 roboto.load cache HIT:', { type, id, hasRealtime: !!cached._realtime, requestedRealtime: !!params.enableRealtime });
|
|
1736
1756
|
this._loggedCacheEvents.add(hitLogKey);
|
|
1737
1757
|
}
|
|
1738
1758
|
|
|
1739
1759
|
// If realtime is requested but cached object doesn't have it, upgrade it
|
|
1740
1760
|
if (params.enableRealtime && !cached._realtime) {
|
|
1761
|
+
//console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', { type, id });
|
|
1741
1762
|
cached._initRealtime();
|
|
1742
1763
|
}
|
|
1743
1764
|
cachedObjects.push(cached);
|
|
@@ -1760,6 +1781,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1760
1781
|
// Only log bulk cache miss once
|
|
1761
1782
|
bulkMissLogKey = "bulk-miss:".concat(type, ":").concat(missingIds.join(','));
|
|
1762
1783
|
if (!this._loggedCacheEvents.has(bulkMissLogKey)) {
|
|
1784
|
+
//console.log('[AgentProviderSync] 📦 roboto.load cache MISS, loading:', { type, ids: missingIds });
|
|
1763
1785
|
this._loggedCacheEvents.add(bulkMissLogKey);
|
|
1764
1786
|
}
|
|
1765
1787
|
|
|
@@ -1783,6 +1805,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1783
1805
|
// Only log cache set once per object to reduce spam
|
|
1784
1806
|
setLogKey = "set:".concat(cacheKey);
|
|
1785
1807
|
if (!this._loggedCacheEvents.has(setLogKey)) {
|
|
1808
|
+
//console.log('[AgentProviderSync] 💾 roboto.load cached object:', { type, id: obj.id });
|
|
1786
1809
|
this._loggedCacheEvents.add(setLogKey);
|
|
1787
1810
|
}
|
|
1788
1811
|
}
|
|
@@ -1830,6 +1853,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1830
1853
|
|
|
1831
1854
|
// If realtime is requested but cached object doesn't have it, upgrade it
|
|
1832
1855
|
if (params.enableRealtime && !_cached._realtime) {
|
|
1856
|
+
//console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', { type, id: ids });
|
|
1833
1857
|
_cached._initRealtime();
|
|
1834
1858
|
}
|
|
1835
1859
|
return _context28.abrupt("return", _cached);
|
|
@@ -1848,6 +1872,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1848
1872
|
// Only log cache miss once per object to reduce spam
|
|
1849
1873
|
missLogKey = "miss:".concat(_cacheKey3);
|
|
1850
1874
|
if (!this._loggedCacheEvents.has(missLogKey)) {
|
|
1875
|
+
//console.log('[AgentProviderSync] 📦 roboto.load cache MISS, loading:', { type, id: ids });
|
|
1851
1876
|
this._loggedCacheEvents.add(missLogKey);
|
|
1852
1877
|
}
|
|
1853
1878
|
|
|
@@ -1875,6 +1900,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1875
1900
|
// Only log cache set once per object to reduce spam
|
|
1876
1901
|
_setLogKey = "set:".concat(_cacheKey3);
|
|
1877
1902
|
if (!_this9._loggedCacheEvents.has(_setLogKey)) {
|
|
1903
|
+
//console.log('[AgentProviderSync] 💾 roboto.load cached object:', { type, id: ids });
|
|
1878
1904
|
_this9._loggedCacheEvents.add(_setLogKey);
|
|
1879
1905
|
}
|
|
1880
1906
|
}
|
|
@@ -1933,6 +1959,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1933
1959
|
this._loggedCacheEvents["delete"]("hit:".concat(cacheKey));
|
|
1934
1960
|
this._loggedCacheEvents["delete"]("miss:".concat(cacheKey));
|
|
1935
1961
|
this._loggedCacheEvents["delete"]("set:".concat(cacheKey));
|
|
1962
|
+
|
|
1963
|
+
//console.log('[AgentProviderSync] 🗑️ roboto.clearCache specific object:', { type, id, removed });
|
|
1936
1964
|
} else if (type) {
|
|
1937
1965
|
// Clear all objects of a specific type
|
|
1938
1966
|
var removedCount = 0;
|
|
@@ -1963,6 +1991,8 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1963
1991
|
this._loggedCacheEvents["delete"](logKey);
|
|
1964
1992
|
}
|
|
1965
1993
|
}
|
|
1994
|
+
|
|
1995
|
+
//console.log('[AgentProviderSync] 🗑️ roboto.clearCache by type:', { type, removedCount });
|
|
1966
1996
|
} catch (err) {
|
|
1967
1997
|
_iterator7.e(err);
|
|
1968
1998
|
} finally {
|
|
@@ -1974,6 +2004,7 @@ var RbtApi = /*#__PURE__*/function () {
|
|
|
1974
2004
|
this._objectCache.clear();
|
|
1975
2005
|
this._loggedCacheEvents.clear();
|
|
1976
2006
|
this._pendingLoads.clear();
|
|
2007
|
+
//console.log('[AgentProviderSync] 🗑️ roboto.clearCache all objects:', { clearedCount: size });
|
|
1977
2008
|
}
|
|
1978
2009
|
}
|
|
1979
2010
|
|
package/dist/esm/rbt_object.js
CHANGED
|
@@ -1046,7 +1046,9 @@ var RbtObject = /*#__PURE__*/function () {
|
|
|
1046
1046
|
userId: msg.userId || msg.delta.userId || null
|
|
1047
1047
|
});
|
|
1048
1048
|
_this3._trigger('change', changeData);
|
|
1049
|
-
if (msg.isStateSync) {
|
|
1049
|
+
if (msg.isStateSync) {
|
|
1050
|
+
//console.log('[RbtObject] Applied state sync:', msg.delta.path, '=', msg.delta.value);
|
|
1051
|
+
}
|
|
1050
1052
|
} else {}
|
|
1051
1053
|
} else if (msg.type === 'save') {
|
|
1052
1054
|
_this3._trigger('save', msg.revision || {});
|
|
@@ -1065,12 +1067,15 @@ var RbtObject = /*#__PURE__*/function () {
|
|
|
1065
1067
|
this._eventHandlers.change.push(cb);
|
|
1066
1068
|
|
|
1067
1069
|
// Log registration with stack trace to identify duplicates
|
|
1070
|
+
//console.log(`[AgentProviderSync] 📝 onChange handler registered #${handlerCount + 1}`);
|
|
1068
1071
|
|
|
1069
1072
|
// Get stack trace to see who registered this handler
|
|
1070
1073
|
var stack = new Error().stack;
|
|
1071
1074
|
var stackLines = stack.split('\n');
|
|
1072
1075
|
// Skip the first 3 lines (Error, onChange, and the immediate caller)
|
|
1073
1076
|
var relevantStack = stackLines.slice(3, 8).join('\n');
|
|
1077
|
+
//console.log('[AgentProviderSync] Registration stack:', relevantStack);
|
|
1078
|
+
|
|
1074
1079
|
// Auto-initialize realtime if this object has WebSocket capability
|
|
1075
1080
|
if (this._ws && !this._realtime) {
|
|
1076
1081
|
this._initRealtime();
|
|
@@ -1084,6 +1089,7 @@ var RbtObject = /*#__PURE__*/function () {
|
|
|
1084
1089
|
var index = this._eventHandlers.change.indexOf(cb);
|
|
1085
1090
|
if (index > -1) {
|
|
1086
1091
|
this._eventHandlers.change.splice(index, 1);
|
|
1092
|
+
//console.log(`[AgentProviderSync] 🗑️ onChange handler removed. Remaining:`, this._eventHandlers.change.length);
|
|
1087
1093
|
return true;
|
|
1088
1094
|
} else {
|
|
1089
1095
|
return false;
|
|
@@ -1113,16 +1119,22 @@ var RbtObject = /*#__PURE__*/function () {
|
|
|
1113
1119
|
key: "_trigger",
|
|
1114
1120
|
value: function _trigger(type, data) {
|
|
1115
1121
|
var handlers = this._eventHandlers[type] || [];
|
|
1122
|
+
//console.log('[AgentProviderSync] _trigger called:', type, 'handlers:', handlers.length, 'data:', data)
|
|
1123
|
+
|
|
1116
1124
|
for (var i = 0; i < handlers.length; i++) {
|
|
1117
1125
|
var fn = handlers[i];
|
|
1118
1126
|
try {
|
|
1127
|
+
//console.log(`[AgentProviderSync] 🔄 Calling handler ${i+1}/${handlers.length}`);
|
|
1119
1128
|
fn(data);
|
|
1129
|
+
//console.log(`[AgentProviderSync] ✅ Handler ${i+1} succeeded`);
|
|
1120
1130
|
} catch (error) {
|
|
1121
1131
|
console.error("[AgentProviderSync] \u274C Handler ".concat(i + 1, "/").concat(handlers.length, " threw error:"), error);
|
|
1122
1132
|
console.error('[AgentProviderSync] Error stack:', error.stack);
|
|
1123
1133
|
// Continue to next handler instead of breaking the loop
|
|
1124
1134
|
}
|
|
1125
1135
|
}
|
|
1136
|
+
|
|
1137
|
+
// ✓ Completed calling ${handlers.length} handlers`);
|
|
1126
1138
|
}
|
|
1127
1139
|
}, {
|
|
1128
1140
|
key: "_broadcastChange",
|
package/dist/esm/rbt_user.js
CHANGED
|
@@ -151,7 +151,7 @@ var RbtUser = /*#__PURE__*/function () {
|
|
|
151
151
|
record = this.toRecord();
|
|
152
152
|
record.type = '<@iac.user>';
|
|
153
153
|
_context.next = 6;
|
|
154
|
-
return this._axios.post('/
|
|
154
|
+
return this._axios.post('/api/iac/saveUser', [record]);
|
|
155
155
|
case 6:
|
|
156
156
|
response = _context.sent;
|
|
157
157
|
if (!(response.data.ok === false)) {
|
package/dist/esm/version.js
CHANGED