Commit Graph
100 Commits
Author SHA1 Message Date
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
Harminder VirkandGitHub ab90900d40 fix: disable admin when running integration tests (#9915) 2024-11-04 16:20:41 +05:30
Harminder VirkandGitHub 300ef8dbb9 fix: consider --host flag and HOST env variable (#9912) 2024-11-04 14:56:57 +05:30
Harminder VirkandGitHub 432af1e2d1 fix: install preview version of dev-cli (#9750) 2024-10-24 08:49:32 +00:00
Harminder VirkandGitHub 809c8a6741 fix: missing dependency in dev-cli (#9730) 2024-10-23 10:01:39 +02:00
Harminder VirkandGitHub 63fff01f2f fix: allow additional_data to be undefined or null (#9687) 2024-10-21 13:44:21 +05:30
Harminder VirkandGitHub 1e0f6188ec fix: resolve paths using require.resolve (#9665) 2024-10-18 13:30:29 +00:00
Harminder VirkandGitHub d77d184729 Fix/production logging (#9658)
Keep the old format (ie combined) when logging in production.

**Development**
![CleanShot 2024-10-18 at 16 51 18@2x](https://github.com/user-attachments/assets/7656422a-0329-4062-ad6a-5bbc4a892b37)

**Production**
![CleanShot 2024-10-18 at 16 52 25@2x](https://github.com/user-attachments/assets/89527547-25e3-432f-b561-2514856b6aec)
2024-10-18 13:11:46 +00:00
Harminder VirkandGitHub aa6a28ac56 feature: use application logger to log HTTP requests (#9655) 2024-10-18 15:08:55 +05:30
Harminder VirkandGitHub 68560787e5 breaking: rename package names to be consistent and under @medusajs scope (#9580) 2024-10-16 22:28:09 +05:30
Harminder VirkandGitHub 20428dac71 fix: resolve provider path before requiring it (#9601) 2024-10-16 14:17:55 +05:30
Harminder VirkandGitHub f8e8b276bd fix: remove default value for the cluster flag (#9570)
Defining the default value applies the flag automatically and hence activates the cluster mode.
2024-10-14 16:54:13 +00:00
ad322f2760 breaking: remove deprecated commands and code (#9521)
* breaking: remove deprecated commands

* feat: remove deprecated code and usages

* refactor: remove more logic around default relations

* fix tests

* remove log

* fix: remove defaultFields usage

* fix: add back accidentally removed code

* refactor: implement feedback

* feat: add --cluster flag to the start command

* refactor: assign limit to defaultLimit property

* fix: breaking code because of removed check

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
2024-10-14 20:11:34 +05:30
Harminder VirkandGitHub 93b38bf47b fix: do not pass additional_data to service (#9532)
Fixes: FRMW-2743

This PR extracts and removes the `additional_data` from the workflow input before calling the steps and hence the `additional_data` is not passed down to the service layer.

However, this bug has made me discover one inconsistency in the input structure of certain workflows.

 **Following is the input structure of the `updateProductsWorkflow`**. Here, we accept the `products` and the `additional_data` as two separate top-level properties.

```ts
// Shape
export type UpdateProductsWorkflowInputSelector = {
  selector: ProductTypes.FilterableProductProps
  update: Omit<ProductTypes.UpdateProductDTO, "variants"> & {
    sales_channels?: { id: string }[]
    variants?: UpdateProductVariantWorkflowInputDTO[]
  }
} & AdditionalData

// Calling the workflow
const { result } = await updateProductsWorkflow(req.scope).run({
  input: {
    selector: { id: req.params.id },
    update,
    additional_data,
  },
})
```

 **Following in the input structure of the `updateCartWorflow`**. In this case, we are accepting the cart properties at the top-level, hence the `additional_data` is merged within those properties, increasing the chance of passing it down to the service layer by mistake.

```ts
// Shape
WorkflowData<UpdateCartWorkflowInputDTO & AdditionalData>

// Calling the workflow
await workflow.run({
  input: {
    ...req.validatedBody // Additional data is part of the validatedBody,
    id: req.params.id,
  },
})
```

Ideally, the input of `updateCartWorkflow` should look as follows.

```ts
WorkflowData<{ cart: UpdateCartWorkflowInputDTO } & AdditionalData>
```
2024-10-11 23:43:13 +00:00
Harminder VirkandGitHub 8d3e7b3336 fix: provide outDir to typescript compiler (#9518) 2024-10-09 17:43:24 +00:00
1560d7ed5f breaking: Standalone builds (#9496)
Fixes: FRMW-2742

In this PR, we fix the build output of the backend source code, which eliminates a lot of magic between the development and production environments.

Right now, we only compile the source files from the `src` directory and write them within the `dist` directory.

**Here's how the `src` directory with a custom module looks like**

```
src
├── modules
│   └── hello
│       ├── index.ts
```

**Here's the build output**

```
dist
├── modules
│   └── hello
│       ├── index.js
```

Let's imagine a file at the root of your project (maybe the `medusa-config.js` file) that wants to import the `modules/hello/index` file. How can we ensure that the import will work in both the development and production environments?

If we write the import targeting the `src` directory, it will break in production because it should target the `dist` directory.

## Solution
The solution is to compile everything within the project and mimic the file structure in the build output, not just the `src` directory.

**Here's how the fixed output should look like**

```
dist
├── src
│  ├── modules
│  │   └── hello
│  │       ├── index.js
├── medusa-config.js
├── yarn.lock
├── package.json
```

If you notice carefully, we also have `medusa-config.js`, `yarn.lock`, and `package.json` within the `dist` directory. We do so to create a standalone built application, something you can copy/paste to your server and run without relying on the original source code.

- This results in small containers since you are not copying unnecessary files.
- Clear distinction between the development and the production code. If you want to run the production server, then `cd` into the `dist` directory and run it from there.

## Changes in the PR

- Breaking: Remove the `dist` and `build` folders. Instead, write them production artefacts within the `.medusa` directory as `.medusa/admin` and `.medusa/server`.
- Breaking: Change the output of the `.medusa/server` folder to mimic the root project structure.
- Refactor: Remove `Symbol.for("ts-node.register.instance")]` check to find from where to load the source code.
- Refactor: Use `tsc` for creating the production build. This ensures we respect `tsconfig` settings when creating the build and also perform type-checking.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-09 15:59:08 +00:00
Harminder VirkandGitHub 2d8ce6fd5b refactor: convert modules enum to a const (#9486) 2024-10-07 14:42:59 +05:30
Harminder VirkandGitHub d98f22c7d6 Feat: Move container bindings declaration merging within the framework (#9467) 2024-10-04 15:47:06 +05:30
Harminder VirkandGitHub 1e046f2b81 feat: allow using typescript path aliases when using ts-node (#9443) 2024-10-03 16:56:36 +05:30