-
Notifications
You must be signed in to change notification settings - Fork 372
Migrates some 'm365group' commands to zod. Closes #6849 #6845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2ef5579 to
f74716f
Compare
914a578 to
880aec0
Compare
|
Hi @martinlingstuyl, could you please check and resolve conflicts? |
880aec0 to
54b6017
Compare
MartinM85
left a comment
There was a problem hiding this 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()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| userNames: zod.alias('userNames', z.string().optional()), | |
| userNames: 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()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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']; |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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.
| teamId: zod.alias('teamId', z.string().uuid().optional()), | ||
| teamName: zod.alias('teamName', z.string().optional()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| teamId: zod.alias('teamId', z.string().uuid().optional()), | |
| teamName: zod.alias('teamName', z.string().optional()), | |
| teamId: z.string().uuid().optional(), | |
| teamName: z.string().optional(), |
| 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()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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()) |
There was a problem hiding this comment.
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.
| 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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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", () => { |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
Migrates some 'm365group' commands to zod. Closes #6849