Skip to content

Migrate entra groupsetting and groupsettingtemplate commands to Zod#7366

Merged
MartinM85 merged 2 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-entra-groupsetting-zod
Jun 17, 2026
Merged

Migrate entra groupsetting and groupsettingtemplate commands to Zod#7366
MartinM85 merged 2 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 5, 2026 11:13
@MartinM85 MartinM85 self-assigned this Jun 6, 2026

@MartinM85 MartinM85 left a comment

Copy link
Copy Markdown
Contributor

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/groupsettingtemplate/groupsettingtemplate-get.spec.ts Outdated
Comment thread src/m365/entra/commands/groupsetting/groupsetting-set.spec.ts
Comment thread src/m365/entra/commands/groupsetting/groupsetting-remove.spec.ts Outdated
Comment thread src/m365/entra/commands/groupsetting/groupsetting-get.spec.ts Outdated
Comment thread src/m365/entra/commands/groupsetting/groupsetting-add.spec.ts Outdated
@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
@MartinM85

Copy link
Copy Markdown
Contributor

Still no new commit, converting it back to draft

@MartinM85 MartinM85 marked this pull request as draft June 8, 2026 04:54
- Export options from groupsetting-add.ts and groupsetting-set.ts
- Fix test imports to use correct command's options schema
- Use commandOptionsSchema.parse() in all action tests
- Add 'no options' and 'unknown options' validation tests for list commands

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz force-pushed the waldekmastykarz/migrate-entra-groupsetting-zod branch from 3b3af27 to 14e1df6 Compare June 8, 2026 08:36
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 8, 2026 10:41
@MartinM85 MartinM85 merged commit 328045c into pnp:main Jun 17, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate entra groupsetting and groupsettingtemplate commands to Zod

3 participants