Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions build/dist/orgcheck/orgcheck-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,22 @@ class DataDependenciesFactory {
/**
* @description Create a new instance of DataDependencies
* @param {{ records: Array<{ id: string, name: string, type: string, url: string, refId: string, refName: string, refType: string, refUrl: string }>, errors: Array<string> }} data
* @param {string} whatId
* @param {Array<string>} whatIds
* @returns {DataDependencies}
*/
static create(data, whatId) {
if (data.errors?.includes(whatId)) {
static create(data, whatIds) {
// Check if at least one of the whatIds is present in the data errors list
if (data.errors?.some(errorId => whatIds.includes(errorId))) {
return {
hadError: true,
using: [],
referenced: [],
referencedByTypes: {}
};
}
const using = data.records.filter(e => e.id === whatId).map(n => {
// Data can contain a lot of dependencies from other ids, we just want to get the dependencies for the given whatIds
// WhatID is using what? -- Here we are getting the dependencies where the ID is in the whatIds list
const using = data.records.filter(e => whatIds.includes(e.id)).map(n => {
return {
id: n.refId,
name: n.refName,
Expand All @@ -272,7 +275,8 @@ class DataDependenciesFactory {
};
});
const referencedByTypes = {};
const referenced = data.records.filter(e => e.refId === whatId).map(n => {
// WhatID is referenced where? -- Here we are getting the dependencies where the REFID is in the whatIds list
const referenced = data.records.filter(e => whatIds.includes(e.refId)).map(n => {
if (referencedByTypes[n.type] === undefined) {
referencedByTypes[n.type] = 1;
} else {
Expand Down Expand Up @@ -7918,10 +7922,14 @@ class DatasetFlows extends Dataset {

// Then retreive dependencies
logger?.log(`Retrieving dependencies of ${flowDefRecords.length} flow versions...`);
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(
await Processor.map(flowDefRecords, (record) => sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId)),
logger
);
const flowDependenciesIds = [];
await Processor.forEach(flowDefRecords, (record) => {
// Add the ID15 of the most interesting flow version
flowDependenciesIds.push(sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId));
// Add the ID15 of the flow definition
flowDependenciesIds.push(sfdcManager.caseSafeId(record.Id));
});
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(flowDependenciesIds, logger);

// List of active flows that we need to get information later (with Metadata API)
const activeFlowIds = [];
Expand Down Expand Up @@ -7952,7 +7960,7 @@ class DatasetFlows extends Dataset {
},
dependencies: {
data: flowDefinitionsDependencies,
idField: 'currentVersionId'
idFields: [ 'id', 'currentVersionId' ]
}
});

Expand Down Expand Up @@ -8265,7 +8273,7 @@ class DataFactoryInstance extends DataFactoryInstanceIntf {
}
// If dependencies are needed...
if (this._isDependenciesNeeded === true && configuration.dependencies) {
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, row[configuration.dependencies.idField || 'id']);
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, (configuration.dependencies.idFields || ['id']).map(f => row[f]));
}
// Return the row finally
return row;
Expand Down
2 changes: 1 addition & 1 deletion build/dist/orgcheck/orgcheck-api.min.js

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions build/src/api/core/orgcheck-api-data-dependencies-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ export class DataDependenciesFactory {
/**
* @description Create a new instance of DataDependencies
* @param {{ records: Array<{ id: string, name: string, type: string, url: string, refId: string, refName: string, refType: string, refUrl: string }>, errors: Array<string> }} data
* @param {string} whatId
* @param {Array<string>} whatIds
* @returns {DataDependencies}
*/
static create(data, whatId) {
if (data.errors?.includes(whatId)) {
static create(data, whatIds) {
// Check if at least one of the whatIds is present in the data errors list
if (data.errors?.some(errorId => whatIds.includes(errorId))) {
return {
hadError: true,
using: [],
referenced: [],
referencedByTypes: {}
};
}
const using = data.records.filter(e => e.id === whatId).map(n => {
// Data can contain a lot of dependencies from other ids, we just want to get the dependencies for the given whatIds
// WhatID is using what? -- Here we are getting the dependencies where the ID is in the whatIds list
const using = data.records.filter(e => whatIds.includes(e.id)).map(n => {
return {
id: n.refId,
name: n.refName,
Expand All @@ -29,7 +32,8 @@ export class DataDependenciesFactory {
};
});
const referencedByTypes = {};
const referenced = data.records.filter(e => e.refId === whatId).map(n => {
// WhatID is referenced where? -- Here we are getting the dependencies where the REFID is in the whatIds list
const referenced = data.records.filter(e => whatIds.includes(e.refId)).map(n => {
if (referencedByTypes[n.type] === undefined) {
referencedByTypes[n.type] = 1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion build/src/api/core/orgcheck-api-datafactory-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class DataFactoryInstance extends DataFactoryInstanceIntf {
}
// If dependencies are needed...
if (this._isDependenciesNeeded === true && configuration.dependencies) {
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, row[configuration.dependencies.idField || 'id']);
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, (configuration.dependencies.idFields || ['id']).map(f => row[f]));
}
// Return the row finally
return row;
Expand Down
14 changes: 9 additions & 5 deletions build/src/api/dataset/orgcheck-api-dataset-flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ export class DatasetFlows extends Dataset {

// Then retreive dependencies
logger?.log(`Retrieving dependencies of ${flowDefRecords.length} flow versions...`);
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(
await Processor.map(flowDefRecords, (record) => sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId)),
logger
);
const flowDependenciesIds = [];
await Processor.forEach(flowDefRecords, (record) => {
// Add the ID15 of the most interesting flow version
flowDependenciesIds.push(sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId));
// Add the ID15 of the flow definition
flowDependenciesIds.push(sfdcManager.caseSafeId(record.Id));
});
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(flowDependenciesIds, logger);

// List of active flows that we need to get information later (with Metadata API)
const activeFlowIds = [];
Expand Down Expand Up @@ -74,7 +78,7 @@ export class DatasetFlows extends Dataset {
},
dependencies: {
data: flowDefinitionsDependencies,
idField: 'currentVersionId'
idFields: [ 'id', 'currentVersionId' ]
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('tests.api.unit.DataDependencies', () => {
describe('Using a predefined set of relationship (001), make sure the using, referenced and refByTypes properties for Apex Class 001 are well defined', () => {

// In the relationShip 001, ApexClass001 uses ApexClass002 and CustomField001 and is referenced in ApexClass003 and CustomField002.
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_001, errors: [] }, APEXCLASS_001.id);
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_001, errors: [] }, [ APEXCLASS_001.id ]);

it('checks if using property is well defined', () => {
const using = dataDep.using;
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('tests.api.unit.DataDependencies', () => {
describe('Using a predefined set of relationship (001), make sure the using, referenced and refByTypes properties for Apex Class 002 are well defined', () => {

// In the relationShip 001, ApexClass002 uses ApexClass003 and is referenced in ApexClass001.
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_001, errors: [] }, APEXCLASS_002.id);
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_001, errors: [] }, [ APEXCLASS_002.id ]);

it('checks if using property is well defined', () => {
const using = dataDep.using;
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('tests.api.unit.DataDependencies', () => {
describe('Using a predefined set of relationship (001), make sure the using, referenced and refByTypes properties for Custom Field 001 are well defined', () => {

// In the relationShip 001, CustomField001 uses CustomField002 and is referenced in ApexClass001.
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_001, errors: [] }, CUSTOMFIELD_001.id);
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_001, errors: [] }, [ CUSTOMFIELD_001.id ]);

it('checks if using property is well defined', () => {
const using = dataDep.using;
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('tests.api.unit.DataDependencies', () => {
describe('Using a predefined set of relationship (002), make sure the using, referenced and refByTypes properties for Custom Field 001 are well defined', () => {

// In the relationShip 002, CustomField001 uses nothing and is referenced in 4 page layouts and in ApexClass001.
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_002, errors: [] }, CUSTOMFIELD_001.id);
const dataDep = DataDependenciesFactory.create({ records: RELATIONSHIP_002, errors: [] }, [ CUSTOMFIELD_001.id ]);

it('checks if using property is well defined', () => {
const using = dataDep.using;
Expand Down
30 changes: 19 additions & 11 deletions force-app/main/default/lwc/orgcheckApp/libs/orgcheck-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,22 @@ class DataDependenciesFactory {
/**
* @description Create a new instance of DataDependencies
* @param {{ records: Array<{ id: string, name: string, type: string, url: string, refId: string, refName: string, refType: string, refUrl: string }>, errors: Array<string> }} data
* @param {string} whatId
* @param {Array<string>} whatIds
* @returns {DataDependencies}
*/
static create(data, whatId) {
if (data.errors?.includes(whatId)) {
static create(data, whatIds) {
// Check if at least one of the whatIds is present in the data errors list
if (data.errors?.some(errorId => whatIds.includes(errorId))) {
return {
hadError: true,
using: [],
referenced: [],
referencedByTypes: {}
};
}
const using = data.records.filter(e => e.id === whatId).map(n => {
// Data can contain a lot of dependencies from other ids, we just want to get the dependencies for the given whatIds
// WhatID is using what? -- Here we are getting the dependencies where the ID is in the whatIds list
const using = data.records.filter(e => whatIds.includes(e.id)).map(n => {
return {
id: n.refId,
name: n.refName,
Expand All @@ -272,7 +275,8 @@ class DataDependenciesFactory {
};
});
const referencedByTypes = {};
const referenced = data.records.filter(e => e.refId === whatId).map(n => {
// WhatID is referenced where? -- Here we are getting the dependencies where the REFID is in the whatIds list
const referenced = data.records.filter(e => whatIds.includes(e.refId)).map(n => {
if (referencedByTypes[n.type] === undefined) {
referencedByTypes[n.type] = 1;
} else {
Expand Down Expand Up @@ -7918,10 +7922,14 @@ class DatasetFlows extends Dataset {

// Then retreive dependencies
logger?.log(`Retrieving dependencies of ${flowDefRecords.length} flow versions...`);
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(
await Processor.map(flowDefRecords, (record) => sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId)),
logger
);
const flowDependenciesIds = [];
await Processor.forEach(flowDefRecords, (record) => {
// Add the ID15 of the most interesting flow version
flowDependenciesIds.push(sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId));
// Add the ID15 of the flow definition
flowDependenciesIds.push(sfdcManager.caseSafeId(record.Id));
});
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(flowDependenciesIds, logger);

// List of active flows that we need to get information later (with Metadata API)
const activeFlowIds = [];
Expand Down Expand Up @@ -7952,7 +7960,7 @@ class DatasetFlows extends Dataset {
},
dependencies: {
data: flowDefinitionsDependencies,
idField: 'currentVersionId'
idFields: [ 'id', 'currentVersionId' ]
}
});

Expand Down Expand Up @@ -8265,7 +8273,7 @@ class DataFactoryInstance extends DataFactoryInstanceIntf {
}
// If dependencies are needed...
if (this._isDependenciesNeeded === true && configuration.dependencies) {
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, row[configuration.dependencies.idField || 'id']);
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, (configuration.dependencies.idFields || ['id']).map(f => row[f]));
}
// Return the row finally
return row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,22 @@ class DataDependenciesFactory {
/**
* @description Create a new instance of DataDependencies
* @param {{ records: Array<{ id: string, name: string, type: string, url: string, refId: string, refName: string, refType: string, refUrl: string }>, errors: Array<string> }} data
* @param {string} whatId
* @param {Array<string>} whatIds
* @returns {DataDependencies}
*/
static create(data, whatId) {
if (data.errors?.includes(whatId)) {
static create(data, whatIds) {
// Check if at least one of the whatIds is present in the data errors list
if (data.errors?.some(errorId => whatIds.includes(errorId))) {
return {
hadError: true,
using: [],
referenced: [],
referencedByTypes: {}
};
}
const using = data.records.filter(e => e.id === whatId).map(n => {
// Data can contain a lot of dependencies from other ids, we just want to get the dependencies for the given whatIds
// WhatID is using what? -- Here we are getting the dependencies where the ID is in the whatIds list
const using = data.records.filter(e => whatIds.includes(e.id)).map(n => {
return {
id: n.refId,
name: n.refName,
Expand All @@ -272,7 +275,8 @@ class DataDependenciesFactory {
};
});
const referencedByTypes = {};
const referenced = data.records.filter(e => e.refId === whatId).map(n => {
// WhatID is referenced where? -- Here we are getting the dependencies where the REFID is in the whatIds list
const referenced = data.records.filter(e => whatIds.includes(e.refId)).map(n => {
if (referencedByTypes[n.type] === undefined) {
referencedByTypes[n.type] = 1;
} else {
Expand Down Expand Up @@ -7918,10 +7922,14 @@ class DatasetFlows extends Dataset {

// Then retreive dependencies
logger?.log(`Retrieving dependencies of ${flowDefRecords.length} flow versions...`);
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(
await Processor.map(flowDefRecords, (record) => sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId)),
logger
);
const flowDependenciesIds = [];
await Processor.forEach(flowDefRecords, (record) => {
// Add the ID15 of the most interesting flow version
flowDependenciesIds.push(sfdcManager.caseSafeId(record.ActiveVersionId ?? record.LatestVersionId));
// Add the ID15 of the flow definition
flowDependenciesIds.push(sfdcManager.caseSafeId(record.Id));
});
const flowDefinitionsDependencies = await sfdcManager.dependenciesQuery(flowDependenciesIds, logger);

// List of active flows that we need to get information later (with Metadata API)
const activeFlowIds = [];
Expand Down Expand Up @@ -7952,7 +7960,7 @@ class DatasetFlows extends Dataset {
},
dependencies: {
data: flowDefinitionsDependencies,
idField: 'currentVersionId'
idFields: [ 'id', 'currentVersionId' ]
}
});

Expand Down Expand Up @@ -8265,7 +8273,7 @@ class DataFactoryInstance extends DataFactoryInstanceIntf {
}
// If dependencies are needed...
if (this._isDependenciesNeeded === true && configuration.dependencies) {
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, row[configuration.dependencies.idField || 'id']);
row.dependencies = DataDependenciesFactory.create(configuration.dependencies.data, (configuration.dependencies.idFields || ['id']).map(f => row[f]));
}
// Return the row finally
return row;
Expand Down
Loading