Skip to content

chore: validation fixes#381

Merged
demeyerthom merged 3 commits intomainfrom
chore/validation-fixes
Mar 24, 2026
Merged

chore: validation fixes#381
demeyerthom merged 3 commits intomainfrom
chore/validation-fixes

Conversation

@demeyerthom
Copy link
Copy Markdown
Member

This pull request introduces several important improvements to the schema generation logic, Docker image publishing workflow, and project tooling. The most significant change is that generated optional fields in schemas are now treated as nullish (accepting both undefined and null), aligning the mock more closely with the behavior of the actual commercetools API. Additionally, the CI/CD workflow for publishing Docker images has been refactored to push multiple tags and to better coordinate releases. The following are the most notable changes:

Schema Generation and API Compatibility:

  • Updated the schema generation logic in scripts/generate-schemas.ts so that optional fields are now marked as .nullish() instead of .optional(), ensuring the mock accepts both undefined and null for optional fields, matching the commercetools API behavior. (.changeset/major-knives-dream.md [1] scripts/generate-schemas.ts [2] [3] [4] [5]

Docker Image Publishing and CI/CD Workflow:

  • Refactored the Docker image publishing process in .github/workflows/ci-cd.yaml to:
    • Only publish Docker images after a successful release.
    • Automatically resolve and use the newest release tag.
    • Push multiple tags (including versioned and latest tags), while ignoring beta tags for latest.
    • Improved output handling and job dependencies for more reliable automation. (.changeset/pink-mammals-wave.md [1] .github/workflows/ci-cd.yaml [2] [3] [4] [5]

Tooling Updates:

  • Added .tool-versions specifying versions for terraform, nodejs, and pnpm to help standardize development environments. (.tool-versions .tool-versionsR1-R3)

Code Style:

  • Minor import order changes in scripts/generate-schemas.ts for consistency.

…r handling of undefined values

- Changed optional fields to use nullish in various schema definitions to allow for more flexible data handling.
- Updated fields in CustomObjectDraftSchema, CustomerGroupDraftSchema, CustomerDraftSchema, DiscountCodeDraftSchema, and others to reflect this change.
Copilot AI review requested due to automatic review settings March 20, 2026 09:56
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: b3533cf

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the mock server’s request validation to better match commercetools behavior by accepting null for optional draft fields, refactors CI/CD so Docker images are published only after a successful Changesets release (with multiple tags), and adds standardized tool version pinning.

Changes:

  • Generate Zod schemas with .nullish() (accept undefined and null) for optional OpenAPI properties.
  • Refactor .github/workflows/ci-cd.yaml to publish Docker images only when a release actually publishes, tagging both version and latest (excluding beta from latest).
  • Add .tool-versions to align local toolchains (terraform/nodejs/pnpm) across dev environments.

Reviewed changes

Copilot reviewed 5 out of 44 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/schemas/generated/zone.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/type.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/tax-category.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/subscription.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/store.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/state.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/standalone-price.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/staged-quote.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/shopping-list.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/shipping-method.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/review.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/recurring-order.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/recurrence-policy.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/quote.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/quote-request.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/product.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/product-type.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/product-tailoring.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/product-selection.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/product-discount.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/payment.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/order-from-cart.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/order-edit.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/my-quote-request.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/inventory-entry.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/extension.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/discount-group.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/discount-code.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/customer.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/customer-group.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/custom-object.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/common.ts Shared schemas updated to .nullish() for optional fields (incl. identifiers & draft helpers)
src/schemas/generated/channel.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/category.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/cart.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/cart-discount.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/business-unit.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/attribute-group.ts Optional draft fields switched from .optional() to .nullish()
src/schemas/generated/associate-role.ts Optional draft fields switched from .optional() to .nullish()
scripts/generate-schemas.ts Generator now emits .nullish() for optional OpenAPI properties
.tool-versions Pins terraform/nodejs/pnpm versions for consistent local tooling
.github/workflows/ci-cd.yaml Publishes Docker images after release; resolves latest tag; pushes version + latest tags
.changeset/pink-mammals-wave.md Changeset entry for Docker tagging changes
.changeset/major-knives-dream.md Changeset entry for nullish optional draft fields
Comments suppressed due to low confidence (1)

.github/workflows/ci-cd.yaml:51

  • The release job if: condition references github.event.pull_request.draft, but this workflow runs the release job on push events. On push, github.event.pull_request is undefined, so this condition evaluates to false and the release (and downstream Docker publish) will never run. Remove the pull_request draft check (or guard it by event type) so releases work on pushes to main.
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.pull_request.draft == false
    permissions:

@demeyerthom demeyerthom merged commit 2d16f79 into main Mar 24, 2026
17 checks passed
@demeyerthom demeyerthom deleted the chore/validation-fixes branch March 24, 2026 08:59
demeyerthom pushed a commit that referenced this pull request Mar 24, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @labdigital/commercetools-mock@3.0.0-beta.1

### Patch Changes

- [#381](#381)
[`2d16f79`](2d16f79)
Thanks [@demeyerthom](https://github.com/demeyerthom)! - Made generated
optional fields nullish instead of optional, as the commercetools API
also accepts null as input and treats it as empty, but the mock
explicitly expects undefined

- [#381](#381)
[`2d16f79`](2d16f79)
Thanks [@demeyerthom](https://github.com/demeyerthom)! - Push multiple
docker image tags so we can pin versions if necessary, ignore beta tags
for latest

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@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.

2 participants