Skip to content

feat: migrate pp aibuildermodel, copilot, and dataverse commands to Zod#7424

Open
waldekmastykarz wants to merge 4 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz-zod-migration-pp-commands
Open

feat: migrate pp aibuildermodel, copilot, and dataverse commands to Zod#7424
waldekmastykarz wants to merge 4 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz-zod-migration-pp-commands

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Member

Summary

Migrates all 11 pp aibuildermodel, pp copilot, and pp dataverse commands from the legacy #initOptions()/#initValidators()/#initTelemetry() pattern to Zod schema-based validation.

Commands migrated:

  • pp aibuildermodel get
  • pp aibuildermodel list
  • pp aibuildermodel remove
  • pp copilot get
  • pp copilot list
  • pp copilot remove
  • pp dataverse table get
  • pp dataverse table list
  • pp dataverse table remove
  • pp dataverse table row list
  • pp dataverse table row remove

Changes per command:

  • Replaced GlobalOptions interface with exported Zod options schema using z.strictObject()
  • Added schema getter and getRefinedSchema() for cross-field validation (option sets)
  • Removed constructor, #initTelemetry(), #initOptions(), #initValidators(), #initOptionSets() methods
  • GUID validation moved to .refine() on the schema
  • Updated spec files to use commandOptionsSchema.safeParse() for validation tests and commandOptionsSchema.parse() for action tests
  • Added "fails validation with unknown options" tests

Closes #7313

Migrates all 11 commands from the legacy #initOptions()/#initValidators()/

- pp aibuildermodel get
- pp aibuildermodel list
- pp aibuildermodel remove
- pp copilot get
- pp copilot list
- pp copilot remove
- pp dataverse table get
- pp dataverse table list
- pp dataverse table remove
- pp dataverse table row list
- pp dataverse table row remove

Closes pnp#7313

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

Migrates the Power Platform pp aibuildermodel, pp copilot, and pp dataverse (table + table row) command set from legacy initOptions/initValidators/initTelemetry to Zod schema-based option definitions and cross-field validation, with corresponding test updates.

Changes:

  • Introduced per-command exported options Zod schemas (using z.strictObject + globalOptionsZod.shape) and wired them via schema/getRefinedSchema().
  • Replaced legacy option-set/validator logic with schema refinements (incl. GUID .refine() and option-set .refine()).
  • Updated specs to validate via commandInfo.command.getSchemaToParse() and added “unknown options” validation tests.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/m365/pp/commands/aibuildermodel/aibuildermodel-get.ts Defines Zod schema + option-set refinement for get by id/name.
src/m365/pp/commands/aibuildermodel/aibuildermodel-get.spec.ts Updates validation/action tests to use schema parsing and adds unknown-option coverage.
src/m365/pp/commands/aibuildermodel/aibuildermodel-list.ts Defines Zod schema for list command options.
src/m365/pp/commands/aibuildermodel/aibuildermodel-list.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
src/m365/pp/commands/aibuildermodel/aibuildermodel-remove.ts Defines Zod schema + option-set refinement for remove by id/name.
src/m365/pp/commands/aibuildermodel/aibuildermodel-remove.spec.ts Updates validation/action tests to use schema parsing and adds unknown-option coverage.
src/m365/pp/commands/copilot/copilot-get.ts Defines Zod schema + option-set refinement for get by id/name.
src/m365/pp/commands/copilot/copilot-get.spec.ts Updates validation/action tests to use schema parsing and adds unknown-option coverage.
src/m365/pp/commands/copilot/copilot-list.ts Defines Zod schema for list command options.
src/m365/pp/commands/copilot/copilot-list.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
src/m365/pp/commands/copilot/copilot-remove.ts Defines Zod schema + option-set refinement for remove by id/name.
src/m365/pp/commands/copilot/copilot-remove.spec.ts Updates validation/action tests to use schema parsing and adds unknown-option coverage.
src/m365/pp/commands/dataverse/dataverse-table-get.ts Defines Zod schema for table get options.
src/m365/pp/commands/dataverse/dataverse-table-get.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
src/m365/pp/commands/dataverse/dataverse-table-list.ts Defines Zod schema for table list options.
src/m365/pp/commands/dataverse/dataverse-table-list.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
src/m365/pp/commands/dataverse/dataverse-table-remove.ts Defines Zod schema for table remove options.
src/m365/pp/commands/dataverse/dataverse-table-remove.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
src/m365/pp/commands/dataverse/dataverse-table-row-list.ts Defines Zod schema + option-set refinement (entitySetName/tableName).
src/m365/pp/commands/dataverse/dataverse-table-row-list.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
src/m365/pp/commands/dataverse/dataverse-table-row-remove.ts Defines Zod schema + GUID validation + option-set refinement (entitySetName/tableName).
src/m365/pp/commands/dataverse/dataverse-table-row-remove.spec.ts Updates tests to validate/parse via Zod schema and adds unknown-option coverage.
.impeccable/hook.cache.json Adds a local tool cache artifact to the repo.
Files not reviewed (1)
  • .impeccable/hook.cache.json: Generated file

Comment thread .impeccable/hook.cache.json Outdated
Comment thread src/m365/pp/commands/copilot/copilot-get.spec.ts
Comment thread src/m365/pp/commands/copilot/copilot-remove.spec.ts
Comment thread src/m365/pp/commands/aibuildermodel/aibuildermodel-get.spec.ts
Comment thread src/m365/pp/commands/aibuildermodel/aibuildermodel-remove.spec.ts
Comment thread src/m365/pp/commands/dataverse/dataverse-table-row-list.spec.ts
Comment thread src/m365/pp/commands/dataverse/dataverse-table-row-remove.spec.ts
waldekmastykarz and others added 3 commits June 26, 2026 11:54
- Changed message: to error: in refine() calls to match repo convention
- Removed .impeccable/hook.cache.json and added to .gitignore
- Added negative tests for option set validation (both/neither specified)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove .impeccable/hook.cache.json from the repo
- Fix .gitignore entry for .impeccable/
- Add negative tests for option set validation (both specified / neither specified) in:
  - copilot-get, copilot-remove
  - aibuildermodel-get, aibuildermodel-remove
  - dataverse-table-row-list, dataverse-table-row-remove

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The option set negative tests (both-specified / neither-specified) were
already present from the Zod migration. A prior fix commit added exact
duplicates; remove them to keep the specs clean.

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 pp aibuildermodel, pp copilot, and pp dataverse commands to Zod

2 participants