Skip to content

Migrate entra approleassignment and enterpriseapp commands to Zod#7365

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

Migrate entra approleassignment and enterpriseapp commands to Zod#7365
waldekmastykarz wants to merge 3 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-entra-commands-to-zod

Conversation

@waldekmastykarz
Copy link
Copy Markdown
Member

Summary

Migrates the following commands from legacy options/validators to Zod schemas:

  • entra approleassignment add
  • entra approleassignment list
  • entra approleassignment remove
  • entra enterpriseapp add
  • entra enterpriseapp get
  • entra enterpriseapp list
  • entra enterpriseapp remove

Changes per command

  • Replaced interface Options extends GlobalOptions with export const options = z.strictObject({...globalOptionsZod.shape, ...})
  • Replaced GUID validation (validation.isValidGuid()) with z.uuid()
  • Replaced #initOptions(), #initValidators(), #initOptionSets(), #initTelemetry(), #initTypes() with declarative Zod schema + getRefinedSchema() for option sets
  • Added get schema() method
  • Removed constructors

Test changes

  • Validation tests now use commandOptionsSchema.safeParse() instead of command.validate()
  • Removed redundant "supports specifying" tests
  • Tests are synchronous (no more async for validation)

Closes #7295

Migrates the following commands from legacy options/validators to Zod schemas:
- entra approleassignment add
- entra approleassignment list
- entra approleassignment remove
- entra enterpriseapp add
- entra enterpriseapp get
- entra enterpriseapp list
- entra enterpriseapp remove

Closes pnp#7295

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 several Microsoft Entra enterpriseapp and approleassignment commands from legacy option/validator initialization to declarative Zod schemas, aligning them with the CLI’s newer schema-driven validation/telemetry pipeline and updating the corresponding validation tests.

Changes:

  • Replaced per-command #initOptions/#initValidators/#initOptionSets/#initTelemetry/#initTypes with schema + getRefinedSchema() built on Zod objects.
  • Updated validation tests to use command.getSchemaToParse().safeParse(...) instead of command.validate(...).
  • Updated npm-shrinkwrap.json metadata (adds peer: true flags for several packages).

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/m365/entra/commands/enterpriseapp/enterpriseapp-remove.ts Migrates enterpriseapp remove options/validation to Zod schema + refined option-set rule.
src/m365/entra/commands/enterpriseapp/enterpriseapp-remove.spec.ts Updates validation tests to use safeParse() (needs minor test name tweak).
src/m365/entra/commands/enterpriseapp/enterpriseapp-list.ts Migrates enterpriseapp list options to Zod schema.
src/m365/entra/commands/enterpriseapp/enterpriseapp-get.ts Migrates enterpriseapp get options/validation to Zod schema + refined option-set rule.
src/m365/entra/commands/enterpriseapp/enterpriseapp-get.spec.ts Updates validation tests to use safeParse() (needs minor test name tweak).
src/m365/entra/commands/enterpriseapp/enterpriseapp-add.ts Migrates enterpriseapp add options/validation to Zod schema + refined option-set rule.
src/m365/entra/commands/enterpriseapp/enterpriseapp-add.spec.ts Updates validation tests to use safeParse().
src/m365/entra/commands/approleassignment/approleassignment-remove.ts Migrates approleassignment remove options/validation to Zod schema + refined option-set rule (resource autocomplete regression).
src/m365/entra/commands/approleassignment/approleassignment-remove.spec.ts Updates validation tests to use safeParse() (needs minor test name tweak).
src/m365/entra/commands/approleassignment/approleassignment-list.ts Migrates approleassignment list options/validation to Zod schema + refined option-set rule.
src/m365/entra/commands/approleassignment/approleassignment-list.spec.ts Updates validation tests to use safeParse() (needs minor test name tweak).
src/m365/entra/commands/approleassignment/approleassignment-add.ts Migrates approleassignment add options/validation to Zod schema + refined option-set rule (resource autocomplete regression).
src/m365/entra/commands/approleassignment/approleassignment-add.spec.ts Updates validation tests to use safeParse() (needs minor test name tweak).
npm-shrinkwrap.json Lockfile metadata update (adds peer: true flags).
Files not reviewed (1)
  • npm-shrinkwrap.json: Language not supported

Comment thread src/m365/entra/commands/approleassignment/approleassignment-add.ts Outdated
Comment thread src/m365/entra/commands/enterpriseapp/enterpriseapp-remove.spec.ts Outdated
Comment thread src/m365/entra/commands/enterpriseapp/enterpriseapp-get.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-add.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-remove.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-list.spec.ts Outdated
@MartinM85 MartinM85 marked this pull request as draft June 3, 2026 08:26
Updates test descriptions to accurately reflect all supported options
(appId/appObjectId/appDisplayName and id/displayName/objectId) instead
of mentioning only a subset.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 5, 2026 11:08
@MartinM85 MartinM85 self-assigned this Jun 5, 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/enterpriseapp/enterpriseapp-remove.spec.ts Outdated
Comment thread src/m365/entra/commands/enterpriseapp/enterpriseapp-list.ts
Comment thread src/m365/entra/commands/enterpriseapp/enterpriseapp-get.spec.ts Outdated
Comment thread src/m365/entra/commands/enterpriseapp/enterpriseapp-get.spec.ts Outdated
Comment thread src/m365/entra/commands/enterpriseapp/enterpriseapp-get.spec.ts
Comment thread src/m365/entra/commands/approleassignment/approleassignment-list.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-list.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-add.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-add.spec.ts Outdated
Comment thread src/m365/entra/commands/approleassignment/approleassignment-add.ts Outdated
@MartinM85 MartinM85 marked this pull request as draft June 5, 2026 19:37
@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 7, 2026 09:12
@MartinM85
Copy link
Copy Markdown
Contributor

Hi @waldekmastykarz, seems like the pull request was created in your fork.

@waldekmastykarz
Copy link
Copy Markdown
Member Author

Hi @waldekmastykarz, seems like the pull request was created in your fork.

Ouch, yeah, definitely not intended. Will fix

@waldekmastykarz waldekmastykarz marked this pull request as draft June 7, 2026 16:24
- Add scopes transform to split comma-separated values into arrays
- Update command code to iterate scopes directly (no manual split)
- Remove non-null assertion from getSchemaToParse() calls
- Use commandOptionsSchema.parse() for action test options
- Migrate enterpriseapp-list.spec.ts to Zod pattern
- Add validation test for id + objectId combination in enterpriseapp-get

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

I guess it's ready for review. Right?

@waldekmastykarz waldekmastykarz marked this pull request as ready for review June 8, 2026 08:26
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 approleassignment and enterpriseapp commands to Zod

3 participants