Skip to content

Commit

Permalink
#38: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phjulia committed Jul 14, 2023
1 parent b0db4b0 commit 969dbda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
6 changes: 3 additions & 3 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ main class
* [.schedule(businessUnit, [selectedType], [keys])](#Mcdev.schedule) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.execute(businessUnit, [selectedType], [keys])](#Mcdev.execute) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.pause(businessUnit, [selectedType], [keys])](#Mcdev.pause) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.fixKeys(businessUnit, type, [keys])](#Mcdev.fixKeys) ⇒ <code>Array</code>
* [.fixKeys(businessUnit, type, [keys])](#Mcdev.fixKeys) ⇒ <code>Array.&lt;string&gt;</code>

<a name="Mcdev.setSkipInteraction"></a>

Expand Down Expand Up @@ -819,11 +819,11 @@ pause an item

<a name="Mcdev.fixKeys"></a>

### Mcdev.fixKeys(businessUnit, type, [keys]) ⇒ <code>Array</code>
### Mcdev.fixKeys(businessUnit, type, [keys]) ⇒ <code>Array.&lt;string&gt;</code>
Updates the key to match the name field

**Kind**: static method of [<code>Mcdev</code>](#Mcdev)
**Returns**: <code>Array</code> - array of fixedKeys
**Returns**: <code>Array.&lt;string&gt;</code> - list of fixedKeys

| Param | Type | Description |
| --- | --- | --- |
Expand Down
15 changes: 3 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ class Mcdev {
* @param {string} businessUnit name of BU
* @param {TYPE.SupportedMetadataTypes} type limit execution to given metadata type
* @param {string[]} [keys] customerkey of the metadata
* @returns {Array} array of fixedKeys
* @returns {string[]} list of fixedKeys
*/
static async fixKeys(businessUnit, type, keys) {
Util.startLogger();
Expand Down Expand Up @@ -1068,16 +1068,6 @@ class Mcdev {
const retrieved = await retriever.retrieve([type], keys, null, false);

const typeArr = Object.values(retrieved)[0];
// merge results if multiple keys were provided
if (keys?.length > 1) {
const base = typeArr[0];
for (let i = 1; i < typeArr.length; i++) {
// merge all items into the first array
Object.assign(base, typeArr[i]);
}
// kick out all but first entry
typeArr.length = 1;
}
const keysForDeploy = MetadataTypeInfo[type].getKeysForFixing(typeArr[0], type);
numItemsToUpdate = keysForDeploy.length;
if (numItemsToUpdate < 1) {
Expand All @@ -1088,6 +1078,7 @@ class Mcdev {
properties.directories.deploy = properties.directories.retrieve;
deployed = await Deployer._deployBU(cred, bu, properties, [type], keysForDeploy, true);
const dependentTypes = await this.#getDependentMetadata(type);
// TODO retrieve and update other types that are dependent on this type.
Util.logger.warn(
`Keys for type '${type}' were updated. Retrieve '${dependentTypes.join(
','
Expand All @@ -1105,7 +1096,7 @@ class Mcdev {
* @private
*
* @param {string} type type of the metadata passed as a parameter to fixKeys function
* @returns {Array} array of types that depend on the given type
* @returns {string[]} array of types that depend on the given type
*/
static async #getDependentMetadata(type) {
const dependencies = [];
Expand Down

0 comments on commit 969dbda

Please sign in to comment.