in src/persistence/mapiObjectStorage.ts [504:572]
public convertArmContractToPaperbitsContract(contractObject: ArmResource | any, isLocalized: boolean = false, isArm: boolean = true): any {
if (contractObject === null || contractObject === undefined) {
return contractObject;
}
let contract: any;
if (isLocalized) {
const localeName = contractObject.properties[selectedLocaleArm]
? selectedLocaleArm
: selectedLocaleArmAlt; // fallback to alternative definition
const localeObject = contractObject.properties[localeName];
const restProperties = _.omit(contractObject.properties, localeName);
contract = {
key: contractObject.id,
locales: {
[selectedLocaleBits]: localeObject,
},
...restProperties,
};
}
else {
if (isArm) {
contract = contractObject.properties;
contract.key = contractObject.id;
}
else {
contract = contractObject;
}
}
let converted;
if (Array.isArray(contract)) {
converted = contract.map(x => this.convertArmContractToPaperbitsContract(x, false, false));
}
else if (typeof contract === "object") {
converted = {};
Object.keys(contract).forEach(propertyName => {
const propertyValue = contract[propertyName];
let convertedKey = propertyName;
let convertedValue = propertyValue;
if (!reservedArmIds.includes(propertyName)) {
convertedKey = propertyName
.replace(/documentId/gm, "contentKey")
.replace(/Id\b/gm, "Key")
.replace(/\bid\b/gm, "key");
}
if (typeof propertyValue === "string" && propertyValue.includes("contentType")) {
convertedValue = this.armResourceToPaperbitsKey(propertyValue);
}
else {
convertedValue = this.convertArmContractToPaperbitsContract(propertyValue, false, false);
}
converted[convertedKey] = convertedValue;
});
}
else {
converted = contract;
}
return converted;
}