Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WaveComponent #220

Merged
merged 6 commits into from
Dec 16, 2021
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
39 changes: 39 additions & 0 deletions __tests__/unit/lib/service/waveHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,30 @@ jest.mock('fs')
const testContext = {
handler: WaveHandler,
testData: [
[
'discovery',
'force-app/main/default/discovery/DiscoveryAIModelTest.model',
new Set(['DiscoveryAIModelTest']),
'DiscoveryAIModel',
],
[
'discovery',
'force-app/main/default/discovery/DiscoveryGoalTest.goal',
new Set(['DiscoveryGoalTest']),
'DiscoveryGoal',
],
[
'wave',
'force-app/main/default/wave/WaveApplicationTest.wapp',
new Set(['WaveApplicationTest']),
'WaveApplication',
],
[
'wave',
'force-app/main/default/wave/WaveComponentTest.wcomp',
new Set(['WaveComponentTest']),
'WaveComponent',
],
[
'wave',
'force-app/main/default/wave/WaveDataflowTest.wdf',
Expand Down Expand Up @@ -47,12 +65,30 @@ const testContext = {
new Set(['WaveXmdTest']),
'WaveXmd',
],
[
'discovery',
'force-app/main/default/discovery/Test/DiscoveryAIModelTest.model',
new Set(['DiscoveryAIModelTest']),
'DiscoveryAIModel',
],
[
'discovery',
'force-app/main/default/discovery/Test/DiscoveryGoalTest.goal',
new Set(['DiscoveryGoalTest']),
'DiscoveryGoal',
],
[
'wave',
'force-app/main/default/wave/Test/WaveApplicationTest.wapp',
new Set(['WaveApplicationTest']),
'WaveApplication',
],
[
'wave',
'force-app/main/default/wave/Test/WaveComponentTest.wcomp',
new Set(['WaveComponentTest']),
'WaveComponent',
],
[
'wave',
'force-app/main/default/wave/Test/WaveDataflowTest.wdf',
Expand Down Expand Up @@ -97,7 +133,10 @@ const testContext = {
}

require('fs').__setMockFiles({
'force-app/main/default/discovery/DiscoveryAIModelTest.model': 'test',
'force-app/main/default/discovery/DiscoveryGoalTest.goal': 'test',
'force-app/main/default/wave/WaveApplicationTest.wapp': 'test',
'force-app/main/default/wave/WaveComponentTest.wcomp': 'test',
'force-app/main/default/wave/WaveDataflowTest.wdf': 'test',
'force-app/main/default/wave/WaveDashboardTest.wdash': 'test',
'force-app/main/default/wave/WaveDatasetTest.wds': 'test',
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/a48.json
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -1173,6 +1188,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/v46.json
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -926,6 +941,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/v47.json
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -1152,6 +1167,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/v49.json
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -1166,6 +1181,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/v50.json
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -1166,6 +1181,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/v51.json
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -1172,6 +1187,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
19 changes: 19 additions & 0 deletions src/metadata/v52.json
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,21 @@
"suffix": "mlDomain",
"xmlName": "MlDomain"
},
{
"directoryName": "discovery",
"inFolder": false,
"metaFile": true,
"content": [
{
"suffix": "model",
"xmlName": "DiscoveryAIModel"
},
{
"suffix": "goal",
"xmlName": "DiscoveryGoal"
}
]
},
{
"directoryName": "wave",
"inFolder": false,
Expand All @@ -1172,6 +1187,10 @@
"suffix": "wapp",
"xmlName": "WaveApplication"
},
{
"suffix": "wcomp",
"xmlName": "WaveComponent"
},
{
"suffix": "wdf",
"xmlName": "WaveDataflow"
Expand Down
1 change: 1 addition & 0 deletions src/service/typeHandlerFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const classes = {
businessProcesses: SubCustomObject,
compactLayouts: SubCustomObject,
dashboards: InFolder,
discovery: Wave,
documents: InFolder,
email: InFolder,
experiences: InResource,
Expand Down
16 changes: 5 additions & 11 deletions src/service/waveHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ const path = require('path')

const WAVE_SUBTYPE = {}

const isEmpty = obj => {
for (let i in obj) return false
return true
}

class WaveHandler extends StandardHandler {
constructor(line, type, work, metadata) {
super(line, type, work, metadata)
if (isEmpty(WAVE_SUBTYPE)) {
StandardHandler.metadata[this.type].content.reduce((acc, val) => {
acc[val.suffix] = val.xmlName
return acc
}, WAVE_SUBTYPE)
}

StandardHandler.metadata[this.type].content.reduce((acc, val) => {
acc[val.suffix] = val.xmlName
return acc
}, WAVE_SUBTYPE)
this.ext = path.parse(this.line).ext.substring(1)
this.suffixRegex = new RegExp(`\\.${this.ext}$`)
}
Expand Down
2 changes: 0 additions & 2 deletions src/utils/metadataConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const LABEL_EXTENSION = 'labels'
const LABEL_DIRECTORY_NAME = `labels.${LABEL_EXTENSION}`
const OBJECT_TRANSLATION_META_XML_SUFFIX = `objectTranslation${METAFILE_SUFFIX}`
const INFOLDER_SUFFIX = `Folder`
const WAVE_SUB_TYPES_PREFIX = 'Wave'
module.exports.METAFILE_SUFFIX = METAFILE_SUFFIX
module.exports.META_REGEX = META_REGEX
module.exports.OBJECT_META_XML_SUFFIX = OBJECT_META_XML_SUFFIX
Expand All @@ -19,4 +18,3 @@ module.exports.LABEL_DIRECTORY_NAME = LABEL_DIRECTORY_NAME
module.exports.INFOLDER_SUFFIX = INFOLDER_SUFFIX
module.exports.OBJECT_TRANSLATION_META_XML_SUFFIX =
OBJECT_TRANSLATION_META_XML_SUFFIX
module.exports.WAVE_SUB_TYPES_PREFIX = WAVE_SUB_TYPES_PREFIX
8 changes: 6 additions & 2 deletions src/utils/packageConstructor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict'
const xmlbuilder = require('xmlbuilder')
const xmlConf = { indent: ' ', newline: '\n', pretty: true }
const mc = require('./metadataConstants')

module.exports = class PackageConstructor {
constructor(config, metadata) {
this.config = config
this.metadata = metadata
this.looseMetadata = Object.keys(this.metadata)
.filter(type => this.metadata[type].content)
.flatMap(type =>
this.metadata[type].content.map(content => content.xmlName)
)
}

constructPackage(strucDiffPerType) {
Expand All @@ -20,7 +24,7 @@ module.exports = class PackageConstructor {
.filter(
type =>
Object.prototype.hasOwnProperty.call(this.metadata, type) ||
type.startsWith(mc.WAVE_SUB_TYPES_PREFIX)
this.looseMetadata.includes(type)
)
.sort()
// @deprecated To remove when the order will not impact the result of the deployment
Expand Down