@agility/cli
Version:
Agility CLI for working with your content. (Public Beta)
34 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.findContentInTargetInstance = findContentInTargetInstance;
var core_1 = require("core");
var change_detection_1 = require("./change-detection");
/**
* Enhanced content item finder with proper target safety and conflict resolution
* Logic Flow: Target Safety FIRST → Change Delta SECOND → Conflict Resolution
*/
function findContentInTargetInstance(_a) {
var sourceContent = _a.sourceContent, referenceMapper = _a.referenceMapper;
var state = (0, core_1.getState)();
// STEP 1: Find existing mapping
//GET FROM SOURCE MAPPING
var mapping = referenceMapper.getContentItemMappingByContentID(sourceContent.contentID, "source");
var locale = referenceMapper.locale;
var targetContent = null;
if (mapping) {
// STEP 2: Find target content item using mapping
targetContent = referenceMapper.getMappedEntity(mapping, "target");
}
// STEP 3: Use change detection for conflict resolution
var decision = (0, change_detection_1.changeDetection)(sourceContent, targetContent, mapping, locale);
return {
content: decision.entity || null,
shouldUpdate: decision.shouldUpdate,
shouldCreate: decision.shouldCreate,
shouldSkip: decision.shouldSkip,
isConflict: decision.isConflict,
reason: decision.reason,
decision: decision
};
}
//# sourceMappingURL=find-content-in-target-instance.js.map