roboto-js 1.9.4 → 1.9.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.
@@ -35,6 +35,9 @@ var _rbt_metrics_api = _interopRequireDefault(require("./rbt_metrics_api.cjs"));
35
35
  var _cookie_storage_adaptor = _interopRequireDefault(require("./cookie_storage_adaptor.cjs"));
36
36
  var _version = require("./version.cjs");
37
37
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
38
+ 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; }
39
+ 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; }
40
+ 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; }
38
41
  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); }
39
42
  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; }
40
43
  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); } }
@@ -240,6 +243,53 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
240
243
  value: function recordToInstance(recordHash) {
241
244
  return new _rbt_object["default"](recordHash, this.api.axios);
242
245
  }
246
+
247
+ /**
248
+ * Wraps raw API response data as RbtObject(s)
249
+ * Use this when receiving raw JSON from custom API endpoints (e.g., /api/tasks/*)
250
+ * that return database objects instead of using roboto's built-in query methods.
251
+ *
252
+ * @param {Object|Array|null} data - Raw response data (single object or array)
253
+ * @returns {RbtObject|Array<RbtObject>|null} - Wrapped RbtObject(s) or original value if null/already wrapped
254
+ *
255
+ * @example
256
+ * // Wrapping a single object
257
+ * const response = await fetch('/api/tasks/boards/123');
258
+ * const data = await response.cjson();
259
+ * const board = roboto.wrapAsRbtObjects(data.board);
260
+ * board.set('title', 'New Title'); // Now you can use RbtObject methods
261
+ *
262
+ * @example
263
+ * // Wrapping an array
264
+ * const response = await fetch('/api/tasks/boards');
265
+ * const data = await response.cjson();
266
+ * const boards = roboto.wrapAsRbtObjects(data.boards);
267
+ * boards.forEach(board => console.log(board.get('title')));
268
+ */
269
+ }, {
270
+ key: "wrapAsRbtObjects",
271
+ value: function wrapAsRbtObjects(data) {
272
+ var _this2 = this;
273
+ if (!data) return data;
274
+
275
+ // If it's already an RbtObject, return as-is (idempotent)
276
+ if (typeof data.get === 'function') {
277
+ return data;
278
+ }
279
+
280
+ // If it's an array, wrap each item
281
+ if (Array.isArray(data)) {
282
+ return data.map(function (item) {
283
+ if (typeof (item === null || item === void 0 ? void 0 : item.get) === 'function') {
284
+ return item;
285
+ }
286
+ return new _rbt_object["default"](item, _this2.api.axios);
287
+ });
288
+ }
289
+
290
+ // Single object - wrap it
291
+ return new _rbt_object["default"](data, this.api.axios);
292
+ }
243
293
  }, {
244
294
  key: "_stripHttpsForDomains",
245
295
  value: function _stripHttpsForDomains(baseUrl, domains) {
@@ -456,64 +506,119 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
456
506
  }
457
507
  return confirmUserEmail;
458
508
  }() //
459
- // create and upload files
509
+ // Organization management
460
510
  //
461
511
  }, {
462
- key: "createFile",
512
+ key: "loadCurrentOrganization",
463
513
  value: function () {
464
- var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
465
- var data,
514
+ var _loadCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
515
+ var forceReload,
466
516
  _args11 = arguments;
467
517
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
468
518
  while (1) switch (_context11.prev = _context11.next) {
469
519
  case 0:
470
- data = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
471
- return _context11.abrupt("return", this.api.createFile(data));
520
+ forceReload = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : false;
521
+ return _context11.abrupt("return", this.api.loadCurrentOrganization(forceReload));
472
522
  case 2:
473
523
  case "end":
474
524
  return _context11.stop();
475
525
  }
476
526
  }, _callee11, this);
477
527
  }));
478
- function createFile() {
479
- return _createFile.apply(this, arguments);
528
+ function loadCurrentOrganization() {
529
+ return _loadCurrentOrganization.apply(this, arguments);
480
530
  }
481
- return createFile;
531
+ return loadCurrentOrganization;
482
532
  }()
483
533
  }, {
484
- key: "loadFile",
534
+ key: "switchOrganization",
485
535
  value: function () {
486
- var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(id) {
536
+ var _switchOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orgId) {
487
537
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
488
538
  while (1) switch (_context12.prev = _context12.next) {
489
539
  case 0:
490
- return _context12.abrupt("return", this.api.loadFile(id));
540
+ return _context12.abrupt("return", this.api.switchOrganization(orgId));
491
541
  case 1:
492
542
  case "end":
493
543
  return _context12.stop();
494
544
  }
495
545
  }, _callee12, this);
496
546
  }));
497
- function loadFile(_x6) {
498
- return _loadFile.apply(this, arguments);
547
+ function switchOrganization(_x6) {
548
+ return _switchOrganization.apply(this, arguments);
499
549
  }
500
- return loadFile;
550
+ return switchOrganization;
501
551
  }()
502
552
  }, {
503
- key: "loadFiles",
553
+ key: "getCurrentOrganization",
554
+ value: function getCurrentOrganization() {
555
+ return this.api.getCurrentOrganization();
556
+ }
557
+ }, {
558
+ key: "currentOrganization",
559
+ get: function get() {
560
+ return this.api.currentOrganization;
561
+ }
562
+
563
+ //
564
+ // create and upload files
565
+ //
566
+ }, {
567
+ key: "createFile",
504
568
  value: function () {
505
- var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(ids) {
569
+ var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
570
+ var data,
571
+ _args13 = arguments;
506
572
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
507
573
  while (1) switch (_context13.prev = _context13.next) {
508
574
  case 0:
509
- return _context13.abrupt("return", this.api.loadFiles(ids));
510
- case 1:
575
+ data = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
576
+ return _context13.abrupt("return", this.api.createFile(data));
577
+ case 2:
511
578
  case "end":
512
579
  return _context13.stop();
513
580
  }
514
581
  }, _callee13, this);
515
582
  }));
516
- function loadFiles(_x7) {
583
+ function createFile() {
584
+ return _createFile.apply(this, arguments);
585
+ }
586
+ return createFile;
587
+ }()
588
+ }, {
589
+ key: "loadFile",
590
+ value: function () {
591
+ var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(id) {
592
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
593
+ while (1) switch (_context14.prev = _context14.next) {
594
+ case 0:
595
+ return _context14.abrupt("return", this.api.loadFile(id));
596
+ case 1:
597
+ case "end":
598
+ return _context14.stop();
599
+ }
600
+ }, _callee14, this);
601
+ }));
602
+ function loadFile(_x7) {
603
+ return _loadFile.apply(this, arguments);
604
+ }
605
+ return loadFile;
606
+ }()
607
+ }, {
608
+ key: "loadFiles",
609
+ value: function () {
610
+ var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(ids) {
611
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
612
+ while (1) switch (_context15.prev = _context15.next) {
613
+ case 0:
614
+ return _context15.abrupt("return", this.api.loadFiles(ids));
615
+ case 1:
616
+ case "end":
617
+ return _context15.stop();
618
+ }
619
+ }, _callee15, this);
620
+ }));
621
+ function loadFiles(_x8) {
517
622
  return _loadFiles.apply(this, arguments);
518
623
  }
519
624
  return loadFiles;
@@ -523,21 +628,21 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
523
628
  }, {
524
629
  key: "create",
525
630
  value: function () {
526
- var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
631
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
527
632
  var data,
528
- _args14 = arguments;
529
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
530
- while (1) switch (_context14.prev = _context14.next) {
633
+ _args16 = arguments;
634
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
635
+ while (1) switch (_context16.prev = _context16.next) {
531
636
  case 0:
532
- data = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
533
- return _context14.abrupt("return", this.api.create(params, data));
637
+ data = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
638
+ return _context16.abrupt("return", this.api.create(params, data));
534
639
  case 2:
535
640
  case "end":
536
- return _context14.stop();
641
+ return _context16.stop();
537
642
  }
538
- }, _callee14, this);
643
+ }, _callee16, this);
539
644
  }));
540
- function create(_x8) {
645
+ function create(_x9) {
541
646
  return _create.apply(this, arguments);
542
647
  }
543
648
  return create;
@@ -545,18 +650,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
545
650
  }, {
546
651
  key: "load",
547
652
  value: function () {
548
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(type, ids, options) {
549
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
550
- while (1) switch (_context15.prev = _context15.next) {
653
+ var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(type, ids, options) {
654
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
655
+ while (1) switch (_context17.prev = _context17.next) {
551
656
  case 0:
552
- return _context15.abrupt("return", this.api.load(type, ids, options));
657
+ return _context17.abrupt("return", this.api.load(type, ids, options));
553
658
  case 1:
554
659
  case "end":
555
- return _context15.stop();
660
+ return _context17.stop();
556
661
  }
557
- }, _callee15, this);
662
+ }, _callee17, this);
558
663
  }));
559
- function load(_x9, _x10, _x11) {
664
+ function load(_x10, _x11, _x12) {
560
665
  return _load.apply(this, arguments);
561
666
  }
562
667
  return load;
@@ -564,18 +669,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
564
669
  }, {
565
670
  key: "query",
566
671
  value: function () {
567
- var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(type, params) {
568
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
569
- while (1) switch (_context16.prev = _context16.next) {
672
+ var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(type, params) {
673
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
674
+ while (1) switch (_context18.prev = _context18.next) {
570
675
  case 0:
571
- return _context16.abrupt("return", this.api.query(type, params));
676
+ return _context18.abrupt("return", this.api.query(type, params));
572
677
  case 1:
573
678
  case "end":
574
- return _context16.stop();
679
+ return _context18.stop();
575
680
  }
576
- }, _callee16, this);
681
+ }, _callee18, this);
577
682
  }));
578
- function query(_x12, _x13) {
683
+ function query(_x13, _x14) {
579
684
  return _query.apply(this, arguments);
580
685
  }
581
686
  return query;
@@ -597,18 +702,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
597
702
  }, {
598
703
  key: "runTask",
599
704
  value: function () {
600
- var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params, callbacks) {
601
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
602
- while (1) switch (_context17.prev = _context17.next) {
705
+ var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params, callbacks) {
706
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
707
+ while (1) switch (_context19.prev = _context19.next) {
603
708
  case 0:
604
- return _context17.abrupt("return", this.api.runTask(params, callbacks));
709
+ return _context19.abrupt("return", this.api.runTask(params, callbacks));
605
710
  case 1:
606
711
  case "end":
607
- return _context17.stop();
712
+ return _context19.stop();
608
713
  }
609
- }, _callee17, this);
714
+ }, _callee19, this);
610
715
  }));
611
- function runTask(_x14, _x15) {
716
+ function runTask(_x15, _x16) {
612
717
  return _runTask.apply(this, arguments);
613
718
  }
614
719
  return runTask;
@@ -616,18 +721,18 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
616
721
  }, {
617
722
  key: "stopJob",
618
723
  value: function () {
619
- var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params, callbacks) {
620
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
621
- while (1) switch (_context18.prev = _context18.next) {
724
+ var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params, callbacks) {
725
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
726
+ while (1) switch (_context20.prev = _context20.next) {
622
727
  case 0:
623
- return _context18.abrupt("return", this.api.stopJob(params, callbacks));
728
+ return _context20.abrupt("return", this.api.stopJob(params, callbacks));
624
729
  case 1:
625
730
  case "end":
626
- return _context18.stop();
731
+ return _context20.stop();
627
732
  }
628
- }, _callee18, this);
733
+ }, _callee20, this);
629
734
  }));
630
- function stopJob(_x16, _x17) {
735
+ function stopJob(_x17, _x18) {
631
736
  return _stopJob.apply(this, arguments);
632
737
  }
633
738
  return stopJob;
@@ -635,39 +740,99 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
635
740
  }, {
636
741
  key: "pollTaskProgress",
637
742
  value: function () {
638
- var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
639
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
640
- while (1) switch (_context19.prev = _context19.next) {
743
+ var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
744
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
745
+ while (1) switch (_context21.prev = _context21.next) {
641
746
  case 0:
642
- return _context19.abrupt("return", this.api.pollTaskProgress(params));
747
+ return _context21.abrupt("return", this.api.pollTaskProgress(params));
643
748
  case 1:
644
749
  case "end":
645
- return _context19.stop();
750
+ return _context21.stop();
646
751
  }
647
- }, _callee19, this);
752
+ }, _callee21, this);
648
753
  }));
649
- function pollTaskProgress(_x18) {
754
+ function pollTaskProgress(_x19) {
650
755
  return _pollTaskProgress.apply(this, arguments);
651
756
  }
652
757
  return pollTaskProgress;
653
- }() //
758
+ }()
759
+ /**
760
+ * Helper to detect if an object looks like a doctree object
761
+ * @private
762
+ */
763
+ }, {
764
+ key: "_isDoctreeObject",
765
+ value: function _isDoctreeObject(obj) {
766
+ if (!obj || _typeof(obj) !== 'object') return false;
767
+ // Check for standard doctree fields
768
+ return obj.hasOwnProperty('id') && obj.hasOwnProperty('type') && obj.hasOwnProperty('timeCreated');
769
+ }
770
+
771
+ /**
772
+ * Auto-wraps response data if it contains doctree objects
773
+ * @private
774
+ */
775
+ }, {
776
+ key: "_autoWrapResponse",
777
+ value: function _autoWrapResponse(data) {
778
+ if (!data) return data;
779
+
780
+ // If response has an 'items' array (common pattern), wrap those
781
+ if (data.items && Array.isArray(data.items)) {
782
+ if (data.items.length > 0 && this._isDoctreeObject(data.items[0])) {
783
+ return _objectSpread(_objectSpread({}, data), {}, {
784
+ items: this.wrapAsRbtObjects(data.items)
785
+ });
786
+ }
787
+ }
788
+
789
+ // If response has a single object property that looks like doctree
790
+ // Check common property names: board, ticket, task, note, etc.
791
+ for (var _i = 0, _Object$keys = Object.keys(data); _i < _Object$keys.length; _i++) {
792
+ var key = _Object$keys[_i];
793
+ if (this._isDoctreeObject(data[key])) {
794
+ return _objectSpread(_objectSpread({}, data), {}, _defineProperty({}, key, this.wrapAsRbtObjects(data[key])));
795
+ }
796
+ // Check if it's an array of doctree objects
797
+ if (Array.isArray(data[key]) && data[key].length > 0 && this._isDoctreeObject(data[key][0])) {
798
+ return _objectSpread(_objectSpread({}, data), {}, _defineProperty({}, key, this.wrapAsRbtObjects(data[key])));
799
+ }
800
+ }
801
+
802
+ // If the root data itself is a doctree object or array of them
803
+ if (this._isDoctreeObject(data)) {
804
+ return this.wrapAsRbtObjects(data);
805
+ }
806
+ if (Array.isArray(data) && data.length > 0 && this._isDoctreeObject(data[0])) {
807
+ return this.wrapAsRbtObjects(data);
808
+ }
809
+ return data;
810
+ }
811
+
812
+ //
654
813
  // Get/Post to endpoint with Roboto authtoken
814
+ // Automatically wraps doctree objects in responses as RbtObjects
655
815
  //
656
816
  }, {
657
817
  key: "get",
658
818
  value: function () {
659
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(endpoint, params) {
660
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
661
- while (1) switch (_context20.prev = _context20.next) {
819
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(endpoint, params) {
820
+ var result;
821
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
822
+ while (1) switch (_context22.prev = _context22.next) {
662
823
  case 0:
663
- return _context20.abrupt("return", this.api.get(endpoint, params));
664
- case 1:
824
+ _context22.next = 2;
825
+ return this.api.get(endpoint, params);
826
+ case 2:
827
+ result = _context22.sent;
828
+ return _context22.abrupt("return", this._autoWrapResponse(result));
829
+ case 4:
665
830
  case "end":
666
- return _context20.stop();
831
+ return _context22.stop();
667
832
  }
668
- }, _callee20, this);
833
+ }, _callee22, this);
669
834
  }));
670
- function get(_x19, _x20) {
835
+ function get(_x20, _x21) {
671
836
  return _get.apply(this, arguments);
672
837
  }
673
838
  return get;
@@ -675,18 +840,23 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
675
840
  }, {
676
841
  key: "post",
677
842
  value: function () {
678
- var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(endpoint, data) {
679
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
680
- while (1) switch (_context21.prev = _context21.next) {
843
+ var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(endpoint, data) {
844
+ var result;
845
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
846
+ while (1) switch (_context23.prev = _context23.next) {
681
847
  case 0:
682
- return _context21.abrupt("return", this.api.post(endpoint, data));
683
- case 1:
848
+ _context23.next = 2;
849
+ return this.api.post(endpoint, data);
850
+ case 2:
851
+ result = _context23.sent;
852
+ return _context23.abrupt("return", this._autoWrapResponse(result));
853
+ case 4:
684
854
  case "end":
685
- return _context21.stop();
855
+ return _context23.stop();
686
856
  }
687
- }, _callee21, this);
857
+ }, _callee23, this);
688
858
  }));
689
- function post(_x21, _x22) {
859
+ function post(_x22, _x23) {
690
860
  return _post.apply(this, arguments);
691
861
  }
692
862
  return post;