Commit Graph

296 Commits

Author SHA1 Message Date
Harminder Virk
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
Kasper Fabricius Kristensen
d71343d6ab feat(dashboard,admin-vite-plugin,admin-bundler,admin-sdk): Rework admin extensions and introduce custom fields API (#9338) 2024-10-09 11:44:40 +00:00
Harminder Virk
48e00169d2 breaking: move shared HTTP utils to the framework (#9402)
Fixes: FRMW-2728, FRMW-2729

After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path.

- applyParamsAsFilters
- clearFiltersByKey
- applyDefaultFilters
- setContext
- getQueryConfig
- httpCompression
- maybeApplyLinkFilter
- refetchEntities
- unlessPath
- validateBody
- validateQuery

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-03 09:42:00 +00:00
Adrien de Peretti
a8e19faf8d chore: use framework sub paths everywhere (#9253) 2024-09-26 16:38:38 +05:30
Adrien de Peretti
358435d715 chore: Move graphl to a single place (#9303)
* chore: Move graphl to a single place

* add new line
2024-09-25 12:04:25 +02:00
Harminder Virk
653a4bff71 feat: add tracing to workflow steps (#9140) 2024-09-17 11:35:38 +05:30
Adrien de Peretti
2c5e72d141 feat: Application types generation from project GQL schema's (#8995) 2024-09-06 15:15:32 +05:30
Kasper Fabricius Kristensen
0fe1201435 feat(admin-sdk,admin-bundler,admin-shared,medusa): Restructure admin packages (#8988)
**What**
- Renames /admin-next -> /admin
- Renames @medusajs/admin-sdk -> @medusajs/admin-bundler
- Creates a new package called @medusajs/admin-sdk that will hold all tooling relevant to creating admin extensions. This is currently `defineRouteConfig` and `defineWidgetConfig`, but will eventually also export methods for adding custom fields, register translation, etc. 
  - cc: @shahednasser we should update the examples in the docs so these functions are imported from `@medusajs/admin-sdk`. People will also need to install the package in their project, as it's no longer a transient dependency.
  - cc: @olivermrbl we might want to publish a changelog when this is merged, as it is a breaking change, and will require people to import the `defineXConfig` from the new package instead of `@medusajs/admin-shared`.
- Updates CODEOWNERS so /admin packages does not require a review from the UI team.
2024-09-04 19:00:25 +00:00
Adrien de Peretti
5294ce8654 chore(medusa): Re enable plugin loading (#8843)
* chore(medusa): Re enable plugin loading

* finalise
2024-08-28 15:38:51 +02:00
Adrien de Peretti
e44332ba62 chore(framework): Allow multiple source dir for subcribers loader (#8407)
* chore(framework): Allow multiple source dir for subcribers loader

* re add  log

* add logs
2024-08-02 13:55:48 +02:00
Adrien de Peretti
9950a7efe2 chore(framework): medusa app loaders (#8393)
RESOLVE FRMW-2636

**What**
cleanup and move medusa app loader for now
2024-08-02 10:38:36 +00:00
Adrien de Peretti
f81652bf6e chore(framework): Move and improve routes loader (#8392)
* chore(framework): Move and improve routes loader

* cleanup

* fix(framework): import
2024-08-01 16:18:42 +02:00
Adrien de Peretti
56602d215b chore(framework): Move and improve workflows loader (#8363)
**What**
Refactoring Workflows loader and move

FIXES FRMW-2627
2024-07-31 14:46:04 +00:00
Adrien de Peretti
12c6a1a022 chore(framework): Move and improve links loader (#8367)
**What**
Refactor and move links loader

FIXES FRMW-2637
2024-07-31 12:33:12 +00:00
Adrien de Peretti
6ccf83128c Chore/framework 6/n (#8356)
**What**
Refactor and improve job loader as well as move it to the framework

FIXES FRMW-2626
2024-07-31 09:17:17 +00:00
Adrien de Peretti
a9fea986b0 chore(framework): Move and improve subscriber loader (#8347)
**What**
Move `SubscriberLoader` and improve implementation

FIXES FRMW-2635
2024-07-30 12:54:31 +00:00
Adrien de Peretti
9b6de8c02d chore(framework): Move feature flags related resources and cleanup (#8297)
**What**
cleanup and move the feature flag related resources to manage them.

It also include some refactoring around loading and registering the flag as well as not relying on the `glob` package anymore plus some reorganization of the code itself

FIXES FRMW-2625
2024-07-30 12:20:03 +00:00
Adrien de Peretti
bcd9d9c2b1 chore(framework): Continue to move loaders to framework (#8258)
**What**
More move and cleanup

FIXES FRMW-2603
FIXES FRMW-2608
FIXES FRMW-2610
FIXES FRMW-2611

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-07-30 08:52:12 +00:00
Harminder Virk
7f4b085964 refactor: revert to using middlewares.ts file (#8280) 2024-07-25 17:16:38 +05:30
Harminder Virk
0bd46c97b7 breaking: remove loading middlewares file in favor of routes-config files (#8274) 2024-07-25 12:53:35 +05:30
Harminder Virk
a356d12ac4 feat: add extend router helper (#8263) 2024-07-24 16:53:04 +05:30
Adrien de Peretti
75ec53e45a chore(framework): update deps (#8261)
* chore(medusa): update framework deps

* update lock

* update deps

* fix
2024-07-24 11:38:50 +02:00
Adrien de Peretti
47dde05517 chore(framework): Initial commit (#8221)
**What**
- Initiate the framework package (which is just a place to move things around for now)
- move the config loader and related resources as well as the `ConfigModule` type
- Create a ConfigManager singleton which prepare and store the config (later can be stored entirely in the container) and allow for easier test override
- re export the logger from the framework
- replace medusa config loader with the framework one
- `build` run type check on tests as well but `prepublishOnly` will not fail on build if tests are typed broken

FIXES FRMW-2607
FIXES FRMW-2609
FIXES FRMW-2614
FIXES FRMW-2618
2024-07-23 15:46:28 +00:00
Adrien de Peretti
f74fdcb644 breaking: rework how links database migrations are managed (#8162) 2024-07-22 13:12:23 +05:30
Adrien de Peretti
ecc97076b5 chore: default isQueryable module (#8192)
* chore: default isQueryable module

* fix defaults

* fix
2024-07-19 16:14:42 +02:00
Stevche Radevski
2ba400f6f1 fix: Log error if a scheduled job handler throws (#8164)
CLOSES TRI-19
2024-07-17 10:45:41 +00:00
Stevche Radevski
26d600b6db feat: Ensure async workflow executions have access to shared container (#8157)
* feat: Ensure async workflow executions have access to shared container

* fix: Register workflow worker on application start
2024-07-17 12:17:48 +02:00
Harminder Virk
f579f0b3be feat: restructure events payload (#8143)
* refactor: restructure events payload

Breaking change: This PR changes the event payload accepted by the event
listeners

* refactor: fix failing tests and implement feedback

* add integration tests

* fix timeout

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
2024-07-16 17:09:16 +01:00
Adrien de Peretti
104b00d4e9 feat(migrations): CLI generate command (#8103) 2024-07-12 13:12:49 +02:00
Harminder Virk
45c573b03a Feat: Improvements to the migrations CLI and workflow (#8060) 2024-07-11 16:52:34 +05:30
Adrien de Peretti
e778870c68 chore: Ensure the events are emitted with the same shape all accross (#8063)
* chore: Ensure the events are emitted with the same shape all accross

* fixes:

* rm unsues type

* types

* fix tests
2024-07-10 19:34:28 +02:00
Stevche Radevski
366231f658 feat: Add static server and adjust file local to work out of the box (#8019)
REF CORE-2496
Closes #8000
2024-07-08 17:44:36 +00:00
Adrien de Peretti
fc7f5ff71a fix: Modules providers loading mechanism to infer the source dir (#8015)
* fix: Modules providers loading mechanism to infer the source dir

* finalize
2024-07-08 14:11:45 +02:00
Adrien de Peretti
f49139b20f fix: custom link resolution in medusa app (#7950)
* fix custom link resolution in medusa app

* improve

* fix duplicate
2024-07-04 16:50:53 +02:00
Adrien de Peretti
7b84d854f0 Feat/mikro orm based linkable (#7944)
**What**
- Generate simple linkable for mikro orm based modules 
- fix module util
- fix joiner config builder
- fix define link relationship extension
- fix migrations not loading custom links
2024-07-04 13:30:47 +00:00
Carlos R. L. Rodrigues
a7844efd09 chore: move ModuleRegistrationName to utils (#7911) 2024-07-03 06:30:56 -03:00
Stevche Radevski
e3a0df3ba0 fix: Prefix the job workflow names with job (#7908) 2024-07-02 13:13:00 +00:00
Oli Juhl
305e1d66ca fix(medusa): Load subscribers and scheduled jobs in worker mode (#7769) 2024-06-18 19:15:55 +02:00
Riqwan Thamir
3d33f06e77 chore: upgrade jest everywhere (#7703) 2024-06-14 07:35:30 +02:00
Stevche Radevski
bef5941714 feat: Add support for scheduled jobs (#7674) 2024-06-11 11:35:56 +00:00
Oli Juhl
3f661c917b feat: Fix subscribers loading + add order <> cart link (#7617) 2024-06-09 12:31:28 +02:00
Carlos R. L. Rodrigues
122186a78d chore(order): cancel order (#7586) 2024-06-03 12:31:33 -03:00
Harminder Virk
11528526fa feat: loosely typed container 2024-05-31 15:22:03 +05:30
Stevche Radevski
aeda24265d feat: Remove returning token from customer and user endpoints (#7523)
* chore: Move generateJwtToken to utils

* feat: Stop returning token on user and customer endpoints
2024-05-29 17:13:01 +02:00
Harminder Virk
82be054a1a chore: Rename config properties to camelCase (#7498)
* refactor: rename config types to camelCase

* refactor: update config references to use renamed options

* refactor: update more references

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-05-28 14:49:29 +02:00
Harminder Virk
ef6d748784 feat: add Filesystem util and load env util (#7487) 2024-05-28 15:31:13 +05:30
Stevche Radevski
10ef32c5a3 feat: Apply authentication middleware globally (#7396)
* feat: Apply auth middleware globally

* feat: Remove local auth middleware where it makes sense
2024-05-27 15:24:53 +02:00
Adrien de Peretti
b8bc3ed16f chore: Start cleaning up medusa-core-utils (#7450)
**What**
- remove medusa-core-utils
- dispatch the utils where they belongs
- update usage

**NOTE**
I have been wondering if the graceful class should go into the utils package or medusa package, I ve put it in the medusa package as it seems to be the best place I can see for now and is tight to the server as well. Also, I wanted to avoid the utils package to depends on http and net dependencies, happy to change that if you feel like it
2024-05-27 08:00:15 +00:00
Adrien de Peretti
d354b253d5 chore: Fixes somes command and migrate to ts (#7444)
**What**
Fix some commands that are using the loaders return unproperly and cleanup, also includes a migration to ts
2024-05-24 14:17:58 +00:00
Adrien de Peretti
16651f9849 chore(medusa): Loader shutdown fixes (#7443)
**What**
prepare shutdown was called after modules shutdown
2024-05-24 12:38:37 +00:00