Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// prepare rest of state
var docContainer = {};
if (conf.statePropName)
docContainer[conf.statePropName] = {};
var restOfState = merge(userState, docContainer);
// if 'doc' mode, set merge initial state onto default values
if (conf.firestoreRefType === 'doc') {
var defaultValsInState = (conf.statePropName)
? restOfState[conf.statePropName]
: restOfState;
conf.sync.defaultValues = copy(merge(defaultValsInState, conf.sync.defaultValues));
}
return {
namespaced: true,
state: merge(pluginState(), restOfState, { _conf: conf }),
mutations: merge(userMutations, pluginMutations(merge(userState, { _conf: conf }))),
actions: merge(userActions, pluginActions(FirebaseDependency)),
getters: merge(userGetters, pluginGetters(FirebaseDependency))
};
}
state._sync.syncStack.inserts.forEach((newDoc, newDocIndex) => {
// get the index of the id that is also in the insert stack
const indexIdInInsert = ids.indexOf(newDoc.id)
if (indexIdInInsert === -1) return
// the doc trying to be synced is also in insert
// prepare the doc as new doc:
const patchDoc = getters.prepareForInsert([doc])[0]
// replace insert sync stack with merged item:
state._sync.syncStack.inserts[newDocIndex] = merge(newDoc, patchDoc)
// empty out the id that was to be patched:
ids.splice(indexIdInInsert, 1)
})
set: function set$$1(obj) {
// $FlowFixMe
this._foldedDefaultProps = isTargetStyledComp ? merge(target.defaultProps, obj) : obj;
},
});
function iniModule (userConfig, FirebaseDependency) {
// prepare state._conf
var conf = copy(merge({ state: {}, mutations: {}, actions: {}, getters: {} }, defaultConfig, userConfig));
if (!errorCheck(conf))
return;
var userState = conf.state;
var userMutations = conf.mutations;
var userActions = conf.actions;
var userGetters = conf.getters;
delete conf.state;
delete conf.mutations;
delete conf.actions;
delete conf.getters;
// prepare rest of state
var docContainer = {};
if (conf.statePropName)
docContainer[conf.statePropName] = {};
var restOfState = merge(userState, docContainer);
// if 'doc' mode, set merge initial state onto default values
var conf = copy(merge({ state: {}, mutations: {}, actions: {}, getters: {} }, defaultConfig, userConfig));
if (!errorCheck(conf))
return;
var userState = conf.state;
var userMutations = conf.mutations;
var userActions = conf.actions;
var userGetters = conf.getters;
delete conf.state;
delete conf.mutations;
delete conf.actions;
delete conf.getters;
// prepare rest of state
var docContainer = {};
if (conf.statePropName)
docContainer[conf.statePropName] = {};
var restOfState = merge(userState, docContainer);
// if 'doc' mode, set merge initial state onto default values
if (conf.firestoreRefType === 'doc') {
var defaultValsInState = (conf.statePropName)
? restOfState[conf.statePropName]
: restOfState;
conf.sync.defaultValues = copy(merge(defaultValsInState, conf.sync.defaultValues));
}
return {
namespaced: true,
state: merge(pluginState(), restOfState, { _conf: conf }),
mutations: merge(userMutations, pluginMutations(merge(userState, { _conf: conf }))),
actions: merge(userActions, pluginActions(FirebaseDependency)),
getters: merge(userGetters, pluginGetters(FirebaseDependency))
};
}
function setDefaultValues (obj, defaultValues) {
if (!isPlainObject(defaultValues))
console.error('[vuex-easy-firestore] Trying to merge target:', obj, 'onto a non-object (defaultValues):', defaultValues);
if (!isPlainObject(obj))
console.error('[vuex-easy-firestore] Trying to merge a non-object:', obj, 'onto the defaultValues:', defaultValues);
var result = merge({ extensions: [convertTimestamps] }, defaultValues, obj);
return findAndReplace(result, '%convertTimestamp%', null, { onlyPlainObjects: true });
}
var userMutations = conf.mutations;
var userActions = conf.actions;
var userGetters = conf.getters;
delete conf.state;
delete conf.mutations;
delete conf.actions;
delete conf.getters;
var docContainer = {};
if (conf.statePropName) docContainer[conf.statePropName] = {};
var state = merge(initialState, userState, docContainer, {
_conf: conf
});
return {
namespaced: true,
state: state,
mutations: iniMutations(userMutations, merge(initialState, userState)),
actions: iniActions(userActions),
getters: iniGetters(userGetters)
};
}
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!getters.collectionMode)
return [2 /*return*/, error('only-in-collection-mode')];
if (!id)
return [2 /*return*/, {}];
doc = merge(getters.storeRef[id], { id: null });
return [4 /*yield*/, dispatch('insert', doc)];
case 1:
dId = _c.sent();
idMap = (_b = {}, _b[id] = dId, _b);
return [2 /*return*/, idMap];
}
});
});