Merged
Conversation
…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.
🦋 Changeset detectedLatest 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 |
Contributor
There was a problem hiding this comment.
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()(acceptundefinedandnull) for optional OpenAPI properties. - Refactor
.github/workflows/ci-cd.yamlto publish Docker images only when a release actually publishes, tagging both version andlatest(excluding beta fromlatest). - Add
.tool-versionsto 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
releasejobif:condition referencesgithub.event.pull_request.draft, but this workflow runs thereleasejob onpushevents. Onpush,github.event.pull_requestis 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 tomain.
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.pull_request.draft == false
permissions:
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
undefinedandnull), 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:
scripts/generate-schemas.tsso that optional fields are now marked as.nullish()instead of.optional(), ensuring the mock accepts bothundefinedandnullfor 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:
.github/workflows/ci-cd.yamlto:latesttags), while ignoring beta tags forlatest.Tooling Updates:
.tool-versionsspecifying versions forterraform,nodejs, andpnpmto help standardize development environments. (.tool-versions .tool-versionsR1-R3)Code Style:
scripts/generate-schemas.tsfor consistency.