Commit Graph

127 Commits

Author SHA1 Message Date
Oli Juhl
0eb68541b8 fix: Resume workflow execution (#7103)
Supercedes #7051 – if OK, I'll move the base of this PR to `develop` and we can run reviews only of this one.

**What**
- Gracefully close BullMQ Worker in Redis Event Bus and Redis Workflow Engine (by @edast, @sradevski)
- Register workflows before MedusaApp is loaded*
- Introduce `onApplicationPrepareShutdown`**
- Refactor plugin resolving for reusability purposes

*We now register workflows before modules are loaded to ensure modules can run workflows as part of bootstrapping. E.g. the Redis Workflow Engine resumes workflows when it starts, which has until this change failed, because the workflows were not registered yet.

**We introduce a new hook to prepare resources for an application shutdown. E.g. closing the BullMQ worker as a preparatory step to closing the BullMQ queue. The worker will continue to process jobs while the queue is still open to receive new jobs (without processing them). 

Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com>
Co-authored-by: Darius <618221+edast@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2024-04-22 12:32:50 +00:00
Carlos R. L. Rodrigues
dd35a4dbff fix(modules-sdk): Remote Query "order" as config options (#6925) 2024-04-08 08:17:53 +02:00
Adrien de Peretti
667c8609cc fix(modules-sdk): Fix remote query selection (#6989)
Fix remote query selection for different relations levels as part of a single processed query
2024-04-07 14:07:31 +00:00
Adrien de Peretti
528ef4ca90 fix(modules-sdk): Select all should send undefined instead of an empty array (#6982) 2024-04-06 21:37:22 +02:00
Carlos R. L. Rodrigues
df0751f122 Feat: draft order api (#6797) 2024-04-06 16:35:10 +02:00
Stevche Radevski
9ccd88d025 feat: Add boilerplate for the file module (#6956) 2024-04-05 14:46:02 +02:00
Adrien de Peretti
e944a627f0 feat: region payment providers management workflows/api (#6864) 2024-04-04 20:41:34 +02:00
Adrien de Peretti
82a176e30e chore(medusa-test-utils):Handle errors gracefully (#6901)
**What**
- Better error handling and error message
- update deps management and dynamic import/require
- Pass a new flag to the modules loaders for the module loaders to be able to act depending on it. In that case, the module can determine what should be run or not. e.g in the workflow engine redis, when we are only partially loading the module, we do not want to set the Distributed transaction storage
2024-04-02 14:10:17 +00:00
Sebastian Rindom
2e914a5fc5 fix: ensure that shutdown works in loaderOnly mode (#6893) 2024-04-01 13:56:42 +00:00
Oli Juhl
1bcb13f892 feat: Remove sales channels from pub keys (#6876)
**What**
- Add workflow + step for detaching sales channels from pub API keys
- Tweak linking error message to be more helpful
- Add `removeRemoteLink` step to delete API key workflow
2024-03-29 15:01:10 +00:00
Adrien de Peretti
8fd1488938 chore: medusa shutdown (#6865)
* chore: medusa shutdown

* continue

* use shutdown

* on application shutdown

* consume shutdown

* more connection close

* more cleanup

* more cleanup

* update lock

* revert package

* graceful shutdown

* Create yellow-apples-attack.md

* graceful shutdown

* graceful shutdown

---------

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
2024-03-29 09:22:29 -03:00
Carlos R. L. Rodrigues
1c6ba4468e feat(modules-sdk): remote query retrieve (#6849)
What:

Remote Joiner options to check if keys exist on entry points or relations
2024-03-29 09:26:24 +00:00
Adrien de Peretti
d4d1f9b2f2 fix: integration tests modules expectations (#6848)
**What**
- fix tests
- cleanup deprecated jest conf
2024-03-27 15:39:20 +00:00
github-actions[bot]
74e17ee6f9 chore: Version Packages (#6757)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-26 18:04:04 +01:00
Sebastian Rindom
56481e683d feat: v2 - add worker mode (#6739)
**What**
- Adds support for starting a Medusa process with a worker mode.
- The worker modes supported are "shared", "worker", "server"
- In "worker" mode, API routes are not registered and modules that need to run workers (e.g., event bus redis) can use the flag to conditionally start workers.
- In "server" mode, API routes are registered and workers are not started.
- In "shared" mode, API routes are registered and workers are started. This is great for development.
2024-03-21 13:08:20 +00:00
Adrien de Peretti
06f22bb48a fis(orchestration): Properly handle select all (#6742)
**What**
Fix select `*` without breaking select none `[]`
2024-03-20 12:09:54 +00:00
github-actions[bot]
26c9bada0a chore: Version Packages (#6360)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-20 10:21:30 +01:00
Adrien de Peretti
e77a02aca5 feat(): Update transformer middleware and API (#6647)
**What**
Update all transform middleware to support the new API
- deprecate `defaultRelations`
- deprecate `allowedRelations`
- Add `defaults` and `allowed` in replacement for `defaultFields` and `allowedFields` respectively
- in the `defaults` it is possible to specify a field such as `*variants` in order to be recognized as a relation only without specifying any property
- add support for `remoteQueryConfig` assigned to req like we have for `listConfig` and `retrieveConfig`
- add support to override `allowed|allowedFields` if a previous middleware have set it up on the req.allowed
- The api now accepts `fields` as the only accepted fields to manage the requested props and relations, the `expand` property have been deprecated. New supported symbols have been added in complement of the fields
  - `+` (e.g `/store/products?fields=+description`) to specify that description should be added as part of the returned data among the other defined fields
  - `-` (e.g `/store/products?fields=-description`) to specify that description should be removed as part of the returned data
  - `*` (e.g `/store/products?fields=*variants`) to specify that the variants relations should be added as part of the returned data among the other defined fields without having to specify which property of the variants should be returned. In the `defaults` config of the transform middleware it is also possible to use this symbol
  - In the case no symbol is provided, it will replace the default fields and mean that only the specified fields must be returned

About the allowed validation, all fields in the `defaults` configuration must be present in the `allowed` configuration. 
In case the `defaults` contains full relation selection (e.g `*product.variants`) it should be present in the `allowed` as `product.variants`. In case in the `defaults` you add `product.variants.id`, it will be allowed if the `allowed` configuration includes either `product.variants.id` as full match or `product.variants` as it means that we allow all properties from `product.variants`

Also, support for `*` selection on the remote query/joiner have been added


**Note**
All v2 end points refactoring can be done separately
2024-03-18 08:37:59 +00:00
Sebastian Rindom
3dd55efd15 Fix/load medusa proj (#6639)
**What**
- Runs loadMedusaV2 when v2 flag is enabled.
- V2 loader loads only project-level framework features. E.g., project APIs, subscribers, jobs, and workflows.
- No plugin support yet.
2024-03-14 12:38:57 +00:00
Carlos R. L. Rodrigues
4625bd1241 feat(orchestration,modules-sdk): options autoCreateServiceNameAlias (#6622)
What:
 Remote joiner options to register service name declared on joiner configs as alias. Default is true, Remote Query in modules-sdk sets it false.
2024-03-07 21:01:30 +00:00
Stevche Radevski
12b035cb18 chore(tests): Try to use the api integration tests for v2 (#6588)
Few things to keep in mind:
1. You need to set MEDUSA_FF_MEDUSA_V2 to true before running the tests to run with the v2 API
2. You can use the `breaking` function to differentiate between v1 and v2 differences. This can help us identify what was breaking pretty quickly afterwards
3. You will need to run specific tests for now instead of all if you want to target v2. I think that's fine though, as we don't really need these to run on every PR until we have feature parity (and by then, all tests would be both v1 and v2 compatible)


**note: Adrien** 
- add a new way to load modules only to run their loaders comparable to the way to run the migrations only
- improve tests runner to cleanup the data properly as well as re running all loaders and core defaults

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-03-07 08:05:43 +00:00
Adrien de Peretti
51bb6f1e89 Chore/integration tests modules utils (#6581)
new wrapper for medusa integration tests.
for now it is only applied to the modules directory, but it could be used in the api integration tests or any other integrations that requires a db and a server up and running. 

It is not perfect, but I wanted to have something working and centralised before improving it, also avoiding too many conflicts with other prs
2024-03-06 10:03:07 +00:00
Riqwan Thamir
d550be3685 feat(core-flows,link-modules,modules-sdk): add cart <> promotion link as source of truth (#6561)
what:

- adds promotion cart link
- update steps to create and remove links
2024-03-04 09:50:49 +00:00
Stevche Radevski
dc025302a1 feat: Add currency module and remove currency models from region and pricing modules (#6536)
What:
- Creates a new currency module
- Removes currency model from the pricing module
- Removes currency model from region module
2024-02-29 15:09:59 +00:00
Stevche Radevski
63be07031b feat: Add skeleton for Store module (#6506) 2024-02-26 12:00:48 +00:00
Philip Korsholm
3fc2aea752 feat(modules-sdk, types, user, utils):init user module events (#6431)
* init user module events

* refactor utils

* undo test script update

* fix feedback

* add eventbus service to module test-runner

* add injected dependencies

* move events to utils

* use const eventname in tests

* rm withTransaction
2024-02-23 09:31:02 +08:00
Stevche Radevski
269be1b64a feat: Add skeleton for api key module (#6451)
Adds a module skeleton for the API Key module.
Implementation of functionalities will follow in separate PRs
2024-02-20 12:28:57 +00:00
Oli Juhl
24fb102a56 feat: CartRegion link, definition + workflow (#6392) 2024-02-16 14:06:26 +00:00
Sebastian Rindom
7df4947ecf feat(tax): tax module scaffolding (#6417)
**What**
- Scaffolds the tax module
2024-02-16 13:24:23 +00:00
Carlos R. L. Rodrigues
586df9da25 fix: Loading custom modules (#6411)
What:
   fix custom modules loading in medusa project
   pass medusa logger reference to MedusaApp
2024-02-15 15:06:02 +00:00
Carlos R. L. Rodrigues
339a946f38 feat(order): module foundation (#6399)
What:
Initial Order module foundation.
Basic models and methods to manage entites like in Cart Module
2024-02-15 13:26:00 +00:00
Oli Juhl
95d0e58d31 feat(region): Add admin region get + list endpoints (#6322)
**What**
Add `GET /admin/regions`
Add `GET /admin/regions/:id`

Blocked by #6320 

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-02-11 17:13:49 +00:00
github-actions[bot]
16851c557d chore: Version Packages (#6241)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-02-08 16:23:19 +01:00
Adrien de Peretti
12054f5c01 feat: Fulfillment module basic structure (#6319)
**What**
Scafold the fulfillment module basic structure

**Bonus**
Simplified module scaffolding with new factories and less directories to manage
- mikro orm connection loader factory
- initialize factory

FIXES CORE-1709
FIXES CORE-1710
2024-02-06 13:29:36 +00:00
Philip Korsholm
b2eaac8cb1 feat(user): Init user module (#6293)
* init user module

* add migration

* update module with latest utils

* pr ready

* make interface types interfaces
2024-02-06 11:10:54 +08:00
Oli Juhl
823b98aaa1 feat: Region Module (basic CRUD) (#6315) 2024-02-05 16:03:26 +00:00
Carlos R. L. Rodrigues
884428a1b5 feat: event aggregator (#6218)
What:
- Event Aggregator Util
- Preparation for normalizing event in a new format (backward compatible with the current format)
- GQL Schema to joiner config and some Entities configured
- Link modules emmiting events
2024-02-05 11:59:10 +00:00
Carlos R. L. Rodrigues
96ba49329b fix: load custom modules by path (#6312)
What:
medusa-config.js loading custom modules by their path.

```typescript
{
  modules: {
    internalModule: {
      scope: MODULE_SCOPE.INTERNAL,
      resources: MODULE_RESOURCE_TYPE.SHARED,
      resolve: "./internal_module",
      definition: {
        key: "internalModule",
        registrationName: "internalModule",
      },
    },
  }
}
```
2024-02-04 14:26:34 +00:00
Oli Juhl
3a103f0c36 feat(modules-sdk): Module provider plugin loader (#6286) 2024-02-01 17:03:31 +01:00
Carlos R. L. Rodrigues
45134e4d11 chore: local workflow proxying methods to pass context (#6263)
What:
- When calling a module's method inside a Local Workflow the MedusaContext is passed as the last argument to the method if not provided
- Add `requestId` to req
- A couple of fixes on Remote Joiner and the data fetcher for internal services

Why:
- The context used to initialize the workflow has to be shared with all modules. properties like transactionId will be used to emit events and requestId to trace logs for example.
2024-02-01 13:37:26 +00:00
Philip Korsholm
512b041929 Feat(auth): Rename authentication to auth (#6229)
**What**
- rename `authenticationModule` -> `authModule`
2024-01-29 10:19:30 +00:00
Frane Polić
3db2f95e65 feat: sales channel module (#5923) 2024-01-29 09:47:28 +01:00
github-actions[bot]
3d0ae72887 chore: Version Packages (#6039)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-01-25 16:23:53 +01:00
Carlos R. L. Rodrigues
302323916b feat: Workflow engine modules (#6128) 2024-01-23 10:08:08 -03:00
Carlos R. L. Rodrigues
d85fee42ee chore: use loaded module reference (#5763) 2024-01-23 08:31:02 -03:00
Sebastian Rindom
12aa1737d5 feat: customer module skeleton (#6126) 2024-01-19 10:18:54 +00:00
Philip Korsholm
2b9f98895e Feat(modules-sdk): Run hooks on application start (#6111)
**What**
- run `onApplicationStart` hook when starting modules
2024-01-17 10:46:44 +00:00
Frane Polić
8472460f53 feat: Payment module package setup (#6059) 2024-01-11 16:41:40 +01:00
github-actions[bot]
47272bf2b9 chore: Version Packages (#5880) 2024-01-09 18:41:35 +01:00
Oli Juhl
925feea04a feat(cart): Add cart module package (#5982)
* feat: Add CartModule foundation

* remove migration

* fix ts issue

* Create hot-dingos-pay.md
2024-01-02 15:59:23 +01:00