packages/graphstore-dev/src/firebase/jparser.js
function cleanItem3(value, parent) {

        var newvalue = null;

        if (Array.isArray(value)) {
            newvalue = [];

            var isAllNumbers = (value.length > 0);
            var isAllStrings = (value.length > 0)
            value.forEach(function (item) {
                if (typeof item !== 'number')
                    isAllNumbers = false;

                if (typeof item !== 'string')
                    isAllStrings = false;
            })

            if (isAllNumbers)
                return [cleanItem3(value[0], parent)];

            if (isAllStrings) {
                var enumKey = "Enum" + getTypeFromKey(parent);
                var hash = value.join("!");
                if (hash in enumFromHash)
                    enumKey = enumFromHash[hash]
                else {
                    var found = true;
                    value.forEach(function (key) {
                        if (!(key in enumFromKey)) found = false;
                    })

                    if (found) {
                        enumKey = enumFromKey[value[0]];
                    } else {
                        enums[enumKey] = value;
                        enumFromHash[hash] = enumKey;

                        value.forEach(function (key) {
                            enumFromKey[key] = "Enum" + getTypeFromKey(parent);
                        })
                    }
                }
                return [enumKey];
            }

            value.forEach(function (item) {
                newvalue.push(cleanItem3(item, parent));
            })

            return newvalue;
        }

        if ((typeof value !== "object") || (value == null)) {
            switch (typeof value) {
                case 'string':
                    if (isId(value)) return 'ID';
                    if (isUser(value)) return 'UserId';
                    if (isUserOrgPrefix(value)) return 'UserOrOrgIdPrefixed';
                    if (ids[value] == "orgs") return 'OrgId';
                    if (ids[value] == "roles") return 'EnumConfigRole';
                    if (value in enumDefaultKeys.values) return enumDefaultKeys.values[value];
                    if (ids[value]) return ids[value] + "Id";
                    return 'String';
                case 'number':
                    if (value > 1300000000 && value < 1700000000)
                        return value % 1 == 0 ? 'Date' : 'Time'
                    return value % 1 == 0 ? 'Int' : 'Float'
                case 'boolean':
                    return 'Boolean';
                default:
                    return value == null ? 'NULL' : value;
            }
        }

        var newvalue = {};

        Object.keys(value).forEach(function (key) {
            newvalue[key] = cleanItem3(value[key], parent + key.substr(0, 1).toUpperCase() + key.substr(1));
        });

        return newvalue;
    }
function cleanItem3(value, parent) {

        var newvalue = null;

        if (Array.isArray(value)) {
            newvalue = [];

            var isAllNumbers = (value.length > 0);
            var isAllStrings = (value.length > 0)
            value.forEach(function (item) {
                if (typeof item !== 'number')
                    isAllNumbers = false;

                if (typeof item !== 'string')
                    isAllStrings = false;
            })

            if (isAllNumbers)
                return [cleanItem3(value[0], parent)];

            if (isAllStrings) {
                var enumKey = "Enum" + getTypeFromKey(parent);
                var hash = value.join("!");
                if (hash in enumFromHash)
                    enumKey = enumFromHash[hash]
                else {
                    var found = true;
                    value.forEach(function (key) {
                        if (!(key in enumFromKey)) found = false;
                    })

                    if (found) {
                        enumKey = enumFromKey[value[0]];
                    } else {
                        enums[enumKey] = value;
                        enumFromHash[hash] = enumKey;

                        value.forEach(function (key) {
                            enumFromKey[key] = "Enum" + getTypeFromKey(parent);
                        })
                    }
                }
                return [enumKey];
            }

            value.forEach(function (item) {
                newvalue.push(cleanItem3(item, parent));
            })

            return newvalue;
        }

        if ((typeof value !== "object") || (value == null)) {
            switch (typeof value) {
                case 'string':
                    if (isId(value)) return 'ID';
                    if (isUser(value)) return 'UserId';
                    if (isUserOrgPrefix(value)) return 'UserOrOrgIdPrefixed';
                    if (ids[value] == "orgs") return 'OrgId';
                    if (ids[value] == "roles") return 'EnumConfigRole';
                    if (value in enumDefaultKeys.values) return enumDefaultKeys.values[value];
                    if (ids[value]) return ids[value] + "Id";
                    return 'String';
                case 'number':
                    if (value > 1300000000 && value < 1700000000)
                        return value % 1 == 0 ? 'Date' : 'Time'
                    return value % 1 == 0 ? 'Int' : 'Float'
                case 'boolean':
                    return 'Boolean';
                default:
                    return value == null ? 'NULL' : value;
            }
        }

        var newvalue = {};

        Object.keys(value).forEach(function (key) {
            newvalue[key] = cleanItem3(value[key], parent + key.substr(0, 1).toUpperCase() + key.substr(1));
        });

        return newvalue;
    }
function cleanItem3 ( value , parent ) { var newvalue = null ; if ( Array . isArray ( value ) ) { newvalue = [ ] ; var isAllNumbers = ( value . length > 0 ) ; var isAllStrings = ( value . length > 0 ) value . forEach ( function ( item ) { if ( typeof item !== 'number' ) isAllNumbers = false ; if ( typeof item !== 'string' ) isAllStrings = false ; } ) if ( isAllNumbers ) return [ cleanItem3 ( value [ 0 ] , parent ) ] ; if ( isAllStrings ) { var enumKey = "Enum" + getTypeFromKey ( parent ) ; var hash = value . join ( "!" ) ; if ( hash in enumFromHash ) enumKey = enumFromHash [ hash ] else { var found = true ; value . forEach ( function ( key ) { if ( ! ( key in enumFromKey ) ) found = false ; } ) if ( found ) { enumKey = enumFromKey [ value [ 0 ] ] ; } else { enums [ enumKey ] = value ; enumFromHash [ hash ] = enumKey ; value . forEach ( function ( key ) { enumFromKey [ key ] = "Enum" + getTypeFromKey ( parent ) ; } ) } } return [ enumKey ] ; } value . forEach ( function ( item ) { newvalue . push ( cleanItem3 ( item , parent ) ) ; } ) return newvalue ; } if ( ( typeof value !== "object" ) || ( value == null ) ) { switch ( typeof value ) { case 'string' : if ( isId ( value ) ) return 'ID' ; if ( isUser ( value ) ) return 'UserId' ; if ( isUserOrgPrefix ( value ) ) return 'UserOrOrgIdPrefixed' ; if ( ids [ value ] == "orgs" ) return 'OrgId' ; if ( ids [ value ] == "roles" ) return 'EnumConfigRole' ; if ( value in enumDefaultKeys . values ) return enumDefaultKeys . values [ value ] ; if ( ids [ value ] ) return ids [ value ] + "Id" ; return 'String' ; case 'number' : if ( value > 1300000000 && value < 1700000000 ) return value % 1 == 0 ? 'Date' : 'Time' return value % 1 == 0 ? 'Int' : 'Float' case 'boolean' : return 'Boolean' ; default : return value == null ? 'NULL' : value ; } } var newvalue = { } ; Object . keys ( value ) . forEach ( function ( key ) { newvalue [ key ] = cleanItem3 ( value [ key ] , parent + key . substr ( 0 , 1 ) . toUpperCase ( ) + key . substr ( 1 ) ) ; } ) ; return newvalue ; }
REMOVE DUPLICATE ENTITIES INSTANCE STRUCTURES
REMOVE DUPLICATE ENTITIES INSTANCE STRUCTURES