roboto-js 1.8.5 → 1.8.7

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.
@@ -1,6 +1,26 @@
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; }
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); } }
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); }); }; }
4
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ 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); }
11
+ 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; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
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; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
1
19
  import _ from 'lodash';
2
- export default class RbtUser {
3
- constructor(record, axiosInstance, options = {}) {
20
+ var RbtUser = /*#__PURE__*/function () {
21
+ function RbtUser(record, axiosInstance) {
22
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
23
+ _classCallCheck(this, RbtUser);
4
24
  this._axios = axiosInstance;
5
25
  this._internalData = record;
6
26
  this.id = record.id;
@@ -15,155 +35,200 @@ export default class RbtUser {
15
35
  this._data = record.dataJson ? this._deepUnpackJson(record.dataJson) : {};
16
36
  }
17
37
  }
18
- get(path) {
19
- return _.get(this._data, path);
20
- }
21
- getData() {
22
- return {
23
- ...this._data
24
- };
25
- }
26
- _addChange(path) {
27
- // Ensure no duplicate paths
28
- if (!this.rpcMeta.changes.includes(path)) {
29
- this.rpcMeta.changes.push(path);
38
+ _createClass(RbtUser, [{
39
+ key: "get",
40
+ value: function get(path) {
41
+ return _.get(this._data, path);
30
42
  }
31
- }
32
- set(path, value) {
33
- const currentValue = _.get(this._data, path);
34
- if (!_.isEqual(currentValue, value)) {
35
- _.set(this._data, path, value);
36
- this._addChange(path);
43
+ }, {
44
+ key: "getData",
45
+ value: function getData() {
46
+ return _objectSpread({}, this._data);
37
47
  }
38
- }
39
- setData(newData) {
40
- if (typeof newData !== 'object' || newData === null) {
41
- throw new Error('setData expects an object');
48
+ }, {
49
+ key: "_addChange",
50
+ value: function _addChange(path) {
51
+ // Ensure no duplicate paths
52
+ if (!this.rpcMeta.changes.includes(path)) {
53
+ this.rpcMeta.changes.push(path);
54
+ }
42
55
  }
43
- Object.keys(newData).forEach(key => {
44
- if (!_.isEqual(_.get(this._data, key), newData[key])) {
45
- _.set(this._data, key, newData[key]);
46
- this._addChange(key);
56
+ }, {
57
+ key: "set",
58
+ value: function set(path, value) {
59
+ var currentValue = _.get(this._data, path);
60
+ if (!_.isEqual(currentValue, value)) {
61
+ _.set(this._data, path, value);
62
+ this._addChange(path);
47
63
  }
48
- });
49
- }
64
+ }
65
+ }, {
66
+ key: "setData",
67
+ value: function setData(newData) {
68
+ var _this = this;
69
+ if (_typeof(newData) !== 'object' || newData === null) {
70
+ throw new Error('setData expects an object');
71
+ }
72
+ Object.keys(newData).forEach(function (key) {
73
+ if (!_.isEqual(_.get(_this._data, key), newData[key])) {
74
+ _.set(_this._data, key, newData[key]);
75
+ _this._addChange(key);
76
+ }
77
+ });
78
+ }
50
79
 
51
- //
52
- // For Arrays
53
- //
80
+ //
81
+ // For Arrays
82
+ //
83
+ }, {
84
+ key: "setAppend",
85
+ value: function setAppend(key, value) {
86
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
87
+ var existingValue = this.get(key) || []; // Get the existing value or default to an empty array
88
+ if (!Array.isArray(existingValue)) {
89
+ existingValue = []; // Ensure existingValue is an array if not already
90
+ }
91
+ var valuesToAdd = Array.isArray(value) ? value : [value]; // Convert value to an array if it's not one
54
92
 
55
- setAppend(key, value, options = {}) {
56
- let existingValue = this.get(key) || []; // Get the existing value or default to an empty array
57
- if (!Array.isArray(existingValue)) {
58
- existingValue = []; // Ensure existingValue is an array if not already
93
+ // Combine existingValue and valuesToAdd, filtering out duplicates
94
+ var mergedValues = Array.from(new Set([].concat(_toConsumableArray(existingValue), _toConsumableArray(valuesToAdd))));
95
+ this.set(key, mergedValues, options); // Set the updated array back to the user data
59
96
  }
60
- const valuesToAdd = Array.isArray(value) ? value : [value]; // Convert value to an array if it's not one
97
+ }, {
98
+ key: "setRemove",
99
+ value: function setRemove(key, value) {
100
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
101
+ var existingValue = this.get(key) || []; // Get the existing value or default to an empty array
102
+ if (!Array.isArray(existingValue)) {
103
+ return; // If it's not an array, there's nothing to remove, so exit early
104
+ }
105
+ var valuesToRemove = Array.isArray(value) ? value : [value]; // Convert value to an array if it's not one
61
106
 
62
- // Combine existingValue and valuesToAdd, filtering out duplicates
63
- const mergedValues = Array.from(new Set([...existingValue, ...valuesToAdd]));
64
- this.set(key, mergedValues, options); // Set the updated array back to the user data
65
- }
66
- setRemove(key, value, options = {}) {
67
- let existingValue = this.get(key) || []; // Get the existing value or default to an empty array
68
- if (!Array.isArray(existingValue)) {
69
- return; // If it's not an array, there's nothing to remove, so exit early
107
+ // Filter out the values to remove from the existing value array
108
+ var filteredValues = existingValue.filter(function (item) {
109
+ return !valuesToRemove.includes(item);
110
+ });
111
+ this.set(key, filteredValues); // Set the updated array back to the user data
70
112
  }
71
- const valuesToRemove = Array.isArray(value) ? value : [value]; // Convert value to an array if it's not one
72
113
 
73
- // Filter out the values to remove from the existing value array
74
- const filteredValues = existingValue.filter(item => !valuesToRemove.includes(item));
75
- this.set(key, filteredValues); // Set the updated array back to the user data
76
- }
77
-
78
- //
79
- //
80
- //
81
-
82
- toRecord() {
83
- return {
84
- ...this._internalData,
85
- dataJson: JSON.stringify(this._data),
86
- rpcMeta: this.rpcMeta
87
- };
88
- }
89
- clone() {
90
- // Create a deep copy of the current object's data
91
- const clonedData = _.cloneDeep(this._internalData);
114
+ //
115
+ //
116
+ //
117
+ }, {
118
+ key: "toRecord",
119
+ value: function toRecord() {
120
+ return _objectSpread(_objectSpread({}, this._internalData), {}, {
121
+ dataJson: JSON.stringify(this._data),
122
+ rpcMeta: this.rpcMeta
123
+ });
124
+ }
125
+ }, {
126
+ key: "clone",
127
+ value: function clone() {
128
+ // Create a deep copy of the current object's data
129
+ var clonedData = _.cloneDeep(this._internalData);
92
130
 
93
- // Reset unique identifiers to ensure a new ID is generated upon saving
94
- delete clonedData.id;
95
- delete clonedData.id_revision;
131
+ // Reset unique identifiers to ensure a new ID is generated upon saving
132
+ delete clonedData.id;
133
+ delete clonedData.id_revision;
96
134
 
97
- // Create a new instance of RbtUser with the cloned data
98
- const clonedObject = new RbtUser(clonedData, this._axios, {
99
- isNew: true
100
- });
101
- return clonedObject;
102
- }
103
- async save() {
104
- try {
105
- debugger;
106
- const record = this.toRecord();
107
- record.type = '<@iac.user>';
108
- const response = await this._axios.post('/user_service/saveUser', [record]);
109
- if (response.data.ok === false) {
110
- throw new Error(response.data.message);
111
- }
112
- this._internalData = response.data;
113
- this.id = response.data.id;
114
- this.id_revision = response.data.id_revision;
115
- this.type = response.data.type;
116
- this.rpcMeta.isNew = false;
117
- return this;
118
- } catch (e) {
119
- console.log('RbtUser.save.error:', e);
120
- //console.log(e.response.data);
121
- throw e;
135
+ // Create a new instance of RbtUser with the cloned data
136
+ var clonedObject = new RbtUser(clonedData, this._axios, {
137
+ isNew: true
138
+ });
139
+ return clonedObject;
122
140
  }
123
- }
124
- _deepUnpackJson(value) {
125
- if (typeof value === 'string') {
126
- try {
127
- // Only parse as JSON if it's not a large number
128
- // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
129
- //
130
- if (!/^\d{16,}$/.test(value)) {
131
- const parsed = JSON.parse(value);
132
- // Recursively parse if the result is a string, object, or array
133
- return this._deepUnpackJson(parsed);
134
- }
135
- } catch (e) {
136
- return value; // Return the original string if parsing fails
141
+ }, {
142
+ key: "save",
143
+ value: function () {
144
+ var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
145
+ var record, response;
146
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
147
+ while (1) switch (_context.prev = _context.next) {
148
+ case 0:
149
+ _context.prev = 0;
150
+ debugger;
151
+ record = this.toRecord();
152
+ record.type = '<@iac.user>';
153
+ _context.next = 6;
154
+ return this._axios.post('/user_service/saveUser', [record]);
155
+ case 6:
156
+ response = _context.sent;
157
+ if (!(response.data.ok === false)) {
158
+ _context.next = 9;
159
+ break;
160
+ }
161
+ throw new Error(response.data.message);
162
+ case 9:
163
+ this._internalData = response.data;
164
+ this.id = response.data.id;
165
+ this.id_revision = response.data.id_revision;
166
+ this.type = response.data.type;
167
+ this.rpcMeta.isNew = false;
168
+ return _context.abrupt("return", this);
169
+ case 17:
170
+ _context.prev = 17;
171
+ _context.t0 = _context["catch"](0);
172
+ throw _context.t0;
173
+ case 20:
174
+ case "end":
175
+ return _context.stop();
176
+ }
177
+ }, _callee, this, [[0, 17]]);
178
+ }));
179
+ function save() {
180
+ return _save.apply(this, arguments);
137
181
  }
138
- } else if (value !== null && typeof value === 'object') {
139
- // If it's an object (including arrays), recursively parse each value
140
- for (const key in value) {
141
- value[key] = this._deepUnpackJson(value[key]);
182
+ return save;
183
+ }()
184
+ }, {
185
+ key: "_deepUnpackJson",
186
+ value: function _deepUnpackJson(value) {
187
+ if (typeof value === 'string') {
188
+ try {
189
+ // Only parse as JSON if it's not a large number
190
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
191
+ //
192
+ if (!/^\d{16,}$/.test(value)) {
193
+ var parsed = JSON.parse(value);
194
+ // Recursively parse if the result is a string, object, or array
195
+ return this._deepUnpackJson(parsed);
196
+ }
197
+ } catch (e) {
198
+ return value; // Return the original string if parsing fails
199
+ }
200
+ } else if (value !== null && _typeof(value) === 'object') {
201
+ // If it's an object (including arrays), recursively parse each value
202
+ for (var key in value) {
203
+ value[key] = this._deepUnpackJson(value[key]);
204
+ }
142
205
  }
206
+ return value;
143
207
  }
144
- return value;
145
- }
146
208
 
147
- //async delete() {
148
- // if (!this._internalData.type) {
149
- // throw new Error('Cannot delete object without type');
150
- // }
151
- //
152
- // try {
153
- // const record = this.toRecord();
154
- // const response = await this._axios.post('/object_service/deleteObject', [record]);
155
- //
156
- // if (response.data.ok === false) {
157
- // throw new Error(response.data.message);
158
- // }
159
- //
160
- // this._internalData = response.data;
161
- // return this;
162
- //
163
- // } catch (e) {
164
- // console.log('RbtUser.delete.error:');
165
- // console.log(e.response.data);
166
- // throw e;
167
- // }
168
- //}
169
- }
209
+ //async delete() {
210
+ // if (!this._internalData.type) {
211
+ // throw new Error('Cannot delete object without type');
212
+ // }
213
+ //
214
+ // try {
215
+ // const record = this.toRecord();
216
+ // const response = await this._axios.post('/object_service/deleteObject', [record]);
217
+ //
218
+ // if (response.data.ok === false) {
219
+ // throw new Error(response.data.message);
220
+ // }
221
+ //
222
+ // this._internalData = response.data;
223
+ // return this;
224
+ //
225
+ // } catch (e) {
226
+ // console.log('RbtUser.delete.error:');
227
+ // console.log(e.response.data);
228
+ // throw e;
229
+ // }
230
+ //}
231
+ }]);
232
+ return RbtUser;
233
+ }();
234
+ export { RbtUser as default };
package/dist/index.js CHANGED
@@ -22,6 +22,8 @@ var Roboto = /*#__PURE__*/function () {
22
22
  var _this = this;
23
23
  var host = _ref.host,
24
24
  accessKey = _ref.accessKey,
25
+ apiKey = _ref.apiKey,
26
+ authToken = _ref.authToken,
25
27
  localStorageAdaptor = _ref.localStorageAdaptor,
26
28
  _ref$disableWebSocket = _ref.disableWebSocket,
27
29
  disableWebSocket = _ref$disableWebSocket === void 0 ? false : _ref$disableWebSocket,
@@ -30,6 +32,17 @@ var Roboto = /*#__PURE__*/function () {
30
32
  useCookies = _ref$useCookies === void 0 ? true : _ref$useCookies;
31
33
  var proxyReq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
32
34
  _classCallCheck(this, Roboto);
35
+ console.log('[Roboto] constructor', {
36
+ host: host,
37
+ accessKey: accessKey,
38
+ apiKey: apiKey,
39
+ authToken: authToken,
40
+ localStorageAdaptor: localStorageAdaptor,
41
+ disableWebSocket: disableWebSocket,
42
+ metricsHost: metricsHost,
43
+ useCookies: useCookies,
44
+ proxyReq: proxyReq
45
+ });
33
46
  if (Roboto.instance && !proxyReq) {
34
47
  // if on client, there can only be one instance
35
48
  // on server, with proxyReq, each request has its own instance
@@ -57,30 +70,38 @@ var Roboto = /*#__PURE__*/function () {
57
70
  }
58
71
  }
59
72
  this.config = {
60
- accessKey: accessKey,
73
+ accesskey: accessKey,
61
74
  // Use passed accessKey
62
75
  baseUrl: "https://".concat(host),
63
76
  // Use passed host
64
77
  localStorageAdaptor: storageAdaptor
65
78
  };
66
79
 
80
+ // Add apikey and authtoken if provided directly
81
+ if (apiKey) {
82
+ this.config.apikey = apiKey;
83
+ }
84
+ if (authToken) {
85
+ this.config.authtoken = authToken;
86
+ }
87
+
67
88
  // DEVELOPMENT
68
89
  this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
69
90
 
70
91
  // Check if a request object is provided
71
92
  if (proxyReq && proxyReq.headers) {
72
- var authtoken = proxyReq.headers.authtoken;
73
- var accesskey = proxyReq.headers.accesskey;
74
- var apikey = proxyReq.headers.apikey;
93
+ var header_authtoken = proxyReq.headers.authtoken;
94
+ var header_accesskey = proxyReq.headers.accesskey;
95
+ var header_apikey = proxyReq.headers.apikey;
75
96
  // Optionally add more headers as needed
76
- if (authtoken) {
77
- this.config.authtoken = authtoken; // Set the authtoken in the config
97
+ if (header_authtoken) {
98
+ this.config.authtoken = header_authtoken; // Set the authtoken in the config
78
99
  }
79
- if (apikey) {
80
- this.config.apikey = apikey; // Set the authtoken in the config
100
+ if (header_apikey) {
101
+ this.config.apikey = header_apikey; // Set the authtoken in the config
81
102
  }
82
- if (accesskey) {
83
- this.config.accesskey = accesskey; // Set the accesskey in the config
103
+ if (header_accesskey) {
104
+ this.config.accesskey = header_accesskey; // Set the accesskey in the config
84
105
  }
85
106
  }
86
107
  this.api = new RbtApi(this.config);
package/dist/rbt_api.js CHANGED
@@ -40,6 +40,12 @@ var RbtApi = /*#__PURE__*/function () {
40
40
  _ref$localStorageAdap = _ref.localStorageAdaptor,
41
41
  localStorageAdaptor = _ref$localStorageAdap === void 0 ? null : _ref$localStorageAdap;
42
42
  _classCallCheck(this, RbtApi);
43
+ console.log('[RbtApi] constructor received:', {
44
+ baseUrl: baseUrl,
45
+ accesskey: accesskey,
46
+ authtoken: authtoken,
47
+ apikey: apikey
48
+ });
43
49
  this.websocketClient = null;
44
50
 
45
51
  // Object cache for sharing instances across multiple load() calls
@@ -89,6 +95,13 @@ var RbtApi = /*#__PURE__*/function () {
89
95
 
90
96
  // Use the storageAdaptor to get the authToken, if available
91
97
  this.initAuthToken(authtoken);
98
+
99
+ // Set apiKey synchronously if provided (don't wait for async initApiKey)
100
+ if (apikey) {
101
+ this.apikey = apikey;
102
+ this.axios.defaults.headers.common['apikey'] = this.apikey;
103
+ console.log('[RbtApi] Set apikey header:', this.axios.defaults.headers.common['apikey']); // ADD THIS LINE
104
+ }
92
105
  this.initApiKey(apikey);
93
106
  }
94
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.8.5",
3
+ "version": "1.8.7",
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 --presets=@babel/preset-env --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",
@@ -32,6 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@babel/cli": "^7.23.9",
34
34
  "@babel/core": "^7.23.9",
35
- "@babel/preset-env": "^7.23.9"
35
+ "@babel/preset-env": "^7.23.9",
36
+ "babel-plugin-transform-remove-console": "^6.9.4"
36
37
  }
37
38
  }
package/src/index.js CHANGED
@@ -20,8 +20,10 @@ export default class Roboto{
20
20
  return '1.7.3';
21
21
  }
22
22
 
23
- constructor({ host, accessKey, localStorageAdaptor, disableWebSocket = false, metricsHost, useCookies = true }, proxyReq = null) {
23
+ constructor({ host, accessKey, apiKey, authToken, localStorageAdaptor, disableWebSocket = false, metricsHost, useCookies = true }, proxyReq = null) {
24
24
 
25
+ console.log('[Roboto] constructor', { host, accessKey, apiKey, authToken, localStorageAdaptor, disableWebSocket, metricsHost, useCookies, proxyReq });
26
+
25
27
  if (Roboto.instance && !proxyReq) {
26
28
  // if on client, there can only be one instance
27
29
  // on server, with proxyReq, each request has its own instance
@@ -51,28 +53,36 @@ export default class Roboto{
51
53
  }
52
54
 
53
55
  this.config = {
54
- accessKey: accessKey, // Use passed accessKey
56
+ accesskey: accessKey, // Use passed accessKey
55
57
  baseUrl: `https://${host}`, // Use passed host
56
58
  localStorageAdaptor: storageAdaptor
57
59
  };
60
+
61
+ // Add apikey and authtoken if provided directly
62
+ if (apiKey) {
63
+ this.config.apikey = apiKey;
64
+ }
65
+ if (authToken) {
66
+ this.config.authtoken = authToken;
67
+ }
58
68
 
59
69
  // DEVELOPMENT
60
70
  this.config.baseUrl = this._stripHttpsForDomains(this.config.baseUrl, ['localhost']);
61
71
 
62
72
  // Check if a request object is provided
63
73
  if (proxyReq && proxyReq.headers) {
64
- const authtoken = proxyReq.headers.authtoken;
65
- const accesskey = proxyReq.headers.accesskey;
66
- const apikey = proxyReq.headers.apikey;
74
+ const header_authtoken = proxyReq.headers.authtoken;
75
+ const header_accesskey = proxyReq.headers.accesskey;
76
+ const header_apikey = proxyReq.headers.apikey;
67
77
  // Optionally add more headers as needed
68
- if (authtoken) {
69
- this.config.authtoken = authtoken; // Set the authtoken in the config
78
+ if (header_authtoken) {
79
+ this.config.authtoken = header_authtoken; // Set the authtoken in the config
70
80
  }
71
- if (apikey) {
72
- this.config.apikey = apikey; // Set the authtoken in the config
81
+ if (header_apikey) {
82
+ this.config.apikey = header_apikey; // Set the authtoken in the config
73
83
  }
74
- if (accesskey) {
75
- this.config.accesskey = accesskey; // Set the accesskey in the config
84
+ if (header_accesskey) {
85
+ this.config.accesskey = header_accesskey; // Set the accesskey in the config
76
86
  }
77
87
 
78
88
  }
package/src/rbt_api.js CHANGED
@@ -10,6 +10,8 @@ export default class RbtApi {
10
10
 
11
11
  constructor({ baseUrl, accesskey, authtoken=null, apikey=null, localStorageAdaptor=null }) {
12
12
 
13
+ console.log('[RbtApi] constructor received:', { baseUrl, accesskey, authtoken, apikey });
14
+
13
15
  this.websocketClient = null;
14
16
 
15
17
  // Object cache for sharing instances across multiple load() calls
@@ -60,6 +62,7 @@ export default class RbtApi {
60
62
  if (apikey) {
61
63
  this.apikey = apikey;
62
64
  this.axios.defaults.headers.common['apikey'] = this.apikey;
65
+ console.log('[RbtApi] Set apikey header:', this.axios.defaults.headers.common['apikey']); // ADD THIS LINE
63
66
  }
64
67
  this.initApiKey(apikey);
65
68
 
package/src/rbt_object.js CHANGED
@@ -43,7 +43,9 @@ export default class RbtObject{
43
43
  }
44
44
 
45
45
  get(path) {
46
- return _.get(this._data, path);
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) {