feat(stock-locations): add metadata field to AdminUpsertStockLocation… #14557
+8
−1
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.
Summary
Enables support for the
metadatafield on stock location addresses in the Admin API, allowing custom key-value data to be stored on the address entity during creation and updates.Problem
The
StockLocationAddressdatabase model already supports ametadatacolumn, but the Admin API type definitions and validators did not allow this field in request payloads. As a result, anymetadatapassed when creating or updating a stock location address was stripped at the API layer, preventing users and integrations from persisting custom address-level data (e.g. internal reference IDs, gate codes).Solution
AdminUpsertStockLocationAddressin@medusajs/typesto include an optionalmetadata?: Record<string, unknown>field.metadatafield.This aligns the Admin API with the underlying
StockLocationAddressmodel, which already handles metadata correctly.How to test
POSTrequest to/admin/stock-locationswith the following payload:{ "name": "Metadata Test Location", "address": { "address_1": "123 Test St", "country_code": "US", "metadata": { "internal_id": "LOC-123", "gate_code": "9999" } } } <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Aligns Admin API with model by allowing custom key-value `metadata` on stock location addresses. > > - Add `metadata` to `AdminStockLocationAddress` entity type > - Add optional `metadata` to `AdminUpsertStockLocationAddress` payload type > - Update admin Zod validator `AdminUpsertStockLocationAddress` to accept `metadata` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ed81272c148db047fcea996826764cfae30d0e70. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->