roboto-js 1.7.4 → 1.8.1
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_api.cjs +72 -38
- package/dist/cjs/rbt_object.cjs +470 -15
- package/dist/esm/rbt_api.js +31 -2
- package/dist/esm/rbt_object.js +337 -0
- package/dist/rbt_api.js +44 -10
- package/dist/rbt_object.js +456 -13
- package/package.json +1 -1
- package/src/rbt_api.js +25 -2
- package/src/rbt_object.js +345 -0
package/dist/rbt_object.js
CHANGED
|
@@ -408,47 +408,490 @@ var RbtObject = /*#__PURE__*/function () {
|
|
|
408
408
|
}
|
|
409
409
|
return save;
|
|
410
410
|
}()
|
|
411
|
+
/**
|
|
412
|
+
* Grants access to this object for specific users and/or user groups.
|
|
413
|
+
* Updates the IAC (Identity and Access Control) permissions.
|
|
414
|
+
*
|
|
415
|
+
* @param {Object} options - Access grant options
|
|
416
|
+
* @param {string[]} [options.userIds=[]] - Array of user IDs to grant read access
|
|
417
|
+
* @param {string[]} [options.groupIds=[]] - Array of user group IDs to grant read access
|
|
418
|
+
* @param {boolean} [options.write=false] - If true, grants write access instead of read access
|
|
419
|
+
* @param {boolean} [options.replace=false] - If true, replaces existing grants; if false, merges with existing
|
|
420
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
421
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* // Grant read access to specific users
|
|
425
|
+
* await myObject.grantAccess({
|
|
426
|
+
* userIds: ['user123', 'user456']
|
|
427
|
+
* });
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* // Grant read access to user groups
|
|
431
|
+
* await myObject.grantAccess({
|
|
432
|
+
* groupIds: ['grpRngAccount', 'grpAdmins']
|
|
433
|
+
* });
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* // Grant write access to users and groups
|
|
437
|
+
* await myObject.grantAccess({
|
|
438
|
+
* userIds: ['user123'],
|
|
439
|
+
* groupIds: ['grpAdmins'],
|
|
440
|
+
* write: true
|
|
441
|
+
* });
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* // Replace existing permissions instead of merging
|
|
445
|
+
* await myObject.grantAccess({
|
|
446
|
+
* userIds: ['user123'],
|
|
447
|
+
* replace: true
|
|
448
|
+
* });
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* // Update permissions without auto-saving
|
|
452
|
+
* await myObject.grantAccess({
|
|
453
|
+
* userIds: ['user123'],
|
|
454
|
+
* save: false
|
|
455
|
+
* });
|
|
456
|
+
* // ... make other changes ...
|
|
457
|
+
* await myObject.save();
|
|
458
|
+
*/
|
|
459
|
+
}, {
|
|
460
|
+
key: "grantAccess",
|
|
461
|
+
value: (function () {
|
|
462
|
+
var _grantAccess = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
463
|
+
var options,
|
|
464
|
+
_options$userIds,
|
|
465
|
+
userIds,
|
|
466
|
+
_options$groupIds,
|
|
467
|
+
groupIds,
|
|
468
|
+
_options$write,
|
|
469
|
+
write,
|
|
470
|
+
_options$replace,
|
|
471
|
+
replace,
|
|
472
|
+
_options$save,
|
|
473
|
+
save,
|
|
474
|
+
iac,
|
|
475
|
+
grantType,
|
|
476
|
+
existingUsers,
|
|
477
|
+
mergedUsers,
|
|
478
|
+
existingGroups,
|
|
479
|
+
mergedGroups,
|
|
480
|
+
_args4 = arguments;
|
|
481
|
+
return _regenerator().w(function (_context4) {
|
|
482
|
+
while (1) switch (_context4.n) {
|
|
483
|
+
case 0:
|
|
484
|
+
options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
485
|
+
_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
|
|
486
|
+
if (Array.isArray(userIds)) {
|
|
487
|
+
_context4.n = 1;
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
throw new Error('userIds must be an array');
|
|
491
|
+
case 1:
|
|
492
|
+
if (Array.isArray(groupIds)) {
|
|
493
|
+
_context4.n = 2;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
throw new Error('groupIds must be an array');
|
|
497
|
+
case 2:
|
|
498
|
+
// Get current IAC settings
|
|
499
|
+
iac = this.get('iac') || {}; // Determine which grant type to update (read or write)
|
|
500
|
+
grantType = write ? 'writeGrants' : 'readGrants'; // Initialize grants if they don't exist
|
|
501
|
+
if (!iac[grantType]) {
|
|
502
|
+
iac[grantType] = {};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Handle users
|
|
506
|
+
if (userIds.length > 0) {
|
|
507
|
+
if (replace) {
|
|
508
|
+
// Replace existing users
|
|
509
|
+
iac[grantType].users = _toConsumableArray(userIds);
|
|
510
|
+
} else {
|
|
511
|
+
// Merge with existing users (avoiding duplicates)
|
|
512
|
+
existingUsers = iac[grantType].users || [];
|
|
513
|
+
mergedUsers = _toConsumableArray(new Set([].concat(_toConsumableArray(existingUsers), _toConsumableArray(userIds))));
|
|
514
|
+
iac[grantType].users = mergedUsers;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Handle user groups
|
|
519
|
+
if (groupIds.length > 0) {
|
|
520
|
+
if (replace) {
|
|
521
|
+
// Replace existing groups
|
|
522
|
+
iac[grantType].userGroups = _toConsumableArray(groupIds);
|
|
523
|
+
} else {
|
|
524
|
+
// Merge with existing groups (avoiding duplicates)
|
|
525
|
+
existingGroups = iac[grantType].userGroups || [];
|
|
526
|
+
mergedGroups = _toConsumableArray(new Set([].concat(_toConsumableArray(existingGroups), _toConsumableArray(groupIds))));
|
|
527
|
+
iac[grantType].userGroups = mergedGroups;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Update the object
|
|
532
|
+
this.set('iac', iac);
|
|
533
|
+
|
|
534
|
+
// Save if requested
|
|
535
|
+
if (!save) {
|
|
536
|
+
_context4.n = 4;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
_context4.n = 3;
|
|
540
|
+
return this.save();
|
|
541
|
+
case 3:
|
|
542
|
+
return _context4.a(2, _context4.v);
|
|
543
|
+
case 4:
|
|
544
|
+
return _context4.a(2, this);
|
|
545
|
+
}
|
|
546
|
+
}, _callee4, this);
|
|
547
|
+
}));
|
|
548
|
+
function grantAccess() {
|
|
549
|
+
return _grantAccess.apply(this, arguments);
|
|
550
|
+
}
|
|
551
|
+
return grantAccess;
|
|
552
|
+
}()
|
|
553
|
+
/**
|
|
554
|
+
* Publishes this object to make it publicly accessible (or unpublishes it).
|
|
555
|
+
* Adds or removes 'public_user' from the IAC read permissions.
|
|
556
|
+
*
|
|
557
|
+
* @param {Object} options - Publishing options
|
|
558
|
+
* @param {boolean} [options.publish=true] - If true, publishes the object; if false, unpublishes it
|
|
559
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
560
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* // Publish an object (make it public)
|
|
564
|
+
* await myObject.publishObject();
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* // Unpublish an object (make it private)
|
|
568
|
+
* await myObject.publishObject({ publish: false });
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* // Publish without auto-saving
|
|
572
|
+
* await myObject.publishObject({ save: false });
|
|
573
|
+
* // ... make other changes ...
|
|
574
|
+
* await myObject.save();
|
|
575
|
+
*/
|
|
576
|
+
)
|
|
577
|
+
}, {
|
|
578
|
+
key: "publishObject",
|
|
579
|
+
value: (function () {
|
|
580
|
+
var _publishObject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
581
|
+
var options,
|
|
582
|
+
_options$publish,
|
|
583
|
+
publish,
|
|
584
|
+
_options$save2,
|
|
585
|
+
save,
|
|
586
|
+
iac,
|
|
587
|
+
_args5 = arguments;
|
|
588
|
+
return _regenerator().w(function (_context5) {
|
|
589
|
+
while (1) switch (_context5.n) {
|
|
590
|
+
case 0:
|
|
591
|
+
options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
|
592
|
+
_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
|
|
593
|
+
iac = this.get('iac') || {}; // Initialize readGrants if it doesn't exist
|
|
594
|
+
if (!iac.readGrants) {
|
|
595
|
+
iac.readGrants = {};
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Initialize users array if it doesn't exist
|
|
599
|
+
if (!Array.isArray(iac.readGrants.users)) {
|
|
600
|
+
iac.readGrants.users = [];
|
|
601
|
+
}
|
|
602
|
+
if (publish) {
|
|
603
|
+
// Add public_user if not already present
|
|
604
|
+
if (!iac.readGrants.users.includes('public_user')) {
|
|
605
|
+
iac.readGrants.users.push('public_user');
|
|
606
|
+
}
|
|
607
|
+
} else {
|
|
608
|
+
// Remove public_user
|
|
609
|
+
iac.readGrants.users = iac.readGrants.users.filter(function (userId) {
|
|
610
|
+
return userId !== 'public_user';
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// Update the object
|
|
615
|
+
this.set('iac', iac);
|
|
616
|
+
|
|
617
|
+
// Save if requested
|
|
618
|
+
if (!save) {
|
|
619
|
+
_context5.n = 2;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
_context5.n = 1;
|
|
623
|
+
return this.save();
|
|
624
|
+
case 1:
|
|
625
|
+
return _context5.a(2, _context5.v);
|
|
626
|
+
case 2:
|
|
627
|
+
return _context5.a(2, this);
|
|
628
|
+
}
|
|
629
|
+
}, _callee5, this);
|
|
630
|
+
}));
|
|
631
|
+
function publishObject() {
|
|
632
|
+
return _publishObject.apply(this, arguments);
|
|
633
|
+
}
|
|
634
|
+
return publishObject;
|
|
635
|
+
}()
|
|
636
|
+
/**
|
|
637
|
+
* Unpublishes this object to remove public access.
|
|
638
|
+
* Removes 'public_user' from the IAC read permissions.
|
|
639
|
+
* This is an alias for publishObject({ publish: false }) for better code clarity.
|
|
640
|
+
*
|
|
641
|
+
* @param {Object} options - Unpublishing options
|
|
642
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
643
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* // Unpublish an object (remove public access)
|
|
647
|
+
* await myObject.unpublishObject();
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* // Unpublish without auto-saving
|
|
651
|
+
* await myObject.unpublishObject({ save: false });
|
|
652
|
+
* // ... make other changes ...
|
|
653
|
+
* await myObject.save();
|
|
654
|
+
*/
|
|
655
|
+
)
|
|
656
|
+
}, {
|
|
657
|
+
key: "unpublishObject",
|
|
658
|
+
value: (function () {
|
|
659
|
+
var _unpublishObject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
660
|
+
var options,
|
|
661
|
+
_args6 = arguments;
|
|
662
|
+
return _regenerator().w(function (_context6) {
|
|
663
|
+
while (1) switch (_context6.n) {
|
|
664
|
+
case 0:
|
|
665
|
+
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
666
|
+
_context6.n = 1;
|
|
667
|
+
return this.publishObject({
|
|
668
|
+
publish: false,
|
|
669
|
+
save: options.save !== undefined ? options.save : true
|
|
670
|
+
});
|
|
671
|
+
case 1:
|
|
672
|
+
return _context6.a(2, _context6.v);
|
|
673
|
+
}
|
|
674
|
+
}, _callee6, this);
|
|
675
|
+
}));
|
|
676
|
+
function unpublishObject() {
|
|
677
|
+
return _unpublishObject.apply(this, arguments);
|
|
678
|
+
}
|
|
679
|
+
return unpublishObject;
|
|
680
|
+
}()
|
|
681
|
+
/**
|
|
682
|
+
* Revokes access from specific users and/or user groups.
|
|
683
|
+
*
|
|
684
|
+
* @param {Object} options - Access revocation options
|
|
685
|
+
* @param {string[]} [options.userIds=[]] - Array of user IDs to remove from read or write access
|
|
686
|
+
* @param {string[]} [options.groupIds=[]] - Array of group IDs to remove from read or write access
|
|
687
|
+
* @param {boolean} [options.write=false] - If true, removes write access; if false, removes read access
|
|
688
|
+
* @param {boolean} [options.save=true] - If true, automatically saves the object after updating permissions
|
|
689
|
+
* @returns {Promise<RbtObject>} - Returns this object (saved if options.save is true)
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* // Revoke read access from specific users
|
|
693
|
+
* await myObject.revokeAccess({
|
|
694
|
+
* userIds: ['user_123', 'user_456']
|
|
695
|
+
* });
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
* // Revoke write access from specific groups
|
|
699
|
+
* await myObject.revokeAccess({
|
|
700
|
+
* groupIds: ['grpEditors'],
|
|
701
|
+
* write: true
|
|
702
|
+
* });
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* // Revoke access from users and groups
|
|
706
|
+
* await myObject.revokeAccess({
|
|
707
|
+
* userIds: ['user_123'],
|
|
708
|
+
* groupIds: ['grpViewers']
|
|
709
|
+
* });
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* // Revoke without auto-saving
|
|
713
|
+
* await myObject.revokeAccess({
|
|
714
|
+
* userIds: ['user_123'],
|
|
715
|
+
* save: false
|
|
716
|
+
* });
|
|
717
|
+
*/
|
|
718
|
+
)
|
|
719
|
+
}, {
|
|
720
|
+
key: "revokeAccess",
|
|
721
|
+
value: (function () {
|
|
722
|
+
var _revokeAccess = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
723
|
+
var options,
|
|
724
|
+
_options$userIds2,
|
|
725
|
+
userIds,
|
|
726
|
+
_options$groupIds2,
|
|
727
|
+
groupIds,
|
|
728
|
+
_options$write2,
|
|
729
|
+
write,
|
|
730
|
+
_options$save3,
|
|
731
|
+
save,
|
|
732
|
+
iac,
|
|
733
|
+
grantType,
|
|
734
|
+
_args7 = arguments;
|
|
735
|
+
return _regenerator().w(function (_context7) {
|
|
736
|
+
while (1) switch (_context7.n) {
|
|
737
|
+
case 0:
|
|
738
|
+
options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
739
|
+
_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
|
|
740
|
+
if (Array.isArray(userIds)) {
|
|
741
|
+
_context7.n = 1;
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
throw new Error('userIds must be an array');
|
|
745
|
+
case 1:
|
|
746
|
+
if (Array.isArray(groupIds)) {
|
|
747
|
+
_context7.n = 2;
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
throw new Error('groupIds must be an array');
|
|
751
|
+
case 2:
|
|
752
|
+
// Get current IAC settings
|
|
753
|
+
iac = this.get('iac') || {}; // Determine which grant type to update (read or write)
|
|
754
|
+
grantType = write ? 'writeGrants' : 'readGrants'; // Initialize grants if they don't exist
|
|
755
|
+
if (!iac[grantType]) {
|
|
756
|
+
iac[grantType] = {};
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// Remove specified users
|
|
760
|
+
if (userIds.length > 0 && Array.isArray(iac[grantType].users)) {
|
|
761
|
+
iac[grantType].users = iac[grantType].users.filter(function (userId) {
|
|
762
|
+
return !userIds.includes(userId);
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Remove specified groups
|
|
767
|
+
if (groupIds.length > 0 && Array.isArray(iac[grantType].userGroups)) {
|
|
768
|
+
iac[grantType].userGroups = iac[grantType].userGroups.filter(function (groupId) {
|
|
769
|
+
return !groupIds.includes(groupId);
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// Update the object
|
|
774
|
+
this.set('iac', iac);
|
|
775
|
+
|
|
776
|
+
// Save if requested
|
|
777
|
+
if (!save) {
|
|
778
|
+
_context7.n = 4;
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
_context7.n = 3;
|
|
782
|
+
return this.save();
|
|
783
|
+
case 3:
|
|
784
|
+
return _context7.a(2, _context7.v);
|
|
785
|
+
case 4:
|
|
786
|
+
return _context7.a(2, this);
|
|
787
|
+
}
|
|
788
|
+
}, _callee7, this);
|
|
789
|
+
}));
|
|
790
|
+
function revokeAccess() {
|
|
791
|
+
return _revokeAccess.apply(this, arguments);
|
|
792
|
+
}
|
|
793
|
+
return revokeAccess;
|
|
794
|
+
}()
|
|
795
|
+
/**
|
|
796
|
+
* Checks if this object is currently published (publicly accessible).
|
|
797
|
+
*
|
|
798
|
+
* @returns {boolean} - True if 'public_user' is in the read grants, false otherwise
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* if (myObject.isPublished()) {
|
|
802
|
+
* console.log('Object is public');
|
|
803
|
+
* }
|
|
804
|
+
*/
|
|
805
|
+
)
|
|
806
|
+
}, {
|
|
807
|
+
key: "isPublished",
|
|
808
|
+
value: function isPublished() {
|
|
809
|
+
var iac = this.get('iac');
|
|
810
|
+
if (!iac || !iac.readGrants || !Array.isArray(iac.readGrants.users)) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
return iac.readGrants.users.includes('public_user');
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Gets the current sharing permissions for this object.
|
|
818
|
+
*
|
|
819
|
+
* @returns {Object} - Object containing read and write grants
|
|
820
|
+
* @returns {Object} returns.readGrants - Read access grants
|
|
821
|
+
* @returns {string[]} returns.readGrants.users - Array of user IDs with read access
|
|
822
|
+
* @returns {string[]} returns.readGrants.userGroups - Array of group IDs with read access
|
|
823
|
+
* @returns {string[]} returns.readGrants.organizations - Array of organization IDs with read access
|
|
824
|
+
* @returns {Object} returns.writeGrants - Write access grants
|
|
825
|
+
* @returns {string[]} returns.writeGrants.users - Array of user IDs with write access
|
|
826
|
+
* @returns {string[]} returns.writeGrants.userGroups - Array of group IDs with write access
|
|
827
|
+
* @returns {string[]} returns.writeGrants.organizations - Array of organization IDs with write access
|
|
828
|
+
*
|
|
829
|
+
* @example
|
|
830
|
+
* const permissions = myObject.getSharing();
|
|
831
|
+
* console.log('Read users:', permissions.readGrants.users);
|
|
832
|
+
* console.log('Read groups:', permissions.readGrants.userGroups);
|
|
833
|
+
*/
|
|
834
|
+
}, {
|
|
835
|
+
key: "getSharing",
|
|
836
|
+
value: function getSharing() {
|
|
837
|
+
var _iac$readGrants, _iac$readGrants2, _iac$readGrants3, _iac$readGrants4, _iac$writeGrants, _iac$writeGrants2, _iac$writeGrants3, _iac$writeGrants4;
|
|
838
|
+
var iac = this.get('iac') || {};
|
|
839
|
+
return {
|
|
840
|
+
readGrants: {
|
|
841
|
+
users: ((_iac$readGrants = iac.readGrants) === null || _iac$readGrants === void 0 ? void 0 : _iac$readGrants.users) || [],
|
|
842
|
+
userGroups: ((_iac$readGrants2 = iac.readGrants) === null || _iac$readGrants2 === void 0 ? void 0 : _iac$readGrants2.userGroups) || [],
|
|
843
|
+
organizations: ((_iac$readGrants3 = iac.readGrants) === null || _iac$readGrants3 === void 0 ? void 0 : _iac$readGrants3.organizations) || [],
|
|
844
|
+
userSegments: ((_iac$readGrants4 = iac.readGrants) === null || _iac$readGrants4 === void 0 ? void 0 : _iac$readGrants4.userSegments) || []
|
|
845
|
+
},
|
|
846
|
+
writeGrants: {
|
|
847
|
+
users: ((_iac$writeGrants = iac.writeGrants) === null || _iac$writeGrants === void 0 ? void 0 : _iac$writeGrants.users) || [],
|
|
848
|
+
userGroups: ((_iac$writeGrants2 = iac.writeGrants) === null || _iac$writeGrants2 === void 0 ? void 0 : _iac$writeGrants2.userGroups) || [],
|
|
849
|
+
organizations: ((_iac$writeGrants3 = iac.writeGrants) === null || _iac$writeGrants3 === void 0 ? void 0 : _iac$writeGrants3.organizations) || [],
|
|
850
|
+
userSegments: ((_iac$writeGrants4 = iac.writeGrants) === null || _iac$writeGrants4 === void 0 ? void 0 : _iac$writeGrants4.userSegments) || []
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
411
854
|
}, {
|
|
412
855
|
key: "delete",
|
|
413
856
|
value: function () {
|
|
414
|
-
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
857
|
+
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
415
858
|
var record, response, _t2;
|
|
416
|
-
return _regenerator().w(function (
|
|
417
|
-
while (1) switch (
|
|
859
|
+
return _regenerator().w(function (_context8) {
|
|
860
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
418
861
|
case 0:
|
|
419
862
|
if (this._internalData.type) {
|
|
420
|
-
|
|
863
|
+
_context8.n = 1;
|
|
421
864
|
break;
|
|
422
865
|
}
|
|
423
866
|
throw new Error('Cannot delete object without type');
|
|
424
867
|
case 1:
|
|
425
|
-
|
|
868
|
+
_context8.p = 1;
|
|
426
869
|
record = this.toRecord();
|
|
427
|
-
|
|
870
|
+
_context8.n = 2;
|
|
428
871
|
return this._axios.post('/object_service/deleteObject', {
|
|
429
872
|
id: record.id,
|
|
430
873
|
type: record.type
|
|
431
874
|
});
|
|
432
875
|
case 2:
|
|
433
|
-
response =
|
|
876
|
+
response = _context8.v;
|
|
434
877
|
if (!(response.data.ok === false)) {
|
|
435
|
-
|
|
878
|
+
_context8.n = 3;
|
|
436
879
|
break;
|
|
437
880
|
}
|
|
438
881
|
throw new Error(response.data.message);
|
|
439
882
|
case 3:
|
|
440
883
|
this._internalData = response.data;
|
|
441
|
-
return
|
|
884
|
+
return _context8.a(2, this);
|
|
442
885
|
case 4:
|
|
443
|
-
|
|
444
|
-
_t2 =
|
|
886
|
+
_context8.p = 4;
|
|
887
|
+
_t2 = _context8.v;
|
|
445
888
|
console.log('RbtObject.delete.error:');
|
|
446
889
|
console.log(_t2.response.data);
|
|
447
890
|
throw _t2;
|
|
448
891
|
case 5:
|
|
449
|
-
return
|
|
892
|
+
return _context8.a(2);
|
|
450
893
|
}
|
|
451
|
-
},
|
|
894
|
+
}, _callee8, this, [[1, 4]]);
|
|
452
895
|
}));
|
|
453
896
|
function _delete() {
|
|
454
897
|
return _delete2.apply(this, arguments);
|
package/package.json
CHANGED
package/src/rbt_api.js
CHANGED
|
@@ -693,6 +693,10 @@ export default class RbtApi {
|
|
|
693
693
|
* - limit: An object to control the pagination of results. It includes:
|
|
694
694
|
* - offset: The starting point from where to fetch the results.
|
|
695
695
|
* - results: The maximum number of results to return.
|
|
696
|
+
* - requestAttrs: An array of attribute paths to include in the response (e.g., ['id', 'configs.title', 'configs.description']).
|
|
697
|
+
* If not provided, all attributes are returned.
|
|
698
|
+
* - excludeAttrs: An array of attribute paths to exclude from the response (e.g., ['details.log', 'internalData']).
|
|
699
|
+
* Excludes the specified paths and all their subpaths.
|
|
696
700
|
* - resolveReferences: An array of attribute names whose references should be resolved in the returned objects.
|
|
697
701
|
* - timeout: A numerical value in milliseconds to set a maximum time limit for the query execution.
|
|
698
702
|
*
|
|
@@ -701,6 +705,8 @@ export default class RbtApi {
|
|
|
701
705
|
* where: 'email="tom@pospa.com"',
|
|
702
706
|
* orderBy: { column: 'timeCreated', direction: 'DESC' },
|
|
703
707
|
* limit: { offset: 0, results: 50 },
|
|
708
|
+
* requestAttrs: ['id', 'configs.title'],
|
|
709
|
+
* excludeAttrs: ['details.log'],
|
|
704
710
|
* resolveReferences: ['translatableContent']
|
|
705
711
|
* });
|
|
706
712
|
*
|
|
@@ -712,6 +718,19 @@ export default class RbtApi {
|
|
|
712
718
|
let paramsKey;
|
|
713
719
|
try {
|
|
714
720
|
//console.log('RBTAPI.query INIT', type, params);
|
|
721
|
+
|
|
722
|
+
// Validate parameters - reject invalid parameter names
|
|
723
|
+
const validParams = ['type', 'where', 'orderBy', 'limit', 'resolveReferences', 'requestAttrs', 'excludeAttrs', 'timeout', 'enableRealtime'];
|
|
724
|
+
const invalidParams = Object.keys(params).filter(key => !validParams.includes(key));
|
|
725
|
+
if (invalidParams.length > 0) {
|
|
726
|
+
throw new Error(`Invalid query parameter(s): ${invalidParams.join(', ')}. Valid parameters are: ${validParams.join(', ')}`);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// Warn if enableRealtime is passed to query() - it should only be used by load()
|
|
730
|
+
if (params.enableRealtime) {
|
|
731
|
+
console.warn('[roboto-js] enableRealtime should not be passed to query(), only to load(). This parameter will be ignored.');
|
|
732
|
+
}
|
|
733
|
+
|
|
715
734
|
params.type = type;
|
|
716
735
|
|
|
717
736
|
// Default ordering and pagination
|
|
@@ -843,7 +862,9 @@ export default class RbtApi {
|
|
|
843
862
|
this._loggedCacheEvents.add(bulkMissLogKey);
|
|
844
863
|
}
|
|
845
864
|
|
|
846
|
-
|
|
865
|
+
// Remove load-specific params that shouldn't be passed to query
|
|
866
|
+
const { enableRealtime, ...queryParams } = params;
|
|
867
|
+
mergedParams = { ...queryParams, where: `id IN ("${missingIds.join(`","`)}")` };
|
|
847
868
|
loadedObjects = await this.query(type, mergedParams);
|
|
848
869
|
|
|
849
870
|
// Cache the newly loaded objects
|
|
@@ -913,7 +934,9 @@ export default class RbtApi {
|
|
|
913
934
|
// Create the loading promise and store it to prevent duplicate requests
|
|
914
935
|
const loadPromise = (async () => {
|
|
915
936
|
try {
|
|
916
|
-
|
|
937
|
+
// Remove load-specific params that shouldn't be passed to query
|
|
938
|
+
const { enableRealtime, ...queryParams } = params;
|
|
939
|
+
mergedParams = { ...queryParams, where: `id="${ids}"` };
|
|
917
940
|
let res = await this.query(type, mergedParams);
|
|
918
941
|
const obj = res[0];
|
|
919
942
|
|