UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

68 lines 2.45 kB
/** * 2025-01-04: MOVE THIS TO fps-core-v7 * * Refactored from node_modules\@mikezimm\fps-library-v2\lib\pnpjs\Users\calls\buildValueUserInfos * * node_modules\@mikezimm\fps-library-v2\lib\pnpjs\Users\interfaces\IValueUserInfos * */ /** * Moved these to separate files * @param theseUsers * @param props * @param realPeopleOnly * @returns */ // export type IValidUserProp = 'Id' | 'Title' | 'Name' | 'Email'; // export interface IValueUserInfos { // Ids: number[]; // Titles: string[]; // Names: string[]; // Emails: string[]; // Users: (ISiteGroupInfo | ISiteUserInfo)[]; // Props: IValidUserProp[]; // result: IFpsRoleAssignmentInfo; // } export function buildValueUserInfosV2(theseUsers, props, realPeopleOnly) { const validUserInfos = { Ids: [], Titles: [], Names: [], Emails: [], Users: [], Props: props, result: null, }; theseUsers.map(Member => { //UserId is typically an object with keys: NameIdIssuer & NameId. Only getting users with that const { Id, Title, LoginName, PrincipalType } = Member; /** * 2024-01-04: * enum: PrincipalType is on both ISiteGroupInfo and ISiteUserProps * Going forward, going to use PrincipalType = 1 to verify if it's a user per the docs. * * NOTES from PRIOR Logic: * Through testing, found that system accounts have a LoginName but NOT UserPrincipalName * So for "real test", I'm using UserPrincipalName to check. */ const isReal = PrincipalType === 1 ? true : false; const Email = Member['Email']; if (isReal === true || realPeopleOnly === false) { if (props.indexOf('Id') > -1 && Id && Id > -1) { validUserInfos.Ids.push(Id); } if (props.indexOf('Title') > -1 && Title) { validUserInfos.Titles.push(Title); } if (props.indexOf('Name') > -1 && LoginName) { validUserInfos.Names.push(LoginName); } if (props.indexOf('Email') > -1 && Email) { validUserInfos.Emails.push(Email); } validUserInfos.Users.push(Member); } }); return validUserInfos; } //# sourceMappingURL=buildValueUserInfoV2.js.map