@kitmi/data
Version:
Jacaranda Framework Data Access Model
50 lines (49 loc) • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
_Processors: function() {
return _Processors;
},
default: function() {
return _default;
},
skipProcessor: function() {
return skipProcessor;
}
});
const _allSync = /*#__PURE__*/ _interop_require_default(require("@kitmi/validators/allSync"));
const _utils = require("@kitmi/utils");
const _normalizePhone = /*#__PURE__*/ _interop_require_default(require("../utils/normalizePhone"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const processorTable = _allSync.default.handlers.processor;
processorTable.normalizePhone = _normalizePhone.default;
const _Processors = _utils._.mapValues(processorTable, (processor, name)=>(entity, field, context, value, options)=>{
if (skipProcessor(field, context, name)) return value;
if (context.options.$dryRun) {
try {
return processor(value, options, field, context);
} catch (error) {
return value;
}
}
return processor(value, options, field, context);
});
const skipProcessor = (field, context, processorName)=>{
const processors = context?.options.$skipProcessors;
if (processors && (processors.has(processorName) || processors.has(field.name + '.' + processorName))) return true;
return false;
};
const _default = processorTable;
//# sourceMappingURL=Processors.js.map