roboto-js 1.7.5 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.last-build +1 -1
- package/SHARING_GUIDE.md +483 -0
- package/dist/cjs/rbt_object.cjs +472 -15
- package/dist/esm/rbt_object.js +338 -0
- package/dist/rbt_object.js +458 -13
- package/examples/sharing-example.js +424 -0
- package/package.json +1 -1
- package/src/rbt_object.js +346 -0
package/dist/cjs/rbt_object.cjs
CHANGED
|
@@ -417,48 +417,505 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
|
|
|
417
417
|
}
|
|
418
418
|
return save;
|
|
419
419
|
}()
|
|
420
|
+
/**
|
|
421
|
+
* Grants access to this object for specific users and/or user groups.
|
|
422
|
+
* Updates the IAC (Identity and Access Control) permissions.
|
|
423
|
+
*
|
|
424
|
+
* @param {Object} options - Access grant options
|
|
425
|
+
* @param {string[]} [options.userIds=[]] - Array of user IDs to grant read access
|
|
426
|
+
* @param {string[]} [options.groupIds=[]] - Array of user group IDs to grant read access
|
|
427
|
+
* @param {boolean} [options.write=false] - If true, grants write access instead of read access
|
|
428
|
+
* @param {boolean} [options.replace=false] - If true, replaces existing grants; if false, merges with existing
|
|
429
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
430
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* // Grant read access to specific users
|
|
434
|
+
* await myObject.grantAccess({
|
|
435
|
+
* userIds: ['user123', 'user456']
|
|
436
|
+
* });
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* // Grant read access to user groups
|
|
440
|
+
* await myObject.grantAccess({
|
|
441
|
+
* groupIds: ['grpRngAccount', 'grpAdmins']
|
|
442
|
+
* });
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* // Grant write access to users and groups
|
|
446
|
+
* await myObject.grantAccess({
|
|
447
|
+
* userIds: ['user123'],
|
|
448
|
+
* groupIds: ['grpAdmins'],
|
|
449
|
+
* write: true
|
|
450
|
+
* });
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* // Replace existing permissions instead of merging
|
|
454
|
+
* await myObject.grantAccess({
|
|
455
|
+
* userIds: ['user123'],
|
|
456
|
+
* replace: true
|
|
457
|
+
* });
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* // Update permissions without auto-saving
|
|
461
|
+
* await myObject.grantAccess({
|
|
462
|
+
* userIds: ['user123'],
|
|
463
|
+
* save: false
|
|
464
|
+
* });
|
|
465
|
+
* // ... make other changes ...
|
|
466
|
+
* await myObject.save();
|
|
467
|
+
*/
|
|
468
|
+
}, {
|
|
469
|
+
key: "grantAccess",
|
|
470
|
+
value: (function () {
|
|
471
|
+
var _grantAccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
472
|
+
var options,
|
|
473
|
+
_options$userIds,
|
|
474
|
+
userIds,
|
|
475
|
+
_options$groupIds,
|
|
476
|
+
groupIds,
|
|
477
|
+
_options$write,
|
|
478
|
+
write,
|
|
479
|
+
_options$replace,
|
|
480
|
+
replace,
|
|
481
|
+
_options$save,
|
|
482
|
+
save,
|
|
483
|
+
iac,
|
|
484
|
+
grantType,
|
|
485
|
+
existingUsers,
|
|
486
|
+
mergedUsers,
|
|
487
|
+
existingGroups,
|
|
488
|
+
mergedGroups,
|
|
489
|
+
_args4 = arguments;
|
|
490
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
491
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
492
|
+
case 0:
|
|
493
|
+
options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
494
|
+
_options$userIds = options.userIds, userIds = _options$userIds === void 0 ? [] : _options$userIds, _options$groupIds = options.groupIds, groupIds = _options$groupIds === void 0 ? [] : _options$groupIds, _options$write = options.write, write = _options$write === void 0 ? false : _options$write, _options$replace = options.replace, replace = _options$replace === void 0 ? false : _options$replace, _options$save = options.save, save = _options$save === void 0 ? true : _options$save; // Validate inputs
|
|
495
|
+
if (Array.isArray(userIds)) {
|
|
496
|
+
_context4.next = 4;
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
throw new Error('userIds must be an array');
|
|
500
|
+
case 4:
|
|
501
|
+
if (Array.isArray(groupIds)) {
|
|
502
|
+
_context4.next = 6;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
throw new Error('groupIds must be an array');
|
|
506
|
+
case 6:
|
|
507
|
+
// Get current IAC settings
|
|
508
|
+
iac = this.get('iac') || {}; // Determine which grant type to update (read or write)
|
|
509
|
+
grantType = write ? 'writeGrants' : 'readGrants'; // Initialize grants if they don't exist
|
|
510
|
+
if (!iac[grantType]) {
|
|
511
|
+
iac[grantType] = {};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Handle users
|
|
515
|
+
if (userIds.length > 0) {
|
|
516
|
+
if (replace) {
|
|
517
|
+
// Replace existing users
|
|
518
|
+
iac[grantType].users = _toConsumableArray(userIds);
|
|
519
|
+
} else {
|
|
520
|
+
// Merge with existing users (avoiding duplicates)
|
|
521
|
+
existingUsers = iac[grantType].users || [];
|
|
522
|
+
mergedUsers = _toConsumableArray(new Set([].concat(_toConsumableArray(existingUsers), _toConsumableArray(userIds))));
|
|
523
|
+
iac[grantType].users = mergedUsers;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Handle user groups
|
|
528
|
+
if (groupIds.length > 0) {
|
|
529
|
+
if (replace) {
|
|
530
|
+
// Replace existing groups
|
|
531
|
+
iac[grantType].userGroups = _toConsumableArray(groupIds);
|
|
532
|
+
} else {
|
|
533
|
+
// Merge with existing groups (avoiding duplicates)
|
|
534
|
+
existingGroups = iac[grantType].userGroups || [];
|
|
535
|
+
mergedGroups = _toConsumableArray(new Set([].concat(_toConsumableArray(existingGroups), _toConsumableArray(groupIds))));
|
|
536
|
+
iac[grantType].userGroups = mergedGroups;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Update the object
|
|
541
|
+
this.set('iac', iac);
|
|
542
|
+
|
|
543
|
+
// Save if requested
|
|
544
|
+
if (!save) {
|
|
545
|
+
_context4.next = 16;
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
_context4.next = 15;
|
|
549
|
+
return this.save();
|
|
550
|
+
case 15:
|
|
551
|
+
return _context4.abrupt("return", _context4.sent);
|
|
552
|
+
case 16:
|
|
553
|
+
return _context4.abrupt("return", this);
|
|
554
|
+
case 17:
|
|
555
|
+
case "end":
|
|
556
|
+
return _context4.stop();
|
|
557
|
+
}
|
|
558
|
+
}, _callee4, this);
|
|
559
|
+
}));
|
|
560
|
+
function grantAccess() {
|
|
561
|
+
return _grantAccess.apply(this, arguments);
|
|
562
|
+
}
|
|
563
|
+
return grantAccess;
|
|
564
|
+
}()
|
|
565
|
+
/**
|
|
566
|
+
* Publishes this object to make it publicly accessible (or unpublishes it).
|
|
567
|
+
* Adds or removes 'public_user' from the IAC read permissions.
|
|
568
|
+
*
|
|
569
|
+
* @param {Object} options - Publishing options
|
|
570
|
+
* @param {boolean} [options.publish=true] - If true, publishes the object; if false, unpublishes it
|
|
571
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
572
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* // Publish an object (make it public)
|
|
576
|
+
* await myObject.publishObject();
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* // Unpublish an object (make it private)
|
|
580
|
+
* await myObject.publishObject({ publish: false });
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* // Publish without auto-saving
|
|
584
|
+
* await myObject.publishObject({ save: false });
|
|
585
|
+
* // ... make other changes ...
|
|
586
|
+
* await myObject.save();
|
|
587
|
+
*/
|
|
588
|
+
)
|
|
589
|
+
}, {
|
|
590
|
+
key: "publishObject",
|
|
591
|
+
value: (function () {
|
|
592
|
+
var _publishObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
593
|
+
var options,
|
|
594
|
+
_options$publish,
|
|
595
|
+
publish,
|
|
596
|
+
_options$save2,
|
|
597
|
+
save,
|
|
598
|
+
currentIac,
|
|
599
|
+
iac,
|
|
600
|
+
_args5 = arguments;
|
|
601
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
602
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
603
|
+
case 0:
|
|
604
|
+
options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
|
605
|
+
_options$publish = options.publish, publish = _options$publish === void 0 ? true : _options$publish, _options$save2 = options.save, save = _options$save2 === void 0 ? true : _options$save2; // Get current IAC settings and create a deep clone to ensure change detection
|
|
606
|
+
currentIac = this.get('iac') || {};
|
|
607
|
+
iac = _lodash["default"].cloneDeep(currentIac); // Initialize readGrants if it doesn't exist
|
|
608
|
+
if (!iac.readGrants) {
|
|
609
|
+
iac.readGrants = {};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Initialize users array if it doesn't exist
|
|
613
|
+
if (!Array.isArray(iac.readGrants.users)) {
|
|
614
|
+
iac.readGrants.users = [];
|
|
615
|
+
}
|
|
616
|
+
if (publish) {
|
|
617
|
+
// Add public_user if not already present
|
|
618
|
+
if (!iac.readGrants.users.includes('public_user')) {
|
|
619
|
+
iac.readGrants.users.push('public_user');
|
|
620
|
+
}
|
|
621
|
+
} else {
|
|
622
|
+
// Remove public_user
|
|
623
|
+
iac.readGrants.users = iac.readGrants.users.filter(function (userId) {
|
|
624
|
+
return userId !== 'public_user';
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// Update the object with the cloned and modified IAC
|
|
629
|
+
this.set('iac', iac);
|
|
630
|
+
|
|
631
|
+
// Save if requested
|
|
632
|
+
if (!save) {
|
|
633
|
+
_context5.next = 12;
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
_context5.next = 11;
|
|
637
|
+
return this.save();
|
|
638
|
+
case 11:
|
|
639
|
+
return _context5.abrupt("return", _context5.sent);
|
|
640
|
+
case 12:
|
|
641
|
+
return _context5.abrupt("return", this);
|
|
642
|
+
case 13:
|
|
643
|
+
case "end":
|
|
644
|
+
return _context5.stop();
|
|
645
|
+
}
|
|
646
|
+
}, _callee5, this);
|
|
647
|
+
}));
|
|
648
|
+
function publishObject() {
|
|
649
|
+
return _publishObject.apply(this, arguments);
|
|
650
|
+
}
|
|
651
|
+
return publishObject;
|
|
652
|
+
}()
|
|
653
|
+
/**
|
|
654
|
+
* Unpublishes this object to remove public access.
|
|
655
|
+
* Removes 'public_user' from the IAC read permissions.
|
|
656
|
+
* This is an alias for publishObject({ publish: false }) for better code clarity.
|
|
657
|
+
*
|
|
658
|
+
* @param {Object} options - Unpublishing options
|
|
659
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
660
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* // Unpublish an object (remove public access)
|
|
664
|
+
* await myObject.unpublishObject();
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* // Unpublish without auto-saving
|
|
668
|
+
* await myObject.unpublishObject({ save: false });
|
|
669
|
+
* // ... make other changes ...
|
|
670
|
+
* await myObject.save();
|
|
671
|
+
*/
|
|
672
|
+
)
|
|
673
|
+
}, {
|
|
674
|
+
key: "unpublishObject",
|
|
675
|
+
value: (function () {
|
|
676
|
+
var _unpublishObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
677
|
+
var options,
|
|
678
|
+
_args6 = arguments;
|
|
679
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
680
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
681
|
+
case 0:
|
|
682
|
+
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
683
|
+
_context6.next = 3;
|
|
684
|
+
return this.publishObject({
|
|
685
|
+
publish: false,
|
|
686
|
+
save: options.save !== undefined ? options.save : true
|
|
687
|
+
});
|
|
688
|
+
case 3:
|
|
689
|
+
return _context6.abrupt("return", _context6.sent);
|
|
690
|
+
case 4:
|
|
691
|
+
case "end":
|
|
692
|
+
return _context6.stop();
|
|
693
|
+
}
|
|
694
|
+
}, _callee6, this);
|
|
695
|
+
}));
|
|
696
|
+
function unpublishObject() {
|
|
697
|
+
return _unpublishObject.apply(this, arguments);
|
|
698
|
+
}
|
|
699
|
+
return unpublishObject;
|
|
700
|
+
}()
|
|
701
|
+
/**
|
|
702
|
+
* Revokes access from specific users and/or user groups.
|
|
703
|
+
*
|
|
704
|
+
* @param {Object} options - Access revocation options
|
|
705
|
+
* @param {string[]} [options.userIds=[]] - Array of user IDs to remove from read or write access
|
|
706
|
+
* @param {string[]} [options.groupIds=[]] - Array of group IDs to remove from read or write access
|
|
707
|
+
* @param {boolean} [options.write=false] - If true, removes write access; if false, removes read access
|
|
708
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
709
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* // Revoke read access from specific users
|
|
713
|
+
* await myObject.revokeAccess({
|
|
714
|
+
* userIds: ['user_123', 'user_456']
|
|
715
|
+
* });
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* // Revoke write access from specific groups
|
|
719
|
+
* await myObject.revokeAccess({
|
|
720
|
+
* groupIds: ['grpEditors'],
|
|
721
|
+
* write: true
|
|
722
|
+
* });
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* // Revoke access from users and groups
|
|
726
|
+
* await myObject.revokeAccess({
|
|
727
|
+
* userIds: ['user_123'],
|
|
728
|
+
* groupIds: ['grpViewers']
|
|
729
|
+
* });
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* // Revoke without auto-saving
|
|
733
|
+
* await myObject.revokeAccess({
|
|
734
|
+
* userIds: ['user_123'],
|
|
735
|
+
* save: false
|
|
736
|
+
* });
|
|
737
|
+
*/
|
|
738
|
+
)
|
|
739
|
+
}, {
|
|
740
|
+
key: "revokeAccess",
|
|
741
|
+
value: (function () {
|
|
742
|
+
var _revokeAccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
743
|
+
var options,
|
|
744
|
+
_options$userIds2,
|
|
745
|
+
userIds,
|
|
746
|
+
_options$groupIds2,
|
|
747
|
+
groupIds,
|
|
748
|
+
_options$write2,
|
|
749
|
+
write,
|
|
750
|
+
_options$save3,
|
|
751
|
+
save,
|
|
752
|
+
iac,
|
|
753
|
+
grantType,
|
|
754
|
+
_args7 = arguments;
|
|
755
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
756
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
757
|
+
case 0:
|
|
758
|
+
options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
759
|
+
_options$userIds2 = options.userIds, userIds = _options$userIds2 === void 0 ? [] : _options$userIds2, _options$groupIds2 = options.groupIds, groupIds = _options$groupIds2 === void 0 ? [] : _options$groupIds2, _options$write2 = options.write, write = _options$write2 === void 0 ? false : _options$write2, _options$save3 = options.save, save = _options$save3 === void 0 ? true : _options$save3; // Validate inputs
|
|
760
|
+
if (Array.isArray(userIds)) {
|
|
761
|
+
_context7.next = 4;
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
throw new Error('userIds must be an array');
|
|
765
|
+
case 4:
|
|
766
|
+
if (Array.isArray(groupIds)) {
|
|
767
|
+
_context7.next = 6;
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
throw new Error('groupIds must be an array');
|
|
771
|
+
case 6:
|
|
772
|
+
// Get current IAC settings
|
|
773
|
+
iac = this.get('iac') || {}; // Determine which grant type to update (read or write)
|
|
774
|
+
grantType = write ? 'writeGrants' : 'readGrants'; // Initialize grants if they don't exist
|
|
775
|
+
if (!iac[grantType]) {
|
|
776
|
+
iac[grantType] = {};
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// Remove specified users
|
|
780
|
+
if (userIds.length > 0 && Array.isArray(iac[grantType].users)) {
|
|
781
|
+
iac[grantType].users = iac[grantType].users.filter(function (userId) {
|
|
782
|
+
return !userIds.includes(userId);
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// Remove specified groups
|
|
787
|
+
if (groupIds.length > 0 && Array.isArray(iac[grantType].userGroups)) {
|
|
788
|
+
iac[grantType].userGroups = iac[grantType].userGroups.filter(function (groupId) {
|
|
789
|
+
return !groupIds.includes(groupId);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// Update the object
|
|
794
|
+
this.set('iac', iac);
|
|
795
|
+
|
|
796
|
+
// Save if requested
|
|
797
|
+
if (!save) {
|
|
798
|
+
_context7.next = 16;
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
_context7.next = 15;
|
|
802
|
+
return this.save();
|
|
803
|
+
case 15:
|
|
804
|
+
return _context7.abrupt("return", _context7.sent);
|
|
805
|
+
case 16:
|
|
806
|
+
return _context7.abrupt("return", this);
|
|
807
|
+
case 17:
|
|
808
|
+
case "end":
|
|
809
|
+
return _context7.stop();
|
|
810
|
+
}
|
|
811
|
+
}, _callee7, this);
|
|
812
|
+
}));
|
|
813
|
+
function revokeAccess() {
|
|
814
|
+
return _revokeAccess.apply(this, arguments);
|
|
815
|
+
}
|
|
816
|
+
return revokeAccess;
|
|
817
|
+
}()
|
|
818
|
+
/**
|
|
819
|
+
* Checks if this object is currently published (publicly accessible).
|
|
820
|
+
*
|
|
821
|
+
* @returns {boolean} - True if 'public_user' is in the read grants, false otherwise
|
|
822
|
+
*
|
|
823
|
+
* @example
|
|
824
|
+
* if (myObject.isPublished()) {
|
|
825
|
+
* console.log('Object is public');
|
|
826
|
+
* }
|
|
827
|
+
*/
|
|
828
|
+
)
|
|
829
|
+
}, {
|
|
830
|
+
key: "isPublished",
|
|
831
|
+
value: function isPublished() {
|
|
832
|
+
var iac = this.get('iac');
|
|
833
|
+
if (!iac || !iac.readGrants || !Array.isArray(iac.readGrants.users)) {
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
return iac.readGrants.users.includes('public_user');
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Gets the current sharing permissions for this object.
|
|
841
|
+
*
|
|
842
|
+
* @returns {Object} - Object containing read and write grants
|
|
843
|
+
* @returns {Object} returns.readGrants - Read access grants
|
|
844
|
+
* @returns {string[]} returns.readGrants.users - Array of user IDs with read access
|
|
845
|
+
* @returns {string[]} returns.readGrants.userGroups - Array of group IDs with read access
|
|
846
|
+
* @returns {string[]} returns.readGrants.organizations - Array of organization IDs with read access
|
|
847
|
+
* @returns {Object} returns.writeGrants - Write access grants
|
|
848
|
+
* @returns {string[]} returns.writeGrants.users - Array of user IDs with write access
|
|
849
|
+
* @returns {string[]} returns.writeGrants.userGroups - Array of group IDs with write access
|
|
850
|
+
* @returns {string[]} returns.writeGrants.organizations - Array of organization IDs with write access
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* const permissions = myObject.getSharing();
|
|
854
|
+
* console.log('Read users:', permissions.readGrants.users);
|
|
855
|
+
* console.log('Read groups:', permissions.readGrants.userGroups);
|
|
856
|
+
*/
|
|
857
|
+
}, {
|
|
858
|
+
key: "getSharing",
|
|
859
|
+
value: function getSharing() {
|
|
860
|
+
var _iac$readGrants, _iac$readGrants2, _iac$readGrants3, _iac$readGrants4, _iac$writeGrants, _iac$writeGrants2, _iac$writeGrants3, _iac$writeGrants4;
|
|
861
|
+
var iac = this.get('iac') || {};
|
|
862
|
+
return {
|
|
863
|
+
readGrants: {
|
|
864
|
+
users: ((_iac$readGrants = iac.readGrants) === null || _iac$readGrants === void 0 ? void 0 : _iac$readGrants.users) || [],
|
|
865
|
+
userGroups: ((_iac$readGrants2 = iac.readGrants) === null || _iac$readGrants2 === void 0 ? void 0 : _iac$readGrants2.userGroups) || [],
|
|
866
|
+
organizations: ((_iac$readGrants3 = iac.readGrants) === null || _iac$readGrants3 === void 0 ? void 0 : _iac$readGrants3.organizations) || [],
|
|
867
|
+
userSegments: ((_iac$readGrants4 = iac.readGrants) === null || _iac$readGrants4 === void 0 ? void 0 : _iac$readGrants4.userSegments) || []
|
|
868
|
+
},
|
|
869
|
+
writeGrants: {
|
|
870
|
+
users: ((_iac$writeGrants = iac.writeGrants) === null || _iac$writeGrants === void 0 ? void 0 : _iac$writeGrants.users) || [],
|
|
871
|
+
userGroups: ((_iac$writeGrants2 = iac.writeGrants) === null || _iac$writeGrants2 === void 0 ? void 0 : _iac$writeGrants2.userGroups) || [],
|
|
872
|
+
organizations: ((_iac$writeGrants3 = iac.writeGrants) === null || _iac$writeGrants3 === void 0 ? void 0 : _iac$writeGrants3.organizations) || [],
|
|
873
|
+
userSegments: ((_iac$writeGrants4 = iac.writeGrants) === null || _iac$writeGrants4 === void 0 ? void 0 : _iac$writeGrants4.userSegments) || []
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
}
|
|
420
877
|
}, {
|
|
421
878
|
key: "delete",
|
|
422
879
|
value: function () {
|
|
423
|
-
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
880
|
+
var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
424
881
|
var record, response;
|
|
425
|
-
return _regeneratorRuntime().wrap(function
|
|
426
|
-
while (1) switch (
|
|
882
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
883
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
427
884
|
case 0:
|
|
428
885
|
if (this._internalData.type) {
|
|
429
|
-
|
|
886
|
+
_context8.next = 2;
|
|
430
887
|
break;
|
|
431
888
|
}
|
|
432
889
|
throw new Error('Cannot delete object without type');
|
|
433
890
|
case 2:
|
|
434
|
-
|
|
891
|
+
_context8.prev = 2;
|
|
435
892
|
record = this.toRecord();
|
|
436
|
-
|
|
893
|
+
_context8.next = 6;
|
|
437
894
|
return this._axios.post('/object_service/deleteObject', {
|
|
438
895
|
id: record.id,
|
|
439
896
|
type: record.type
|
|
440
897
|
});
|
|
441
898
|
case 6:
|
|
442
|
-
response =
|
|
899
|
+
response = _context8.sent;
|
|
443
900
|
if (!(response.data.ok === false)) {
|
|
444
|
-
|
|
901
|
+
_context8.next = 9;
|
|
445
902
|
break;
|
|
446
903
|
}
|
|
447
904
|
throw new Error(response.data.message);
|
|
448
905
|
case 9:
|
|
449
906
|
this._internalData = response.data;
|
|
450
|
-
return
|
|
907
|
+
return _context8.abrupt("return", this);
|
|
451
908
|
case 13:
|
|
452
|
-
|
|
453
|
-
|
|
909
|
+
_context8.prev = 13;
|
|
910
|
+
_context8.t0 = _context8["catch"](2);
|
|
454
911
|
console.log('RbtObject.delete.error:');
|
|
455
|
-
console.log(
|
|
456
|
-
throw
|
|
912
|
+
console.log(_context8.t0.response.data);
|
|
913
|
+
throw _context8.t0;
|
|
457
914
|
case 18:
|
|
458
915
|
case "end":
|
|
459
|
-
return
|
|
916
|
+
return _context8.stop();
|
|
460
917
|
}
|
|
461
|
-
},
|
|
918
|
+
}, _callee8, this, [[2, 13]]);
|
|
462
919
|
}));
|
|
463
920
|
function _delete() {
|
|
464
921
|
return _delete2.apply(this, arguments);
|