| 383 | }; |
| 384 | // Transforms a Database format ACL to a REST API format ACL |
| 385 | const untransformObjectACL = ({ _rperm, _wperm, ...output }) => { |
| 386 | if (_rperm || _wperm) { |
| 387 | output.ACL = {}; |
| 388 | |
| 389 | (_rperm || []).forEach(entry => { |
| 390 | if (!output.ACL[entry]) { |
| 391 | output.ACL[entry] = { read: true }; |
| 392 | } else { |
| 393 | output.ACL[entry]['read'] = true; |
| 394 | } |
| 395 | }); |
| 396 | |
| 397 | (_wperm || []).forEach(entry => { |
| 398 | if (!output.ACL[entry]) { |
| 399 | output.ACL[entry] = { write: true }; |
| 400 | } else { |
| 401 | output.ACL[entry]['write'] = true; |
| 402 | } |
| 403 | }); |
| 404 | } |
| 405 | return output; |
| 406 | }; |
| 407 | |
| 408 | /** |
| 409 | * When querying, the fieldName may be compound, extract the root fieldName |