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