Skip to content

Commit e29ee85

Browse files
authored
Merge pull request #409 from SalesforceLabs/Beryllium-UAT-phase-2
Beryllium uat phase 2
2 parents 966a292 + f42ef03 commit e29ee85

File tree

123 files changed

+6963
-3724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+6963
-3724
lines changed

build/package.readme

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,11 @@
1-
============================================================
2-
Push source in a scratch org
3-
============================================================
4-
sfdx force:org:create --definitionfile config/project-scratch-def.json --setalias MyScratchOrg --targetdevhubusername vfinet.devhub@salesforce.com --wait 10
5-
sfdx force:source:push --targetusername MyScratchOrg --forceoverwrite
6-
profileName=$(sfdx force:data:soql:query --targetusername MyScratchOrg --query "SELECT Name FROM Profile WHERE UserLicense.MasterLabel = 'Salesforce' AND Name LIKE '%Admin%' AND PermissionsViewAllData = true LIMIT 1" --resultformat=csv | tail -1)
7-
sfdx force:user:create --setalias uatuser --definitionfile config/user-uat-def.json "profileName=${profileName}" permsets=OrgCheck_Users --targetusername MyScratchOrg
8-
9-
uatUserId=$(sfdx force:data:soql:query --query "SELECT Id FROM User WHERE Profile.Name = '${profileName}' AND IsActive = true" --resultformat=csv --targetusername MyScratchOrg | tail -1)
10-
11-
## Set French Local/Language
12-
sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=fr LanguageLocaleKey=fr" --targetusername MyScratchOrg
13-
14-
## Set English Local/Language
15-
sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=en_US LanguageLocaleKey=en_US" --targetusername MyScratchOrg
16-
17-
## Set Japanese Local/Language
18-
sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=ja LanguageLocaleKey=ja" --targetusername MyScratchOrg
19-
20-
## In case of persistente language, please close all browsers before launching the next command.
21-
sfdx force:org:open --targetusername uatuser
22-
23-
24-
sfdx force:user:list --targetusername MyScratchOrg
25-
sfdx force:org:open --targetusername MyScratchOrg
26-
27-
sfdx force:org:delete --targetusername MyScratchOrg
28-
29-
301
============================================================
312
List of usefull commands for packaging
323
============================================================
33-
##sfdx force:package:version:list --targetdevhubusername vfinet.devhub@salesforce.com
34-
##sfdx force:package:version:create --targetdevhubusername vfinet.devhub@salesforce.com --package OrgCheck --definitionfile config/project-scratch-def.json --installationkeybypass --codecoverage --wait 10
35-
##sfdx force:package:version:promote --targetdevhubusername vfinet.devhub@salesforce.com --package OrgCheck@2.4.1-0
36-
37-
sfdx package version list --target-hub-org vfinet.devhub@salesforce.com
38-
sfdx package version create --target-hub-org vfinet.devhub@salesforce.com --package OrgCheck --definition-file config/project-scratch-def.json --installation-key-bypass --code-coverage --wait 10
39-
sfdx package version promote --target-hub-org vfinet.devhub@salesforce.com --package OrgCheck@2.5.0-0
404

5+
sf package version list --target-dev-hub vfinet.devhub@salesforce.com
6+
sf package version create --target-dev-hub vfinet.devhub@salesforce.com --package OrgCheck --definition-file config/project-scratch-def.json --installation-key-bypass --code-coverage --wait 10
7+
sf package version promote --target-dev-hub vfinet.devhub@salesforce.com --package OrgCheck@2.5.0-0
8+
sf package version delete --target-dev-hub vfinet.devhub@salesforce.com --package OrgCheck@2.5.0-0
419

4210

4311
============================================================

force-app/main/default/lwc/orgcheckApp/api/core/orgcheck-api-data-dependencies.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export class OrgCheckDataDependencies {
44
referenced;
55
referencedByTypes;
66

7-
constructor(data, whatid) {
7+
constructor(data, whatId) {
88

9-
this.using = data.filter(e => e.id === whatid).map(n => {
9+
this.using = data.filter(e => e.id === whatId).map(n => {
1010
return {
1111
id: n.refId,
1212
name: n.refName,
@@ -15,7 +15,7 @@ export class OrgCheckDataDependencies {
1515
};
1616
});
1717
this.referencedByTypes = {};
18-
this.referenced = data.filter(e => e.refId === whatid).map(n => {
18+
this.referenced = data.filter(e => e.refId === whatId).map(n => {
1919
if (this.referencedByTypes[n.type] === undefined) {
2020
this.referencedByTypes[n.type] = 1;
2121
} else {
Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,17 @@
1-
import { OrgCheckDataDependencies } from './orgcheck-api-data-dependencies';
2-
1+
/**
2+
* This class represents a set of information around a unique instance of a specific artefact (like User, Profile, UserRole, ...)
3+
* Such class are created by a "data factory" (see OrgCheckDataFactory) which also computes its "score" based on specific best practices rules.
4+
*/
35
export class OrgCheckData {
4-
5-
badScore;
6+
score;
67
badFields;
8+
badReasonIds;
79
dependencies;
8-
9-
initData(setup) {
10-
11-
// Copy properties from setup to object
12-
// NB: Please note that ONLY the properties explicitely set in
13-
// the class will be copied from setup to object
14-
Object.keys(this).forEach((p) => { this[p] = setup[p]; });
15-
16-
// If need scoring...
17-
if (setup.isScoreNeeded === true) {
18-
this.badFields = [];
19-
}
20-
21-
// If dependencies are needed...
22-
if (setup.isDependenciesNeeded === true) {
23-
if (!setup.allDependencies) {
24-
throw new TypeError(`Missing 'allDependencies' information in setup as this data does need dependencies.`);
25-
}
26-
if (!setup.dependenciesFor) {
27-
throw new TypeError(`Missing 'dependenciesFor' information in setup as this data does need dependencies.`);
28-
}
29-
const id = this[setup.dependenciesFor];
30-
if (!id) {
31-
throw new TypeError(`The property "${setup.dependenciesFor}" is undefined for this data. Impossible to calculate dependencies.`);
32-
}
33-
this.dependencies = new OrgCheckDataDependencies(setup.allDependencies, id);
34-
}
35-
36-
Object.seal(this);
37-
}
38-
39-
setBadField(field) {
40-
if (!this.badFields) {
41-
throw new TypeError('Should not call setBadField() as this data does not need score.');
42-
}
43-
if (!field) {
44-
throw new TypeError('Field is a mandatory when calling setBadField()');
45-
}
46-
if (this.badFields.includes(field) === false) {
47-
this.badFields.push(field);
48-
this.badScore = this.badFields.length;
49-
}
50-
}
51-
52-
isItReferenced() {
53-
if (!this.dependencies) {
54-
throw new TypeError('Should not call isItReferenced() as this data does not need dependencies.');
55-
}
56-
return this.dependencies.referenced.length > 0;
57-
}
58-
}
10+
}
11+
12+
/**
13+
* This class represents a sub set of information included in a, instance of OrgCheckData, but it does not need score and dependencies automation at its level.
14+
* The best example of this is a FlowDefinition and its active FlowVersion. The flowDefinition will be a OrgCheckData, including a reference to a OrgCheckInnerData
15+
* to represent the FlowVersion. All score information and dependencies will be reported to the flowDef instance.
16+
*/
17+
export class OrgCheckInnerData {}

force-app/main/default/lwc/orgcheckApp/api/core/orgcheck-api-datacache.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ const generateLogicalKey = (key) => {
88
return key.startsWith(CACHE_PREFIX) ? key.substring(CACHE_PREFIX.length) : key;
99
}
1010

11+
const NB_MILLISEC_IN_ONE_DAY = 1000*60*60*24;
12+
1113
const getEntryFromCache = (key) => {
1214
const entryFromStorage = localStorage.getItem(key);
1315
if (!entryFromStorage) return null
14-
return JSON.parse(entryFromStorage);
16+
const entry = JSON.parse(entryFromStorage);
17+
if (Date.now() - entry.created > NB_MILLISEC_IN_ONE_DAY) return null;
18+
return entry;
1519
}
1620

1721
const isItOneOfOurKeys = (key) => {
@@ -20,14 +24,13 @@ const isItOneOfOurKeys = (key) => {
2024

2125
export class OrgCheckDataCacheManager {
2226
has(key) {
23-
return localStorage.getItem(generatePhysicalKey(key)) !== null;
27+
return getEntryFromCache(generatePhysicalKey(key)) !== null;
2428
}
2529
get(key) {
2630
const entry = getEntryFromCache(generatePhysicalKey(key));
2731
if (!entry) return null;
2832
if (entry.type === 'map') return new Map(entry.data);
2933
return entry.data;
30-
3134
}
3235
set(key, value) {
3336
try {
@@ -40,7 +43,7 @@ export class OrgCheckDataCacheManager {
4043
{
4144
type: 'map',
4245
length: value.size,
43-
data: Array.from(value.entries().filter(([k, v]) => k.endsWith('Ref') === false)),
46+
data: Array.from(value.entries().filter(([k]) => k.endsWith('Ref') === false)),
4447
created: Date.now()
4548
}
4649
)

0 commit comments

Comments
 (0)