Skip to content

Migrate file commands to Zod#7370

Open
waldekmastykarz wants to merge 2 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-file-commands-to-zod
Open

Migrate file commands to Zod#7370
waldekmastykarz wants to merge 2 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz/migrate-file-commands-to-zod

Conversation

@waldekmastykarz
Copy link
Copy Markdown
Member

Summary

Migrates all 5 file commands to use Zod schemas for option definitions and validation, replacing the old #initTelemetry, #initOptions, and #initValidators pattern.

Commands migrated

Command Key changes
file add folderUrl/siteUrl SharePoint URL validation via Zod refine; filePath existence check via getRefinedSchema
file copy webUrl SharePoint URL validation; nameConflictBehavior as z.enum
file list webUrl SharePoint URL validation; recursive as optional boolean
file move webUrl SharePoint URL validation; nameConflictBehavior as z.enum
file convert pdf sourceFile/targetFile existence checks via getRefinedSchema

Changes per file

  • Command files: Removed constructors, #initTelemetry, #initOptions, #initValidators; added exported z.strictObject schema with globalOptionsZod.shape spread and get schema() getter
  • Spec files: Updated validation tests to use commandOptionsSchema.safeParse() instead of command.validate()

Closes #7303

waldekmastykarz and others added 2 commits May 28, 2026 15:20
Migrates all 5 file commands under src/m365/file/commands/ from the
old options/validators/telemetry pattern to Zod schemas:

- file add
- file copy
- file list
- file move
- file convert pdf

Closes pnp#7303

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds missing test to cover the folderUrl validation error callback,
fixing 100% function coverage.

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 file commands to Zod

1 participant