Commit Graph

556 Commits

Author SHA1 Message Date
Carlos R. L. Rodrigues
356b2862d2 chore(core-flows): import zod (#13197) 2025-08-13 15:12:14 -03:00
olivermrbl
394226b5c1 chore: Release 2025-07-24 09:45:13 +02:00
Riqwan Thamir
d5a2cfbc5a chore: upgrade to latest zod v3 (#12938)
* chore: upgrade to latest zod v3

* chore: set explicit versions

* chore: remove v3 scope

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-07-14 14:23:47 +02:00
olivermrbl
1ee146edb2 chore: Release 2025-07-08 19:53:24 +02:00
olivermrbl
ac76e19194 chore: Release 2025-06-30 16:20:45 +02:00
olivermrbl
e0b5bb0b22 chore: Release 2025-06-25 11:47:49 +02:00
Adrien de Peretti
d517dbd66a feat(): Add support for jwt asymetric keys (#12813)
* feat(): Add support for jwt asymetric keys

* Create early-chefs-chew.md

* fix unit tests

* Add verify options support

* feedback

* fix unit tests
2025-06-25 10:29:32 +02:00
juanzgc
3826bde591 fix(medusa): Query Config update Order By filter (#12781)
**What**
Fixed a bug in the prepareListQuery function where nested field ordering was not properly building the expected nested object structure. The function was returning flat objects like { "employee.first_name": "ASC" } instead of the correct nested structure { "employee": { "first_name": "ASC" } }.

**Why**
The buildOrder function is designed to create nested objects from dot-notation field paths, which is essential for proper query building in the Medusa framework. When this functionality was broken, it prevented correct ordering of related fields and caused queries to fail or return unexpected results.

**How**
- Root cause: The `prepareListQuery` function was not properly utilizing the `buildOrder` utility function to transform dot-notation field paths into nested objects
- Before: order = "employee.first_name" → { "employee.first_name": "ASC" }
- After: order = "employee.first_name" → { "employee": { "first_name": "ASC" } }
- Added comprehensive tests: Created detailed unit tests for the prepareListQuery function focusing on buildOrder functionality, covering various scenarios including:
  - Simple ascending/descending order
  - Nested field ordering (e.g., product.title)
  - Deeply nested ordering (e.g., product.variants.prices.amount)
  - Multiple nesting levels (up to 5 levels deep)
- Added integration tests: Created integration tests in `product.spec.ts` to verify the full end-to-end functionality of nested ordering with variant titles

The fix ensures that the buildOrder function properly transforms dot-notation field paths into the expected nested object structure, enabling correct query building for related field ordering throughout the Medusa framework.

Resolves SUP-1868
2025-06-24 15:45:54 +00:00
Harminder Virk
00505b4f8e chore: upgrade to use glob 10 (#12754)
Glob 7 uses the `inflight` module, which leaks memory. Also, all other Medusa packages are using glob 10+. So upgraded the one used by the framework too.

Fixes: FRMW-2972
2025-06-17 12:52:27 +00:00
olivermrbl
cab00ff2b8 chore: Release 2025-06-05 20:36:32 +02:00
Harminder Virk
cf0297f74a feat: implement stream based processing of the files (#12574)
Fixes: FRMW-2960

This PR adds support for processing large CSV files by breaking them into chunks and processing one chunk at a time. This is how it works in nutshell.

- The CSV file is read as a stream and each chunk of the stream is one CSV row.
- We read upto 1000 rows (plus a few more to ensure product variants of a product are not split into multiple chunks).
- Each chunk is then normalized using the `CSVNormalizer` and validated using zod schemas. If there is an error, the entire process will be aborted and the existing chunks will be deleted.
- Each chunk is written to a JSON file, so that we can process them later (after user confirms) without re-processing or validating the CSV file.
- The confirmation process will start consuming one chunk at a time and create/update products using the `batchProducts` workflow.

## Resume or not to resume processing of chunks

Let's imagine during processing of chunks, we find that chunk 3 leads to a database error. However, till this time we have processed the first two chunks already. How do we deal with this situation? Options are:

- We store at which chunk we failed and then during the re-upload we ignore chunks before the failed one. In my conversation with @olivermrbl we discovered that resuming will have to work with certain assumptions if we decide to implement it.
   - What if a user updates the CSV rows which are part of the already processed chunks? These changes will be ignored and they will never notice it.
   - Resuming works if the file name is still the same. What if they made changes and saved the file with "Save as - New name". In that case we will anyways process the entire file.
   - We will have to fetch the old workflow from the workflow engine using some `ilike` search, so that we can see at which chunk the last run failed for the given file.

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-05-29 05:42:16 +00:00
olivermrbl
4936315b2d chore: Release 2025-05-22 14:08:05 +02:00
Harminder Virk
d9fdabe96d fix: mark posthog-node as a peer dependency (#12539)
Since the runtime of the `@medusajs/analytics-posthog` relies on `posthog-node` package. It should be either installed as a dependency or a peerDependency that will be satisfied by the user project.

In this PR, I have added it as a peer dependency
2025-05-20 14:51:51 +00:00
Stevche Radevski
b9a51e217d feat: Add an analytics module and local and posthog providers (#12505)
* feat: Add an analytics module and local and posthog providers

* fix: Add tests and wire up in missing places

* fix: Address feedback and add missing module typing

* fix: Address feedback and add missing module typing

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-05-19 19:57:13 +02:00
Adrien de Peretti
85d2b3c992 fix(utils): Missing zod deps (#12518) 2025-05-18 15:49:59 +02:00
olivermrbl
d73d8e9903 chore: Release 2025-05-16 11:35:18 +02:00
Harminder Virk
e149a99886 feat: define validators and use normalize-products step (#12473)
Fixes: FRMW-2965

In this PR we replace/remove the existing step to normalize a CSV file with the newly written CSV normalizer and also we validate the file contents further using a Zod schema.

I have duplicated the schema for now. But it is makes sense to re-use the schema for CSV validating and `/admin/products/batch`, then I can keep one source of truth under utils and re-export it. WDYT?

**Screenshots of some errors after validating the file strictly**

![CleanShot 2025-05-15 at 16 36 46@2x](https://github.com/user-attachments/assets/c7fa424f-b947-4898-9b94-47c48617c129)

![CleanShot 2025-05-15 at 16 36 34@2x](https://github.com/user-attachments/assets/0fefef79-148b-4eeb-8ef0-3077e8063ea8)
2025-05-16 08:37:25 +00:00
olivermrbl
3e61715597 chore: Release 2025-05-15 09:51:07 +02:00
olivermrbl
0c698194ea chore: Release 2025-05-13 12:59:20 +02:00
Pepijn
cdb135e491 fix(dashboard): Added missing admin dashboard dependencies (#12346) 2025-05-06 19:30:04 +02:00
Adrien de Peretti
80007f3afd feat(workflows-*): Allow to re run non idempotent but stored workflow with the same transaction id if considered done (#12362) 2025-05-06 17:17:49 +02:00
Harminder Virk
cb53b8a529 feat: upgrade opentelemetry packages to support the latest release (#12266)
Fixes: FRMW-2947
2025-04-23 08:26:03 +00:00
olivermrbl
c53d25e442 chore: Release 2025-04-23 09:30:11 +02:00
Harminder Virk
b890263725 feature: add support for dynamoDB for storing sessions and some types cleanup (#12140) 2025-04-16 14:55:14 +05:30
olivermrbl
af5918d03f chore: Release 2025-04-11 10:27:27 +02:00
Oli Juhl
40b08f7325 chore: Patch changesets to avoid major bumps (#12151) 2025-04-11 10:18:31 +02:00
Harminder Virk
cab6f3a8ad feat: add support for accessing step results via context (#11907)
Fixes: FRMW-2934

This PR adds support for accessing the results of a hook using the `hook.getResult` method.
2025-03-21 10:15:38 +00:00
Kasper Fabricius Kristensen
ec56a8bc85 fix(medusa,utils,test-utils,types,framework,dashboard,admin-vite-plugin,admin-bundler): Fix broken plugin dependencies in development server (#11720)
**What**
- Reworks how admin extensions are loaded from plugins.
- Reworks how extensions are managed internally in the dashboard project.

**Why**
- Previously we loaded extensions from plugins the same way we do for extension found in a users application. This being scanning the source code for possible extensions in `.medusa/server/src/admin`, and including any extensions that were discovered in the final virtual modules.
- This was causing issues with how Vite optimizes dependencies, and would lead to CJS/ESM issues. Not sure of the exact cause of this, but the issue was pinpointed to Vite not being able to register correctly which dependencies to optimize when they were loaded through the virtual module from a plugin in `node_modules`.

**What changed**
- To circumvent the above issue we have changed to a different strategy for loading extensions from plugins. The changes are the following:
  - We now build plugins slightly different, if a plugin has admin extensions we now build those to `.medusa/server/src/admin/index.mjs` and `.medusa/server/src/admin/index.js` for a ESM and CJS build.
  - When determining how to load extensions from a source we follow these rules:
    - If the source has a `medusa-plugin-options.json` or is the root application we determine that it is a `local` extension source, and load extensions as previously through a virtual module.
    - If it has neither of the above, but has a `./admin` export in its package.json then we determine that it is a `package` extension, and we update the entry point for the dashboard to import the package and pass its extensions a long to the dashboard manager.

**Changes required by plugin authors**
- The change has no breaking changes, but requires plugin authors to update the `package.json` of their plugins to also include a `./admin` export. It should look like this:

```json
{
  "name": "@medusajs/plugin",
  "version": "0.0.1",
  "description": "A starter for Medusa plugins.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "files": [
    ".medusa/server"
  ],
  "exports": {
    "./package.json": "./package.json",
    "./workflows": "./.medusa/server/src/workflows/index.js",
    "./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
    "./modules/*": "./.medusa/server/src/modules/*/index.js",
    "./providers/*": "./.medusa/server/src/providers/*/index.js",
    "./*": "./.medusa/server/src/*.js",
    "./admin": {
      "import": "./.medusa/server/src/admin/index.mjs",
      "require": "./.medusa/server/src/admin/index.js",
      "default": "./.medusa/server/src/admin/index.js"
    }
  },
}
```
2025-03-11 11:28:33 +00:00
olivermrbl
b9edc066c8 chore: Release 2025-03-10 15:47:42 +01:00
Harminder Virk
2a0bd86204 chore: pin swc to 1.5.7 (#11759)
Fixes https://github.com/medusajs/medusa/issues/11681
2025-03-07 11:01:30 +00:00
Oli Juhl
3b470f4142 chore: remove ranges on medusa packages (#11738) 2025-03-06 14:17:05 +01:00
Adrien de Peretti
cc1309d370 chore(product): Improve product normalization and fix http router with tracing (#11724)
**What**
- Improve product normalization and prevent over fetching data
- Fix HTTP router wrap handler with tracing enabled
2025-03-05 13:04:25 +00:00
olivermrbl
9e410be04a chore: Release 2025-03-04 14:12:26 +01:00
Harminder Virk
aabbbb7292 feat: Replace existing router with the new implementation (#11646) 2025-03-04 17:22:20 +05:30
Kasper Fabricius Kristensen
d814d9540e fix(types): Allow providing either vite@5 or vite@6 for the peer dependency (#11581)
**What**
- The types package has an optional peerDep on vite@5. This causes issues if the package is installed in a repo that has vite@6 installed. An example could be a `react-router/remix` storefront.
- Loosen the dependency to accept either vite@5 or vite@6.

Resolves SUP-970
2025-02-25 18:59:38 +00:00
olivermrbl
34fc7c53fd chore: Release 2025-02-24 11:36:46 +01:00
Stevche Radevski
8d10731343 fix: Remove swc/core as a production dependency (#11416) 2025-02-12 13:22:59 +01:00
Kasper Fabricius Kristensen
a039dd6932 chore(admin-sdk): Pin Zod version (#11413)
**What**
In order to prevent multiple version to exists and that might not be compatible with one another, we fix the zod package version in the admin-sdk in complement to the starter
2025-02-12 10:30:46 +00:00
Kasper Fabricius Kristensen
47edd01dee fix(admin-vite-plugin,admin-bundler,ui,icons,dashboard,framework,types): Update Vite dependencies (#11414)
**What**
- Bumps the versions of Vite across the entire stack, to prevent an issue similar to what is described here: https://github.com/vitejs/vite/discussions/18271

Not entirely sure what was happening as I couldn't reproduce the issue, but Adrien faced the issue yesterday when working with local versions of our packages. It does appear as if the range we had before could lead to a version of Vite to be installed with said bug.
2025-02-12 10:09:39 +00:00
olivermrbl
3c25aec006 chore: Release 2025-02-11 12:03:20 +01:00
Oli Juhl
db03738b5f chore: Revert version range to ^ (#11390) 2025-02-11 11:35:25 +01:00
Kasper Fabricius Kristensen
3dbef519d9 fix(admin-vite-plugin,icons,ui,dashboard): Upgrade vitest in all packages and align Vite version (#11361) 2025-02-09 11:46:50 +01:00
Kasper Fabricius Kristensen
fcd3e2226e feat(ui,dashboard): Migrate SC tables to DataTable (#11106) 2025-02-07 14:26:49 +00:00
Harminder Virk
f4c2cd112e fix: issues with peer dependencies (#11272) 2025-02-03 18:46:03 +05:30
Kasper Fabricius Kristensen
9822bd930b chore(ui,dashboard): Use radix-ui package (#11195)
* update deps for ui

* chore(ui,dashboard): Use radix-ui package

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-02-02 14:20:34 +01:00
olivermrbl
df4facbbef chore: Release 2025-01-27 09:35:34 +01:00
Kasper Fabricius Kristensen
57892bee00 fix(admin-bundler): Optimize tanstack/react-query (#11112) 2025-01-23 14:10:10 +00:00
Harminder Virk
0deffe7b9b fix: switch from tsc watch to chokidar (#11110) 2025-01-23 19:12:07 +05:30
Adrien de Peretti
9321920227 fix: Medusa package version should use ~ instead of ^ (#11077)
RESOLVES FRMW-2859
2025-01-22 15:15:30 +00:00
Carlos R. L. Rodrigues
cc73802ab3 chore(order): dml (#10292)
* ../../core/types/src/dml/index.ts

* ../../core/types/src/dml/index.ts

* fix: relationships mapping

* handle nullable foreign keys types

* handle nullable foreign keys types

* handle nullable foreign keys types

* continue to update product category repository

* fix all product category repositories issues

* fix product category service types

* fix product module service types

* fix product module service types

* fix repository template type

* refactor: use a singleton DMLToMikroORM factory instance

Since the MikroORM MetadataStorage is global, we will also have to turn DML
to MikroORM entities conversion use a global bucket as well

* refactor: update product module to use DML in tests

* wip: tests

* WIP product linkable fixes

* continue type fixing and start test fixing

* test: fix more tests

* fix repository

* fix pivot table computaion + fix mikro orm repository

* fix many to many management and configuration

* fix many to many management and configuration

* fix many to many management and configuration

* update product tag relation configuration

* Introduce experimental dml hooks to fix some issues with categories

* more fixes

* fix product tests

* add missing id prefixes

* fix product category handle management

* test: fix more failing tests

* test: make it all green

* test: fix breaking tests

* fix: build issues

* fix: build issues

* fix: more breaking tests

* refactor: fix issues after merge

* refactor: fix issues after merge

* refactor: surpress types error

* test: fix DML failing tests

* improve many to many inference + tests

* Wip fix columns from product entity

* remove product model before create hook and manage handle validation and transformation at the service level

* test: fix breaking unit tests

* fix: product module service to not update handle on product update

* fix define link and joiner config

* test: fix joiner config test

* test: fix joiner config test

* fix joiner config primary keys

* Fix joiner config builder

* Fix joiner config builder

* test: remove only modifier from test

* refactor: remove hooks usage from product collection

* refactor: remove hooks usage from product-option

* refactor: remove hooks usage for computing category handle

* refactor: remove hooks usage from productCategory model

* refactor: remove hooks from DML

* refactor: remove cruft

* order dml

* cleanup

* re add foerign key indexes

* wip

* chore: remove unused types

* wip

* changes

* rm raw

* autoincrement

* wip

* rel

* refactor: cleanup

* migration and models configuration adjustments

* cleanup

* number searchable

* fix random ordering

* fix

* test: fix product-category tests

* test: update breaking DML tests

* test: array assertion to not care about ordering

* fix: temporarily apply id ordering for products

* types

* wip

* WIP type improvements

* update order models

* partially fix types temporarely

* rel

* fix: recursive type issue

* improve type inference breaks

* improve type inference breaks

* update models

* rm nullable

* default value

* repository

* update default value handling

* fix unit tests

* WIP

* toMikroORM

* fix relations

* cascades

* fix

* experimental dml hooks

* rm migration

* serial

* nullable autoincrement

* fix model

* model changes

* fix one to one DML

* order test

* fix addresses

* fix unit tests

* Re align dml entity name inference

* update model table name config

* update model table name config

* revert

* update return relation

* WIP

* hasOne

* models

* fix

* model

* initial commit

* cart service

* order module

* utils unit test

* index engine

* changeset

* merge

* fix hasOne with fk

* update

* free text filter per entity

* tests

* prod category

* property string many to many

* fix big number

* link modules migration set names

* merge

* shipping option rules

* serializer

* unit test

* fix test mikro orm init

* fix test mikro orm init

* Maintain merge object properties

* fix test mikro orm init

* prevent unit test from connecting to db

* wip

* fix test

* fix test

* link test

* schema

* models

* auto increment

* hook

* model hooks

* order

* wip

* orm version

* request return field

* fix return configuration on order model

* workflows

* core flows

* unit test

* test

* base repo

* test

* base repo

* test fix

* inventory move

* locking inventory

* test

* free text fix

* rm timeout mock

* migrate fulfillment values

* v6.4.3

* cleanup

* link-modules update sql

* revert test

* remove fake timers

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
Co-authored-by: Harminder Virk <virk.officials@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-01-21 08:04:47 -05:00