Commit Graph

46 Commits

Author SHA1 Message Date
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
196e821ff2 feat: Modify api key and sales channel link to use modules and add test (#6546) 2024-03-01 09:24:50 +00:00
Oli Juhl
cdb01e073b feat(link-modules): Cart, Payment Collection link definition (#6508)
* Add cart payment collection joiner confg

* fix migration

* chore: Exclude inventory tests

* remove jest ignore

* add back payment module
2024-02-29 19:33:16 +01:00
Oli Juhl
5db3ec09e2 feat: Cart Customer link + create cart with customer (#6426) 2024-02-19 08:28:44 +01:00
Oli Juhl
1ba35b02dd feat: Cart SalesChannel link + clean-up (#6418) 2024-02-16 20:48:56 +01:00
Oli Juhl
24fb102a56 feat: CartRegion link, definition + workflow (#6392) 2024-02-16 14:06:26 +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
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
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
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
Oli Juhl
d5e4707084 feat(medusa): Use remote query in get cart API route (#6285) 2024-01-31 19:20:48 +01: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
Adrien de Peretti
b6ac768698 chore: abstract the modules repository (#6035)
**What**
Reduce the work effort to create repositories when building new modules by abstracting the most common cases into the base class default implementation returned by a factory

- [x] Migrate all modules

Co-authored-by: Riqwan Thamir <5105988+riqwan@users.noreply.github.com>
2024-01-10 13:12:02 +00:00
github-actions[bot]
47272bf2b9 chore: Version Packages (#5880) 2024-01-09 18:41:35 +01:00
Frane Polić
6fc6a9de6a feat(medusa, link-modules): sales channel <> pubkey link (#5820) 2024-01-05 14:51:57 +01:00
Frane Polić
fe007d01bd feat(medusa, link-modules): sales channel <> order link (#5810) 2024-01-03 14:07:54 +01:00
Philip Korsholm
d16d10619d Feat(medusa-test-utils, utils, pricing, product, link-modules): upgrade mikro orm version to latest (#5985)
* update mikro-orm version

* add changeset

* update product tests

* add optional number serializer util

* upgrade cart mikro-orm versions

* clean up test
2024-01-02 17:11:55 +01:00
Frane Polić
76332ca6c1 feat(medusa, link-modules): sales channel <> cart link (#5459)
* feat: sales channel joiner config

* feat: product sales channel link config, SC list method

* feat: migration

* fix: refactor list SC

* refactor: SC repo api

* chore: changeset

* feat: add dedicated FF

* wip: cart<>sc link and migration

* chore: changeset

* fix: update migration with the cart table constraints

* feat: populate the pivot table

* chore: remove relation from joiner config

* fix: constraint name

* fix: filter out link relations when calling internal services

* feat: product<> sc join entity

* fix: update case

* fix: add FF on in the repository, fix tests

* fix: assign id when FF is on

* fix: target table

* feat: product service - fetch SC with RQ

* feat: admin list products & SC with isolated product domain

* feat: get admin product

* feat: store endpoints

* fix: remove duplicate import

* fix: remove "name" prop

* feat: typeorm entity changes

* feat: pivot table, entity, on cart create changes

* feat: update carts' SC

* feat: cart - getValidatedSalesChannel with RQ

* feat: refactor

* wip: changes to create cart workflow

* fix: remove join table entity due to migrations failing

* fix: product seeder if FF is on

* feat: attach SC handler and test

* fix: env

* feat: workflow compensation, cart service retrieve with RQ

* fix: remote joiner implode map

* chore: update changesets

* fix: remove methods from SC service/repo

* feat: use remote link in handlers

* fix: remove SC service calls

* fix: link params

* fix: migration add constraint to make link upsert pass

* refactor: workflow product handlers to handle remote links

* fix: condition

* fix: use correct method

* fix: build

* wip: update FF

* fix: update FF in the handlers

* chore: migrate to medusav2 FF

* chore: uncomment test

* fix: product factory

* fix: unlinking SC and product

* fix: use module name variable

* refactor: cleanup query definitions

* fix: add constraint

* wip: migrate FF

* fix: comments

* feat: cart entity callbacks, fix tests

* fix: only create SC in test

* wip: services updates, changes to models

* chore: rename prop

* fix: add hook

* fix: address comments

* fix: temp sc filtering

* fix: use RQ to filter by SC

* fix: relations on retrieve

* feat: migration sync data, remove FF

* fix: revert order of queries

* fix: alter migration, relations in service

* fix: revert id

* fix: migrations

* fix: make expand work

* fix: remote link method call

* fix: try making tests work without id in the pivot table

* test: use remote link

* test: relations changes

* fix: preserve channel id column

* fix: seeder and factory

* fix: remove sales_channels from response

* feat: support feature flag arrays

* fix: cover everything with correct FF

* fix: remove verbose

* fix: unit and plugin tests

* chore: comments

* fix: reenable workflow handler, add comments, split cart create workflow tests

* chore: reenable link in the create mehod, update changesets

* fix: address feedback

* fix: revert migration

* fix: change the migration to follow link module

* fix: migration syntax

* fix: merge conflicts

* fix: typo

* feat: remove store sales channel foreign key

* fix: merge migrations

* fix: FF keys

* refactor: cart service

* refactor: FF missing key

* fix: comments

* fix: address PR comments

* fix: new changesets

* fix: revert flag router changes

* chore: refactor `isFeatureEnabled`

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
2023-12-22 13:05:36 +01:00
Frane Polić
1d7888afca feat(medusa, link-modules): sales channel <> product module link (#5450)
* feat: sales channel joiner config

* feat: product sales channel link config, SC list method

* feat: migration

* fix: refactor list SC

* refactor: SC repo api

* chore: changeset

* feat: add dedicated FF

* feat: product<> sc join entity

* fix: update case

* fix: add FF on in the repository, fix tests

* fix: assign id when FF is on

* fix: target table

* feat: product service - fetch SC with RQ

* feat: admin list products & SC with isolated product domain

* feat: get admin product

* feat: store endpoints

* fix: remove duplicate import

* fix: remove "name" prop

* feat: refactor

* fix: product seeder if FF is on

* fix: env

* refactor: workflow product handlers to handle remote links

* fix: condition

* fix: use correct method

* fix: build

* wip: update FF

* fix: update FF in the handlers

* chore: migrate to medusav2 FF

* chore: uncomment test

* fix: product factory

* fix: unlinking SC and product

* fix: use module name variable

* refactor: cleanup query definitions

* fix: add constraint

* chore: rename prop

* fix: add hook

* fix: address comments

* fix: temp sc filtering

* fix: use RQ to filter by SC

* fix: add sc to filter to list

---------

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
2023-12-15 13:43:00 +01:00
github-actions[bot]
7f5e638f61 chore: Version Packages (#5754)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-14 15:27:39 +01:00
Adrien de Peretti
946db51a9b chore(): Add engines to all package.json if needed (#5812) 2023-12-07 17:03:50 +01:00
Adrien de Peretti
8f25ed8a10 feat(link-modules, pricing, product, utils): Custom database config in shared mode (#5755)
* feat(link-modules, pricing, product, utils): Should be able to set some custom database config even in shared mode

* Create wet-hounds-retire.md
2023-11-29 08:19:28 +00:00
github-actions[bot]
935e9f0561 chore: Version Packages (#5673)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-27 16:43:51 +00:00
Philip Korsholm
de8f748674 fix(link-modules, utils): remove limits on queries when primary-key is provided (#5732) 2023-11-27 15:42:25 +00:00
Carlos R. L. Rodrigues
9f9db39698 feat(workflows): Workflow DX (#5607) 2023-11-22 17:23:39 +00:00
github-actions[bot]
71d59d2c81 chore: Version Packages (#5527)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-10 10:28:21 +01:00
Adrien de Peretti
154c9b43bd feat(medusa, modules-sdk, types, utils): Re work modules loading and remove legacy functions (#5496) 2023-11-02 17:59:13 +01:00
github-actions[bot]
309c82e175 chore: Version Packages (#5454)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-01 08:19:58 +01:00
Philip Korsholm
148f537b47 feat(medusa): integrate pricing module to core (#5304)
* add pricing integraiton feature flag

* init

* first endpoint

* cleanup

* remove console.logs

* refactor to util and implement across endpoints

* add changeset

* rename variables

* remove mistype

* feat(medusa): move price module integration to pricing service (#5322)

* initial changes

* chore: make product service always internal for pricing module

* add notes

---------

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* nit

* cleanup

* update to object querying

* update cart integration test

* remove uppercase currency_code

* nit

* Feat/admin product pricing module reads (#5354)

* initial changes to list prices for admin

* working price module implementation of list prices

* nit

* variant pricing

* redo integration test changes

* cleanup

* cleanup

* fix unit tests

* [wip] Core <> Pricing - price updates  (#5364)

* chore: update medusa-app

* wip

* get links and modules working with migration

* wip

* chore: make test pass

* Feat/rule type utils (#5371)

* initial rule type utils

* update migration script

* chore: cleanup

* ensure prices are always decorated

* chore: use seed instead

* chore: fix oas conflict

* region id add to admin price read!

---------

Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com>

* pr feedback

* create remoteQueryFunction type

* fix merge

* fix loaders issue

* Feat(medusa, types, pricing): pricing module migration script (#5409)

* add migration script for money amounts in pricing module

* add changeset

* rename file

* cleanup imports

* update changeset

* add check for pricing module and ff

* feat(medusa,workflows,types): update prices on product and variant update (#5412)

* wip

* chore: update product prices through workflow

* chore: cleanup

* chore: update product handler updates prices for variants

* chore: handle reverts

* chore: address pr comments

* chore: scope workflow handlers to flag handlers

* chore: update return

* chore: update db url

* chore: remove migration

* chore: increase jest timeout

* Feat(medusa): update migration and initDb to run link-migrations (#5437)

* initial

* loader update

* more progress on loaders

* update integration tests and remote-query loader

* remove helper

* migrate isolated modules

* fix test

* fix integration test

* update with pr feedback

* unregister medusa-app

* re-register medusaApp

* fix featureflag

* set timeout

* set timeout

* conditionally run link-module migrations

* pr feedback 1

* add driver options for db

* throw if link is not defined in migration script

* pass config module directly

* include container in migrate command

* chore: increase timeout

* rm redis from api integration tests to test

* chore: temporarily skip tests

* chore: undo skips + add timeout for workflow tests

* chore: increase timeout for order edits

* re-add redis

* include final resolution

* add sharedcontainer to medusaapp loader

* chore: move migration under run command

* try removing redis_url from api tests

* chore: cleanup server on process exit

* chore: clear container on exit

* chore: adjustments

* chore: remove consoles

* chore: close express app on finish

* chore: destroy pg connection on shutdown

* chore: skip

* chore: unskip test

* chore: cleanup container pg connection

* chore: skip

---------

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
2023-10-30 14:42:17 +01:00
Adrien de Peretti
a45da9215d fix(medusa, modules-sdk, modules): Module loading missing dependencies + remote query reference issue (#5468) 2023-10-26 20:24:38 +02:00
github-actions[bot]
c0d74bc682 chore: Version Packages (#5340)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-10-19 15:58:48 +02:00
Riqwan Thamir
b62af612c7 feat(link-modules,modules-sdk,pricing): Medusa App Migrations + Core compatible migrations (#5317)
* chore: remove skipping logic for migrations

* chore: medusa app returns migrations to run for modules

* chore: added migration for feature compatible

* chore: added changelog

* chore: create table only if it does not exist

* chore: update migration to pluck from registered modules

* chore: cleanup

* chore: make product an internal service temp

* chore: added options and deps to module

* chore: added link module options

* chore: remove duplicate

* chore: added missing column names in core + remove from model

* chore: scope migrations to only to create if not exist - money amount, currency

---------

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
2023-10-10 16:23:38 +02:00
github-actions[bot]
35d5fbe8cc chore: Version Packages (#5272)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-10-06 08:41:24 -07:00
Carlos R. L. Rodrigues
130cbc1f43 feat(*): Modules export entities and fields (#5242) 2023-10-03 14:20:43 -07:00
github-actions[bot]
223a4a4cd9 chore: Version Packages (#5002)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-15 17:09:34 +02:00
Riqwan Thamir
3d68be2b6b fix(orchestration,link-modules,pricing,types): fix shippingprofile errror outside of core + change link alias name (#5025)
* fix(orchestration,link-modules,pricing,types): fix shippingprofile error outside of core + change link alias name

* chore: scope relationships and move condition inside

* chore: remove islist

* chore: fix merge conflict

* chore: reverted serviceName scoping

* chore: change shape to make methodOverride compatible

* chore: added methodOverride to remote query

* chore: revert override
2023-09-13 12:16:00 +02:00
Adrien de Peretti
30863fee52 feat(medusa): List products with Remote Query (#4969)
**What**
- includes some type fixes in the DAL layer
- List products including their prices and filtered by the sales channel as well as q parameter and category scope and all other filters
- Assign shipping profile
- ordering
- Add missing columns in the product module
- update product module migrations

**Comment**
-  In regards to the fields, we can pass whatever we want the module will only return the one that exists (default behavior), but on the other hand, that is not possible for the relations.

**question**
- To simplify usage, should we expose the fields/relations available from the module to simplify building a query for the user and be aware of what the module provides

**todo**
- Add back the support for the user to ask for fields/relations
2023-09-12 15:55:05 +00:00
Riqwan Thamir
834da5c41a feat(pricing, types): PriceSets as entry point to pricing module (#4978)
What:
- Adds PriceSet, PriceSetMoneyAmount, updates schema
- Adds service/repo for PriceSet
- Shifts entry point to use PriceSet
- Updates link/joiner config

RESOLVES CORE-1495
2023-09-11 17:24:31 +00:00
Riqwan Thamir
d3ebb42cb8 fix(link-modules): fix link configuration for product shipping profile (#5014) 2023-09-11 14:36:45 +02:00
Adrien de Peretti
a87d07655b fix(link-modules): Fix link module initialization (#4990)
**What**
Add a new configuration on the relationship to specify if the relation is consumed from an internal service (from medusa core). In that case do not check if the service is part of the loaded modules
2023-09-11 08:49:23 +00:00
github-actions[bot]
98b91d1137 chore: Version Packages (#4891)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-08 14:09:39 +02:00
Carlos R. L. Rodrigues
a4906d0ac0 chore(medusa,orchestration,link-modules,modules-sdk): internal services as modules (#4925) 2023-09-04 11:36:05 -03:00
Riqwan Thamir
fcb6b4f510 feat(pricing, utils, types): adds money amount to pricing module (#4909)
What:

- Adds money amount service / repo / model
- Adds money amount to entry service
- Adds tests for services
- Refreshes schema
- Update joiner config to include money amounts


RESOLVES CORE-1478
RESOLVES CORE-1479

Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2023-08-31 13:03:10 +00:00
Riqwan Thamir
87bade096e fix(utils, product, pricing, link-modules): add missing dependencies for utils + fix migration path issue (#4915)
* fix: add missing dependencies for utils

* chore: migration path is set from the calling package

* chore: update changeset
2023-08-31 09:16:02 +02:00
Carlos R. L. Rodrigues
4d16acf5f0 feat(link-modules,modules-sdk, utils, types, products) - Remote Link and Link modules (#4695)
What:
- Definition of all Modules links
- `link-modules` package to manage the creation of all pre-defined link or custom ones

```typescript
import { initialize as iniInventory } from "@medusajs/inventory";
import { initialize as iniProduct } from "@medusajs/product";

import {
  initialize as iniLinks,
  runMigrations as migrateLinks
} from "@medusajs/link-modules";

await Promise.all([iniInventory(), iniProduct()]);


await migrateLinks(); // create tables based on previous loaded modules

await iniLinks(); // load link based on previous loaded modules

await iniLinks(undefined, [
  {
    serviceName: "product_custom_translation_service_link",
    isLink: true,
    databaseConfig: {
      tableName: "product_transalations",
    },
    alias: [
      {
        name: "translations",
      },
    ],
    primaryKeys: ["id", "product_id", "translation_id"],
    relationships: [
      {
        serviceName: Modules.PRODUCT,
        primaryKey: "id",
        foreignKey: "product_id",
        alias: "product",
      },
      {
        serviceName: "custom_translation_service",
        primaryKey: "id",
        foreignKey: "translation_id",
        alias: "transalation",
        deleteCascade: true,
      },
    ],
    extends: [
      {
        serviceName: Modules.PRODUCT,
        relationship: {
          serviceName: "product_custom_translation_service_link",
          primaryKey: "product_id",
          foreignKey: "id",
          alias: "translations",
          isList: true,
        },
      },
      {
        serviceName: "custom_translation_service",
        relationship: {
          serviceName: "product_custom_translation_service_link",
          primaryKey: "product_id",
          foreignKey: "id",
          alias: "product_link",
        },
      },
    ],
  },
]); // custom links
```

Remote Link

```typescript
import { RemoteLink, Modules } from "@medusajs/modules-sdk";

// [...] initialize modules and links

const remoteLink = new RemoteLink();

// upsert the relationship
await remoteLink.create({ // one (object) or many (array)
  [Modules.PRODUCT]: {
    variant_id: "var_abc",
  },
  [Modules.INVENTORY]: {
    inventory_item_id: "iitem_abc",
  },
  data: { // optional additional fields
    required_quantity: 5
  }
});

// dismiss (doesn't cascade)
await remoteLink.dismiss({ // one (object) or many (array)
  [Modules.PRODUCT]: {
    variant_id: "var_abc",
  },
  [Modules.INVENTORY]: {
    inventory_item_id: "iitem_abc",
  },
});

// delete
await remoteLink.delete({
  // every key is a module
  [Modules.PRODUCT]: {
    // every key is a linkable field
    variant_id: "var_abc", // single or multiple values
  },
});

// restore
await remoteLink.restore({
  // every key is a module
  [Modules.PRODUCT]: {
    // every key is a linkable field
    variant_id: "var_abc", // single or multiple values
  },
});

```

Co-authored-by: Riqwan Thamir <5105988+riqwan@users.noreply.github.com>
2023-08-30 14:31:32 +00:00