mcdev 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug.yml +4 -1
- package/docs/dist/documentation.md +18 -18
- package/lib/metadataTypes/Automation.js +6 -4
- package/lib/metadataTypes/DataExtension.js +8 -8
- package/lib/metadataTypes/DataExtract.js +9 -5
- package/lib/metadataTypes/EventDefinition.js +9 -5
- package/lib/metadataTypes/FileTransfer.js +9 -5
- package/lib/metadataTypes/ImportFile.js +9 -6
- package/lib/metadataTypes/MetadataType.js +22 -28
- package/lib/metadataTypes/Script.js +2 -2
- package/package.json +1 -1
|
@@ -1061,7 +1061,7 @@ Automation MetadataType
|
|
|
1061
1061
|
* [.retrieve(retrieveDir)](#Automation.retrieve) ⇒ <code>Promise.<{metadata:AutomationMap, type:string}></code>
|
|
1062
1062
|
* [.retrieveChangelog()](#Automation.retrieveChangelog) ⇒ <code>Promise.<{metadata:AutomationMap, type:string}></code>
|
|
1063
1063
|
* [.retrieveForCache()](#Automation.retrieveForCache) ⇒ <code>Promise.<{metadata:AutomationMap, type:string}></code>
|
|
1064
|
-
* [.retrieveAsTemplate(templateDir, name,
|
|
1064
|
+
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#Automation.retrieveAsTemplate) ⇒ <code>Promise.<{metadata:AutomationMap, type:string}></code>
|
|
1065
1065
|
* [.postRetrieveTasks(metadata, [_], [isTemplating])](#Automation.postRetrieveTasks) ⇒ <code>AutomationItem</code>
|
|
1066
1066
|
* [.deploy(metadata, targetBU, retrieveDir)](#Automation.deploy) ⇒ [<code>Promise.<AutomationMap></code>](#AutomationMap)
|
|
1067
1067
|
* [.create(metadata)](#Automation.create) ⇒ <code>Promise</code>
|
|
@@ -1105,7 +1105,7 @@ Retrieves automation metadata for caching
|
|
|
1105
1105
|
**Returns**: <code>Promise.<{metadata:AutomationMap, type:string}></code> - Promise of metadata
|
|
1106
1106
|
<a name="Automation.retrieveAsTemplate"></a>
|
|
1107
1107
|
|
|
1108
|
-
### Automation.retrieveAsTemplate(templateDir, name,
|
|
1108
|
+
### Automation.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.<{metadata:AutomationMap, type:string}></code>
|
|
1109
1109
|
Retrieve a specific Automation Definition by Name
|
|
1110
1110
|
|
|
1111
1111
|
**Kind**: static method of [<code>Automation</code>](#Automation)
|
|
@@ -1115,7 +1115,7 @@ Retrieve a specific Automation Definition by Name
|
|
|
1115
1115
|
| --- | --- | --- |
|
|
1116
1116
|
| templateDir | <code>string</code> | Directory where retrieved metadata directory will be saved |
|
|
1117
1117
|
| name | <code>string</code> | name of the metadata file |
|
|
1118
|
-
|
|
|
1118
|
+
| templateVariables | <code>Util.TemplateMap</code> | variables to be replaced in the metadata |
|
|
1119
1119
|
|
|
1120
1120
|
<a name="Automation.postRetrieveTasks"></a>
|
|
1121
1121
|
|
|
@@ -1369,7 +1369,7 @@ DataExtension MetadataType
|
|
|
1369
1369
|
* [.document(buObject, [metadata], [isDeploy])](#DataExtension.document) ⇒ <code>Promise.<void></code>
|
|
1370
1370
|
* [.deleteByKey(buObject, customerKey)](#DataExtension.deleteByKey) ⇒ <code>Promise.<void></code>
|
|
1371
1371
|
* [.retrieveForCache(buObject, [_], [isDeploy])](#DataExtension.retrieveForCache) ⇒ <code>Promise</code>
|
|
1372
|
-
* [.retrieveAsTemplate(templateDir, name,
|
|
1372
|
+
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#DataExtension.retrieveAsTemplate) ⇒ <code>Promise.<{metadata:DataExtensionMap, type:string}></code>
|
|
1373
1373
|
|
|
1374
1374
|
<a name="DataExtension.client"></a>
|
|
1375
1375
|
|
|
@@ -1534,7 +1534,7 @@ Retrieves folder metadata into local filesystem. Also creates a uniquePath attri
|
|
|
1534
1534
|
|
|
1535
1535
|
<a name="DataExtension.retrieveAsTemplate"></a>
|
|
1536
1536
|
|
|
1537
|
-
### DataExtension.retrieveAsTemplate(templateDir, name,
|
|
1537
|
+
### DataExtension.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.<{metadata:DataExtensionMap, type:string}></code>
|
|
1538
1538
|
Retrieves dataExtension metadata in template format.
|
|
1539
1539
|
|
|
1540
1540
|
**Kind**: static method of [<code>DataExtension</code>](#DataExtension)
|
|
@@ -1544,7 +1544,7 @@ Retrieves dataExtension metadata in template format.
|
|
|
1544
1544
|
| --- | --- | --- |
|
|
1545
1545
|
| templateDir | <code>string</code> | Directory where retrieved metadata directory will be saved |
|
|
1546
1546
|
| name | <code>string</code> | name of the metadata item |
|
|
1547
|
-
|
|
|
1547
|
+
| templateVariables | <code>Util.TemplateMap</code> | variables to be replaced in the metadata |
|
|
1548
1548
|
|
|
1549
1549
|
<a name="DataExtensionField"></a>
|
|
1550
1550
|
|
|
@@ -1671,7 +1671,7 @@ DataExtract MetadataType
|
|
|
1671
1671
|
* [DataExtract](#DataExtract) ⇐ [<code>MetadataType</code>](#MetadataType)
|
|
1672
1672
|
* [.retrieve(retrieveDir)](#DataExtract.retrieve) ⇒ <code>Promise.<Object></code>
|
|
1673
1673
|
* [.retrieveForCache()](#DataExtract.retrieveForCache) ⇒ <code>Promise.<Object></code>
|
|
1674
|
-
* [.retrieveAsTemplate(templateDir, name,
|
|
1674
|
+
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#DataExtract.retrieveAsTemplate) ⇒ <code>Promise.<Object></code>
|
|
1675
1675
|
* [.postRetrieveTasks(fileTransfer)](#DataExtract.postRetrieveTasks) ⇒ <code>Array.<Object></code>
|
|
1676
1676
|
* [.create(dataExtract)](#DataExtract.create) ⇒ <code>Promise</code>
|
|
1677
1677
|
* [.update(dataExtract)](#DataExtract.update) ⇒ <code>Promise</code>
|
|
@@ -1700,7 +1700,7 @@ Retrieves Metadata of Data Extract Activity for caching
|
|
|
1700
1700
|
**Returns**: <code>Promise.<Object></code> - Promise of metadata
|
|
1701
1701
|
<a name="DataExtract.retrieveAsTemplate"></a>
|
|
1702
1702
|
|
|
1703
|
-
### DataExtract.retrieveAsTemplate(templateDir, name,
|
|
1703
|
+
### DataExtract.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.<Object></code>
|
|
1704
1704
|
Retrieve a specific dataExtract Definition by Name
|
|
1705
1705
|
|
|
1706
1706
|
**Kind**: static method of [<code>DataExtract</code>](#DataExtract)
|
|
@@ -1710,7 +1710,7 @@ Retrieve a specific dataExtract Definition by Name
|
|
|
1710
1710
|
| --- | --- | --- |
|
|
1711
1711
|
| templateDir | <code>String</code> | Directory where retrieved metadata directory will be saved |
|
|
1712
1712
|
| name | <code>String</code> | name of the metadata file |
|
|
1713
|
-
|
|
|
1713
|
+
| templateVariables | <code>Object</code> | variables to be replaced in the metadata |
|
|
1714
1714
|
|
|
1715
1715
|
<a name="DataExtract.postRetrieveTasks"></a>
|
|
1716
1716
|
|
|
@@ -1977,7 +1977,7 @@ EventDefinition MetadataType
|
|
|
1977
1977
|
* [EventDefinition](#EventDefinition) ⇐ [<code>MetadataType</code>](#MetadataType)
|
|
1978
1978
|
* [.retrieve(retrieveDir)](#EventDefinition.retrieve) ⇒ <code>Promise.<Object></code>
|
|
1979
1979
|
* [.retrieveForCache()](#EventDefinition.retrieveForCache) ⇒ <code>Promise.<Object></code>
|
|
1980
|
-
* [.retrieveAsTemplate(templateDir, name,
|
|
1980
|
+
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#EventDefinition.retrieveAsTemplate) ⇒ <code>Promise.<Object></code>
|
|
1981
1981
|
* [.postRetrieveTasks(eventDef)](#EventDefinition.postRetrieveTasks) ⇒ <code>Array.<Object></code>
|
|
1982
1982
|
* [.create(EventDefinition)](#EventDefinition.create) ⇒ <code>Promise</code>
|
|
1983
1983
|
* [.update(EventDefinition)](#EventDefinition.update) ⇒ <code>Promise</code>
|
|
@@ -2007,7 +2007,7 @@ Retrieves event definition metadata for caching
|
|
|
2007
2007
|
**Returns**: <code>Promise.<Object></code> - Promise of metadata
|
|
2008
2008
|
<a name="EventDefinition.retrieveAsTemplate"></a>
|
|
2009
2009
|
|
|
2010
|
-
### EventDefinition.retrieveAsTemplate(templateDir, name,
|
|
2010
|
+
### EventDefinition.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise.<Object></code>
|
|
2011
2011
|
Retrieve a specific Event Definition by Name
|
|
2012
2012
|
|
|
2013
2013
|
**Kind**: static method of [<code>EventDefinition</code>](#EventDefinition)
|
|
@@ -2017,7 +2017,7 @@ Retrieve a specific Event Definition by Name
|
|
|
2017
2017
|
| --- | --- | --- |
|
|
2018
2018
|
| templateDir | <code>String</code> | Directory where retrieved metadata directory will be saved |
|
|
2019
2019
|
| name | <code>String</code> | name of the metadata file |
|
|
2020
|
-
|
|
|
2020
|
+
| templateVariables | <code>Object</code> | variables to be replaced in the metadata |
|
|
2021
2021
|
|
|
2022
2022
|
<a name="EventDefinition.postRetrieveTasks"></a>
|
|
2023
2023
|
|
|
@@ -2090,7 +2090,7 @@ FileTransfer MetadataType
|
|
|
2090
2090
|
* [FileTransfer](#FileTransfer) ⇐ [<code>MetadataType</code>](#MetadataType)
|
|
2091
2091
|
* [.retrieve(retrieveDir)](#FileTransfer.retrieve) ⇒ <code>Promise</code>
|
|
2092
2092
|
* [.retrieveForCache()](#FileTransfer.retrieveForCache) ⇒ <code>Promise</code>
|
|
2093
|
-
* [.retrieveAsTemplate(templateDir, name,
|
|
2093
|
+
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#FileTransfer.retrieveAsTemplate) ⇒ <code>Promise</code>
|
|
2094
2094
|
* [.postRetrieveTasks(metadata)](#FileTransfer.postRetrieveTasks) ⇒ <code>Array.<Object></code>
|
|
2095
2095
|
* [.create(fileTransfer)](#FileTransfer.create) ⇒ <code>Promise</code>
|
|
2096
2096
|
* [.update(fileTransfer)](#FileTransfer.update) ⇒ <code>Promise</code>
|
|
@@ -2119,7 +2119,7 @@ Retrieves Metadata of FileTransfer Activity for caching
|
|
|
2119
2119
|
**Returns**: <code>Promise</code> - Promise
|
|
2120
2120
|
<a name="FileTransfer.retrieveAsTemplate"></a>
|
|
2121
2121
|
|
|
2122
|
-
### FileTransfer.retrieveAsTemplate(templateDir, name,
|
|
2122
|
+
### FileTransfer.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise</code>
|
|
2123
2123
|
Retrieve a specific File Transfer Definition by Name
|
|
2124
2124
|
|
|
2125
2125
|
**Kind**: static method of [<code>FileTransfer</code>](#FileTransfer)
|
|
@@ -2129,7 +2129,7 @@ Retrieve a specific File Transfer Definition by Name
|
|
|
2129
2129
|
| --- | --- | --- |
|
|
2130
2130
|
| templateDir | <code>String</code> | Directory where retrieved metadata directory will be saved |
|
|
2131
2131
|
| name | <code>String</code> | name of the metadata file |
|
|
2132
|
-
|
|
|
2132
|
+
| templateVariables | <code>Object</code> | variables to be replaced in the metadata |
|
|
2133
2133
|
|
|
2134
2134
|
<a name="FileTransfer.postRetrieveTasks"></a>
|
|
2135
2135
|
|
|
@@ -2404,7 +2404,7 @@ ImportFile MetadataType
|
|
|
2404
2404
|
* [ImportFile](#ImportFile) ⇐ [<code>MetadataType</code>](#MetadataType)
|
|
2405
2405
|
* [.retrieve(retrieveDir)](#ImportFile.retrieve) ⇒ <code>Promise</code>
|
|
2406
2406
|
* [.retrieveForCache()](#ImportFile.retrieveForCache) ⇒ <code>Promise</code>
|
|
2407
|
-
* [.retrieveAsTemplate(templateDir, name,
|
|
2407
|
+
* [.retrieveAsTemplate(templateDir, name, templateVariables)](#ImportFile.retrieveAsTemplate) ⇒ <code>Promise</code>
|
|
2408
2408
|
* [.postRetrieveTasks(importDef)](#ImportFile.postRetrieveTasks) ⇒ <code>Array.<Object></code>
|
|
2409
2409
|
* [.create(importFile)](#ImportFile.create) ⇒ <code>Promise</code>
|
|
2410
2410
|
* [.update(importFile)](#ImportFile.update) ⇒ <code>Promise</code>
|
|
@@ -2434,7 +2434,7 @@ Retrieves import definition metadata for caching
|
|
|
2434
2434
|
**Returns**: <code>Promise</code> - Promise
|
|
2435
2435
|
<a name="ImportFile.retrieveAsTemplate"></a>
|
|
2436
2436
|
|
|
2437
|
-
### ImportFile.retrieveAsTemplate(templateDir, name,
|
|
2437
|
+
### ImportFile.retrieveAsTemplate(templateDir, name, templateVariables) ⇒ <code>Promise</code>
|
|
2438
2438
|
Retrieve a specific Import Definition by Name
|
|
2439
2439
|
|
|
2440
2440
|
**Kind**: static method of [<code>ImportFile</code>](#ImportFile)
|
|
@@ -2444,7 +2444,7 @@ Retrieve a specific Import Definition by Name
|
|
|
2444
2444
|
| --- | --- | --- |
|
|
2445
2445
|
| templateDir | <code>String</code> | Directory where retrieved metadata directory will be saved |
|
|
2446
2446
|
| name | <code>String</code> | name of the metadata file |
|
|
2447
|
-
|
|
|
2447
|
+
| templateVariables | <code>Object</code> | variables to be replaced in the metadata |
|
|
2448
2448
|
|
|
2449
2449
|
<a name="ImportFile.postRetrieveTasks"></a>
|
|
2450
2450
|
|
|
@@ -202,10 +202,10 @@ class Automation extends MetadataType {
|
|
|
202
202
|
* Retrieve a specific Automation Definition by Name
|
|
203
203
|
* @param {string} templateDir Directory where retrieved metadata directory will be saved
|
|
204
204
|
* @param {string} name name of the metadata file
|
|
205
|
-
* @param {Util.TemplateMap}
|
|
205
|
+
* @param {Util.TemplateMap} templateVariables variables to be replaced in the metadata
|
|
206
206
|
* @returns {Promise<{metadata:AutomationMap,type:string}>} Promise of metadata
|
|
207
207
|
*/
|
|
208
|
-
static async retrieveAsTemplate(templateDir, name,
|
|
208
|
+
static async retrieveAsTemplate(templateDir, name, templateVariables) {
|
|
209
209
|
const results = await new Promise((resolve) => {
|
|
210
210
|
this.client.SoapClient.retrieve(
|
|
211
211
|
'Program',
|
|
@@ -239,12 +239,14 @@ class Automation extends MetadataType {
|
|
|
239
239
|
})
|
|
240
240
|
).body;
|
|
241
241
|
let val = null;
|
|
242
|
+
let originalKey;
|
|
242
243
|
// if parsing fails, we should just save what we get
|
|
243
244
|
try {
|
|
244
245
|
const parsedDetails = this.parseMetadata(details);
|
|
246
|
+
originalKey = parsedDetails[this.definition.keyField];
|
|
245
247
|
if (parsedDetails !== null) {
|
|
246
248
|
val = JSON.parse(
|
|
247
|
-
Util.replaceByObject(JSON.stringify(parsedDetails),
|
|
249
|
+
Util.replaceByObject(JSON.stringify(parsedDetails), templateVariables)
|
|
248
250
|
);
|
|
249
251
|
}
|
|
250
252
|
} catch (ex) {
|
|
@@ -259,7 +261,7 @@ class Automation extends MetadataType {
|
|
|
259
261
|
this.keepTemplateFields(val);
|
|
260
262
|
File.writeJSONToFile(
|
|
261
263
|
[templateDir, this.definition.type].join('/'),
|
|
262
|
-
|
|
264
|
+
originalKey + '.' + this.definition.type + '-meta',
|
|
263
265
|
val
|
|
264
266
|
);
|
|
265
267
|
Util.logger.info(
|
|
@@ -868,10 +868,10 @@ class DataExtension extends MetadataType {
|
|
|
868
868
|
* Retrieves dataExtension metadata in template format.
|
|
869
869
|
* @param {string} templateDir Directory where retrieved metadata directory will be saved
|
|
870
870
|
* @param {string} name name of the metadata item
|
|
871
|
-
* @param {Util.TemplateMap}
|
|
871
|
+
* @param {Util.TemplateMap} templateVariables variables to be replaced in the metadata
|
|
872
872
|
* @returns {Promise<{metadata:DataExtensionMap,type:string}>} Promise of items
|
|
873
873
|
*/
|
|
874
|
-
static async retrieveAsTemplate(templateDir, name,
|
|
874
|
+
static async retrieveAsTemplate(templateDir, name, templateVariables) {
|
|
875
875
|
const options = {
|
|
876
876
|
filter: {
|
|
877
877
|
leftOperand: 'Name',
|
|
@@ -896,20 +896,20 @@ class DataExtension extends MetadataType {
|
|
|
896
896
|
// API returns field unsorted
|
|
897
897
|
metadata[key].Fields.sort((a, b) => a.Ordinal - b.Ordinal);
|
|
898
898
|
|
|
899
|
+
const originalKey = key;
|
|
899
900
|
const metadataCleaned = JSON.parse(
|
|
900
|
-
JSON.stringify(
|
|
901
|
+
JSON.stringify(
|
|
902
|
+
await this.postRetrieveTasks(metadata[key], null, !!templateVariables)
|
|
903
|
+
)
|
|
901
904
|
);
|
|
902
905
|
|
|
903
906
|
this.keepTemplateFields(metadataCleaned);
|
|
904
907
|
const metadataTemplated = JSON.parse(
|
|
905
|
-
Util.replaceByObject(JSON.stringify(metadataCleaned),
|
|
908
|
+
Util.replaceByObject(JSON.stringify(metadataCleaned), templateVariables)
|
|
906
909
|
);
|
|
907
910
|
File.writeJSONToFile(
|
|
908
911
|
[templateDir, this.definition.type].join('/'),
|
|
909
|
-
|
|
910
|
-
'.' +
|
|
911
|
-
this.definition.type +
|
|
912
|
-
'-meta',
|
|
912
|
+
originalKey + '.' + this.definition.type + '-meta',
|
|
913
913
|
metadataTemplated
|
|
914
914
|
);
|
|
915
915
|
} catch (ex) {
|
|
@@ -30,10 +30,10 @@ class DataExtract extends MetadataType {
|
|
|
30
30
|
* Retrieve a specific dataExtract Definition by Name
|
|
31
31
|
* @param {String} templateDir Directory where retrieved metadata directory will be saved
|
|
32
32
|
* @param {String} name name of the metadata file
|
|
33
|
-
* @param {Object}
|
|
33
|
+
* @param {Object} templateVariables variables to be replaced in the metadata
|
|
34
34
|
* @returns {Promise<Object>} Promise of metadata
|
|
35
35
|
*/
|
|
36
|
-
static async retrieveAsTemplate(templateDir, name,
|
|
36
|
+
static async retrieveAsTemplate(templateDir, name, templateVariables) {
|
|
37
37
|
const options = {
|
|
38
38
|
uri: '/automation/v1/dataextracts/?$filter=name%20eq%20' + name.split(' ').join('%20'),
|
|
39
39
|
};
|
|
@@ -51,16 +51,20 @@ class DataExtract extends MetadataType {
|
|
|
51
51
|
const extended = await this.client.RestClient.get({
|
|
52
52
|
uri: '/automation/v1/dataextracts/' + metadata.id,
|
|
53
53
|
});
|
|
54
|
+
const originalKey = extended.body[this.definition.keyField];
|
|
54
55
|
const val = JSON.parse(
|
|
55
|
-
Util.replaceByObject(
|
|
56
|
+
Util.replaceByObject(
|
|
57
|
+
JSON.stringify(this.parseMetadata(extended.body)),
|
|
58
|
+
templateVariables
|
|
59
|
+
)
|
|
56
60
|
);
|
|
57
61
|
|
|
58
62
|
// remove all fields listed in Definition for templating
|
|
59
63
|
this.keepTemplateFields(val);
|
|
60
64
|
File.writeJSONToFile(
|
|
61
65
|
[templateDir, this.definition.type].join('/'),
|
|
62
|
-
|
|
63
|
-
JSON.parse(Util.replaceByObject(JSON.stringify(val),
|
|
66
|
+
originalKey + '.' + this.definition.type + '-meta',
|
|
67
|
+
JSON.parse(Util.replaceByObject(JSON.stringify(val), templateVariables))
|
|
64
68
|
);
|
|
65
69
|
Util.logger.info(
|
|
66
70
|
`Dataextracts.retrieveAsTemplate:: Written Metadata to filesystem (${name})`
|
|
@@ -32,10 +32,10 @@ class EventDefinition extends MetadataType {
|
|
|
32
32
|
* Retrieve a specific Event Definition by Name
|
|
33
33
|
* @param {String} templateDir Directory where retrieved metadata directory will be saved
|
|
34
34
|
* @param {String} name name of the metadata file
|
|
35
|
-
* @param {Object}
|
|
35
|
+
* @param {Object} templateVariables variables to be replaced in the metadata
|
|
36
36
|
* @returns {Promise<Object>} Promise of metadata
|
|
37
37
|
*/
|
|
38
|
-
static async retrieveAsTemplate(templateDir, name,
|
|
38
|
+
static async retrieveAsTemplate(templateDir, name, templateVariables) {
|
|
39
39
|
// todo template based on name
|
|
40
40
|
const options = {
|
|
41
41
|
uri: '/interaction/v1/EventDefinitions?name=' + encodeURIComponent(name),
|
|
@@ -51,8 +51,12 @@ class EventDefinition extends MetadataType {
|
|
|
51
51
|
`please rename to be unique to avoid issues`
|
|
52
52
|
);
|
|
53
53
|
} else if (event && event.length === 1) {
|
|
54
|
+
const originalKey = event[0][this.definition.keyField];
|
|
54
55
|
const eventDef = JSON.parse(
|
|
55
|
-
Util.replaceByObject(
|
|
56
|
+
Util.replaceByObject(
|
|
57
|
+
JSON.stringify(this.parseMetadata(event[0])),
|
|
58
|
+
templateVariables
|
|
59
|
+
)
|
|
56
60
|
);
|
|
57
61
|
if (!eventDef.dataExtensionId) {
|
|
58
62
|
throw new Error(
|
|
@@ -67,8 +71,8 @@ class EventDefinition extends MetadataType {
|
|
|
67
71
|
this.keepTemplateFields(eventDef);
|
|
68
72
|
File.writeJSONToFile(
|
|
69
73
|
[templateDir, this.definition.type].join('/'),
|
|
70
|
-
|
|
71
|
-
JSON.parse(Util.replaceByObject(JSON.stringify(eventDef),
|
|
74
|
+
originalKey + '.' + this.definition.type + '-meta',
|
|
75
|
+
JSON.parse(Util.replaceByObject(JSON.stringify(eventDef), templateVariables))
|
|
72
76
|
);
|
|
73
77
|
Util.logger.info(
|
|
74
78
|
`EventDefinition.retrieveAsTemplate:: Written Metadata to filesystem (${name})`
|
|
@@ -30,10 +30,10 @@ class FileTransfer extends MetadataType {
|
|
|
30
30
|
* Retrieve a specific File Transfer Definition by Name
|
|
31
31
|
* @param {String} templateDir Directory where retrieved metadata directory will be saved
|
|
32
32
|
* @param {String} name name of the metadata file
|
|
33
|
-
* @param {Object}
|
|
33
|
+
* @param {Object} templateVariables variables to be replaced in the metadata
|
|
34
34
|
* @returns {Promise} Promise
|
|
35
35
|
*/
|
|
36
|
-
static async retrieveAsTemplate(templateDir, name,
|
|
36
|
+
static async retrieveAsTemplate(templateDir, name, templateVariables) {
|
|
37
37
|
const options = {
|
|
38
38
|
uri: '/automation/v1/filetransfers/?$filter=name%20eq%20' + name.split(' ').join('%20'),
|
|
39
39
|
};
|
|
@@ -51,16 +51,20 @@ class FileTransfer extends MetadataType {
|
|
|
51
51
|
const extended = await this.client.RestClient.get({
|
|
52
52
|
uri: '/automation/v1/filetransfers/' + metadata.id,
|
|
53
53
|
});
|
|
54
|
+
const originalKey = extended.body[this.definition.keyField];
|
|
54
55
|
const val = JSON.parse(
|
|
55
|
-
Util.replaceByObject(
|
|
56
|
+
Util.replaceByObject(
|
|
57
|
+
JSON.stringify(this.parseMetadata(extended.body)),
|
|
58
|
+
templateVariables
|
|
59
|
+
)
|
|
56
60
|
);
|
|
57
61
|
|
|
58
62
|
// remove all fields listed in Definition for templating
|
|
59
63
|
this.keepTemplateFields(val);
|
|
60
64
|
File.writeJSONToFile(
|
|
61
65
|
[templateDir, this.definition.type].join('/'),
|
|
62
|
-
|
|
63
|
-
JSON.parse(Util.replaceByObject(JSON.stringify(val),
|
|
66
|
+
originalKey + '.' + this.definition.type + '-meta',
|
|
67
|
+
JSON.parse(Util.replaceByObject(JSON.stringify(val), templateVariables))
|
|
64
68
|
);
|
|
65
69
|
Util.logger.info(
|
|
66
70
|
`FileTransfer.retrieveAsTemplate:: Written Metadata to filesystem (${name})`
|
|
@@ -32,10 +32,10 @@ class ImportFile extends MetadataType {
|
|
|
32
32
|
* Retrieve a specific Import Definition by Name
|
|
33
33
|
* @param {String} templateDir Directory where retrieved metadata directory will be saved
|
|
34
34
|
* @param {String} name name of the metadata file
|
|
35
|
-
* @param {Object}
|
|
35
|
+
* @param {Object} templateVariables variables to be replaced in the metadata
|
|
36
36
|
* @returns {Promise} Promise
|
|
37
37
|
*/
|
|
38
|
-
static async retrieveAsTemplate(templateDir, name,
|
|
38
|
+
static async retrieveAsTemplate(templateDir, name, templateVariables) {
|
|
39
39
|
const options = {
|
|
40
40
|
uri: '/automation/v1/imports/?$filter=name%20eq%20' + name.split(' ').join('%20'),
|
|
41
41
|
};
|
|
@@ -48,17 +48,20 @@ class ImportFile extends MetadataType {
|
|
|
48
48
|
Util.logger.error(`No ${this.definition.typeName} found with name "${name}"`);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
const originalKey = metadata[this.definition.keyField];
|
|
52
52
|
const val = JSON.parse(
|
|
53
|
-
Util.replaceByObject(
|
|
53
|
+
Util.replaceByObject(
|
|
54
|
+
JSON.stringify(this.parseMetadata(metadata)),
|
|
55
|
+
templateVariables
|
|
56
|
+
)
|
|
54
57
|
);
|
|
55
58
|
|
|
56
59
|
// remove all fields listed in Definition for templating
|
|
57
60
|
this.keepTemplateFields(val);
|
|
58
61
|
File.writeJSONToFile(
|
|
59
62
|
[templateDir, this.definition.type].join('/'),
|
|
60
|
-
|
|
61
|
-
JSON.parse(Util.replaceByObject(JSON.stringify(val),
|
|
63
|
+
originalKey + '.' + this.definition.type + '-meta',
|
|
64
|
+
JSON.parse(Util.replaceByObject(JSON.stringify(val), templateVariables))
|
|
62
65
|
);
|
|
63
66
|
Util.logger.info(
|
|
64
67
|
`ImportFile.retrieveAsTemplate:: Written Metadata to filesystem (${name})`
|
|
@@ -1072,11 +1072,11 @@ class MetadataType {
|
|
|
1072
1072
|
const savedResults = {};
|
|
1073
1073
|
const subtypeExtension = '.' + (overrideType || this.definition.type) + '-meta';
|
|
1074
1074
|
let filterCounter = 0;
|
|
1075
|
-
for (const
|
|
1075
|
+
for (const originalKey in results) {
|
|
1076
1076
|
try {
|
|
1077
1077
|
if (
|
|
1078
|
-
this.isFiltered(results[
|
|
1079
|
-
this.isFiltered(results[
|
|
1078
|
+
this.isFiltered(results[originalKey], true) ||
|
|
1079
|
+
this.isFiltered(results[originalKey], false)
|
|
1080
1080
|
) {
|
|
1081
1081
|
// if current metadata entry is filtered don't save it
|
|
1082
1082
|
filterCounter++;
|
|
@@ -1085,21 +1085,21 @@ class MetadataType {
|
|
|
1085
1085
|
// define directory into which the current metdata shall be saved
|
|
1086
1086
|
const baseDir = [retrieveDir, ...(overrideType || this.definition.type).split('-')];
|
|
1087
1087
|
|
|
1088
|
-
results[
|
|
1089
|
-
results[
|
|
1088
|
+
results[originalKey] = await this.postRetrieveTasks(
|
|
1089
|
+
results[originalKey],
|
|
1090
1090
|
retrieveDir,
|
|
1091
1091
|
templateVariables ? true : false
|
|
1092
1092
|
);
|
|
1093
|
-
if (!results[
|
|
1093
|
+
if (!results[originalKey] || results[originalKey] === null) {
|
|
1094
1094
|
// we encountered a situation in our postRetrieveTasks that made us want to filter this record
|
|
1095
|
-
delete results[
|
|
1095
|
+
delete results[originalKey];
|
|
1096
1096
|
filterCounter++;
|
|
1097
1097
|
continue;
|
|
1098
1098
|
}
|
|
1099
1099
|
|
|
1100
1100
|
if (
|
|
1101
|
-
this.isFilteredFolder(results[
|
|
1102
|
-
this.isFilteredFolder(results[
|
|
1101
|
+
this.isFilteredFolder(results[originalKey], true) ||
|
|
1102
|
+
this.isFilteredFolder(results[originalKey], false)
|
|
1103
1103
|
) {
|
|
1104
1104
|
// if current metadata entry is filtered don't save it
|
|
1105
1105
|
filterCounter++;
|
|
@@ -1107,20 +1107,20 @@ class MetadataType {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
1109
|
// for complex types like asset, script, query we need to save the scripts that were extracted from the JSON
|
|
1110
|
-
if (results[
|
|
1110
|
+
if (results[originalKey].json && results[originalKey].codeArr) {
|
|
1111
1111
|
// replace market values with template variable placeholders (do not do it on .codeArr)
|
|
1112
1112
|
if (templateVariables) {
|
|
1113
|
-
results[
|
|
1114
|
-
results[
|
|
1113
|
+
results[originalKey].json = Util.replaceByObject(
|
|
1114
|
+
results[originalKey].json,
|
|
1115
1115
|
templateVariables
|
|
1116
1116
|
);
|
|
1117
|
-
results[
|
|
1118
|
-
results[
|
|
1117
|
+
results[originalKey].subFolder = Util.replaceByObject(
|
|
1118
|
+
results[originalKey].subFolder,
|
|
1119
1119
|
templateVariables
|
|
1120
1120
|
);
|
|
1121
1121
|
}
|
|
1122
1122
|
|
|
1123
|
-
const postRetrieveData = results[
|
|
1123
|
+
const postRetrieveData = results[originalKey];
|
|
1124
1124
|
if (postRetrieveData.subFolder) {
|
|
1125
1125
|
// very complex types have their own subfolder
|
|
1126
1126
|
baseDir.push(...postRetrieveData.subFolder);
|
|
@@ -1141,13 +1141,13 @@ class MetadataType {
|
|
|
1141
1141
|
);
|
|
1142
1142
|
}
|
|
1143
1143
|
// normalize results[metadataEntry]
|
|
1144
|
-
results[
|
|
1144
|
+
results[originalKey] = postRetrieveData.json;
|
|
1145
1145
|
} else {
|
|
1146
1146
|
// not a complex type, run the the entire JSON through templating
|
|
1147
1147
|
// replace market values with template variable placeholders
|
|
1148
1148
|
if (templateVariables) {
|
|
1149
|
-
results[
|
|
1150
|
-
results[
|
|
1149
|
+
results[originalKey] = Util.replaceByObject(
|
|
1150
|
+
results[originalKey],
|
|
1151
1151
|
templateVariables
|
|
1152
1152
|
);
|
|
1153
1153
|
}
|
|
@@ -1156,7 +1156,7 @@ class MetadataType {
|
|
|
1156
1156
|
// we dont store Id on local disk, but we need it for caching logic,
|
|
1157
1157
|
// so its in retrieve but not in save. Here we put into the clone so that the original
|
|
1158
1158
|
// object used for caching doesnt have the Id removed.
|
|
1159
|
-
const saveClone = JSON.parse(JSON.stringify(results[
|
|
1159
|
+
const saveClone = JSON.parse(JSON.stringify(results[originalKey]));
|
|
1160
1160
|
if (!this.definition.keepId) {
|
|
1161
1161
|
delete saveClone[this.definition.idField];
|
|
1162
1162
|
}
|
|
@@ -1166,22 +1166,16 @@ class MetadataType {
|
|
|
1166
1166
|
} else {
|
|
1167
1167
|
this.keepRetrieveFields(saveClone);
|
|
1168
1168
|
}
|
|
1169
|
-
savedResults[
|
|
1169
|
+
savedResults[originalKey] = saveClone;
|
|
1170
1170
|
File.writeJSONToFile(
|
|
1171
1171
|
// manage subtypes
|
|
1172
1172
|
baseDir,
|
|
1173
|
-
|
|
1173
|
+
originalKey + subtypeExtension,
|
|
1174
1174
|
saveClone
|
|
1175
1175
|
);
|
|
1176
1176
|
} catch (ex) {
|
|
1177
1177
|
console.log(ex.stack);
|
|
1178
|
-
Util.metadataLogger(
|
|
1179
|
-
'error',
|
|
1180
|
-
this.definition.type,
|
|
1181
|
-
'saveResults',
|
|
1182
|
-
ex,
|
|
1183
|
-
metadataEntry
|
|
1184
|
-
);
|
|
1178
|
+
Util.metadataLogger('error', this.definition.type, 'saveResults', ex, originalKey);
|
|
1185
1179
|
}
|
|
1186
1180
|
}
|
|
1187
1181
|
if (filterCounter) {
|
|
@@ -178,12 +178,12 @@ class Script extends MetadataType {
|
|
|
178
178
|
templateName
|
|
179
179
|
) {
|
|
180
180
|
// get SSJS from filesystem
|
|
181
|
-
let code = this._mergeCode(metadata, templateDir, templateName);
|
|
182
|
-
|
|
181
|
+
let code = await this._mergeCode(metadata, templateDir, templateName);
|
|
183
182
|
// replace template variables with their values
|
|
184
183
|
try {
|
|
185
184
|
code = Mustache.render(code, variables);
|
|
186
185
|
} catch (ex) {
|
|
186
|
+
Util.logger.debug('script.buildDefinitionForExtracts: ' + ex.message);
|
|
187
187
|
throw new Error(
|
|
188
188
|
`${this.definition.type}:: Error applying template variables on ${
|
|
189
189
|
metadata[this.definition.keyField] + '.' + this.definition.type
|