All files / apps/data-refreshments/src/refreshments-execute/sync/mappers users-id-source.mapper.ts

100% Statements 26/26
100% Branches 6/6
100% Functions 2/2
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 23x 23x 23x 23x 23x 1x 1x 19x 19x 19x 19x 19x  
import { upperCase } from 'lodash-es';
 
import { type DataConnectorTypes } from '@amalia/data-capture/connectors/types';
import { isEnum } from '@amalia/ext/typescript';
import { UserExternalIdSource, UserHrisIdSource } from '@amalia/tenants/users/types';
 
/**
 * A function that maps a connector type to an externalIdSource.\
 * If the connector type is not a valid externalIdSource, it returns OTHERSOURCE.
 *
 * @param connectorType
 * @returns
 */
export const toExternalIdSource = (connectorType: DataConnectorTypes): UserExternalIdSource => {
  const connectorTypeUppercase = upperCase(connectorType);
  const isValidExternalIdSource = isEnum(connectorTypeUppercase, UserExternalIdSource);
 
  return isValidExternalIdSource ? connectorTypeUppercase : UserExternalIdSource.OTHERSOURCE;
};
 
export const toHrisIdSource = (connectorType: DataConnectorTypes): UserHrisIdSource => {
  const connectorTypeUppercase = upperCase(connectorType);
  const isValidHrisIdSource = isEnum(connectorTypeUppercase, UserHrisIdSource);
 
  return isValidHrisIdSource ? connectorTypeUppercase : UserHrisIdSource.OTHERSOURCE;
};