Skip to content

Commit

Permalink
prepare importer for relation validation on CTD creation
Browse files Browse the repository at this point in the history
  • Loading branch information
CiotkaCierpienia committed Feb 19, 2025
1 parent 35af2e2 commit 3e1f9ef
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions commands/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ async function restoreDefinitions(remoteContentTypeDefinitions, brokenConstraint
}
}

function fixRelationsInCTDs(remoteContentTypeDefinitions, CTDs) {
return remoteContentTypeDefinitions.map(rCTD => {
const newCTD = CTDs.find(ctd => ctd.name === rCTD.name);
if (newCTD) {
return newCTD;
}
return rCTD;
});
}

async function importer(directory, flotiqApi, skipDefinitions, skipContent, updateDefinitions, disableWebhooks, fixDefinitions, ctd, skipCtd)
{
if (fixDefinitions) {
Expand Down Expand Up @@ -207,6 +217,7 @@ async function importer(directory, flotiqApi, skipDefinitions, skipContent, upda
if (skipContent) {
if(brokenConstraints.length) {
remoteContentTypeDefinitions = await flotiqApi.fetchContentTypeDefs();
remoteContentTypeDefinitions = fixRelationsInCTDs(remoteContentTypeDefinitions, CTDs)
await restoreDefinitions(remoteContentTypeDefinitions, brokenConstraints, flotiqApi, '2');
}
logger.info('All done')
Expand All @@ -217,6 +228,7 @@ async function importer(directory, flotiqApi, skipDefinitions, skipContent, upda

if(!remoteContentTypeDefinitions) {
remoteContentTypeDefinitions = await flotiqApi.fetchContentTypeDefs();
remoteContentTypeDefinitions = fixRelationsInCTDs(remoteContentTypeDefinitions, CTDs)
}

/**
Expand Down

0 comments on commit 3e1f9ef

Please sign in to comment.