import { cloneDeep , compact , isPlainObject } from "lodash-es" ; import { v4 } from "uuid" ; export function isQuery ( dataId ) { return dataId === "ROOT_QUERY" || dataId === "ROOT_MUTATION" ; } /**
 * Returns a store entity ID matching the path at which the entity is found in the entity store.
 * For a store entity of a normalized type, the entity ID would be the data ID:
 * ex. Employee:1
 * For a store entity of a query, the entity ID would be the root operation plus the field name if specified:
 * ex. ROOT_QUERY.employees
 */ export function makeEntityId ( dataId , fieldName ? ) { if ( isQuery ( dataId ) ) { return compact ( [ dataId , fieldName ] ) . join ( "." ) ; } return dataId ; } export const maybeDeepClone = ( obj ) => isPlainObject ( obj ) && Object . isFrozen ( obj ) ? cloneDeep ( obj ) : obj ; export var TypeOrFieldNameRegExp = /^[_a-z][_0-9a-z]*/i ; export function fieldNameFromStoreName ( storeFieldName ) { var match = storeFieldName . match ( TypeOrFieldNameRegExp ) ; return match ? match [ 0 ] : storeFieldName ; } export function generateFragmentFieldName ( ) { return `-fragment-${ v4 ( ) }` ; }