(group, sourceId)
| 821 | } |
| 822 | |
| 823 | function pickGroupGrantsForSource(group, sourceId) { |
| 824 | if (!group || typeof group !== 'object') return {}; |
| 825 | const sid = normalizeSourceId(sourceId); |
| 826 | const bySource = (group.grantsBySource && typeof group.grantsBySource === 'object' && !Array.isArray(group.grantsBySource)) |
| 827 | ? group.grantsBySource |
| 828 | : null; |
| 829 | if (bySource) { |
| 830 | if (sid && Object.prototype.hasOwnProperty.call(bySource, sid)) { |
| 831 | const candidate = bySource[sid]; |
| 832 | return (candidate && typeof candidate === 'object' && !Array.isArray(candidate)) ? candidate : {}; |
| 833 | } |
| 834 | if (!sid && Object.prototype.hasOwnProperty.call(bySource, 'local')) { |
| 835 | const candidate = bySource.local; |
| 836 | return (candidate && typeof candidate === 'object' && !Array.isArray(candidate)) ? candidate : {}; |
| 837 | } |
| 838 | if (isLocalSourceId(sid)) { |
| 839 | const legacy = group.grants; |
| 840 | return (legacy && typeof legacy === 'object' && !Array.isArray(legacy)) ? legacy : {}; |
| 841 | } |
| 842 | return {}; |
| 843 | } |
| 844 | if (isLocalSourceId(sid)) { |
| 845 | const legacy = group.grants; |
| 846 | return (legacy && typeof legacy === 'object' && !Array.isArray(legacy)) ? legacy : {}; |
| 847 | } |
| 848 | return {}; |
| 849 | } |
| 850 | |
| 851 | function setGroupGrantsForSource(group, sourceId, grants) { |
| 852 | if (!group || typeof group !== 'object') return; |
no test coverage detected