dist/index.cjs.js
function pluginMutations (userState) {
    return {
        SET_PATHVARS: function (state, pathVars) {
            var self = this;
            Object.keys(pathVars).forEach(function (key) {
                var pathPiece = pathVars[key];
                self._vm.$set(state._sync.pathVariables, key, pathPiece);
            });
        },
        SET_SYNCFILTERS: function (state, _a) {
            var where = _a.where, orderBy = _a.orderBy;
            if (where && isWhat.isArray(where))
                state._conf.sync.where = where;
            if (orderBy && isWhat.isArray(orderBy))
                state._conf.sync.orderBy = orderBy;
        },
        SET_USER_ID: function (state, userId) {
            if (!userId) {
                state._sync.signedIn = false;
                state._sync.userId = null;
            }
            else {
                state._sync.signedIn = true;
                state._sync.userId = userId;
            }
        },
        CLEAR_USER: function (state) {
            state._sync.signedIn = false;
            state._sync.userId = null;
        },
        RESET_VUEX_EASY_FIRESTORE_STATE: function (state) {
            // unsubscribe all DBChannel listeners:
            Object.keys(state._sync.unsubscribe).forEach(function (unsubscribe) {
                if (isWhat.isFunction(unsubscribe))
                    unsubscribe();
            });
            var self = this;
            var _sync = merge(state._sync, {
                // make null once to be able to overwrite with empty object
                unsubscribe: null,
                pathVariables: null,
                syncStack: { updates: null, propDeletions: null },
                fetched: null,
            }, {
                unsubscribe: {},
                pathVariables: {},
                patching: false,
                syncStack: {
                    inserts: [],
                    updates: {},
                    propDeletions: {},
                    deletions: [],
                    debounceTimer: null,
                },
                fetched: {},
                stopPatchingTimeout: null
            });
            var newState = merge(userState, { _sync: _sync });
            var docContainer = (state._conf.statePropName)
                ? state[state._conf.statePropName]
                : state;
            Object.keys(newState).forEach(function (key) {
                self._vm.$set(state, key, newState[key]);
            });
            Object.keys(docContainer).forEach(function (key) {
                if (Object.keys(newState).includes(key))
                    return;
                self._vm.$delete(docContainer, key);
            });
        },
        resetSyncStack: function (state) {
            state._sync.syncStack = {
                updates: {},
                deletions: [],
                inserts: [],
                debounceTimer: null
            };
        },
        INSERT_DOC: function (state, doc) {
            if (state._conf.firestoreRefType.toLowerCase() !== 'collection')
                return;
            if (state._conf.statePropName) {
                this._vm.$set(state[state._conf.statePropName], doc.id, doc);
            }
            else {
                this._vm.$set(state, doc.id, doc);
            }
        },
        PATCH_DOC: function (state, patches) {
            var _this = this;
            // Get the state prop ref
            var ref = (state._conf.statePropName)
                ? state[state._conf.statePropName]
                : state;
            if (state._conf.firestoreRefType.toLowerCase() === 'collection') {
                ref = ref[patches.id];
            }
            if (!ref)
                return error('patch-no-ref');
            return Object.keys(patches).forEach(function (key) {
                var newVal = patches[key];
                // Merge if exists
                function helpers(originVal, newVal) {
                    if (isWhat.isArray(originVal) && isArrayHelper(newVal)) {
                        newVal = newVal.executeOn(originVal);
                    }
                    if (isWhat.isNumber(originVal) && isIncrementHelper(newVal)) {
                        newVal = newVal.executeOn(originVal);
                    }
                    return newVal; // always return newVal as fallback!!
                }
                newVal = merge({ extensions: [helpers] }, ref[key], patches[key]);
                _this._vm.$set(ref, key, newVal);
            });
        },
        DELETE_DOC: function (state, id) {
            if (state._conf.firestoreRefType.toLowerCase() !== 'collection')
                return;
            if (state._conf.statePropName) {
                this._vm.$delete(state[state._conf.statePropName], id);
            }
            else {
                this._vm.$delete(state, id);
            }
        },
        DELETE_PROP: function (state, path) {
            var searchTarget = (state._conf.statePropName)
                ? state[state._conf.statePropName]
                : state;
            var propArr = path.split('.');
            var target = propArr.pop();
            if (!propArr.length) {
                return this._vm.$delete(searchTarget, target);
            }
            var ref = vuexEasyAccess.getDeepRef(searchTarget, propArr.join('.'));
            return this._vm.$delete(ref, target);
        }
    };
}
function pluginMutations (userState) {
    return {
        SET_PATHVARS: function (state, pathVars) {
            var self = this;
            Object.keys(pathVars).forEach(function (key) {
                var pathPiece = pathVars[key];
                self._vm.$set(state._sync.pathVariables, key, pathPiece);
            });
        },
        SET_SYNCFILTERS: function (state, _a) {
            var where = _a.where, orderBy = _a.orderBy;
            if (where && isWhat.isArray(where))
                state._conf.sync.where = where;
            if (orderBy && isWhat.isArray(orderBy))
                state._conf.sync.orderBy = orderBy;
        },
        SET_USER_ID: function (state, userId) {
            if (!userId) {
                state._sync.signedIn = false;
                state._sync.userId = null;
            }
            else {
                state._sync.signedIn = true;
                state._sync.userId = userId;
            }
        },
        CLEAR_USER: function (state) {
            state._sync.signedIn = false;
            state._sync.userId = null;
        },
        RESET_VUEX_EASY_FIRESTORE_STATE: function (state) {
            // unsubscribe all DBChannel listeners:
            Object.keys(state._sync.unsubscribe).forEach(function (unsubscribe) {
                if (isWhat.isFunction(unsubscribe))
                    unsubscribe();
            });
            var self = this;
            var _sync = merge(state._sync, {
                // make null once to be able to overwrite with empty object
                unsubscribe: null,
                pathVariables: null,
                syncStack: { updates: null, propDeletions: null },
                fetched: null,
            }, {
                unsubscribe: {},
                pathVariables: {},
                patching: false,
                syncStack: {
                    inserts: [],
                    updates: {},
                    propDeletions: {},
                    deletions: [],
                    debounceTimer: null,
                },
                fetched: {},
                stopPatchingTimeout: null
            });
            var newState = merge(userState, { _sync: _sync });
            var docContainer = (state._conf.statePropName)
                ? state[state._conf.statePropName]
                : state;
            Object.keys(newState).forEach(function (key) {
                self._vm.$set(state, key, newState[key]);
            });
            Object.keys(docContainer).forEach(function (key) {
                if (Object.keys(newState).includes(key))
                    return;
                self._vm.$delete(docContainer, key);
            });
        },
        resetSyncStack: function (state) {
            state._sync.syncStack = {
                updates: {},
                deletions: [],
                inserts: [],
                debounceTimer: null
            };
        },
        INSERT_DOC: function (state, doc) {
            if (state._conf.firestoreRefType.toLowerCase() !== 'collection')
                return;
            if (state._conf.statePropName) {
                this._vm.$set(state[state._conf.statePropName], doc.id, doc);
            }
            else {
                this._vm.$set(state, doc.id, doc);
            }
        },
        PATCH_DOC: function (state, patches) {
            var _this = this;
            // Get the state prop ref
            var ref = (state._conf.statePropName)
                ? state[state._conf.statePropName]
                : state;
            if (state._conf.firestoreRefType.toLowerCase() === 'collection') {
                ref = ref[patches.id];
            }
            if (!ref)
                return error('patch-no-ref');
            return Object.keys(patches).forEach(function (key) {
                var newVal = patches[key];
                // Merge if exists
                function helpers(originVal, newVal) {
                    if (isWhat.isArray(originVal) && isArrayHelper(newVal)) {
                        newVal = newVal.executeOn(originVal);
                    }
                    if (isWhat.isNumber(originVal) && isIncrementHelper(newVal)) {
                        newVal = newVal.executeOn(originVal);
                    }
                    return newVal; // always return newVal as fallback!!
                }
                newVal = merge({ extensions: [helpers] }, ref[key], patches[key]);
                _this._vm.$set(ref, key, newVal);
            });
        },
        DELETE_DOC: function (state, id) {
            if (state._conf.firestoreRefType.toLowerCase() !== 'collection')
                return;
            if (state._conf.statePropName) {
                this._vm.$delete(state[state._conf.statePropName], id);
            }
            else {
                this._vm.$delete(state, id);
            }
        },
        DELETE_PROP: function (state, path) {
            var searchTarget = (state._conf.statePropName)
                ? state[state._conf.statePropName]
                : state;
            var propArr = path.split('.');
            var target = propArr.pop();
            if (!propArr.length) {
                return this._vm.$delete(searchTarget, target);
            }
            var ref = vuexEasyAccess.getDeepRef(searchTarget, propArr.join('.'));
            return this._vm.$delete(ref, target);
        }
    };
}
function pluginMutations ( userState ) { return { SET_PATHVARS : function ( state , pathVars ) { var self = this ; Object . keys ( pathVars ) . forEach ( function ( key ) { var pathPiece = pathVars [ key ] ; self . _vm . $set ( state . _sync . pathVariables , key , pathPiece ) ; } ) ; } , SET_SYNCFILTERS : function ( state , _a ) { var where = _a . where , orderBy = _a . orderBy ; if ( where && isWhat . isArray ( where ) ) state . _conf . sync . where = where ; if ( orderBy && isWhat . isArray ( orderBy ) ) state . _conf . sync . orderBy = orderBy ; } , SET_USER_ID : function ( state , userId ) { if ( ! userId ) { state . _sync . signedIn = false ; state . _sync . userId = null ; } else { state . _sync . signedIn = true ; state . _sync . userId = userId ; } } , CLEAR_USER : function ( state ) { state . _sync . signedIn = false ; state . _sync . userId = null ; } , RESET_VUEX_EASY_FIRESTORE_STATE : function ( state ) { // unsubscribe all DBChannel listeners: Object . keys ( state . _sync . unsubscribe ) . forEach ( function ( unsubscribe ) { if ( isWhat . isFunction ( unsubscribe ) ) unsubscribe ( ) ; } ) ; var self = this ; var _sync = merge ( state . _sync , { // make null once to be able to overwrite with empty object unsubscribe : null , pathVariables : null , syncStack : { updates : null , propDeletions : null } , fetched : null , } , { unsubscribe : { } , pathVariables : { } , patching : false , syncStack : { inserts : [ ] , updates : { } , propDeletions : { } , deletions : [ ] , debounceTimer : null , } , fetched : { } , stopPatchingTimeout : null } ) ; var newState = merge ( userState , { _sync : _sync } ) ; var docContainer = ( state . _conf . statePropName ) ? state [ state . _conf . statePropName ] : state ; Object . keys ( newState ) . forEach ( function ( key ) { self . _vm . $set ( state , key , newState [ key ] ) ; } ) ; Object . keys ( docContainer ) . forEach ( function ( key ) { if ( Object . keys ( newState ) . includes ( key ) ) return ; self . _vm . $delete ( docContainer , key ) ; } ) ; } , resetSyncStack : function ( state ) { state . _sync . syncStack = { updates : { } , deletions : [ ] , inserts : [ ] , debounceTimer : null } ; } , INSERT_DOC : function ( state , doc ) { if ( state . _conf . firestoreRefType . toLowerCase ( ) !== 'collection' ) return ; if ( state . _conf . statePropName ) { this . _vm . $set ( state [ state . _conf . statePropName ] , doc . id , doc ) ; } else { this . _vm . $set ( state , doc . id , doc ) ; } } , PATCH_DOC : function ( state , patches ) { var _this = this ; // Get the state prop ref var ref = ( state . _conf . statePropName ) ? state [ state . _conf . statePropName ] : state ; if ( state . _conf . firestoreRefType . toLowerCase ( ) === 'collection' ) { ref = ref [ patches . id ] ; } if ( ! ref ) return error ( 'patch-no-ref' ) ; return Object . keys ( patches ) . forEach ( function ( key ) { var newVal = patches [ key ] ; // Merge if exists function helpers ( originVal , newVal ) { if ( isWhat . isArray ( originVal ) && isArrayHelper ( newVal ) ) { newVal = newVal . executeOn ( originVal ) ; } if ( isWhat . isNumber ( originVal ) && isIncrementHelper ( newVal ) ) { newVal = newVal . executeOn ( originVal ) ; } return newVal ; // always return newVal as fallback!! } newVal = merge ( { extensions : [ helpers ] } , ref [ key ] , patches [ key ] ) ; _this . _vm . $set ( ref , key , newVal ) ; } ) ; } , DELETE_DOC : function ( state , id ) { if ( state . _conf . firestoreRefType . toLowerCase ( ) !== 'collection' ) return ; if ( state . _conf . statePropName ) { this . _vm . $delete ( state [ state . _conf . statePropName ] , id ) ; } else { this . _vm . $delete ( state , id ) ; } } , DELETE_PROP : function ( state , path ) { var searchTarget = ( state . _conf . statePropName ) ? state [ state . _conf . statePropName ] : state ; var propArr = path . split ( '.' ) ; var target = propArr . pop ( ) ; if ( ! propArr . length ) { return this . _vm . $delete ( searchTarget , target ) ; } var ref = vuexEasyAccess . getDeepRef ( searchTarget , propArr . join ( '.' ) ) ; return this . _vm . $delete ( ref , target ) ; } } ; }
a function returning the mutations object

@export
@param {object} userState
@returns {AnyObject} the mutations object
a function returning the mutations object