
# Service Library - `projectPortfolio`

This document provides a complete reference of the custom code library for the `projectPortfolio` service. It includes all library functions, edge functions with their REST endpoints, templates, and assets.


## Library Functions

Library functions are reusable modules available to all business APIs and other custom code within the service via `require("lib/<moduleName>")`.


### `isUserGrantedAccess.js`

```js
const { fetchRemoteObjectByMQuery } = require('serviceCommon');
module.exports = async function isUserGrantedAccess(projectId, userId) {
  if(!projectId || !userId) return false;
  const grant = await fetchRemoteObjectByMQuery('accessGrant', { projectId, granteeUserId: userId, status: 'granted' });
  return !!grant;
};
```


### `listProjectIdsGrantedToUser.js`

```js
const { fetchRemoteListByMQuery } = require('serviceCommon');
module.exports = async function listProjectIdsGrantedToUser(userId) {
  if(!userId) return [];
  const grants = await fetchRemoteListByMQuery('accessGrant', { granteeUserId: userId, status: 'granted' }, 0, 1000);
  return grants.map(g=>g.projectId);
};
```














---

*This document was generated from the service library configuration and should be kept in sync with design changes.*
