Migrate entra approleassignment and enterpriseapp commands to Zod#7365
Migrate entra approleassignment and enterpriseapp commands to Zod#7365waldekmastykarz wants to merge 3 commits into
Conversation
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>
There was a problem hiding this comment.
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/#initTypeswithschema+getRefinedSchema()built on Zod objects. - Updated validation tests to use
command.getSchemaToParse().safeParse(...)instead ofcommand.validate(...). - Updated
npm-shrinkwrap.jsonmetadata (addspeer: trueflags 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
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>
MartinM85
left a comment
There was a problem hiding this comment.
Hi @waldekmastykarz , I have a couple of comments, great job otherwise. 👍
|
Hi @waldekmastykarz, seems like the pull request was created in your fork. |
Ouch, yeah, definitely not intended. Will fix |
- 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>
|
I guess it's ready for review. Right? |
Summary
Migrates the following commands from legacy options/validators to Zod schemas:
entra approleassignment addentra approleassignment listentra approleassignment removeentra enterpriseapp addentra enterpriseapp getentra enterpriseapp listentra enterpriseapp removeChanges per command
interface Options extends GlobalOptionswithexport const options = z.strictObject({...globalOptionsZod.shape, ...})validation.isValidGuid()) withz.uuid()#initOptions(),#initValidators(),#initOptionSets(),#initTelemetry(),#initTypes()with declarative Zod schema +getRefinedSchema()for option setsget schema()methodTest changes
commandOptionsSchema.safeParse()instead ofcommand.validate()asyncfor validation)Closes #7295