Repository: Accenture/sfmc-devtools (js)

Issue:
[BUG] delete only processes first --metadata entry
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

assume:
`mcdev del ../.. -m a:key -m b:key2 -m c:key3`
this will only execute delete for a:key but not even error for b:key2 or c:key3

### Expected Behavior

it should delete all 3 elements

### Steps To Reproduce

1. Go to '...'
2. Click on '....'
3. Run '...'
4. See error...


### Version

7.0.3

### Environment

- OS:
- Node:
- npm:


### Participation

- [X] I am willing to submit a pull request for this issue.

### Additional comments

_No response_

Pull request description:
Bug/1411 delete only processes first metadata entry
# PR details

## What changes did you make? (Give an overview)

- closes #1411 

## Further details (optional)

...

## Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] test scripts updated
- [ ] Wiki updated (**TODO**)


Patch:
diff --git a/@types/lib/index.d.ts b/@types/lib/index.d.ts
index 4b611f1f..146ad35d 100644
--- a/@types/lib/index.d.ts
+++ b/@types/lib/index.d.ts
@@ -170,11 +170,11 @@ declare class Mcdev {
      * deletes metadata from MC instance by key
      *
      * @param {string} businessUnit references credentials from properties.json
-     * @param {string} type supported metadata type
-     * @param {string} customerKey Identifier of metadata
+     * @param {string | TypeKeyCombo} selectedTypes supported metadata type (single) or complex object
+     * @param {string[] | string} [keyArr] Identifier of metadata
      * @returns {Promise.<boolean>} true if successful, false otherwise
      */
-    static deleteByKey(businessUnit: string, type: string, customerKey: string): Promise<boolean>;
+    static deleteByKey(businessUnit: string, selectedTypes: string | TypeKeyCombo, keyArr?: string[] | string): Promise<boolean>;
     /**
      * get name & key for provided id
      *
diff --git a/@types/lib/index.d.ts.map b/@types/lib/index.d.ts.map
index bf62130d..fae19fdb 100644
--- a/@types/lib/index.d.ts.map
+++ b/@types/lib/index.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";uBAoBa,OAAO,qBAAqB,EAAE,QAAQ;0BACtC,OAAO,q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GAAC,SAAS,GAAC,oBAAoB,gBAChD,MAAM,iBACN,MAAM,SACN,MAAM,EAAE,GACN;YAAiB,MAAM,GAAE,MAAM,EAAE;MAAE,CAmK/C;IACD;;;;;;;;;OASG;IACH,mCAPW,SAAS,GAAC,OAAO,GAAC,SAAS,GAAC,oBAAoB,QAChD,MAAM,MACN,MAAM,SACN,MAAM,WACN,MAAM,EAAE,GACN,QAAS,MAAM,EAAE,CAAC,CAuD9B;IAED;;;;;;OAMG;IACH,kDAJW,MAAM,YACN,QAAQ,GACN,QAAS,MAAM,EAAE,CAAC,CA0D9B;IACD;;;;;;;;OAQG;IACH,6BANW,MAAM,MACN,MAAM,QACN,MAAM,WACN,MAAM,EAAE,GACN,QAAS,MAAM,EAAE,CAAC,CA0E9B;IACD;;;;;;;;OAQG;IACH,wCANW,MAAM,MACN,MAAM,QACN,MAAM,WACN,MAAM,EAAE,GACN,QAAS,MAAM,EAAE,CAAC,CAyE9B;IACD;;;;;;;OAOG;IACH,yCALW,MAAM,GAAC,MAAM,EAAE,GAAC,SAAS,uBACzB,MAAM,EAAE,cACR,OAAO,GACL,YAAY,CA2ExB;CACJ"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";uBAoBa,OAAO,qBAAqB,EAAE,QAAQ;0BACtC,OAAO,qBAAqB,EAAE,WAAW;8BACzC,OAAO,qBAAqB,EAAE,eAAe;2BAC7C,OAAO,qBAAqB,EAAE,YAAY;sBAC1C,OAAO,qBAAqB,EAAE,OAAO;+BACrC,OAAO,qBAAqB,EAAE,gBAAgB;mCAC9C,OAAO,qBAAqB,EAAE,oBAAoB;kCAClD,OAAO,qBAAqB,EAAE,mBAAmB;8BACjD,OAAO,qBAAqB,EAAE,eAAe;iCAC7C,OAAO,qBAAqB,EAAE,kBAAkB;oCAChD,OAAO,qBAAqB,EAAE,qBAAqB;mCACnD,OAAO,qBAAqB,EAAE,oBAAoB;8BAClD,OAAO,qBAA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D9B;IACD;;;;;;;;OAQG;IACH,6BANW,MAAM,MACN,MAAM,QACN,MAAM,WACN,MAAM,EAAE,GACN,QAAS,MAAM,EAAE,CAAC,CA0E9B;IACD;;;;;;;;OAQG;IACH,wCANW,MAAM,MACN,MAAM,QACN,MAAM,WACN,MAAM,EAAE,GACN,QAAS,MAAM,EAAE,CAAC,CAyE9B;IACD;;;;;;;OAOG;IACH,yCALW,MAAM,GAAC,MAAM,EAAE,GAAC,SAAS,uBACzB,MAAM,EAAE,cACR,OAAO,GACL,YAAY,CA2ExB;CACJ"}
\ No newline at end of file
diff --git a/lib/cli.js b/lib/cli.js
index a6e38b75..369dce07 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -258,21 +258,19 @@ yargs(hideBin(process.argv))
                 .option('metadata', {
                     type: 'string',
                     alias: 'm',
-                    group: 'Options for retrieve:',
-                    describe:
-                        'type or type:key or type:i:id or type:n:name to retrieve; if not provided, all metadata will be retrieved',
+                    group: 'Options for delete:',
+                    describe: 'type or type:key or type:i:id or type:n:name to delete',
                 });
         },
         handler: (argv) => {
             Mcdev.setOptions(argv);
-            const typeKeyCombo = Mcdev.metadataToTypeKey(argv.metadata, ['key', 'id'], true);
+            const typeKeyCombo = Mcdev.metadataToTypeKey(argv.metadata, ['key', 'id']);
             if ('undefined' === typeof typeKeyCombo) {
                 if (argv.TYPE && argv.KEY) {
-                    Mcdev.deleteByKey(argv.BU, argv.TYPE, argv.KEY);
+                    Mcdev.deleteByKey(argv.BU, argv.TYPE, csvToArray(argv.KEY));
                 }
             } else {
-                const type = Object.keys(typeKeyCombo)[0];
-                Mcdev.deleteByKey(argv.BU, type, typeKeyCombo[type][0]);
+                Mcdev.deleteByKey(argv.BU, typeKeyCombo, null);
             }
         },
     })
diff --git a/lib/index.js b/lib/index.js
index 1c5fcd93..e3f7d2d2 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -557,39 +557,74 @@ class Mcdev {
      * deletes metadata from MC instance by key
      *
      * @param {string} businessUnit references credentials from properties.json
-     * @param {string} type supported metadata type
-     * @param {string} customerKey Identifier of metadata
+     * @param {string | TypeKeyCombo} selectedTypes supported metadata type (single) or complex object
+     * @param {string[] | string} [keyArr] Identifier of metadata
      * @returns {Promise.<boolean>} true if successful, false otherwise
      */
-    static async deleteByKey(businessUnit, type, customerKey) {
+    static async deleteByKey(businessUnit, selectedTypes, keyArr) {
         Util.startLogger();
         Util.logger.info('mcdev:: delete');
-        if (!Util._isValidType(type)) {
-            return;
+        /** @typedef {string[]} */
+        let selectedTypesArr;
+        /** @typedef {TypeKeyCombo} */
+        let selectedTypesObj;
+        if ('string' === typeof keyArr) {
+            keyArr = [keyArr];
+        }
+        if ('string' === typeof selectedTypes) {
+            selectedTypesArr = [selectedTypes];
+        } else {
+            selectedTypesObj = selectedTypes;
+            // reset keys array because it will be overriden by values from selectedTypesObj
+            keyArr = null;
+        }
+        // check if types are valid
+        for (const selectedType of selectedTypesArr || Object.keys(selectedTypesObj)) {
+            if (!Util._isValidType(selectedType)) {
+                return;
+            }
         }
         const properties = await config.getProperties();
         if (!(await config.checkProperties(properties))) {
             return null;
         }
         const buObject = await Cli.getCredentialObject(properties, businessUnit);
-        if (buObject !== null) {
-            try {
-                MetadataTypeInfo[type].client = auth.getSDK(buObject);
-            } catch (ex) {
-                Util.logger.error(ex.message);
+        if (!buObject) {
+            return;
+        }
+        let client;
+        try {
+            client = auth.getSDK(buObject);
+        } catch (ex) {
+            Util.logger.error(ex.message);
+            return;
+        }
+        let status = true;
+        for (const type of selectedTypesArr || Object.keys(selectedTypesObj)) {
+            keyArr = selectedTypesArr ? keyArr : selectedTypesObj[type];
+            if (!keyArr) {
+                Util.logger.error(`No keys set for ${type}`);
                 return;
             }
-            Util.logger.info(
-                Util.getGrayMsg(` - Deleting ${type} ${customerKey} on BU ${businessUnit}`)
-            );
-            try {
-                MetadataTypeInfo[type].properties = properties;
-                MetadataTypeInfo[type].buObject = buObject;
-                return await MetadataTypeInfo[type].deleteByKey(customerKey);
-            } catch (ex) {
-                Util.logger.errorStack(ex, ` - Deleting ${type} failed`);
+            for (const key of keyArr) {
+                MetadataTypeInfo[type].client = client;
+
+                Util.logger.info(
+                    Util.getGrayMsg(` - Deleting ${type} ${key} on BU ${businessUnit}`)
+                );
+                try {
+                    MetadataTypeInfo[type].properties = properties;
+                    MetadataTypeInfo[type].buObject = buObject;
+                    const result = await MetadataTypeInfo[type].deleteByKey(key);
+                    status &&= result;
+                } catch (ex) {
+                    Util.logger.errorStack(ex, ` - Deleting ${type} failed`);
+                    status = false;
+                }
             }
         }
+
+        return status;
     }
     /**
      * get name & key for provided id


Test patch:
diff --git a/test/general.test.js b/test/general.test.js
index 9b099c2a..dd997920 100644
--- a/test/general.test.js
+++ b/test/general.test.js
@@ -1191,6 +1191,24 @@ describe('GENERAL', () => {
                 );
             });
         });
+
+        describe('Delete --metadata ~~~', () => {
+            it('Should delete the item', async () => {
+                const argvMetadata = [
+                    'asset:testExisting_asset',
+                    'automation:testExisting_automation',
+                    'journey:testExisting_journey_Quicksend/1',
+                    'journey:testExisting_journey_Multistep/1',
+                ];
+                const typeKeyCombo = handler.metadataToTypeKey(argvMetadata);
+                // WHEN
+                const isDeleted = await handler.deleteByKey('testInstance/testBU', typeKeyCombo);
+                // THEN
+                assert.equal(process.exitCode, 0, 'deleteByKey should not have thrown an error');
+                assert.equal(isDeleted, true, 'deleteByKey should have returned true');
+                return;
+            });
+        });
     });
 
     describe('without --metadata ================', () => {
diff --git a/test/resources/9999999/interaction/v1/interactions/0175b971-71a3-4d8e-98ac-48121f3fbf4f/delete-response.txt b/test/resources/9999999/interaction/v1/interactions/0175b971-71a3-4d8e-98ac-48121f3fbf4f/delete-response.txt
new file mode 100644
index 00000000..9d53d75c
--- /dev/null
+++ b/test/resources/9999999/interaction/v1/interactions/0175b971-71a3-4d8e-98ac-48121f3fbf4f/delete-response.txt
@@ -0,0 +1,1 @@
+0175b971-71a3-4d8e-98ac-48121f3fbf4f
\ No newline at end of file
diff --git a/test/type.journey.test.js b/test/type.journey.test.js
index ef459b0b..de62e25a 100644
--- a/test/type.journey.test.js
+++ b/test/type.journey.test.js
@@ -278,6 +278,19 @@ describe('type: journey', () => {
             assert.equal(isDeleted, true, 'should have deleted the item');
             return;
         });
+
+        it('Should delete 2 items with version', async () => {
+            // WHEN
+            const isDeleted = await handler.deleteByKey('testInstance/testBU', 'journey', [
+                'testExisting_journey_Quicksend/1',
+                'testExisting_journey_Multistep/1',
+            ]);
+            // THEN
+            assert.equal(process.exitCode, 0, 'delete should not have thrown an error');
+
+            assert.equal(isDeleted, true, 'should have deleted the item');
+            return;
+        });
     });
 
     describe('ReplaceContentBlockByX ================', () => {