Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function errorCheck (config) {
var errors = [];
var reqProps = ['firestorePath', 'moduleName'];
reqProps.forEach(function (prop) {
if (!config[prop]) {
errors.push("Missing `" + prop + "` in your module!");
}
});
if (config.statePropName !== null && !isWhat.isString(config.statePropName)) {
errors.push('statePropName must be null or a string');
}
if (isWhat.isString(config.statePropName) && /(\.|\/)/.test(config.statePropName)) {
errors.push("statePropName must be null or a string without special characters");
}
if (/\./.test(config.moduleName)) {
errors.push("moduleName must only include letters from [a-z] and forward slashes '/'");
}
var syncProps = ['where', 'orderBy', 'fillables', 'guard', 'defaultValues', 'insertHook', 'patchHook', 'deleteHook', 'insertBatchHook', 'patchBatchHook', 'deleteBatchHook'];
syncProps.forEach(function (prop) {
if (config[prop]) {
errors.push("We found `" + prop + "` on your module, are you sure this shouldn't be inside a prop called `sync`?");
}
});
var serverChangeProps = ['modifiedHook', 'defaultValues', 'addedHook', 'removedHook'];
serverChangeProps.forEach(function (prop) {
if (config[prop]) {
errors.push("We found `" + prop + "` on your module, are you sure this shouldn't be inside a prop called `serverChange`?");
}
function getId(payloadPiece, conf, path, fullPayload) {
if (isWhat.isObject(payloadPiece)) {
if ('id' in payloadPiece)
return payloadPiece.id;
if (Object.keys(payloadPiece).length === 1)
return Object.keys(payloadPiece)[0];
}
if (isWhat.isString(payloadPiece))
return payloadPiece;
error('wildcardFormatWrong', conf, path);
return '';
}
/**
function getId(payloadPiece, conf, path, fullPayload) {
if (isWhat.isObject(payloadPiece)) {
if ('id' in payloadPiece)
return payloadPiece.id;
if (Object.keys(payloadPiece).length === 1)
return Object.keys(payloadPiece)[0];
}
if (isWhat.isString(payloadPiece))
return payloadPiece;
error('wildcardFormatWrong', conf, path);
return '';
}
/**
function getId(payloadPiece, conf, path, fullPayload) {
if (isObject(payloadPiece)) {
if ('id' in payloadPiece)
return payloadPiece.id;
if (Object.keys(payloadPiece).length === 1)
return Object.keys(payloadPiece)[0];
}
if (isString(payloadPiece))
return payloadPiece;
error('wildcardFormatWrong', conf, path);
return '';
}
/**
function getId (
payloadPiece: object | ({ id: string } & object) | string,
conf?: object,
path?: string,
fullPayload?: any[] | object | string
): string {
if (isObject(payloadPiece)) {
if ('id' in payloadPiece) return payloadPiece.id
if (Object.keys(payloadPiece).length === 1) return Object.keys(payloadPiece)[0]
}
if (isString(payloadPiece)) return payloadPiece
error('wildcardFormatWrong', conf, path)
return ''
}
stringProps.forEach(function (prop) {
var _prop = config[prop];
if (!isWhat.isString(_prop))
errors.push("`" + prop + "` should be a String, but is not.");
});
var arrayProps = ['where', 'orderBy', 'fillables', 'guard'];
function getId(payloadPiece, conf, path, fullPayload) {
if (isObject(payloadPiece)) {
if (payloadPiece.id) return payloadPiece.id;
if (Object.keys(payloadPiece).length === 1) return Object.keys(payloadPiece)[0];
}
if (isString(payloadPiece)) return payloadPiece;
return false;
}
/**