Skip to content

Migrates spo listitem commands to Zod. Closes #7334 - #7659

Open
MartinM85 wants to merge 1 commit into
pnp:mainfrom
MartinM85:feature/7334-migrate-spo-listitem-commands-to-zod
Open

MartinM85 wants to merge 1 commit into
pnp:mainfrom
MartinM85:feature/7334-migrate-spo-listitem-commands-to-zod

Conversation

@MartinM85

Copy link
Copy Markdown
Contributor

Closes #7334

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.

🟡 Changes recommended

The .positive() validator rejects the documented first-page value --pageNumber 0; it should allow zero and include a regression test.

1 open issue
What changed in this PR

Migrates the 24 spo listitem commands to the CLI’s Zod-based validation model, addressing #7334 as part of the broader migration in #6807.

Changes:

  • Replaces legacy option registration, validators, and telemetry setup with exported schemas and cross-option refinements.
  • Updates tests to parse options through schemas and check validation errors.
  • Adapts tenant extension commands to the inferred output-option type.
File Description
src/​m365/​spo/​commands/​tenant/​tenant-commandset-add.ts Narrows output values passed to list-item creation.
src/​m365/​spo/​commands/​tenant/​tenant-commandset-add.spec.ts Exercises the none output option.
src/​m365/​spo/​commands/​tenant/​tenant-applicationcustomizer-add.ts Narrows output values passed to list-item creation.
src/​m365/​spo/​commands/​tenant/​tenant-applicationcustomizer-add.spec.ts Exercises the none output option.
src/​m365/​spo/​commands/​listitem/​listitem-set.ts Adds a schema preserving arbitrary field options.
src/​m365/​spo/​commands/​listitem/​listitem-roleinheritance-reset.ts Migrates inheritance-reset validation to Zod.
src/​m365/​spo/​commands/​listitem/​listitem-roleinheritance-reset.spec.ts Uses schema validation in reset tests.
src/​m365/​spo/​commands/​listitem/​listitem-roleinheritance-break.ts Migrates inheritance-break validation to Zod.
src/​m365/​spo/​commands/​listitem/​listitem-roleinheritance-break.spec.ts Uses schema validation in inheritance-break tests.
src/​m365/​spo/​commands/​listitem/​listitem-roleassignment-remove.ts Adds list and principal selection refinements.
src/​m365/​spo/​commands/​listitem/​listitem-roleassignment-add.ts Adds list, principal, and role selection refinements.
src/​m365/​spo/​commands/​listitem/​listitem-retentionlabel-remove.ts Adds a schema and passes numeric item IDs directly.
src/​m365/​spo/​commands/​listitem/​listitem-retentionlabel-remove.spec.ts Updates removal tests for schema parsing.
src/​m365/​spo/​commands/​listitem/​listitem-retentionlabel-ensure.ts Adds label-selection validation and numeric item IDs.
src/​m365/​spo/​commands/​listitem/​listitem-remove.ts Migrates deletion options and validation to Zod.
src/​m365/​spo/​commands/​listitem/​listitem-remove.spec.ts Updates validation tests and corrects action inputs.
src/​m365/​spo/​commands/​listitem/​listitem-record-unlock.ts Adds record-unlock schema validation.
src/​m365/​spo/​commands/​listitem/​listitem-record-unlock.spec.ts Parses unlock inputs and tests unknown options.
src/​m365/​spo/​commands/​listitem/​listitem-record-undeclare.ts Adds record-undeclaration schema validation.
src/​m365/​spo/​commands/​listitem/​listitem-record-undeclare.spec.ts Migrates tests and corrects the item-ID option.
src/​m365/​spo/​commands/​listitem/​listitem-record-lock.ts Adds record-lock schema validation.
src/​m365/​spo/​commands/​listitem/​listitem-record-lock.spec.ts Parses lock inputs and tests unknown options.
src/​m365/​spo/​commands/​listitem/​listitem-record-declare.ts Adds date validation and numeric item-ID typing.
src/​m365/​spo/​commands/​listitem/​listitem-list.ts Adds pagination and query-option schema constraints.
src/​m365/​spo/​commands/​listitem/​listitem-isrecord.ts Adds a schema and numeric request-body ID typing.
src/​m365/​spo/​commands/​listitem/​listitem-isrecord.spec.ts Migrates record-status tests to schema parsing.
src/​m365/​spo/​commands/​listitem/​listitem-get.ts Adds list and item identifier selection refinements.
src/​m365/​spo/​commands/​listitem/​listitem-batch-set.ts Adds file-path and batch-update option validation.
src/​m365/​spo/​commands/​listitem/​listitem-batch-set.spec.ts Updates schema tests and file-existence stubs.
src/​m365/​spo/​commands/​listitem/​listitem-batch-remove.ts Moves CSV and ID validation into schema refinements.
src/​m365/​spo/​commands/​listitem/​listitem-batch-add.ts Adds list and CSV-source selection refinements.
src/​m365/​spo/​commands/​listitem/​listitem-batch-add.spec.ts Tests schema parsing and CSV-source exclusivity.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-set.ts Adds attachment-update schema and file validation.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-set.spec.ts Migrates tests and corrects the GUID fixture.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-remove.ts Adds attachment-removal schema validation.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-remove.spec.ts Parses removal inputs and tests unknown options.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-list.ts Adds attachment-list schema validation.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-list.spec.ts Migrates list-selection and action tests.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-get.ts Adds attachment-retrieval schema validation.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-get.spec.ts Migrates retrieval and validation tests.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-add.ts Adds attachment-creation schema and file validation.
src/​m365/​spo/​commands/​listitem/​listitem-attachment-add.spec.ts Migrates tests and corrects the GUID fixture.
src/​m365/​spo/​commands/​listitem/​listitem-add.ts Adds a schema preserving arbitrary field options.
src/​m365/​spo/​commands/​listitem/​listitem-add.spec.ts Migrates creation tests while retaining custom fields.

Review effort: Balanced

listTitle: z.string().optional().alias('t'),
listUrl: z.string().optional(),
pageSize: z.number().int().positive().optional().alias('s'),
pageNumber: z.number().int().positive().optional().alias('n'),

This branch has not been deployed

No deployments
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 spo listitem commands to Zod

2 participants