Skip to content

Migrate entra groupsetting and groupsettingtemplate commands to Zod#7366

Open
waldekmastykarz wants to merge 3 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-entra-groupsetting-zod
Open

Migrate entra groupsetting and groupsettingtemplate commands to Zod#7366
waldekmastykarz wants to merge 3 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-entra-groupsetting-zod

Conversation

@waldekmastykarz
Copy link
Copy Markdown
Member

Summary

Migrates all 7 entra groupsetting and entra groupsettingtemplate commands to use Zod schemas for option validation, replacing the legacy #initOptions(), #initValidators(), #initTelemetry(), and #initOptionSets() patterns.

Closes #7297

Commands migrated

Command Schema type Notes
entra groupsetting add looseObject Supports unknown options
entra groupsetting get strictObject
entra groupsetting list strictObject No custom options
entra groupsetting remove strictObject
entra groupsetting set looseObject Supports unknown options
entra groupsettingtemplate get strictObject Option set via getRefinedSchema
entra groupsettingtemplate list strictObject No custom options

Changes per command

  • Replaced interface Options extends GlobalOptions with Zod schema definitions
  • Replaced manual GUID validation with z.uuid()
  • Added .alias() for short option names
  • Implemented get schema() getter
  • Used getRefinedSchema() for option set validation (groupsettingtemplate get)
  • Removed constructor-based #initOptions(), #initValidators(), #initTelemetry(), #initOptionSets()

Test changes

  • Validation tests updated from command.validate() to commandOptionsSchema.safeParse()
  • Removed legacy supports specifying tests that checked command.options array
  • Removed settingsNames stubs no longer needed for option set validation

Migrate all 7 commands to use Zod schemas for option validation:
- entra groupsetting add
- entra groupsetting get
- entra groupsetting list
- entra groupsetting remove
- entra groupsetting set
- entra groupsettingtemplate get
- entra groupsettingtemplate list

Closes pnp#7297

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the Entra groupsetting and groupsettingtemplate command set from legacy option initialization/validation/telemetry patterns to Zod-based schemas, aligning these commands with the newer validation and telemetry flow in the CLI.

Changes:

  • Introduces Zod schemas (schema + optional getRefinedSchema) for option validation across the 7 commands.
  • Replaces manual GUID validation with z.uuid() and adds short option aliases via .alias().
  • Updates unit tests to validate via command.getSchemaToParse().safeParse() rather than command.validate().

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-list.ts Adds Zod schema for global-only options and exposes it via schema.
src/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-get.ts Adds strict Zod schema + refined schema enforcing the id/displayName option set.
src/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-get.spec.ts Updates validation tests to use safeParse() against the schema-to-parse.
src/m365/entra/commands/groupsetting/groupsetting-set.ts Migrates to loose Zod schema to support unknown options + GUID validation via z.uuid().
src/m365/entra/commands/groupsetting/groupsetting-set.spec.ts Updates tests to validate via Zod schema parsing.
src/m365/entra/commands/groupsetting/groupsetting-remove.ts Migrates to strict Zod schema with id and optional force flag.
src/m365/entra/commands/groupsetting/groupsetting-remove.spec.ts Updates validation tests to use schema parsing; removes legacy option-list assertions.
src/m365/entra/commands/groupsetting/groupsetting-list.ts Adds Zod schema for global-only options and exposes it via schema.
src/m365/entra/commands/groupsetting/groupsetting-get.ts Migrates to strict Zod schema for id with UUID validation + alias.
src/m365/entra/commands/groupsetting/groupsetting-get.spec.ts Updates GUID validation tests to use safeParse().
src/m365/entra/commands/groupsetting/groupsetting-add.ts Migrates to loose Zod schema for templateId + allows unknown options.
src/m365/entra/commands/groupsetting/groupsetting-add.spec.ts Updates GUID validation tests to use safeParse().

Comment thread src/m365/entra/commands/groupsetting/groupsetting-set.spec.ts Outdated
Comment thread src/m365/entra/commands/groupsetting/groupsetting-set.ts Outdated
Comment thread src/m365/entra/commands/groupsetting/groupsetting-add.spec.ts Outdated
Comment thread src/m365/entra/commands/groupsetting/groupsetting-add.ts Outdated
@MartinM85 MartinM85 marked this pull request as draft June 3, 2026 08:26
Address review comments:
- Export options const in groupsetting-add.ts and groupsetting-set.ts
- Fix spec files to import options from their own command file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 5, 2026 11:13
@MartinM85 MartinM85 self-assigned this Jun 6, 2026
Copy link
Copy Markdown
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.

Hi @waldekmastykarz , I have a couple of comments, great job otherwise. 👍

Comment thread src/m365/entra/commands/groupsetting/groupsetting-list.ts
Comment thread src/m365/entra/commands/groupsetting/groupsetting-set.spec.ts
Comment thread src/m365/entra/commands/groupsetting/groupsetting-remove.spec.ts
Comment thread src/m365/entra/commands/groupsetting/groupsetting-get.spec.ts
Comment thread src/m365/entra/commands/groupsetting/groupsetting-add.spec.ts
@MartinM85 MartinM85 marked this pull request as draft June 6, 2026 13:54
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 7, 2026 09:11
@MartinM85
Copy link
Copy Markdown
Contributor

Hi @waldekmastykarz, I don't see any new commit

@waldekmastykarz
Copy link
Copy Markdown
Member Author

Something must've gone wrong. Let me check. Thanks for catching it

@waldekmastykarz waldekmastykarz marked this pull request as draft June 7, 2026 16:22
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 7, 2026 16:40
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 groupsetting and groupsettingtemplate commands to Zod

4 participants