in src/utils/configUtils.js [485:516]
function deriveMappingAndCustomTypeInfo(
firstLine: Array<?string>,
): {
mapping: {[string]: string},
customTypeInfo: {[string]: {baseType: 'text' | 'number'}}
} {
const mapping = {};
const customTypeInfo = {};
firstLine.forEach((header, column) => {
if (header == null) {
throw new Error('Invalid header for preprocessed data.');
}
if (isCustomData(header)) {
const indexOfColon = header.lastIndexOf(':');
if (indexOfColon < 0) {
throw new Error(
`Custom data field '${header}' does not have a type, please use `
+ `either '${header}:text' or '${header}:number'.`,
);
}
const customDataField = header.substring(0, indexOfColon);
const typeField = header.substring(indexOfColon + 1);
const customDataKey = customDataField
.substring(customDataField.indexOf('.') + 1);
mapping[String(column)] = customDataField;
customTypeInfo[customDataKey] = {baseType: typeField};
} else {
mapping[String(column)] = header;
}
});
return {mapping, customTypeInfo};
}