Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-it committed Jul 18, 2023
1 parent 48d8cb1 commit e937bf4
Show file tree
Hide file tree
Showing 49 changed files with 66 additions and 275 deletions.
6 changes: 1 addition & 5 deletions src/m365/aad/commands/app/app-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,7 @@ class AadAppRemoveCommand extends GraphCommand {
throw `No Azure AD application registration with ${applicationIdentifier} found`;
}

const resultAsKeyValuePair: any = {};
res.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD application registration with name '${name}' found. Choose the correct ID:`, `Multiple Azure AD application registration with name '${name}' found.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/app/app-role-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ class AadAppRoleAddCommand extends GraphCommand {
throw `No Azure AD application registration with ${applicationIdentifier} found`;
}

const resultAsKeyValuePair: any = {};
res.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD application registration with name '${appName}' found. Choose the correct ID:`, `Multiple Azure AD application registration with name '${appName}' found.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/app/app-role-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ class AadAppRoleListCommand extends GraphCommand {
throw `No Azure AD application registration with ${applicationIdentifier} found`;
}

const resultAsKeyValuePair: any = {};
res.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD application registration with name '${appName}' found. Choose the correct ID:`, `Multiple Azure AD application registration with name '${appName}' found.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
12 changes: 2 additions & 10 deletions src/m365/aad/commands/app/app-role-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ class AadAppRoleRemoveCommand extends GraphCommand {
appRoleToDelete !== undefined &&
appRoleToDelete.length > 1) {

const resultAsKeyValuePair: any = {};
appRoleToDelete.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', appRoleToDelete);
appRoleToDelete[0] = (await Cli.handleMultipleResultsFound(`Multiple roles with name '${args.options.name}' found. Choose the correct ID:`, `Multiple roles with name '${args.options.name}' found.`, resultAsKeyValuePair)) as AppRole;
}
if (appRoleToDelete.length === 0) {
Expand Down Expand Up @@ -246,11 +242,7 @@ class AadAppRoleRemoveCommand extends GraphCommand {
throw `No Azure AD application registration with ${applicationIdentifier} found`;
}

const resultAsKeyValuePair: any = {};
res.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD application registration with name '${appName}' found. Choose the correct ID:`, `Multiple Azure AD application registration with name '${appName}' found.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/app/app-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ class AadAppSetCommand extends GraphCommand {
throw `No Azure AD application registration with ${applicationIdentifier} found`;
}

const resultAsKeyValuePair: any = {};
res.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD application registration with name '${name}' found. Choose the correct ID:`, `Multiple Azure AD application registration with name '${name}' found.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ class AadAppRoleAssignmentAddCommand extends GraphCommand {
}

if (servicePrincipalResult.value.length > 1) {
const resultAsKeyValuePair: any = {};
servicePrincipalResult.value.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', servicePrincipalResult.value);
servicePrincipalResult.value[0] = (await Cli.handleMultipleResultsFound(`Multiple service principal found. Choose the correct ID:`, `More than one service principal found. Please use the appId or appObjectId option to make sure the right service principal is specified.`, resultAsKeyValuePair)) as ServicePrincipal;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ class AadO365GroupRecycleBinItemRemoveCommand extends GraphCommand {
}

if (groups.length > 1) {
const resultAsKeyValuePair: any = {};
groups.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', groups);
groups[0] = (await Cli.handleMultipleResultsFound(`Multiple groups with name '${displayName || mailNickname}' found. Choose the correct ID:`, `Multiple groups with name '${displayName || mailNickname}' found: ${groups.map(x => x.id).join(',')}.`, resultAsKeyValuePair)) as Group;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ class AadO365GroupRecycleBinItemRestoreCommand extends GraphCommand {
}

if (groups.length > 1) {
const resultAsKeyValuePair: any = {};
groups.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', groups);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple groups with name '${displayName || mailNickname}' found. Choose the correct ID:`, `Multiple groups with name '${displayName || mailNickname}' found: ${groups.map(x => x.id).join(',')}.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/o365group/o365group-teamify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ class AadO365GroupTeamifyCommand extends GraphCommand {
}

if (response.value.length > 1) {
const resultAsKeyValuePair: any = {};
response.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Microsoft 365 Groups with name '${args.options.mailNickname}' found. Choose the correct ID:`, `Multiple Microsoft 365 Groups with name '${args.options.mailNickname}' found: ${response.value.map(x => x.id).join(',')}.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/sp/sp-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ class AadSpAddCommand extends GraphCommand {
}

if (response.value.length > 1) {
const resultAsKeyValuePair: any = {};
response.value.forEach((obj) => {
resultAsKeyValuePair[obj.appId] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('appId', response.value);
const result: { appId: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD apps with name '${args.options.appName}' found. Choose the correct ID:`, `Multiple Azure AD apps with name '${args.options.appName}' found: ${response.value.map(x => x.appId).join(',')}.`, resultAsKeyValuePair)) as { appId: string };
return result.appId;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/sp/sp-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ class AadSpGetCommand extends GraphCommand {
}

if (response.value.length > 1) {
const resultAsKeyValuePair: any = {};
response.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple Azure AD apps with name '${args.options.appDisplayName}' found. Choose the correct ID:`, `Multiple Azure AD apps with name '${args.options.appDisplayName}' found: ${response.value.map(x => x.id).join(',')}.`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/aad/commands/user/user-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ class AadUserGetCommand extends GraphCommand {
}

if (res.value.length > 1) {
const resultAsKeyValuePair: any = {};
res.value.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
res.value[0] = (await Cli.handleMultipleResultsFound(`Multiple users with ${identifier} found. Choose the correct ID:`, `Multiple users with ${identifier} found. Please disambiguate (user names): ${res.value.map(a => a.userPrincipalName).join(', ')} or (ids): ${res.value.map(a => a.id).join(', ')}`, resultAsKeyValuePair)) as User;
}

Expand Down
6 changes: 1 addition & 5 deletions src/m365/booking/commands/business/business-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ class BookingBusinessGetCommand extends GraphCommand {
}

if (bookingBusinesses.length > 1) {
const resultAsKeyValuePair: any = {};
bookingBusinesses.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', bookingBusinesses);
bookingBusinesses[0] = (await Cli.handleMultipleResultsFound(`Multiple businesses with name '${options.name}' found. Choose the correct ID:`, `Multiple businesses with name '${options.name}' found. Please disambiguate: ${bookingBusinesses.map(x => x.id).join(', ')}`, resultAsKeyValuePair)) as BookingBusiness;
}

Expand Down
6 changes: 1 addition & 5 deletions src/m365/outlook/commands/message/message-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ class OutlookMessageListCommand extends GraphCommand {
}

if (response.value.length > 1) {
const resultAsKeyValuePair: any = {};
response.value.forEach((obj) => {
resultAsKeyValuePair[obj.id] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
const result: { id: string } = (await Cli.handleMultipleResultsFound(`Multiple folders with name '${args.options.folderName!}' found. Choose the correct ID:`, `Multiple folders with name '${args.options.folderName!}' found. Please disambiguate:${os.EOL}${response.value.map(f => `- ${f.id}`).join(os.EOL)}`, resultAsKeyValuePair)) as { id: string };
return result.id;
}
Expand Down
6 changes: 1 addition & 5 deletions src/m365/outlook/commands/message/message-move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ class OutlookMessageMoveCommand extends GraphCommand {
}

if (response.value.length > 1) {
const resultAsKeyValuePair: any = {};
response.value.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
response.value[0] = (await Cli.handleMultipleResultsFound(`Multiple folders with name '${folderName as string}' found. Choose the correct ID:`, `Multiple folders with name '${folderName as string}' found. Please disambiguate:${os.EOL}${response.value.map(f => `- ${f.id}`).join(os.EOL)}`, resultAsKeyValuePair)) as { id: string; };
}

Expand Down
7 changes: 2 additions & 5 deletions src/m365/planner/commands/bucket/bucket-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { planner } from '../../../../utils/planner';
import GraphCommand from '../../../base/GraphCommand';
import commands from '../../commands';
import { Cli } from '../../../../cli/Cli';
import { formatting } from '../../../../utils/formatting';

interface CommandArgs {
options: Options;
Expand Down Expand Up @@ -161,11 +162,7 @@ class PlannerBucketGetCommand extends GraphCommand {
}

if (filteredBuckets.length > 1) {
const resultAsKeyValuePair: any = {};
filteredBuckets.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
filteredBuckets[0] = (await Cli.handleMultipleResultsFound(`Multiple buckets with name '${name}' found. Choose the correct ID:`, `Multiple buckets with name '${name}' found: ${filteredBuckets.map(x => x.id)}`, resultAsKeyValuePair)) as PlannerBucket;
}

Expand Down
7 changes: 2 additions & 5 deletions src/m365/planner/commands/bucket/bucket-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { aadGroup } from '../../../../utils/aadGroup';
import { planner } from '../../../../utils/planner';
import GraphCommand from '../../../base/GraphCommand';
import commands from '../../commands';
import { formatting } from '../../../../utils/formatting';

interface CommandArgs {
options: Options;
Expand Down Expand Up @@ -197,11 +198,7 @@ class PlannerBucketRemoveCommand extends GraphCommand {
}

if (filteredBuckets.length > 1) {
const resultAsKeyValuePair: any = {};
filteredBuckets.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
filteredBuckets[0] = (await Cli.handleMultipleResultsFound(`Multiple buckets with name '${args.options.name}' found. Choose the correct ID:`, `Multiple buckets with name '${args.options.name}' found: ${filteredBuckets.map(x => x.id)}`, resultAsKeyValuePair)) as PlannerBucket;
}

Expand Down
7 changes: 2 additions & 5 deletions src/m365/planner/commands/bucket/bucket-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { planner } from '../../../../utils/planner';
import GraphCommand from '../../../base/GraphCommand';
import commands from '../../commands';
import { Cli } from '../../../../cli/Cli';
import { formatting } from '../../../../utils/formatting';

interface CommandArgs {
options: Options;
Expand Down Expand Up @@ -199,11 +200,7 @@ class PlannerBucketSetCommand extends GraphCommand {
}

if (filteredBuckets.length > 1) {
const resultAsKeyValuePair: any = {};
filteredBuckets.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
filteredBuckets[0] = (await Cli.handleMultipleResultsFound(`Multiple buckets with name '${args.options.name}' found. Choose the correct ID:`, `Multiple buckets with name '${args.options.name}' found: ${filteredBuckets.map(x => x.id)}`, resultAsKeyValuePair)) as PlannerBucket;
}

Expand Down
12 changes: 2 additions & 10 deletions src/m365/planner/commands/task/task-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ class PlannerTaskGetCommand extends GraphCommand {
}

if (tasks.length > 1) {
const resultAsKeyValuePair: any = {};
tasks.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', tasks);
tasks[0] = (await Cli.handleMultipleResultsFound(`Multiple tasks with title '${options.title}' found. Choose the correct ID:`, `Multiple tasks with title '${options.title}' found: ${tasks.map(x => x.id)}`, resultAsKeyValuePair)) as PlannerTask;
}

Expand Down Expand Up @@ -216,11 +212,7 @@ class PlannerTaskGetCommand extends GraphCommand {
}

if (buckets.length > 1) {
const resultAsKeyValuePair: any = {};
buckets.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', buckets);
buckets[0] = (await Cli.handleMultipleResultsFound(`Multiple buckets with name '${options.bucketName}' found. Choose the correct ID:`, `Multiple buckets with name '${options.bucketName}' found: ${buckets.map(x => x.id)}`, resultAsKeyValuePair)) as PlannerBucket;
}

Expand Down
13 changes: 3 additions & 10 deletions src/m365/planner/commands/task/task-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { validation } from '../../../../utils/validation';
import { planner } from '../../../../utils/planner';
import GraphCommand from '../../../base/GraphCommand';
import commands from '../../commands';
import { formatting } from '../../../../utils/formatting';

interface CommandArgs {
options: Options;
Expand Down Expand Up @@ -191,11 +192,7 @@ class PlannerTaskRemoveCommand extends GraphCommand {
}

if (filteredtasks.length > 1) {
const resultAsKeyValuePair: any = {};
filteredtasks.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredtasks);
filteredtasks[0] = (await Cli.handleMultipleResultsFound(`Multiple tasks with title '${title}' found. Choose the correct ID:`, `Multiple tasks with title '${title}' found: Please disambiguate: ${os.EOL}${filteredtasks.map(f => `- ${f.id}`).join(os.EOL)}`, resultAsKeyValuePair)) as PlannerTask;
}

Expand Down Expand Up @@ -226,11 +223,7 @@ class PlannerTaskRemoveCommand extends GraphCommand {
}

if (filteredBuckets.length > 1) {
const resultAsKeyValuePair: any = {};
filteredBuckets.forEach((obj) => {
resultAsKeyValuePair[obj.id!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
filteredBuckets[0] = (await Cli.handleMultipleResultsFound(`Multiple buckets with name '${bucketName}' found. Choose the correct ID:`, `Multiple buckets with name '${bucketName}' found: Please disambiguate:${os.EOL}${filteredBuckets.map(f => `- ${f.id}`).join(os.EOL)}`, resultAsKeyValuePair)) as PlannerBucket;
}

Expand Down
7 changes: 2 additions & 5 deletions src/m365/pp/commands/aibuildermodel/aibuildermodel-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Cli } from '../../../../cli/Cli';
import { Logger } from '../../../../cli/Logger';
import GlobalOptions from '../../../../GlobalOptions';
import request, { CliRequestOptions } from '../../../../request';
import { formatting } from '../../../../utils/formatting';
import { powerPlatform } from '../../../../utils/powerPlatform';
import { validation } from '../../../../utils/validation';
import PowerPlatformCommand from '../../../base/PowerPlatformCommand';
Expand Down Expand Up @@ -123,11 +124,7 @@ class PpAiBuilderModelGetCommand extends PowerPlatformCommand {
}

if (result.value.length > 1) {
const resultAsKeyValuePair: any = {};
result.value.forEach((obj) => {
resultAsKeyValuePair[obj.msdyn_aimodelid!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('msdyn_aimodelid', result.value);
result.value[0] = (await Cli.handleMultipleResultsFound(`Multiple AI builder models with name '${options.name}' found. Choose the correct ID:`, `Multiple AI builder models with name '${options.name}' found: ${result.value.map(x => x.msdyn_aimodelid).join(',')}`, resultAsKeyValuePair));
}

Expand Down
7 changes: 2 additions & 5 deletions src/m365/pp/commands/card/card-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import commands from '../../commands';
import request, { CliRequestOptions } from '../../../../request';
import { validation } from '../../../../utils/validation';
import { Cli } from '../../../../cli/Cli';
import { formatting } from '../../../../utils/formatting';

interface CommandArgs {
options: Options;
Expand Down Expand Up @@ -124,11 +125,7 @@ class PpCardGetCommand extends PowerPlatformCommand {
}

if (result.value.length > 1) {
const resultAsKeyValuePair: any = {};
result.value.forEach((obj) => {
resultAsKeyValuePair[obj.cardid] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('cardid', result.value);
return Cli.handleMultipleResultsFound(`Multiple cards with name '${options.name}' found. Choose the correct ID:`, `Multiple cards with name '${options.name}' found.`, resultAsKeyValuePair);
}

Expand Down
6 changes: 1 addition & 5 deletions src/m365/pp/commands/chatbot/chatbot-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ class PpChatbotGetCommand extends PowerPlatformCommand {
const result = await request.get<{ value: any[] }>(requestOptions);

if (result.value.length > 1) {
const resultAsKeyValuePair: any = {};
result.value.forEach((obj) => {
resultAsKeyValuePair[obj.botid!] = obj;
});

const resultAsKeyValuePair = formatting.convertArrayToHashTable('botid', result.value);
result.value[0] = (await Cli.handleMultipleResultsFound(`Multiple chatbots with name '${options.name}' found. Choose the correct ID:`, `Multiple chatbots with name '${options.name}' found: ${result.value.map(x => x.botid).join(',')}`, resultAsKeyValuePair));
}

Expand Down
Loading

0 comments on commit e937bf4

Please sign in to comment.