roboto-js 1.8.6 → 1.8.8
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/BUILD_NOTES.md +11 -1
- package/babel.config.json +26 -10
- package/dist/cjs/index.cjs +14 -10
- package/dist/cjs/rbt_object.cjs +3 -1
- package/dist/esm/cookie_storage_adaptor.js +3 -8
- package/dist/esm/index.js +32 -54
- package/dist/esm/rbt_api.js +26 -32
- package/dist/esm/rbt_file.js +10 -16
- package/dist/esm/rbt_metrics_api.js +6 -12
- package/dist/esm/rbt_object.js +33 -37
- package/dist/esm/rbt_user.js +11 -17
- package/dist/rbt_object.js +3 -1
- package/package.json +3 -3
- package/src/index.js +13 -10
- package/src/rbt_object.js +3 -1
package/.last-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2025-11-
|
|
1
|
+
2025-11-12T07:28:57.602Z
|
package/BUILD_NOTES.md
CHANGED
|
@@ -7,8 +7,10 @@ The build process automatically strips all `console.log`, `console.warn`, and ot
|
|
|
7
7
|
### How It Works
|
|
8
8
|
|
|
9
9
|
- Uses `babel-plugin-transform-remove-console` during the build process
|
|
10
|
-
- Configuration is in `babel.config.json`
|
|
10
|
+
- Configuration is in `babel.config.json` with environment-specific settings
|
|
11
11
|
- Applies to both CommonJS (`dist/cjs`) and ESM (`dist/esm`) builds
|
|
12
|
+
- ESM build preserves ES module syntax (`modules: false`)
|
|
13
|
+
- CJS build uses CommonJS syntax (`modules: "commonjs"`)
|
|
12
14
|
|
|
13
15
|
### Development vs Production
|
|
14
16
|
|
|
@@ -23,8 +25,16 @@ The build process automatically strips all `console.log`, `console.warn`, and ot
|
|
|
23
25
|
- `console.debug()` - ❌ Removed
|
|
24
26
|
- `console.error()` - ✅ **Preserved** (for critical error reporting)
|
|
25
27
|
|
|
28
|
+
### Build Environments
|
|
29
|
+
|
|
30
|
+
The build uses `BABEL_ENV` to configure different output formats:
|
|
31
|
+
- `BABEL_ENV=esm` - ES Modules build with preserved import/export syntax
|
|
32
|
+
- `BABEL_ENV=cjs` - CommonJS build with require/exports syntax
|
|
33
|
+
|
|
26
34
|
### Scripts
|
|
27
35
|
|
|
28
36
|
- `npm run build` - Builds both CJS and ESM with console removal
|
|
37
|
+
- `npm run build:cjs` - Build CommonJS only (`BABEL_ENV=cjs`)
|
|
38
|
+
- `npm run build:esm` - Build ES Modules only (`BABEL_ENV=esm`)
|
|
29
39
|
- `npm publish` - Automatically runs `prepublishOnly` which builds with console removal
|
|
30
40
|
|
package/babel.config.json
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"env": {
|
|
3
|
+
"cjs": {
|
|
4
|
+
"presets": [
|
|
5
|
+
["@babel/preset-env", {
|
|
6
|
+
"modules": "commonjs"
|
|
7
|
+
}]
|
|
8
|
+
],
|
|
9
|
+
"plugins": [
|
|
10
|
+
["transform-remove-console", {
|
|
11
|
+
"exclude": ["error"]
|
|
12
|
+
}]
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"esm": {
|
|
16
|
+
"presets": [
|
|
17
|
+
["@babel/preset-env", {
|
|
18
|
+
"modules": false
|
|
19
|
+
}]
|
|
20
|
+
],
|
|
21
|
+
"plugins": [
|
|
22
|
+
["transform-remove-console", {
|
|
23
|
+
"exclude": ["error"]
|
|
24
|
+
}]
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
12
28
|
}
|
|
13
29
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -102,19 +102,23 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
102
102
|
this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
|
|
103
103
|
|
|
104
104
|
// Check if a request object is provided
|
|
105
|
-
if (proxyReq
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
if (proxyReq) {
|
|
106
|
+
var _proxyReq$headers, _proxyReq$headers2, _proxyReq$headers3;
|
|
107
|
+
// First priority: properties set by middleware (supports cookie-based auth)
|
|
108
|
+
// Second priority: custom headers (backward compatibility)
|
|
109
|
+
var req_authtoken = proxyReq.authToken || ((_proxyReq$headers = proxyReq.headers) === null || _proxyReq$headers === void 0 ? void 0 : _proxyReq$headers.authtoken);
|
|
110
|
+
var req_accesskey = proxyReq.accessKey || ((_proxyReq$headers2 = proxyReq.headers) === null || _proxyReq$headers2 === void 0 ? void 0 : _proxyReq$headers2.accesskey);
|
|
111
|
+
var req_apikey = proxyReq.apiKey || ((_proxyReq$headers3 = proxyReq.headers) === null || _proxyReq$headers3 === void 0 ? void 0 : _proxyReq$headers3.apikey);
|
|
112
|
+
|
|
109
113
|
// Optionally add more headers as needed
|
|
110
|
-
if (
|
|
111
|
-
this.config.authtoken =
|
|
114
|
+
if (req_authtoken) {
|
|
115
|
+
this.config.authtoken = req_authtoken; // Set the authtoken in the config
|
|
112
116
|
}
|
|
113
|
-
if (
|
|
114
|
-
this.config.apikey =
|
|
117
|
+
if (req_apikey) {
|
|
118
|
+
this.config.apikey = req_apikey; // Set the apikey in the config
|
|
115
119
|
}
|
|
116
|
-
if (
|
|
117
|
-
this.config.accesskey =
|
|
120
|
+
if (req_accesskey) {
|
|
121
|
+
this.config.accesskey = req_accesskey; // Set the accesskey in the config
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
this.api = new _rbt_api["default"](this.config);
|
package/dist/cjs/rbt_object.cjs
CHANGED
|
@@ -72,7 +72,9 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
72
72
|
_createClass(RbtObject, [{
|
|
73
73
|
key: "get",
|
|
74
74
|
value: function get(path) {
|
|
75
|
-
|
|
75
|
+
var value = _lodash["default"].get(this._data, path);
|
|
76
|
+
// Return a deep clone to prevent reference issues when modifying returned objects
|
|
77
|
+
return _lodash["default"].cloneDeep(value);
|
|
76
78
|
}
|
|
77
79
|
}, {
|
|
78
80
|
key: "getData",
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
3
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
@@ -24,7 +18,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
18
|
* Provides a localStorage-compatible interface using cookies
|
|
25
19
|
* This enables server-side access to authentication tokens
|
|
26
20
|
*/
|
|
27
|
-
var CookieStorageAdaptor =
|
|
21
|
+
var CookieStorageAdaptor = /*#__PURE__*/function () {
|
|
28
22
|
function CookieStorageAdaptor() {
|
|
29
23
|
var _options$secure, _options$sameSite, _options$path, _options$maxAge, _options$domain, _options$prefix, _options$serverAccess;
|
|
30
24
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -380,4 +374,5 @@ var CookieStorageAdaptor = exports["default"] = /*#__PURE__*/function () {
|
|
|
380
374
|
}
|
|
381
375
|
}]);
|
|
382
376
|
return CookieStorageAdaptor;
|
|
383
|
-
}();
|
|
377
|
+
}();
|
|
378
|
+
export { CookieStorageAdaptor as default };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "CookieStorageAdaptor", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _cookie_storage_adaptor["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "RbtApi", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _rbt_api["default"];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "RbtFile", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _rbt_file["default"];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "RbtObject", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _rbt_object["default"];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
exports["default"] = void 0;
|
|
31
|
-
var _rbt_api = _interopRequireDefault(require("./rbt_api.js"));
|
|
32
|
-
var _rbt_object = _interopRequireDefault(require("./rbt_object.js"));
|
|
33
|
-
var _rbt_file = _interopRequireDefault(require("./rbt_file.js"));
|
|
34
|
-
var _rbt_metrics_api = _interopRequireDefault(require("./rbt_metrics_api.js"));
|
|
35
|
-
var _cookie_storage_adaptor = _interopRequireDefault(require("./cookie_storage_adaptor.js"));
|
|
36
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
37
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
38
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
39
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -43,7 +7,16 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
43
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
44
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
45
9
|
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); }
|
|
46
|
-
|
|
10
|
+
import RbtApi from './rbt_api.js';
|
|
11
|
+
import RbtObject from './rbt_object.js';
|
|
12
|
+
import RbtFile from './rbt_file.js';
|
|
13
|
+
import RbtMetricsApi from './rbt_metrics_api.js';
|
|
14
|
+
import CookieStorageAdaptor from './cookie_storage_adaptor.js';
|
|
15
|
+
export { RbtApi, RbtObject, RbtFile, CookieStorageAdaptor
|
|
16
|
+
//User,
|
|
17
|
+
//Site
|
|
18
|
+
};
|
|
19
|
+
var Roboto = /*#__PURE__*/function () {
|
|
47
20
|
function Roboto(_ref) {
|
|
48
21
|
var _this = this;
|
|
49
22
|
var host = _ref.host,
|
|
@@ -70,7 +43,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
70
43
|
var storageAdaptor = localStorageAdaptor;
|
|
71
44
|
if (!storageAdaptor && isBrowser && useCookies) {
|
|
72
45
|
// Use cookies by default in browser for better server-side compatibility
|
|
73
|
-
storageAdaptor = new
|
|
46
|
+
storageAdaptor = new CookieStorageAdaptor({
|
|
74
47
|
secure: window.location.protocol === 'https:',
|
|
75
48
|
sameSite: 'Lax',
|
|
76
49
|
maxAge: 24 * 60 * 60 // 24 hours
|
|
@@ -102,22 +75,26 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
102
75
|
this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
|
|
103
76
|
|
|
104
77
|
// Check if a request object is provided
|
|
105
|
-
if (proxyReq
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
if (proxyReq) {
|
|
79
|
+
var _proxyReq$headers, _proxyReq$headers2, _proxyReq$headers3;
|
|
80
|
+
// First priority: properties set by middleware (supports cookie-based auth)
|
|
81
|
+
// Second priority: custom headers (backward compatibility)
|
|
82
|
+
var req_authtoken = proxyReq.authToken || ((_proxyReq$headers = proxyReq.headers) === null || _proxyReq$headers === void 0 ? void 0 : _proxyReq$headers.authtoken);
|
|
83
|
+
var req_accesskey = proxyReq.accessKey || ((_proxyReq$headers2 = proxyReq.headers) === null || _proxyReq$headers2 === void 0 ? void 0 : _proxyReq$headers2.accesskey);
|
|
84
|
+
var req_apikey = proxyReq.apiKey || ((_proxyReq$headers3 = proxyReq.headers) === null || _proxyReq$headers3 === void 0 ? void 0 : _proxyReq$headers3.apikey);
|
|
85
|
+
|
|
109
86
|
// Optionally add more headers as needed
|
|
110
|
-
if (
|
|
111
|
-
this.config.authtoken =
|
|
87
|
+
if (req_authtoken) {
|
|
88
|
+
this.config.authtoken = req_authtoken; // Set the authtoken in the config
|
|
112
89
|
}
|
|
113
|
-
if (
|
|
114
|
-
this.config.apikey =
|
|
90
|
+
if (req_apikey) {
|
|
91
|
+
this.config.apikey = req_apikey; // Set the apikey in the config
|
|
115
92
|
}
|
|
116
|
-
if (
|
|
117
|
-
this.config.accesskey =
|
|
93
|
+
if (req_accesskey) {
|
|
94
|
+
this.config.accesskey = req_accesskey; // Set the accesskey in the config
|
|
118
95
|
}
|
|
119
96
|
}
|
|
120
|
-
this.api = new
|
|
97
|
+
this.api = new RbtApi(this.config);
|
|
121
98
|
if (isBrowser) {
|
|
122
99
|
this.api.initLocalDb();
|
|
123
100
|
|
|
@@ -133,7 +110,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
133
110
|
if (metricsHost && metricsHost !== host) {
|
|
134
111
|
var metricsUrl = metricsHost.startsWith('http') ? metricsHost : "https://".concat(metricsHost);
|
|
135
112
|
// You can customize headers if needed
|
|
136
|
-
this.metrics = new
|
|
113
|
+
this.metrics = new RbtMetricsApi({
|
|
137
114
|
config: {
|
|
138
115
|
baseURL: this._stripHttpsForDomains(metricsUrl, ['localhost']),
|
|
139
116
|
headers: {
|
|
@@ -143,7 +120,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
143
120
|
});
|
|
144
121
|
} else {
|
|
145
122
|
// Use the same axios instance as main API
|
|
146
|
-
this.metrics = new
|
|
123
|
+
this.metrics = new RbtMetricsApi({
|
|
147
124
|
axiosInstance: this.api.axios
|
|
148
125
|
});
|
|
149
126
|
}
|
|
@@ -187,7 +164,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
187
164
|
value: function setMetricsHost(host) {
|
|
188
165
|
this.metricsHost = host;
|
|
189
166
|
var metricsUrl = host.startsWith('http') ? host : "https://".concat(host);
|
|
190
|
-
this.metrics = new
|
|
167
|
+
this.metrics = new RbtMetricsApi({
|
|
191
168
|
config: {
|
|
192
169
|
baseURL: this._stripHttpsForDomains(metricsUrl, ['localhost']),
|
|
193
170
|
headers: {
|
|
@@ -211,7 +188,7 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
211
188
|
}, {
|
|
212
189
|
key: "recordToInstance",
|
|
213
190
|
value: function recordToInstance(recordHash) {
|
|
214
|
-
return new
|
|
191
|
+
return new RbtObject(recordHash, this.api.axios);
|
|
215
192
|
}
|
|
216
193
|
}, {
|
|
217
194
|
key: "_stripHttpsForDomains",
|
|
@@ -666,4 +643,5 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
|
|
|
666
643
|
}()
|
|
667
644
|
}]);
|
|
668
645
|
return Roboto;
|
|
669
|
-
}();
|
|
646
|
+
}();
|
|
647
|
+
export { Roboto as default };
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
var _cryptoJs = _interopRequireDefault(require("crypto-js"));
|
|
9
|
-
var _rbt_object = _interopRequireDefault(require("./rbt_object.js"));
|
|
10
|
-
var _rbt_user = _interopRequireDefault(require("./rbt_user.js"));
|
|
11
|
-
var _rbt_file = _interopRequireDefault(require("./rbt_file.js"));
|
|
12
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
var _idb = require("idb");
|
|
14
1
|
var _excluded = ["enableRealtime"],
|
|
15
2
|
_excluded2 = ["enableRealtime"];
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
3
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
18
4
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -35,7 +21,14 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
35
21
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
36
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
37
23
|
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); }
|
|
38
|
-
|
|
24
|
+
import axios from 'axios';
|
|
25
|
+
import CryptoJS from 'crypto-js';
|
|
26
|
+
import RbtObject from './rbt_object.js';
|
|
27
|
+
import RbtUser from './rbt_user.js';
|
|
28
|
+
import RbtFile from './rbt_file.js';
|
|
29
|
+
import _ from 'lodash';
|
|
30
|
+
import { openDB } from 'idb';
|
|
31
|
+
var RbtApi = /*#__PURE__*/function () {
|
|
39
32
|
function RbtApi(_ref) {
|
|
40
33
|
var baseUrl = _ref.baseUrl,
|
|
41
34
|
accesskey = _ref.accesskey,
|
|
@@ -56,7 +49,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
56
49
|
|
|
57
50
|
// Track what we've already logged to reduce console spam
|
|
58
51
|
this._loggedCacheEvents = new Set();
|
|
59
|
-
this.axios =
|
|
52
|
+
this.axios = axios.create({
|
|
60
53
|
baseURL: baseUrl,
|
|
61
54
|
headers: {
|
|
62
55
|
'accesskey': accesskey
|
|
@@ -180,7 +173,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
180
173
|
if (cachedUser) {
|
|
181
174
|
parsed = typeof cachedUser === 'string' ? JSON.parse(cachedUser) : cachedUser;
|
|
182
175
|
if (parsed && parsed.id) {
|
|
183
|
-
this.currentUser = new
|
|
176
|
+
this.currentUser = new RbtUser({
|
|
184
177
|
id: parsed.id
|
|
185
178
|
}, this.axios);
|
|
186
179
|
this.currentUser.setData(parsed);
|
|
@@ -370,7 +363,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
370
363
|
while (1) switch (_context4.prev = _context4.next) {
|
|
371
364
|
case 0:
|
|
372
365
|
_context4.next = 2;
|
|
373
|
-
return
|
|
366
|
+
return openDB('RBTFileDatabase', 1, {
|
|
374
367
|
upgrade: function upgrade(db) {
|
|
375
368
|
if (!db.objectStoreNames.contains('files')) {
|
|
376
369
|
db.createObjectStore('files', {
|
|
@@ -464,7 +457,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
464
457
|
_context6.next = 3;
|
|
465
458
|
return this.axios.post('/user_service/loginUser', [{
|
|
466
459
|
email: params.email,
|
|
467
|
-
password: params.password ?
|
|
460
|
+
password: params.password ? CryptoJS.MD5(params.password).toString(CryptoJS.enc.Hex) : null,
|
|
468
461
|
// legacy hash password (md5)
|
|
469
462
|
passwd: params.password || null,
|
|
470
463
|
// current password
|
|
@@ -479,7 +472,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
479
472
|
return _context6.abrupt("return", this._handleError(response));
|
|
480
473
|
case 6:
|
|
481
474
|
this.iac_session = response.data;
|
|
482
|
-
this.currentUser = this.iac_session ? new
|
|
475
|
+
this.currentUser = this.iac_session ? new RbtUser(this.iac_session.user, this.axios) : null;
|
|
483
476
|
// update axios instance headers with authtoken
|
|
484
477
|
this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
|
|
485
478
|
this.authtoken = response.data.authToken;
|
|
@@ -533,7 +526,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
533
526
|
return _context7.abrupt("return", this._handleError(response));
|
|
534
527
|
case 6:
|
|
535
528
|
this.iac_session = response;
|
|
536
|
-
this.currentUser = this.iac_session ? new
|
|
529
|
+
this.currentUser = this.iac_session ? new RbtUser(this.iac_session.user, this.axios) : null;
|
|
537
530
|
// update axios instance headers with authtoken
|
|
538
531
|
this.axios.defaults.headers.common['authtoken'] = response.authToken;
|
|
539
532
|
this.authtoken = response.authToken;
|
|
@@ -669,7 +662,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
669
662
|
_context9.next = 11;
|
|
670
663
|
break;
|
|
671
664
|
}
|
|
672
|
-
_this2.currentUser = new
|
|
665
|
+
_this2.currentUser = new RbtUser({
|
|
673
666
|
id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
|
|
674
667
|
}, _this2.axios);
|
|
675
668
|
_this2.currentUser.setData(response.user);
|
|
@@ -839,7 +832,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
839
832
|
case 2:
|
|
840
833
|
response = _context14.sent;
|
|
841
834
|
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
842
|
-
User = new
|
|
835
|
+
User = new RbtUser({
|
|
843
836
|
id: userData.id
|
|
844
837
|
}, _this4.axios);
|
|
845
838
|
User.setData(userData);
|
|
@@ -968,7 +961,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
968
961
|
case 4:
|
|
969
962
|
response = _context17.sent;
|
|
970
963
|
record = response.data;
|
|
971
|
-
return _context17.abrupt("return", new
|
|
964
|
+
return _context17.abrupt("return", new RbtUser(record, this.axios));
|
|
972
965
|
case 9:
|
|
973
966
|
_context17.prev = 9;
|
|
974
967
|
_context17.t0 = _context17["catch"](1);
|
|
@@ -1008,7 +1001,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1008
1001
|
if (dataHash) {
|
|
1009
1002
|
record.data = dataHash;
|
|
1010
1003
|
}
|
|
1011
|
-
return _context18.abrupt("return", new
|
|
1004
|
+
return _context18.abrupt("return", new RbtFile(record, this.axios, this.localDb));
|
|
1012
1005
|
case 9:
|
|
1013
1006
|
_context18.prev = 9;
|
|
1014
1007
|
_context18.t0 = _context18["catch"](0);
|
|
@@ -1044,7 +1037,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1044
1037
|
return _context19.abrupt("return", null);
|
|
1045
1038
|
case 6:
|
|
1046
1039
|
record = response.toRecord();
|
|
1047
|
-
return _context19.abrupt("return", new
|
|
1040
|
+
return _context19.abrupt("return", new RbtFile(record, this.axios, this.localDb));
|
|
1048
1041
|
case 10:
|
|
1049
1042
|
_context19.prev = 10;
|
|
1050
1043
|
_context19.t0 = _context19["catch"](0);
|
|
@@ -1082,7 +1075,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1082
1075
|
case 6:
|
|
1083
1076
|
return _context20.abrupt("return", responses.map(function (response) {
|
|
1084
1077
|
var record = response.toRecord();
|
|
1085
|
-
return new
|
|
1078
|
+
return new RbtFile(record, _this5.axios, _this5.localDb);
|
|
1086
1079
|
}));
|
|
1087
1080
|
case 9:
|
|
1088
1081
|
_context20.prev = 9;
|
|
@@ -1131,7 +1124,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1131
1124
|
if (dataHash) {
|
|
1132
1125
|
record.data = dataHash;
|
|
1133
1126
|
}
|
|
1134
|
-
return _context21.abrupt("return", new
|
|
1127
|
+
return _context21.abrupt("return", new RbtObject(record, this.axios, {
|
|
1135
1128
|
isNew: true,
|
|
1136
1129
|
websocketClient: this.websocketClient,
|
|
1137
1130
|
enableRealtime: options.enableRealtime || false
|
|
@@ -1300,7 +1293,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1300
1293
|
websocketClient = this.getWebSocketClient();
|
|
1301
1294
|
}
|
|
1302
1295
|
response.data.items = response.data.items.map(function (record) {
|
|
1303
|
-
return new
|
|
1296
|
+
return new RbtObject(record, _this7.axios, {
|
|
1304
1297
|
websocketClient: websocketClient,
|
|
1305
1298
|
enableRealtime: options.enableRealtime || false
|
|
1306
1299
|
});
|
|
@@ -2064,9 +2057,9 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2064
2057
|
var res = this.customErrorHandler(err);
|
|
2065
2058
|
if (res) return;
|
|
2066
2059
|
}
|
|
2067
|
-
if (
|
|
2060
|
+
if (_.isObject(err) && _.get(err, 'response')) {
|
|
2068
2061
|
if (err.response) {}
|
|
2069
|
-
var msg =
|
|
2062
|
+
var msg = _.get(err, 'response.data.message', 'Error in API response');
|
|
2070
2063
|
if (msg.key) {
|
|
2071
2064
|
//throw new Error(msg.key);
|
|
2072
2065
|
throw {
|
|
@@ -2092,4 +2085,5 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
2092
2085
|
}
|
|
2093
2086
|
}]);
|
|
2094
2087
|
return RbtApi;
|
|
2095
|
-
}();
|
|
2088
|
+
}();
|
|
2089
|
+
export { RbtApi as default };
|
package/dist/esm/rbt_file.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
var _tusJsClient = require("tus-js-client");
|
|
9
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
-
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
13
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
14
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -27,7 +17,10 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
27
17
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
18
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
19
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
30
|
-
|
|
20
|
+
import { Upload } from 'tus-js-client';
|
|
21
|
+
import _ from 'lodash';
|
|
22
|
+
import EventEmitter from 'eventemitter3';
|
|
23
|
+
var RbtFile = /*#__PURE__*/function (_EventEmitter) {
|
|
31
24
|
_inherits(RbtFile, _EventEmitter);
|
|
32
25
|
function RbtFile(record, axiosInstance) {
|
|
33
26
|
var _this;
|
|
@@ -45,12 +38,12 @@ var RbtFile = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
|
45
38
|
_createClass(RbtFile, [{
|
|
46
39
|
key: "get",
|
|
47
40
|
value: function get(path) {
|
|
48
|
-
return
|
|
41
|
+
return _.get(this._data, path);
|
|
49
42
|
}
|
|
50
43
|
}, {
|
|
51
44
|
key: "set",
|
|
52
45
|
value: function set(path, value) {
|
|
53
|
-
|
|
46
|
+
_.set(this._data, path, value);
|
|
54
47
|
}
|
|
55
48
|
}, {
|
|
56
49
|
key: "getData",
|
|
@@ -61,7 +54,7 @@ var RbtFile = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
|
61
54
|
key: "setData",
|
|
62
55
|
value: function setData(data) {
|
|
63
56
|
// Use lodash's merge to deeply merge the incoming data into _data
|
|
64
|
-
|
|
57
|
+
_.merge(this._data, data);
|
|
65
58
|
return _objectSpread({}, this._data); // Return the updated _data as a new object
|
|
66
59
|
}
|
|
67
60
|
}, {
|
|
@@ -164,7 +157,7 @@ var RbtFile = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
|
164
157
|
value: function uploadFile(file) {
|
|
165
158
|
var _this2 = this;
|
|
166
159
|
return new Promise(function (resolve, reject) {
|
|
167
|
-
var upload = new
|
|
160
|
+
var upload = new Upload(file, {
|
|
168
161
|
endpoint: _this2._axios.defaults.baseURL + "/file_service/files",
|
|
169
162
|
retryDelays: [0, 1000, 3000, 5000],
|
|
170
163
|
metadata: {
|
|
@@ -228,4 +221,5 @@ var RbtFile = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
|
228
221
|
}
|
|
229
222
|
}]);
|
|
230
223
|
return RbtFile;
|
|
231
|
-
}(
|
|
224
|
+
}(EventEmitter);
|
|
225
|
+
export { RbtFile as default };
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
1
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
2
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -26,6 +17,8 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
26
17
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
18
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
28
19
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
import axios from 'axios';
|
|
21
|
+
import EventEmitter from 'eventemitter3';
|
|
29
22
|
function getOrCreateDeviceId() {
|
|
30
23
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
31
24
|
var deviceId = localStorage.getItem('robotoDeviceId');
|
|
@@ -39,7 +32,7 @@ function getOrCreateDeviceId() {
|
|
|
39
32
|
// On server/Node.js, return undefined (or you can fallback to some other logic)
|
|
40
33
|
return undefined;
|
|
41
34
|
}
|
|
42
|
-
var RbtMetricsApi =
|
|
35
|
+
var RbtMetricsApi = /*#__PURE__*/function (_EventEmitter) {
|
|
43
36
|
_inherits(RbtMetricsApi, _EventEmitter);
|
|
44
37
|
/**
|
|
45
38
|
* You can pass either:
|
|
@@ -56,7 +49,7 @@ var RbtMetricsApi = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
|
56
49
|
if (axiosInstance) {
|
|
57
50
|
_this._axios = axiosInstance;
|
|
58
51
|
} else if (config) {
|
|
59
|
-
_this._axios =
|
|
52
|
+
_this._axios = axios.create(config);
|
|
60
53
|
} else {
|
|
61
54
|
throw new Error("RbtMetricsApi requires either axiosInstance or config");
|
|
62
55
|
}
|
|
@@ -206,4 +199,5 @@ var RbtMetricsApi = exports["default"] = /*#__PURE__*/function (_EventEmitter) {
|
|
|
206
199
|
}())
|
|
207
200
|
}]);
|
|
208
201
|
return RbtMetricsApi;
|
|
209
|
-
}(
|
|
202
|
+
}(EventEmitter);
|
|
203
|
+
export { RbtMetricsApi as default };
|
package/dist/esm/rbt_object.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
3
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
@@ -29,7 +21,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
29
21
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
30
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
31
23
|
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); }
|
|
32
|
-
|
|
24
|
+
import _ from 'lodash';
|
|
25
|
+
var RbtObject = /*#__PURE__*/function () {
|
|
33
26
|
function RbtObject(record, axiosInstance) {
|
|
34
27
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
35
28
|
_classCallCheck(this, RbtObject);
|
|
@@ -72,7 +65,9 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
72
65
|
_createClass(RbtObject, [{
|
|
73
66
|
key: "get",
|
|
74
67
|
value: function get(path) {
|
|
75
|
-
|
|
68
|
+
var value = _.get(this._data, path);
|
|
69
|
+
// Return a deep clone to prevent reference issues when modifying returned objects
|
|
70
|
+
return _.cloneDeep(value);
|
|
76
71
|
}
|
|
77
72
|
}, {
|
|
78
73
|
key: "getData",
|
|
@@ -84,11 +79,11 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
84
79
|
// Return an object with only the specified keys
|
|
85
80
|
return keys.reduce(function (result, key) {
|
|
86
81
|
// Use lodash.get to handle deep key paths
|
|
87
|
-
var value =
|
|
82
|
+
var value = _.get(_this._data, key);
|
|
88
83
|
// If the value exists, add it to the result object using the key path as the property name
|
|
89
84
|
if (value !== undefined) {
|
|
90
85
|
// Create nested structure based on the key path
|
|
91
|
-
|
|
86
|
+
_.set(result, key, value);
|
|
92
87
|
}
|
|
93
88
|
return result;
|
|
94
89
|
}, {});
|
|
@@ -109,14 +104,14 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
109
104
|
key: "set",
|
|
110
105
|
value: function set(path, value) {
|
|
111
106
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
112
|
-
var currentValue =
|
|
107
|
+
var currentValue = _.get(this._data, path); // Fetch current value at deep path
|
|
113
108
|
|
|
114
109
|
if (options.merge) {
|
|
115
|
-
var mergedValue =
|
|
110
|
+
var mergedValue = _.mergeWith({}, currentValue, value, function (objValue, srcValue) {
|
|
116
111
|
if (srcValue === undefined) {
|
|
117
112
|
return undefined; // Indicate to delete when merging
|
|
118
113
|
}
|
|
119
|
-
if (
|
|
114
|
+
if (_.isArray(objValue)) {
|
|
120
115
|
return srcValue; // Customize merging behavior for arrays
|
|
121
116
|
}
|
|
122
117
|
// Handle null, 0, and "" explicitly
|
|
@@ -127,11 +122,11 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
127
122
|
// Process merged object to remove any keys set explicitly to undefined
|
|
128
123
|
Object.keys(mergedValue).forEach(function (key) {
|
|
129
124
|
if (mergedValue[key] === undefined) {
|
|
130
|
-
|
|
125
|
+
_.unset(mergedValue, key);
|
|
131
126
|
}
|
|
132
127
|
});
|
|
133
|
-
if (!
|
|
134
|
-
|
|
128
|
+
if (!_.isEqual(currentValue, mergedValue)) {
|
|
129
|
+
_.set(this._data, path, mergedValue); // Set the merged value at the deep path
|
|
135
130
|
this._addChange(path);
|
|
136
131
|
// Trigger local change events for any registered handlers
|
|
137
132
|
this._trigger('change', {
|
|
@@ -143,7 +138,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
143
138
|
} else {
|
|
144
139
|
// If value is undefined and not merging, delete the key
|
|
145
140
|
if (value === undefined) {
|
|
146
|
-
|
|
141
|
+
_.unset(this._data, path);
|
|
147
142
|
this._addChange(path);
|
|
148
143
|
// Trigger local change events for any registered handlers
|
|
149
144
|
this._trigger('change', {
|
|
@@ -151,8 +146,8 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
151
146
|
value: undefined,
|
|
152
147
|
options: options
|
|
153
148
|
});
|
|
154
|
-
} else if (!
|
|
155
|
-
|
|
149
|
+
} else if (!_.isEqual(currentValue, value)) {
|
|
150
|
+
_.set(this._data, path, value); // Set the value directly at the deep path
|
|
156
151
|
this._addChange(path);
|
|
157
152
|
this._broadcastChange(path, value);
|
|
158
153
|
// Trigger local change events for any registered handlers
|
|
@@ -175,11 +170,11 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
175
170
|
var _options$merge = options.merge,
|
|
176
171
|
merge = _options$merge === void 0 ? false : _options$merge;
|
|
177
172
|
Object.keys(newData).forEach(function (path) {
|
|
178
|
-
var currentValue =
|
|
173
|
+
var currentValue = _.get(_this2._data, path);
|
|
179
174
|
var newValue = newData[path];
|
|
180
|
-
if (merge &&
|
|
181
|
-
var mergedValue =
|
|
182
|
-
if (
|
|
175
|
+
if (merge && _.isObject(currentValue) && _.isObject(newValue)) {
|
|
176
|
+
var mergedValue = _.mergeWith({}, currentValue, newValue, function (objValue, srcValue) {
|
|
177
|
+
if (_.isArray(srcValue)) {
|
|
183
178
|
return _toConsumableArray(srcValue); // Customize merging behavior for arrays
|
|
184
179
|
}
|
|
185
180
|
// Handle null, 0, and "" explicitly
|
|
@@ -187,8 +182,8 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
187
182
|
return srcValue;
|
|
188
183
|
}
|
|
189
184
|
});
|
|
190
|
-
if (!
|
|
191
|
-
|
|
185
|
+
if (!_.isEqual(currentValue, mergedValue)) {
|
|
186
|
+
_.set(_this2._data, path, mergedValue);
|
|
192
187
|
_this2._addChange(path);
|
|
193
188
|
// Trigger change event for this path
|
|
194
189
|
_this2._trigger('change', {
|
|
@@ -197,9 +192,9 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
197
192
|
options: options
|
|
198
193
|
});
|
|
199
194
|
}
|
|
200
|
-
} else if (!
|
|
201
|
-
|
|
202
|
-
if (key === nsPath.split('.').pop() && !
|
|
195
|
+
} else if (!_.isEqual(currentValue, newValue)) {
|
|
196
|
+
_.setWith(_this2._data, path, newValue, function (nsValue, key, nsObject, nsPath) {
|
|
197
|
+
if (key === nsPath.split('.').pop() && !_.has(nsObject, key)) {
|
|
203
198
|
return nsObject[key] = {}; // Create any missing parts of the path as plain objects
|
|
204
199
|
}
|
|
205
200
|
return nsValue;
|
|
@@ -318,14 +313,14 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
318
313
|
// Populate deltaData only with keys specified in changes
|
|
319
314
|
changes.forEach(function (path) {
|
|
320
315
|
// default value explicitly set to undefined
|
|
321
|
-
var value =
|
|
316
|
+
var value = _.get(sourceData, path, undefined);
|
|
322
317
|
// Use _.set to ensure nested keys are correctly assigned
|
|
323
|
-
|
|
318
|
+
_.set(deltaData, path, value);
|
|
324
319
|
});
|
|
325
320
|
|
|
326
321
|
// mark as delta
|
|
327
322
|
this.rpcMeta.delta = true;
|
|
328
|
-
var clonedData =
|
|
323
|
+
var clonedData = _.cloneDeep(this._internalData);
|
|
329
324
|
clonedData.data = deltaData;
|
|
330
325
|
return _objectSpread(_objectSpread({}, clonedData), {}, {
|
|
331
326
|
dataJson: JSON.stringify(deltaData),
|
|
@@ -336,7 +331,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
336
331
|
key: "clone",
|
|
337
332
|
value: function clone() {
|
|
338
333
|
// Create a deep copy of the current object's data
|
|
339
|
-
var clonedData =
|
|
334
|
+
var clonedData = _.cloneDeep(this._internalData);
|
|
340
335
|
|
|
341
336
|
// Reset unique identifiers to ensure a new ID is generated upon saving
|
|
342
337
|
delete clonedData.id;
|
|
@@ -603,7 +598,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
603
598
|
options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
|
604
599
|
_options$publish = options.publish, publish = _options$publish === void 0 ? true : _options$publish, _options$save2 = options.save, save = _options$save2 === void 0 ? true : _options$save2; // Get current IAC settings and create a deep clone to ensure change detection
|
|
605
600
|
currentIac = this.get('iac') || {};
|
|
606
|
-
iac =
|
|
601
|
+
iac = _.cloneDeep(currentIac); // Initialize readGrants if it doesn't exist
|
|
607
602
|
if (!iac.readGrants) {
|
|
608
603
|
iac.readGrants = {};
|
|
609
604
|
}
|
|
@@ -997,7 +992,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
997
992
|
if (msg.objectId !== _this3.id) return;
|
|
998
993
|
if (msg.type === 'update') {
|
|
999
994
|
if (msg.delta && msg.delta.path !== undefined) {
|
|
1000
|
-
|
|
995
|
+
_.set(_this3._data, msg.delta.path, msg.delta.value);
|
|
1001
996
|
|
|
1002
997
|
// Add metadata to indicate if this is state sync vs live update
|
|
1003
998
|
var changeData = _objectSpread(_objectSpread({}, msg.delta), {}, {
|
|
@@ -1120,4 +1115,5 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
1120
1115
|
}
|
|
1121
1116
|
}]);
|
|
1122
1117
|
return RbtObject;
|
|
1123
|
-
}();
|
|
1118
|
+
}();
|
|
1119
|
+
export { RbtObject as default };
|
package/dist/esm/rbt_user.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
1
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
2
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
3
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -24,7 +16,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
24
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
18
|
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); }
|
|
27
|
-
|
|
19
|
+
import _ from 'lodash';
|
|
20
|
+
var RbtUser = /*#__PURE__*/function () {
|
|
28
21
|
function RbtUser(record, axiosInstance) {
|
|
29
22
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
30
23
|
_classCallCheck(this, RbtUser);
|
|
@@ -45,7 +38,7 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
|
|
|
45
38
|
_createClass(RbtUser, [{
|
|
46
39
|
key: "get",
|
|
47
40
|
value: function get(path) {
|
|
48
|
-
return
|
|
41
|
+
return _.get(this._data, path);
|
|
49
42
|
}
|
|
50
43
|
}, {
|
|
51
44
|
key: "getData",
|
|
@@ -63,9 +56,9 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
|
|
|
63
56
|
}, {
|
|
64
57
|
key: "set",
|
|
65
58
|
value: function set(path, value) {
|
|
66
|
-
var currentValue =
|
|
67
|
-
if (!
|
|
68
|
-
|
|
59
|
+
var currentValue = _.get(this._data, path);
|
|
60
|
+
if (!_.isEqual(currentValue, value)) {
|
|
61
|
+
_.set(this._data, path, value);
|
|
69
62
|
this._addChange(path);
|
|
70
63
|
}
|
|
71
64
|
}
|
|
@@ -77,8 +70,8 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
|
|
|
77
70
|
throw new Error('setData expects an object');
|
|
78
71
|
}
|
|
79
72
|
Object.keys(newData).forEach(function (key) {
|
|
80
|
-
if (!
|
|
81
|
-
|
|
73
|
+
if (!_.isEqual(_.get(_this._data, key), newData[key])) {
|
|
74
|
+
_.set(_this._data, key, newData[key]);
|
|
82
75
|
_this._addChange(key);
|
|
83
76
|
}
|
|
84
77
|
});
|
|
@@ -133,7 +126,7 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
|
|
|
133
126
|
key: "clone",
|
|
134
127
|
value: function clone() {
|
|
135
128
|
// Create a deep copy of the current object's data
|
|
136
|
-
var clonedData =
|
|
129
|
+
var clonedData = _.cloneDeep(this._internalData);
|
|
137
130
|
|
|
138
131
|
// Reset unique identifiers to ensure a new ID is generated upon saving
|
|
139
132
|
delete clonedData.id;
|
|
@@ -237,4 +230,5 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
|
|
|
237
230
|
//}
|
|
238
231
|
}]);
|
|
239
232
|
return RbtUser;
|
|
240
|
-
}();
|
|
233
|
+
}();
|
|
234
|
+
export { RbtUser as default };
|
package/dist/rbt_object.js
CHANGED
|
@@ -66,7 +66,9 @@ var RbtObject = /*#__PURE__*/function () {
|
|
|
66
66
|
return _createClass(RbtObject, [{
|
|
67
67
|
key: "get",
|
|
68
68
|
value: function get(path) {
|
|
69
|
-
|
|
69
|
+
var value = _.get(this._data, path);
|
|
70
|
+
// Return a deep clone to prevent reference issues when modifying returned objects
|
|
71
|
+
return _.cloneDeep(value);
|
|
70
72
|
}
|
|
71
73
|
}, {
|
|
72
74
|
key: "getData",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "roboto-js",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/cjs/index.cjs",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"clean": "rm -rf node_modules; rm package-lock.json; npm install",
|
|
13
13
|
"build": "npm run build:cjs && npm run build:esm",
|
|
14
|
-
"build:cjs": "babel src --out-dir dist/cjs --extensions \".js,.jsx\" --out-file-extension .cjs && npm run postbuild:cjs",
|
|
15
|
-
"build:esm": "babel src --out-dir dist/esm",
|
|
14
|
+
"build:cjs": "BABEL_ENV=cjs babel src --out-dir dist/cjs --extensions \".js,.jsx\" --out-file-extension .cjs && npm run postbuild:cjs",
|
|
15
|
+
"build:esm": "BABEL_ENV=esm babel src --out-dir dist/esm",
|
|
16
16
|
"xbuild:esm": "babel src --out-dir dist/esm --presets=@babel/preset-env --no-babelrc --config-file ./babel.esm.config.json",
|
|
17
17
|
"postbuild:cjs": "node postbuild-cjs.js",
|
|
18
18
|
"test": "echo \"Error: no test specified\" && exit 1",
|
package/src/index.js
CHANGED
|
@@ -70,19 +70,22 @@ export default class Roboto{
|
|
|
70
70
|
this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
|
|
71
71
|
|
|
72
72
|
// Check if a request object is provided
|
|
73
|
-
if (proxyReq
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
73
|
+
if (proxyReq) {
|
|
74
|
+
// First priority: properties set by middleware (supports cookie-based auth)
|
|
75
|
+
// Second priority: custom headers (backward compatibility)
|
|
76
|
+
const req_authtoken = proxyReq.authToken || proxyReq.headers?.authtoken;
|
|
77
|
+
const req_accesskey = proxyReq.accessKey || proxyReq.headers?.accesskey;
|
|
78
|
+
const req_apikey = proxyReq.apiKey || proxyReq.headers?.apikey;
|
|
79
|
+
|
|
77
80
|
// Optionally add more headers as needed
|
|
78
|
-
if (
|
|
79
|
-
this.config.authtoken =
|
|
81
|
+
if (req_authtoken) {
|
|
82
|
+
this.config.authtoken = req_authtoken; // Set the authtoken in the config
|
|
80
83
|
}
|
|
81
|
-
if (
|
|
82
|
-
this.config.apikey =
|
|
84
|
+
if (req_apikey) {
|
|
85
|
+
this.config.apikey = req_apikey; // Set the apikey in the config
|
|
83
86
|
}
|
|
84
|
-
if (
|
|
85
|
-
this.config.accesskey =
|
|
87
|
+
if (req_accesskey) {
|
|
88
|
+
this.config.accesskey = req_accesskey; // Set the accesskey in the config
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
}
|
package/src/rbt_object.js
CHANGED
|
@@ -43,7 +43,9 @@ export default class RbtObject{
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
get(path) {
|
|
46
|
-
|
|
46
|
+
const value = _.get(this._data, path);
|
|
47
|
+
// Return a deep clone to prevent reference issues when modifying returned objects
|
|
48
|
+
return _.cloneDeep(value);
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
getData(keys = null) {
|