-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Check Salesforce package version (#131)
* Add query the package versions installed in the Salesforce organization to check for dependencies.
- Loading branch information
Showing
15 changed files
with
131 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { getRecords } from './database/database'; | ||
import { SQLitePageLayoutSection, SQLitePageLayoutItem } from '../types/sqlite'; | ||
import { SurveyLayout } from '../types/survey'; | ||
import { logger } from '../utility/logger'; | ||
import { DB_TABLE } from '../constants'; | ||
|
||
/** | ||
* Construct page layout object from locally stored page layout sections and items | ||
* @param layoutId | ||
*/ | ||
export const buildLayoutDetail = async (layoutId: string): Promise<SurveyLayout> => { | ||
// sections in the layout | ||
const sections: Array<SQLitePageLayoutSection> = await getRecords( | ||
DB_TABLE.PAGE_LAYOUT_SECTION, | ||
`where layoutId='${layoutId}'` | ||
); | ||
// items used in the sections | ||
const sectionIds = sections.map(s => s.id); | ||
const items: Array<SQLitePageLayoutItem> = await getRecords( | ||
DB_TABLE.PAGE_LAYOUT_ITEM, | ||
`where sectionId in (${sectionIds.map(id => `'${id}'`).join(',')})` | ||
); | ||
logger('FINE', 'buildLayoutDetail', items); | ||
|
||
// group items by section id | ||
const sectionIdToItems = items.reduce( | ||
(result, item) => ({ | ||
...result, | ||
[item.sectionId]: [...(result[item.sectionId] || []), item], | ||
}), | ||
{} | ||
); | ||
|
||
const layout: SurveyLayout = { | ||
sections: sections.map(s => ({ | ||
id: s.id, | ||
title: s.sectionLabel, | ||
data: sectionIdToItems[s.id] | ||
? sectionIdToItems[s.id].map(item => ({ | ||
name: item.fieldName, | ||
label: item.fieldLabel, | ||
type: item.fieldType, | ||
required: !!item.required, | ||
})) | ||
: [], | ||
})), | ||
}; | ||
|
||
return layout; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { METADATA_ERROR, MIN_PACKAGE_VERSION, SUBSCRIBER_PACKAGE_VERSION } from '../../constants'; | ||
import { fetchToolingRecords } from './core'; | ||
|
||
export const validateInstalledPackageVersion = async () => { | ||
const query = `SELECT SubscriberPackageVersion.MajorVersion,SubscriberPackageVersion.MinorVersion, SubscriberPackageVersion.PatchVersion, SubscriberPackageVersion.BuildNumber FROM InstalledSubscriberPackage WHERE SubscriberPackageId = '${SUBSCRIBER_PACKAGE_VERSION}'`; | ||
const records = await fetchToolingRecords(query); | ||
if (records.length === 0) { | ||
return Promise.reject({ error: METADATA_ERROR.INVALID_PACKAGE_VERSION }); | ||
} | ||
const record = records[0].SubscriberPackageVersion; | ||
const version = `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}.${record.BuildNumber}`; | ||
if (version < MIN_PACKAGE_VERSION) { | ||
return Promise.reject({ error: METADATA_ERROR.INVALID_PACKAGE_VERSION }); | ||
} | ||
return Promise.resolve({}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters