Skip to content

Migrate purview retentionevent and retentioneventtype commands to Zod#7420

Open
waldekmastykarz wants to merge 4 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz-migrate-purview-commands-to-zod
Open

Migrate purview retentionevent and retentioneventtype commands to Zod#7420
waldekmastykarz wants to merge 4 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz-migrate-purview-commands-to-zod

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Member

Summary

Migrates the following commands from the legacy #initOptions()/#initValidators()/#initTelemetry() pattern to Zod schema-based validation:

  • purview retentionevent add
  • purview retentionevent get
  • purview retentionevent remove
  • purview retentioneventtype add
  • purview retentioneventtype get
  • purview retentioneventtype remove
  • purview retentioneventtype set

Changes

  • Replaced legacy #initOptions(), #initValidators(), #initTelemetry(), #initOptionSets() methods and constructors with Zod schemas
  • Added schema getter and getRefinedSchema() where cross-field validation is needed
  • Updated all spec files to use commandOptionsSchema.safeParse() for validation tests and commandOptionsSchema.parse() for action tests
  • Added "fails validation with unknown options" tests for all commands
  • Validation tests are now synchronous

Closes #7315

Migrates the following commands from the legacy
#initOptions()/#initValidators()/#initTelemetry() pattern to Zod
schema-based validation:

- purview retentionevent add
- purview retentionevent get
- purview retentionevent remove
- purview retentioneventtype add
- purview retentioneventtype get
- purview retentioneventtype remove
- purview retentioneventtype set

Closes pnp#7315

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 Purview retentionevent and retentioneventtype command set from legacy option/validator/telemetry initialization to the CLI’s Zod schema-based option parsing and validation model.

Changes:

  • Replaced legacy #initOptions()/#initValidators()/#initTelemetry() patterns with schema getters and Zod option schemas.
  • Introduced getRefinedSchema() where cross-option validation is required (option sets / “required” refinements).
  • Updated unit tests to validate via command.getSchemaToParse() (safeParse/parse) and added “unknown options” validation cases.

Reviewed changes

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

Show a summary per file
File Description
src/m365/purview/commands/retentioneventtype/retentioneventtype-add.ts Migrates retentioneventtype add options to Zod schema.
src/m365/purview/commands/retentioneventtype/retentioneventtype-add.spec.ts Updates tests to use schema parsing and adds unknown-option validation coverage.
src/m365/purview/commands/retentioneventtype/retentioneventtype-get.ts Migrates retentioneventtype get options/validation to Zod schema.
src/m365/purview/commands/retentioneventtype/retentioneventtype-get.spec.ts Updates tests to schema-based validation/parsing and adds unknown-option test.
src/m365/purview/commands/retentioneventtype/retentioneventtype-remove.ts Migrates retentioneventtype remove options/validation to Zod schema.
src/m365/purview/commands/retentioneventtype/retentioneventtype-remove.spec.ts Updates tests to schema-based validation/parsing and adds unknown-option test.
src/m365/purview/commands/retentioneventtype/retentioneventtype-set.ts Migrates retentioneventtype set to Zod schema and adds refined validation.
src/m365/purview/commands/retentioneventtype/retentioneventtype-set.spec.ts Updates tests to schema-based validation/parsing and adds unknown-option test.
src/m365/purview/commands/retentionevent/retentionevent-add.ts Migrates retentionevent add to Zod schema and adds refined cross-field validation.
src/m365/purview/commands/retentionevent/retentionevent-add.spec.ts Updates tests to schema-based validation/parsing and adds unknown-option test.
src/m365/purview/commands/retentionevent/retentionevent-get.ts Migrates retentionevent get options/validation to Zod schema.
src/m365/purview/commands/retentionevent/retentionevent-get.spec.ts Updates tests to schema-based validation/parsing and adds unknown-option test.
src/m365/purview/commands/retentionevent/retentionevent-remove.ts Migrates retentionevent remove options/validation to Zod schema and updates internal typing.
src/m365/purview/commands/retentionevent/retentionevent-remove.spec.ts Updates tests to schema-based validation/parsing and adds unknown-option test.
npm-shrinkwrap.json Lockfile changes included alongside command migration.
.impeccable/hook.cache.json Adds a tool cache file with developer-local paths.
Files not reviewed (2)
  • .impeccable/hook.cache.json: Generated file
  • npm-shrinkwrap.json: Generated file

Comment thread src/m365/purview/commands/retentionevent/retentionevent-add.ts Outdated
Comment thread .impeccable/hook.cache.json Outdated
Comment thread npm-shrinkwrap.json
- Added path to refine params for customCode required
- Changed message: to error: in refine calls
- Removed .impeccable/hook.cache.json and added to .gitignore
- Reverted unintentional npm-shrinkwrap.json changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MartinM85 MartinM85 self-assigned this Jun 27, 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.

I have a couple of small comments, nothing major. Great work @waldekmastykarz 🚀

Comment thread .gitignore Outdated
Comment thread .gitignore
@MartinM85 MartinM85 marked this pull request as draft June 27, 2026 11:48
- Put .impeccable/ on its own line in .gitignore
- Remove tracked .impeccable/hook.cache.json
- Reset npm-shrinkwrap.json to upstream main

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz marked this pull request as ready for review July 2, 2026 09:02
Comment thread npm-shrinkwrap.json
…vert npm-shrinkwrap

- Update retentioneventtype-set and retentionevent-add refines to use
  customCode: 'optionSet' with params.options so prompting works without a path
- Revert npm-shrinkwrap.json to match the branch's package.json (merge-base)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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 purview retentionevent and purview retentioneventtype commands to Zod

3 participants