Skip to content

Conversation

@martinlingstuyl
Copy link
Contributor

@martinlingstuyl martinlingstuyl commented Aug 14, 2025

Migrates some 'm365group' commands to zod. Closes #6849

@martinlingstuyl martinlingstuyl force-pushed the zod-m365group-commands branch 3 times, most recently from 2ef5579 to f74716f Compare August 15, 2025 11:53
@martinlingstuyl martinlingstuyl changed the title Migrates some 'm365group' commands to zod Migrates some 'm365group' commands to zod. Closes #6849 Aug 15, 2025
@martinlingstuyl martinlingstuyl force-pushed the zod-m365group-commands branch 3 times, most recently from 914a578 to 880aec0 Compare September 10, 2025 15:00
@MartinM85
Copy link
Contributor

Hi @martinlingstuyl, could you please check and resolve conflicts?

@MartinM85 MartinM85 self-assigned this Dec 6, 2025
Copy link
Contributor

@MartinM85 MartinM85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @martinlingstuyl . Just a few minor suggestions from my side.

In some commands you have replaced single quotes with double quotes for import, sinon.stub and test names. I think we prefer single quotes in this case. I would suggest reverting these changes.

const options = globalOptionsZod
.extend({
ids: zod.alias('ids', z.string().optional()),
userNames: zod.alias('userNames', z.string().optional()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
userNames: zod.alias('userNames', z.string().optional()),
userNames: z.string().optional(),

Comment on lines +18 to +20
groupName: zod.alias('groupName', z.string().optional()),
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
groupName: zod.alias('groupName', z.string().optional()),
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
groupName: z.string().optional(),
teamId: z.string().uuid().optional(),
teamName: z.string().optional(),

}

class EntraM365GroupUserAddCommand extends GraphCommand {
private readonly allowedRoles: string[] = ['owner', 'member'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace the allowedRoles with an enum similar to the GroupVisibility used in the m365 group add command?
Then we can omit the allowedRoles from refining in the getRefinedSchema and define the role option as zod.coercedEnum()

groupId: zod.alias('i', z.string().uuid().optional()),
groupDisplayName: zod.alias('d', z.string().optional()),
properties: zod.alias('p', z.string().optional()),
role: zod.alias('r', z.string().optional())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use enum for the role option.

Comment on lines +17 to +18
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
teamId: z.string().uuid().optional(),
teamName: z.string().optional(),

Comment on lines +16 to +21
ids: zod.alias('ids', z.string().optional()),
userNames: zod.alias('userNames', z.string().optional()),
groupId: zod.alias('i', z.string().uuid().optional()),
groupName: zod.alias('groupName', z.string().optional()),
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ids: zod.alias('ids', z.string().optional()),
userNames: zod.alias('userNames', z.string().optional()),
groupId: zod.alias('i', z.string().uuid().optional()),
groupName: zod.alias('groupName', z.string().optional()),
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
ids: z.string().optional(),
userNames: z.string().optional(),
groupId: zod.alias('i', z.string().uuid().optional()),
groupName: z.string().optional(),
teamId: z.string().uuid().optional(),
teamName: z.string().optional(),

groupName: zod.alias('groupName', z.string().optional()),
teamId: zod.alias('teamId', z.string().uuid().optional()),
teamName: zod.alias('teamName', z.string().optional()),
role: zod.alias('r', z.string())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the enum for the role.

Comment on lines +23 to +36
id: zod.alias('i', z.string().uuid().optional()),
displayName: zod.alias('n', z.string().optional()),
newDisplayName: zod.alias('newDisplayName', z.string().optional()),
description: zod.alias('d', z.string().optional()),
ownerIds: zod.alias('ownerIds', z.string().optional()),
ownerUserNames: zod.alias('ownerUserNames', z.string().optional()),
memberIds: zod.alias('memberIds', z.string().optional()),
memberUserNames: zod.alias('memberUserNames', z.string().optional()),
isPrivate: zod.alias('isPrivate', z.boolean().optional()),
logoPath: zod.alias('l', z.string().optional()),
allowExternalSenders: zod.alias('allowExternalSenders', z.boolean().optional()),
autoSubscribeNewMembers: zod.alias('autoSubscribeNewMembers', z.boolean().optional()),
hideFromAddressLists: zod.alias('hideFromAddressLists', z.boolean().optional()),
hideFromOutlookClients: zod.alias('hideFromOutlookClients', z.boolean().optional())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id: zod.alias('i', z.string().uuid().optional()),
displayName: zod.alias('n', z.string().optional()),
newDisplayName: zod.alias('newDisplayName', z.string().optional()),
description: zod.alias('d', z.string().optional()),
ownerIds: zod.alias('ownerIds', z.string().optional()),
ownerUserNames: zod.alias('ownerUserNames', z.string().optional()),
memberIds: zod.alias('memberIds', z.string().optional()),
memberUserNames: zod.alias('memberUserNames', z.string().optional()),
isPrivate: zod.alias('isPrivate', z.boolean().optional()),
logoPath: zod.alias('l', z.string().optional()),
allowExternalSenders: zod.alias('allowExternalSenders', z.boolean().optional()),
autoSubscribeNewMembers: zod.alias('autoSubscribeNewMembers', z.boolean().optional()),
hideFromAddressLists: zod.alias('hideFromAddressLists', z.boolean().optional()),
hideFromOutlookClients: zod.alias('hideFromOutlookClients', z.boolean().optional())
id: zod.alias('i', z.string().uuid().optional()),
displayName: zod.alias('n', z.string().optional()),
newDisplayName: z.string().optional(),
description: zod.alias('d', z.string().optional()),
ownerIds: z.string().optional(),
ownerUserNames: z.string().optional(),
memberIds: z.string().optional(),
memberUserNames: z.string().optional(),
isPrivate: z.boolean().optional(),
logoPath: zod.alias('l', z.string().optional()),
allowExternalSenders: z.boolean().optional(),
autoSubscribeNewMembers: z.boolean().optional(),
hideFromAddressLists: z.boolean().optional(),
hideFromOutlookClients: z.boolean().optional()

});

it('has correct name', () => {
it("has correct name", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that we prefer single quotes for the test names.

import { sinonUtil } from '../../../../utils/sinonUtil.js';
import commands from '../../commands.js';
import command from './m365group-list.js';
import { Group } from "@microsoft/microsoft-graph-types";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer single quotes for imports.

@MartinM85 MartinM85 marked this pull request as draft December 6, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate 'entra m365group' commands to zod

2 participants