Skip to content

Migrate spo sitescript commands to Zod. Closes #7342 - #7627

Merged
milanholemans merged 4 commits into
pnp:mainfrom
MartinM85:feature/7342-migrate-spo-sitescript-commands-to-zod
Oct 20, 2026
Merged

milanholemans merged 4 commits into
pnp:mainfrom
MartinM85:feature/7342-migrate-spo-sitescript-commands-to-zod

Conversation

@MartinM85

Copy link
Copy Markdown
Contributor

Closes #7342

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.

🟢 Approval recommended

The migrations preserve command behavior and include appropriate schema validation coverage.

0 open findings

What changed in this PR

Migrates five spo sitescript commands from legacy option initialization and validation to Zod schemas.

Changes:

  • Adds strict Zod schemas with aliases and validation.
  • Updates tests to parse options through command schemas.
  • Adds unknown-option validation coverage.
File Description
sitescript-add.ts Adds schema-based JSON validation.
sitescript-add.spec.ts Updates schema and action tests.
sitescript-get.ts Adds GUID and flag schema.
sitescript-get.spec.ts Tests migrated validation.
sitescript-list.ts Adds strict global-options schema.
sitescript-list.spec.ts Tests empty and unknown options.
sitescript-remove.ts Adds GUID and force schema.
sitescript-remove.spec.ts Updates validation and action tests.
sitescript-set.ts Adds update-option schemas and refinements.
sitescript-set.spec.ts Covers migrated validation paths.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@milanholemans milanholemans self-assigned this Oct 19, 2026

@milanholemans milanholemans 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.

Few remarks while reviewing. Also I think the PR has to be rebased to the latest version of Zod to fix the code coverage issue (other PRs probably as well).

Comment thread src/m365/spo/commands/sitescript/sitescript-get.ts Outdated
Comment thread src/m365/spo/commands/sitescript/sitescript-remove.ts Outdated
Comment thread src/m365/spo/commands/sitescript/sitescript-set.ts Outdated
Comment thread src/m365/spo/commands/sitescript/sitescript-set.ts Outdated
@milanholemans
milanholemans marked this pull request as draft October 19, 2026 22:06
@MartinM85
MartinM85 force-pushed the feature/7342-migrate-spo-sitescript-commands-to-zod branch from 6092f94 to 0d59240 Compare October 20, 2026 06:18
@MartinM85
MartinM85 marked this pull request as ready for review October 20, 2026 06:24

@milanholemans milanholemans 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.

With a few changes, it's good to go.


export const options = z.strictObject({
...globalOptionsZod.shape,
id: z.uuid().alias('i'),

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.

Instead of uuid, we should use guid. The UUID check is stricter than GUID:

  • The first character of the 3rd group must be 1–8.
  • The first character of the 4th group must be 8, 9, a or b.


export const options = z.strictObject({
...globalOptionsZod.shape,
id: z.uuid().alias('i'),

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.

Also here, let's use guid.


export const options = z.strictObject({
...globalOptionsZod.shape,
id: z.uuid().alias('i'),

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.

Same here

id: z.uuid().alias('i'),
title: z.string().optional().alias('t'),
description: z.string().optional().alias('d'),
version: z.string().optional()

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.

If you move the .optional() to the back, you don't have to perform an undefined check.

@milanholemans
milanholemans merged commit cce6ed8 into pnp:main Oct 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate spo sitescript and spo storageentity commands to Zod

3 participants