Skip to content

Migrates entra user commands to Zod validation#7372

Open
waldekmastykarz wants to merge 1 commit into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-entra-user-to-zod
Open

Migrates entra user commands to Zod validation#7372
waldekmastykarz wants to merge 1 commit into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-entra-user-to-zod

Conversation

@waldekmastykarz
Copy link
Copy Markdown
Member

Summary

Migrates all entra user commands to use Zod schemas for option validation, replacing the old constructor-based pattern (#initTelemetry, #initOptions, #initValidators, #initOptionSets, #initTypes).

Closes #7301

Commands migrated (17 total)

  • user-add, user-get, user-set, user-list
  • user-remove, user-guest-add
  • user-license-add, user-license-list, user-license-remove
  • user-groupmembership-list, user-signin-list, user-hibp
  • user-password-validate
  • user-recyclebinitem-clear, user-recyclebinitem-remove, user-recyclebinitem-restore
  • user-registrationdetails-list

Changes

  • Replaced constructor-based option registration with z.strictObject() / z.looseObject() schemas
  • Commands with allowUnknownOptions (user-list, user-add, user-set) use z.looseObject() and zod.schemaToOptions(this.schema!) for unknown option detection
  • Updated 2 external dependents (group-member-remove.ts, group-set.ts) to work with the new typed Options export from user-get.ts
  • Updated all corresponding test files to use Zod parsing pattern

Results

  • ✅ Build passes
  • ✅ All 15,723 tests pass
  • ✅ 100% function coverage
  • Net -891 lines (1,026 added, 1,917 removed)

Migrates all entra user commands to use Zod schemas for option
validation, replacing the old pattern of constructor-based
#initTelemetry, #initOptions, #initValidators, #initOptionSets,
and #initTypes methods.

Commands migrated:
- user-add, user-get, user-set, user-list
- user-remove, user-guest-add
- user-license-add, user-license-list, user-license-remove
- user-groupmembership-list, user-signin-list, user-hibp
- user-password-validate
- user-recyclebinitem-clear, user-recyclebinitem-remove,
  user-recyclebinitem-restore
- user-registrationdetails-list

Updates external dependents (group-member-remove, group-set) to
work with the new Options type from user-get.

Closes pnp#7301

Co-authored-by: Copilot <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 entra user commands to Zod

1 participant