Commit Graph
100 Commits
Author SHA1 Message Date
Harminder VirkandGitHub 10dff3e266 fix: do not apply prefix when getting file contents as buffer or stream (#12831)
* fix: do not apply prefix when getting file contents as buffer or stream

* Create spotty-mayflies-bathe.md
2025-06-26 13:58:17 +05:30
Harminder VirkandGitHub 94b62c6724 fix: initiate request container before other express middleware (#12761) 2025-06-19 07:23:15 +00:00
Harminder VirkandGitHub 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
Harminder VirkandGitHub b316924572 fix: remote query types (#12712)
* fix: remote query types

* fix: breaking types

* Create eleven-falcons-return.md
2025-06-12 15:49:26 +05:30
Harminder VirkandGitHub ce202968c6 fix: update product import template (#12697)
Closes: #12688
Fixes: FRMW-2977
2025-06-10 12:38:42 +00:00
Harminder VirkandGitHub f2cb528a56 feat: wire up direct uploads with local file provider (#12643) 2025-06-10 15:07:54 +05:30
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
Harminder VirkandGitHub 791276e80f feat: introduce bulkDelete method for IFileProvider (#12614)
Fixes: FRMW-2974

Currently during the product imports, we create multiple chunks that must be deleted after the import has finished (either successfully or with an error). Deleting files one by one leads to multiple network calls and slows down everything.

The `bulkDelete` method deletes multiple files (with their fileKey) in one go
2025-05-27 06:52:11 +00:00
Harminder VirkandGitHub 1f5f50010a fix: expand method ALL for bodyparser config and additional validator (#12612)
Fixes: FRMW-2969
2025-05-26 10:22:26 +00:00
117fc25aea feat: run workflow hooks inside a when/then block (#11963)
* feat: run workflow hooks inside a when/then block

* fix conditionals and add test

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-05-23 09:52:18 -03:00
Harminder VirkandGitHub f6f34cc0e4 fix: module import paths to contain unix slash (#12592)
Currently when types are generated on Windows, they result in using Windows slash for relative imports. This PR, fixes that to always use Unix imports
2025-05-23 08:09:34 +00:00
Harminder VirkandGitHub 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
Harminder VirkandGitHub fca5ad77b4 feat: process import from pre-processed chunks (#12527)
Fixes: FRMW-2968

In this PR we have done two major things.

- First, we remove storing CSV contents within the workflow storage and neither store the JSON payloads to be created/updated in workflows. Earlier, they all were workflow inputs, hence were stored in the workflow
- Introduce a naive concept of chunks and process chunks one by one. The next PR making chunking a bit more robust while using streams, adding ability to resume from the failed chunk and so on.

> [!IMPORTANT]  
> The new endpoint `/admin/product/imports` is not in use yet. But it will be after the next (final) PR.

## Old context in workflow storage

![CleanShot 2025-05-19 at 17 11 08@2x](https://github.com/user-attachments/assets/798bdcc9-a368-4c1f-afdd-2a77f5ce43e0)

## New context in workflow storage

![CleanShot 2025-05-19 at 17 15 08@2x](https://github.com/user-attachments/assets/0463d035-403f-4600-a9cd-5af24d5fee7c)
2025-05-20 12:33:18 +00:00
5cd4ff6fe7 test: remove snapshots usage (#12516)
* test: remove snapshots usage

* test: remove unneeded assertions

* Create plenty-poems-reply.md

* update tests

* update tests

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
2025-05-16 16:11:01 +02:00
Harminder VirkandGitHub 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
Harminder VirkandGitHub 4602163b56 feat: create CSV normalizer to normalize a CSV file (#12396) 2025-05-13 18:04:59 +05:30
Harminder VirkandGitHub e4d853185f fix: export ProductImage to allow for custom links to add alt text (#12357) 2025-05-05 14:24:25 +05:30
Harminder VirkandGitHub 84f58f9058 feat: implement direct upload (#12328)
* feat: implement direct upload

* feat: add direct-upload endpoint

* refactor: implement feedback

* refactor: have a dedicated endpoint for direct uploads

* refactor: convert responses to snakecase

* refactor: rename method to createImport

* test: add tests for the presigned-urls endpoint
2025-05-04 12:58:10 +02:00
Harminder VirkandGitHub ceb504db2c feat: add needed methods to the file module and providers (#12325) 2025-04-30 13:17:31 +05:30
Harminder VirkandGitHub 552dc52228 test: use shared as integration-tests level (#12278) 2025-04-28 18:41:19 +05:30
Harminder VirkandGitHub cb53b8a529 feat: upgrade opentelemetry packages to support the latest release (#12266)
Fixes: FRMW-2947
2025-04-23 08:26:03 +00:00
Harminder VirkandGitHub 71a9a7210c fix: oas CLI to convert Windows paths to unix (#12254)
* fix: oas CLI to convert Windows paths to unix

* Create tidy-pigs-heal.md

* refactor: revert to isolate the issue

* refactor: add back the change with logs

* fix: remove external dependency
2025-04-22 14:41:58 +02:00
Harminder VirkandGitHub c2fe3f1520 fix: steps to return undefined and still chain the config method (#12255)
Fixes: FRMW-2946
2025-04-22 10:57:15 +00:00
Harminder VirkandGitHub 24af8f2d8e fix: expose beforeRefreshingPaymentCollection hook (#12232)
Fixes: FRMW-2942
Fixes: #12228
2025-04-18 09:31:19 +00:00
Harminder VirkandGitHub ee35f3ce90 fix: apply additional data validator using a global middleware (#12194) 2025-04-16 16:26:44 +05:30
Harminder VirkandGitHub b890263725 feature: add support for dynamoDB for storing sessions and some types cleanup (#12140) 2025-04-16 14:55:14 +05:30
d3e725a907 feat: add hasMany flag to enforce in app link uniqueness (#12039)
* feat: add createMultiple flag to enforce inApp link uniqueness

* changes

* mocks

* default

* many to many

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-04-02 10:46:51 +02:00
Harminder VirkandGitHub 2f7eb0ee03 fix: validate module names to disallow unallowed characters (#12025) 2025-03-28 22:39:39 +05:30
Harminder VirkandGitHub b1b3b48474 feat: Set pricing context hook (#11891) 2025-03-28 15:17:52 +05:30
Harminder VirkandGitHub 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
Harminder VirkandGitHub ff3885500c fix: hooks auto-generated types to have precise input options (#11886) 2025-03-18 15:41:01 +05:30
Harminder VirkandGitHub aa6d5aa3cf fix: register locking provider with its unique id (#11874) 2025-03-18 15:04:47 +05:30
Harminder VirkandGitHub cae47d9e49 feat: add check for uniqueness when creating links with isList=false (#11767) 2025-03-17 13:23:18 +05:30
Harminder VirkandGitHub 375c4a5ab1 refactor: use module name as the snapshot name (#11802)
Fixes: FRMW-2930

This PR updates the MikroORM config to use the module name as the snapshot name when generating migration files. Otherwise, MikroORM defaults to the database name and every time you update the database name, it will create a new snapshot. 

Also, we migrate existing snapshot files to be same the new file name to avoid breaking changes.
2025-03-12 07:02:19 +00:00
Harminder VirkandGitHub 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
Harminder VirkandGitHub aabbbb7292 feat: Replace existing router with the new implementation (#11646) 2025-03-04 17:22:20 +05:30
Harminder VirkandGitHub b0a16488e0 feat: add middleware-file-loader (#11638)
Fixes: FRMW-2920

The feature is called `middleware-file-loader`, because it does more than just collecting middlewares. It also collects the bodyParser config for routes
2025-02-27 09:42:29 +00:00
Harminder VirkandGitHub 9e2af4801d feat: add routes loader (#11592)
Fixes: FRMW-2919

This PR adds a new routes loader with a single responsibility of scanning the filesystem and collecting routes. Sorting of routes, merging middleware and registering them with express are going to separate implementations.

The new `RoutesLoader` class allows overriding routes as-well (not recommended though) and this is how routes are de-duplicated.

- When two routes for the exact route pattern/matcher are discovered, the routes loader will only keep the last one.

- Routes files can also override handlers for specific HTTP methods. For example, the original route file exported handlers for `GET` and `POST`, but the overriding one only defines `GET`. In that case, we will continue using the original implementation for the `POST` handler.

- If an overriding route file exports additional configuration like `export const AUTHENTICATION=false`, then this will only impact the handlers exported from this file and not the original handlers.

Routes sorting has been already been implemented in a separate PR and you can visualize it using this URL. https://routes-visualizer.fly.dev/
2025-02-26 07:24:10 +00:00
Harminder VirkandGitHub feec0243ab feat: add middleware and routes sorter (#11526)
Fixes: FRMW-2918
2025-02-24 10:17:15 +00:00
Harminder VirkandGitHub 0e6ffad30f fix: allow setting DB_PORT and DATABASE_URL env variables (#11519)
Fixes: FRMW-2896

Closes: https://github.com/medusajs/medusa/issues/11502
2025-02-19 08:07:15 +00:00
Harminder VirkandGitHub 32c5015f56 fix: generate posix paths for migrations (#11468)
Fixes: FRMW-2913

Related Github issue - https://github.com/medusajs/medusa/issues/11330
2025-02-17 09:57:00 +00:00
Harminder VirkandGitHub a5ff1b92ce refactor: remove host from the server ready log (#11485) 2025-02-17 14:07:44 +05:30
Harminder VirkandGitHub bc02fde236 feat: allow all NodeSDK options via registerOtel (#11460) 2025-02-14 15:37:32 +05:30
Harminder VirkandGitHub d1cbe4c61e fix: relationships to accept ids (#11399) 2025-02-14 05:41:36 +00:00
Harminder VirkandGitHub 1a3843a92a fix: listVariantsList types (#11441) 2025-02-13 20:53:35 +05:30
Harminder VirkandGitHub 244cd714b2 fix: add foreign keys to the generated query types output (#11388) 2025-02-11 14:16:10 +05:30
Harminder VirkandGitHub 3c51709daf feat: map container types for core services to interface (#11295) 2025-02-04 15:47:55 +05:30
Harminder VirkandGitHub 016e332e9b feat: make AbstractModuleService create method type-safe (#11216) 2025-02-03 21:25:01 +05:30
Harminder VirkandGitHub f4c2cd112e fix: issues with peer dependencies (#11272) 2025-02-03 18:46:03 +05:30
Harminder VirkandGitHub c982117186 fix: always load .env file alongside the environment specific file (#11188) 2025-01-29 14:22:50 +05:30
Harminder VirkandGitHub 716de2cb3a fix: exit process with a status code when build fails (#11206)
Fixes: FRMW-2897
CLOSES CLO-434

Still need the frontend Admin bundler to provide some way to know if the build has failed or not.
2025-01-29 08:34:47 +00:00
Harminder VirkandGitHub 10962a5c54 feat: Add tasks orchestrator (#11161)
Fixes: FRMW-2885
2025-01-27 12:43:49 +00:00
Harminder VirkandGitHub 0deffe7b9b fix: switch from tsc watch to chokidar (#11110) 2025-01-23 19:12:07 +05:30
Harminder VirkandGitHub e53b8b0a97 fix: Flaky behavior of Yalc (#11084) 2025-01-22 14:26:07 +05:30
Harminder VirkandGitHub 171088b47a fix: missing dependencies in the framework package (#11049)
In the framework package we are directly importing many uninstalled dependencies. The issue does not occur for transitive dependencies. However, the `glob` package is not a transitive dependency of any production dependency and hence it fails.

Fixes: #11044
Fixes: FRMW-2877
2025-01-20 11:51:44 +00:00
Harminder VirkandGitHub 114b2133aa chore: lazy import admin-bundler and run scripts during publish (#10996) 2025-01-16 20:28:17 +05:30
Harminder VirkandGitHub c75678d6d4 feat: add support for loading admin extensions from the source (#10975) 2025-01-16 11:06:56 +05:30
Harminder VirkandGitHub b0f581cc7c feat: add plugin build command (#10935)
Fixes: FRMW-2863

Adds the `plugin:build` command that is used to compile the source code of a plugin for publishing it to a package registry. The command is similar to the `build` command, except it does not copy the `package.json` and the `lock` files to the build output
2025-01-13 13:33:54 +00:00
Harminder VirkandGitHub 69e2a6d695 Feat/plugin develop (#10926)
Fixes: FRMW-2865

In this PR we add support for developing a plugin in watch mode. During the file change, we re-compile the source code (incrementally), publishes the package, and updates the installations of the plugin. 

We are using `yalc` under the hood and it must be installed as a dev dependency in the plugin project and the main Medusa app.
2025-01-13 13:08:02 +00:00
Harminder VirkandGitHub 428fce5313 chore: move build utilities to Compiler class (#10904)
Fixes: FRMW-2866
2025-01-10 11:30:48 +00:00
c1930bd656 feat: Merge plugin modules (#10895)
Fixes: FRMW-2858

This PR merge the modules exported by the plugins with the modules defined within the user config. As a result, all modules get loaded without changing the internals of the loader.

However, you cannot disable the module of a plugin by re-adding it to the `modules` array. That is something we should handle separately. 

We've added the breaking change label because of the following fix:
We did broke the ability to completely disable modules in the past pr's, in this pr we re add the ability to disable a module and that this modules does not get loaded at all. ([here](https://github.com/medusajs/medusa/pull/10895/commits/6dd164f783d632c927e0a48c50090dcf7387ccdd))

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2025-01-10 10:02:09 +00:00
Harminder VirkandGitHub 28febfc643 feat: remove dead code and refactor the logic of resolving plugins (#10874) 2025-01-09 14:52:10 +05:30
Harminder VirkandGitHub 67782350a9 feat: add default retry strategy for redis (#10880)
Fixes: FRMW-2861
2025-01-09 05:26:08 +00:00
Harminder VirkandGitHub e40878d9f3 chore: rename remote-query-entry-points.d.ts to query-entry-points.d.ts (#10831) 2025-01-07 16:44:49 +05:30
Harminder VirkandGitHub 988931a551 Fix/product variants filter (#10808)
Fixes: FRMW-2854
2025-01-03 14:00:02 +00:00
Harminder VirkandGitHub ecc09fd77d feat: generate modules mappings at runtime (#10791) 2025-01-03 15:49:47 +05:30
Harminder VirkandGitHub 5e9d86d75d feat: deprecate remoteQueryConfig in favor of queryConfig (#10773)
Fixes: FRMW-2783
2025-01-03 08:46:23 +00:00
bbf790ea44 feat: deprecate remote link (#10768)
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-12-30 14:57:43 +05:30
Harminder VirkandGitHub 0559d54c18 fix: pluralization of words ending in y, where y follows a vowel (#10697)
Fixes: FRMW-2851
2024-12-23 13:07:27 +00:00
Harminder VirkandGitHub ae1d875fcf fix: pluralization rule for the info word (#10599) 2024-12-13 16:09:09 +05:30
Harminder VirkandGitHub e021c9258c Feat/tax dml (#10525)
Fixes: FRMW-2842

There are zero breaking changes and the users will have to run the migrations
2024-12-12 09:35:11 +00:00
Harminder VirkandGitHub 885c82ded6 feat: add support for float properties (#10551) 2024-12-12 10:34:39 +05:30
Harminder VirkandGitHub 16d27ea6e4 feat: Migrate customer module to DML (#10499) 2024-12-11 14:37:27 +05:30
Harminder VirkandGitHub fad85a9d29 refactor: migrate promotion module (#10410) 2024-12-11 13:12:39 +05:30
Harminder VirkandGitHub 4ad9ac1e5f refactor: migration stock location module (#10471)
Fixes: FRMW-2831
2024-12-10 16:08:48 +00:00
Harminder VirkandGitHub f3c91c908a refactor: migrate store module to DML (#10467) 2024-12-06 17:38:15 +05:30
Harminder VirkandGitHub 70d77ea22f refactor: migrate api key module to DML (#10450)
Fixes: FRMW-2827
2024-12-05 16:37:54 +00:00
Harminder VirkandGitHub be15240909 refactor: migrate sales-channel to DML (#10452)
Fixes: FRMW-2830
2024-12-05 14:02:08 +00:00
Harminder VirkandGitHub 0a16efa426 refactor: migrate cart module to DML (#10385)
FIXES: FRMW-2815

This PR has no breaking changes
2024-12-05 12:30:50 +00:00
Harminder VirkandGitHub 223bcff379 feat: add support for defining hasOne with FK (#10441) 2024-12-05 14:15:13 +05:30
Harminder VirkandGitHub 3e98364bd1 feature: add support for check constraints in DML (#10391) 2024-12-02 17:59:50 +05:30
913cf15e2b refactor: migrate pricing entities to DML models (#10335)
Fixes: FRMW-2810

## Breaking changes
There is only one breaking change

- The `min_quantity` and `max_quantity` properties are now consistently typed as numbers. Earlier, it was [typed as numbers](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L68-L69) in some API responses and as [string in others](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L186-L187). I did not go to the bottom of this inconsistency, but the tests reveals them.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-12-02 09:44:41 +00:00
Harminder VirkandGitHub 194361b95a fix: do not rely on model loading order to find an implicit owner (#10360) 2024-11-29 16:02:34 +05:30
Harminder VirkandGitHub d57c739052 fix: do not initialize FKs to null (#10337) 2024-11-28 17:15:08 +05:30
9f204817b0 feat: convert MikroORM entities to DML entities (#10043)
* feat: convert MikroORM entities to DML entities

* feat: wip on repository changes

* continue repositories and types rework

* fix order repository usage

* continue to update product category repository

* Add foreign key as part of the inferred DML type

* ../../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

* cleanup

* re add foerign key indexes

* chore: remove unused types

* refactor: cleanup

* migration and models configuration adjustments

* cleanup

* 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

* fix ordering

* fix ordering remove logs

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-11-26 20:01:02 +05:30
Harminder VirkandGitHub 7390c14c20 feat: add support for making relationships searchable (#10172)
Closes: FRMW-2784
2024-11-20 08:39:44 +00:00
Harminder VirkandGitHub 9dff05cdde Revert "feat: add optional fields" (#10159)
Reverts medusajs/medusa#10150
2024-11-19 13:28:02 +00:00
Harminder VirkandGitHub 661ea7865c feat: add optional fields (#10150) 2024-11-19 16:28:33 +05:30
Harminder VirkandGitHub d933b3f1e4 Refactor/finish rename order (#10136) 2024-11-18 15:31:29 +05:30
Harminder VirkandGitHub 2c957c64be refactor: rename workflow to singular (#10134) 2024-11-18 14:58:30 +05:30
Harminder VirkandGitHub 98bf8c9006 test: add tests for self relationships (#10071)
Initially I thought that we will have to add special checks to allow relationships referencing itself. However, it turned out that not to be the case. Instead, it had more to do with how self relationships are defined in Mikro ORM.

In case of `belongsTo` relationship we have to define the other side as well either as a `hasMany` or `hasOne`. For example:

** The following code will fail, because no children are defined for the parent**
```ts
const user = model.define("user", {
  id: model.number(),
  username: model.text(),
  parent: model.belongsTo(() => user)
})
```

** Addition of children relationship will make things work**
```ts
const user = model.define("user", {
  id: model.number(),
  username: model.text(),
  parent: model.belongsTo(() => user, { mappedBy: "children" }),
  children: model.hasMany(() => user, { mappedBy: "parent" }),
})
```

We can see the similar setup here with our `ProductCategory` MikroORM entity. https://github.com/medusajs/medusa/blob/develop/packages/modules/product/src/models/product-category.ts#L87-L94

@adrien2p Correct me if I am wrong. But I have added the tests for now so that we know the behavior of self relationships
2024-11-13 17:20:27 +00:00
Harminder VirkandGitHub d9d4e575f6 fix: do not update the .env.template file with the database name (#10073)
Fixes FRMW-2775
2024-11-13 12:28:13 +00:00
Harminder VirkandGitHub bc2d556c2c docs: add changeset for #10011 (#10018)
Missed changeset in this PR https://github.com/medusajs/medusa/pull/10011.

Trying to get into the habit of creating one 🙏
2024-11-11 12:15:48 +00:00
Harminder VirkandGitHub e228088f8d fix: pluralize type helper to account for uncountable nouns and special rules (#10011) 2024-11-11 17:18:23 +05:30
Harminder VirkandGitHub 307f1015cd fix: define ssl options when specified in the connection string (#9992) 2024-11-09 00:21:45 +05:30
Harminder VirkandGitHub 1a0882cc01 fix: commands to run from within the .medusa/server directory (#9941) 2024-11-07 14:12:54 +05:30
Harminder VirkandGitHub 3704700a49 chore: remove husky (#9967)
Fixes: FRMW-2765, FRMW-2760

Since no one is using it for a very long time we can get rid of it

Closes: #9867
2024-11-07 07:54:30 +00:00
Harminder VirkandGitHub b0f416769f fix: do not set default host to localhost (#9957)
Fixes bug introduced by https://github.com/medusajs/medusa/pull/9912

By default the Node.js server listens on the `0.0.0.0` host. However, the related PR changes the host to `localhost` and hence resulted in an unwanted breaking change. This PR reverts the default value assignment and let Node.js decide the host when not explicitly specified.
2024-11-06 17:04:49 +00:00
Harminder VirkandGitHub c9a2b42252 fix: log cause property from the error (#9944)
Fixes: FRMW-2762

This PR fixes the error reporting to include the original error message and the error cause when logging it using the JSON formatter of Winston.

> Side note: There is still a lot of room for improvements in our logging. But that require a overhaul cleanup in multiple places and will require dedicated loggers for commands and APP and special treatment for pretty printing errors.

## Error output in JSON format

**Before**
![CleanShot 2024-11-06 at 13 12 32@2x](https://github.com/user-attachments/assets/a986d33c-9c30-45bc-816d-e9aa142ea097)

**After**
![CleanShot 2024-11-06 at 13 11 28@2x](https://github.com/user-attachments/assets/15430e55-40b3-4d1c-b91d-3b3b4f9d0d39)
2024-11-06 15:43:54 +00:00
Harminder VirkandGitHub 293b10cfc5 feat: move to a form based bug report template (#9930) 2024-11-05 14:44:52 +05:30