Commit Graph

64 Commits

Author SHA1 Message Date
Riqwan Thamir
281b0746cf feat(medusa,workflows) Create cart workflow (#4685)
* chore: add baseline test for create cart

* chore: add basic paths into handlers + make first tests pass

* chore: move input alias to cart specific workflow

* chore: move data around into buckets

* chore: normalize handlers and introduce types

* chore: move aliases to handlers concern

* chore: add compensation step for create cart

* chore: merge with latest develop

* chore: handle error manually + type inputs

* chore: handle error manually

* chore: added types for each handler

* chore: remove addresses

* chore: added changset

* chore: undo package changes

* chore: added config settings to retreieve, cleanup of types

* chore: capitalize cart handlers

* chore: rename todo

* chore: add feature flag for workflow

* chore: reorder handlers

* chore: add logger to route handler

* chore: removed weird vscode moving around things

* chore: refactor handlers

* chore: refactor compensate step

* chore: changed poistion

* chore: aggregate config data

* chore: moved handlers to their own domain + pr review addressing

* chore: address pr reviews

* chore: move types to type package

* chore: update type to include config

* chore: remove error scoping
2023-08-08 12:10:27 +02:00
Oli Juhl
5c60aad177 feat(medusa, utils): Allow object feature flags (#4701)
Feature flags can be set as follows:

**Environment variables**
```
MEDUSA_FF_ANALYTICS=true
MEDUSA_FF_WORKFLOWS=createProducts,addShippingMethods
```

**Project config**
```
{
  featureFlags: {
    analytics: true,
    workflows: {
      createProducts: true,
      addShippingMethods: true,
    }
  }
}
```
2023-08-07 09:38:25 +00:00
Adrien de Peretti
dc46927bc6 feat(medusa, types, utils, workflow): Migrate medusa workflow to the workflow package (#4682) 2023-08-05 16:03:45 +02:00
Adrien de Peretti
4b80ba8a35 fix(product, integration-tests): Fix integration tests (#4674)
* fix(product, integration-tests): Fix integration tests

* improve test

* Create dirty-eagles-shop.md
2023-08-02 13:44:53 +02:00
Carlos R. L. Rodrigues
f12299deb1 Feat: @medusajs/workflows (#4553)
feat: medusa workflows
2023-07-25 10:13:14 -03:00
Adrien de Peretti
d2a8cf0378 feat(medusa): Continue create product workflow changes (#4473) 2023-07-24 13:30:24 +02:00
Adrien de Peretti
4d326fbbdf chore: Move factories and helpers to a better place (#4551)
* chore: Move factories and helpers to a better place

* align factory product variant

* fix factory cart

* add simple store fac

* fix tests

* fix tests

* fix

* fix cart seeder
2023-07-20 13:16:04 +02:00
Philip Korsholm
d184d23c63 Feat/bulk operations for inventory service (#4503)
* initial push

* bulk delete reservations by location ids

* add method to interface (not implemented yet)

* bulk update

* delete reservations by location id bulk

* add create bulk for inventory item

* refactor attach inventory item method

* add changeset

* verbose false

* method override instead of multiple methods

* change up method signature

* redo changes when updating interface

* update createInventoryLevel method

* rename variables

* fix feedback

* return correct string array when emitting event

* refactor inventory service

* redo order changes

* snapshot

* move prep methods
2023-07-18 11:17:57 +02:00
Adrien de Peretti
befc2f1c80 feat(product): Create (+ workflow), delete, restore (#4459)
* Feat: create product with product module

* feat: create product wip

* feat: create product wip

* feat: update product relation and generate image migration

* lint

* conitnue implementation

* continue implementation and add integration tests for produceService.create

* Add integration tests for product creation at the module level for the complete flow

* only use persist since write operations are always wrapped in a transaction which will be committed and flushed

* simplify the transaction wrapper to make future changes easier

* feat: move some utils to the utils package to simplify its usage

* tests: fix unit tests

* feat: create variants along side the product

* Add more integration tests an update migrations

* chore: Update actions workflow to include packages integration tests

* small types and utils cleanup

* chore: Add support for database debug option

* chore: Add missing types in package.json from types and util, validate that all the models are sync with medusa

* expose retrieve method

* fix types issues

* fix unit tests and move integration tests workflow with the plugins integration tests

* chore: remove migration function export from the definition to prevent them to be ran by the medusa cli just in case

* fix package.json script

* chore: workflows

* feat: start creating the create product workflow

* feat: add empty step for prices and sales channel

* tests: update scripts and action envs

* fix imports

* feat: Add proper soft deleted support + add product deletion service public api

* chore: update migrations

* chore: update migrations

* chore: update todo

* feat: Add product deletion to the create-product workflow as compensation

* chore: cleanup product utils

* feat: Add support for cascade soft-remove

* feat: refactor repository to take into account withDeleted

* fix integration tests

* Add support for force delete -> delete, cleanup repositories and improvements

* Add support for restoring a product and add integration tests

* cleaup + tests

* types

* fix integration tests

* remove unnecessary comments

* move specific mikro orm usage to the DAL

* Cleanup workflow functions

* Make deleted_at optional at the property level and add url index for the images

* address feedback + cleanup

* fix export

* merge migrations into one

* feat(product, types): added missing product variant methods (#4475)

* chore: added missing product variant methods

* chore: address PR feedback

* chore: catch undefined case for retrieve + specs for variant service

* chore: align TEntity + add changeset

* chore: revert changeset, TEntity to ProductVariant

* chore: write tests for pagination, unskip the test

* Create chilled-mice-deliver.md

* update integration fixtuers

* update pipeline node version

* rename github action

* fix pipeline

* feat(medusa, types): added missing category tests and service methods (#4499)

* chore: added missing category tests and service methods

* chore: added type changes to module service

* chore: address pr feedback

* update repositories manager usage and serialisation from the write public API

* move serializisation to the DAL

* rename template args

* chore: added collection methods for module and collection service (#4505)

* chore: added collection methods for module and collection service

* Create fresh-islands-teach.md

* chore: move retrieve entity to utils package

* chore: make products optional in DTO type

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* feat(product): Apply transaction decorators to the services (#4512)

---------

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2023-07-16 20:19:23 +02:00
Adrien de Peretti
9dcdc0041a fix(medusa, utils): fix the way selects are consumed alongside the relations (#4389)
**What**
There is actually an issue with using the `fields` query params with the way the repositories are using our custom query strategy. This pr aims to fix this issue by reworking the strategy.

What we had to do was to rework the way the selects are built for each subquery in order to follow the aliasing convention and to be taken into consideration. Alongside these changes, the join used to always select everything, this needed to be changed so that if there are any selects provided for a join, the join should not select everything and let the query select the fields that are requested.

Another notable change is that all the repositories are now using the repository util in order to centralize the customization and to have a single place to update when this kind of issue arises. This means that the eager relations when using the query builder are not necessarily taken into account. For that reason, I have removed the `shipping_option` eager option in favor of explicitly asking for the relations like we started to do it in some places.

FIXES CORE-1413
2023-06-29 13:26:41 +00:00
Philip Korsholm
eadf13cb21 feat(medusa): variants expand inventory_items (#4203)
* add expand params for inventory items to product and variant endpoints in store

* add changeset

* update integration test naming

* make priceSeelctionParams extends findParams and adjust api accordingly
2023-06-05 20:14:05 +02:00
Philip Korsholm
0a35f21af7 feat(medusa, inventory): Search inventory items by title and description (#4154)
* initial filtering based on query

* add changeset

* add expect clause to ensure other items are not inluded
2023-05-24 11:52:25 +01:00
Philip Korsholm
3a38c84f88 feat(medusa,inventory,types): Expand list-reservation capabilities (#3979)
**What**
- Add filter capabilities to reservation items based on: 
  - description query: "contains", "startsWith", "endsWith", "equals"
  - date querying

**How**
- Introducing a new filtering primitive: "StringSearchOperator" resembling the "dateComparisonOperator"

Fixes CORE-1373
2023-05-24 09:54:25 +00:00
Philip Korsholm
4f3c8f5d70 feat(admin-ui,medusa): Reservations management (#4081)
* add location filtering to list-location levels

* cleanup

* add location filtering to list-location levels

* cleanup

* Initial work on route,table,new reservation form

* generated types

* add block

* udpate clients

* initial create reservation

* update actionables for reservation table

* update edit-allocation modal

* misc naming updates

* update reservations table

* add expand capabilities for list-reservations

* expand fields and show columns

* update oas

* make remove item work in focus modal

* add yarn lock

* add integration test

* Fix display when label doesn't match search term

* remove unused file

* Update packages/admin-ui/ui/src/components/templates/reservations-table/components/reservation-form/index.tsx

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/admin-ui/ui/src/domain/orders/details/allocations/edit-allocation-modal.tsx

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/admin-ui/ui/src/components/templates/reservations-table/new/index.tsx

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* initial changes

* add changeset

* update font size

* cleanup reservations table + select

* add decorated inventory item type

* use type

* feedback changes

* Update packages/admin-ui/ui/src/components/molecules/item-search/index.tsx

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

* decorate response for list inventory item to include total quantities

* update decorated properties

* decorate type

* adrien feedback

* Update packages/generated/client-types/src/lib/models/DecoratedInventoryItemDTO.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* update join-utils

* fix caching

---------

Co-authored-by: Rares Capilnar <rares.capilnar@gmail.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
2023-05-23 05:24:28 +02:00
Philip Korsholm
4fb443c0ea feat(medusa): Add location id filtering to list location levels (#4066)
**What**
- add capabilities for filtering locations by id when listing locations for an inventory item
2023-05-16 12:21:53 +00:00
Frane Polić
0c58ead6d8 fix(medusa): Validate customer_id when completing a cart (#3967) 2023-05-07 13:12:06 +02:00
Philip Korsholm
9838723192 fix(medusa): Performance improvement for variant availability (#3921)
**What**
- refactor availability invocations to only do one call to the inventory module

@adrien2p would love to run through some tests of this with you and get your take on approach
2023-05-03 09:17:55 +00:00
Riqwan Thamir
4e8045a0ac fix(medusa): Use query relation load strategy on Products (#3926)
* fix(medusa): products retrieve uses query strategy for performance

* chore: packaged version of medusa typeorm fix

* chore: update path

* chore: stock locations uses typeorm version

* chore: resolve typeorm to medusa package

* chore: Update medusa project in CI action

* chore: temp disable transaction timeout for plugins

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: olivermrbl <oliver@mrbltech.com>
2023-05-02 19:37:44 +02:00
Oliver Windall Juhl
3b3236cc01 fix(medusa): Reduce joins in cart retrieval (#3909)
* fix(medusa): Remove discounts.regions relation from cart retrieval

* Create violet-poets-rule.md

* fix service test

* update snapshot

---------

Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
2023-04-25 12:51:33 +02:00
Philip Korsholm
2be144ff05 feat(medusa): Add purchasable prop on variants when setting availability (#3811)
* write integration tests

* update variant inventory decorator

* update types

* add changeset

* feedback comments

* add yaml schemas

* different oas approach

* pr feedback

* update oas

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-04-20 08:54:26 +02:00
Oliver Windall Juhl
085fedb1f7 chore(medusa): Upgrade ioredis-mock (#3704)
* chore(medusa): Upgrade ioredis-mock

* Create .changeset/old-spoons-bow.md

* chore: Increas jest timeout

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-09 16:10:04 +02:00
Philip Korsholm
748833383f hotfix(medusa): Temporary multi-warehouse support for draft orders (#3665)
* remove reservations from draft order creation and show correct inventory

* add changeset

* add integration tests

* adjust inventory on payment if no inventory service is installed
2023-04-04 11:36:51 +02:00
Philip Korsholm
0cca13779d Fix(medusa): stocked quantity counting when listing products (#3684)
* count stocked quantity correctly when listing products

* add integration test

* add changeset
2023-04-03 11:07:56 +02:00
Oliver Windall Juhl
809ab2e0eb chore: Merge master to develop (#3653) 2023-03-31 13:09:57 +02:00
Philip Korsholm
5e405be02c feat(medusa): Remove reservations for all line items when an order edit is accepted (#3544)
**What**
- Remove all allocations to line items once an order edit is confirmed

**Why**
- Since all line items of an order are discarded once an order edit is confirmed it will orphan the reservations causing inconsistencies with the stock
2023-03-30 09:56:10 +00:00
Philip Korsholm
5fd74b38ae feat(medusa): remove created reservations on subsequent failure for cart completion (#3554)
**What**
- If cart completion fails after creating reservations, remove those reservations

**Why**
- To avoid hanging reservations if something fails at a later point
2023-03-29 17:03:53 +00:00
Philip Korsholm
55c5fba0d3 Feat(admin, medusa): add locations to claim and swap creation (#3522)
**What**
- Add location selection to claim and swap creation

Fixes CORE-1269
2023-03-20 14:05:37 +00:00
Philip Korsholm
026bdab05d Feat/fulfill swaps and claims with locations (#3518)
* re-add if statements

* initial implementation

* add changeset

* address feedback

* remove context param from create-fulfillment

* fix tests
2023-03-20 13:48:25 +01:00
Philip Korsholm
ea2633bccf Fix/minor mw fixes (#3521)
**What**
- Fix stock locations quantities being shown as `undefined` and `NaN`
- Throw if updates to location levels are made with negative quantities through the api
- Show "allocated" in order summary for partially fulfilled orders

Fixes CORE-1268, CORE-1267, CORE-1265
2023-03-19 20:28:59 +00:00
Philip Korsholm
0d1b63d773 fix(medusa): Use get for creating fulfillments (#3498)
* use get

* changeset

* use set

* add tests

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-16 19:03:36 +01:00
Philip Korsholm
02c77d7059 Fix/adjust reservations correctly (#3474)
**What**
- Adjust reservations correctly according to the following heuristic: 

adjustment by addition:  (i.e. positive quantity adjustment passed to the adjustment method)
- if a reservation for the line-item in the location exists add quantity to that
- if not create a new reservation

adjustment by subtraction: 
- if a reservation with the exact quantity exists, delete it and return
- if a reservation with a greater quantity exists, subtract from it and return 
- otherwise delete from reservations until a reservation with greater quantity than the remaining is found and adjust that with the remaining quantity OR there are no more reservations

Fixes CORE-1247
2023-03-16 09:47:54 +00:00
Philip Korsholm
38c8d49f46 Feat(medusa): handle reservation quantity update for line items (#3484)
**What**
-  Raise exception if a reservation is updated or created to have larger quantity than is unfulfilled for a line-item

Fixes CORE-1249
2023-03-16 09:15:39 +00:00
Carlos R. L. Rodrigues
77d46220c2 Feat(modules-sdk,inventory,stock-location): modules isolated connection (#3329)
* feat: scoped container for modules
2023-03-15 12:09:45 -03:00
Philip Korsholm
10bf05c147 Fix(inventory, stock-location): Remove orphaned location levels and reservations (#3460)
**What**
- Remove related inventory levels and reservation items when a stock location is removed

**How**
- Add bulk deletion methods for both inventory levels and reservation items to the inventory service api
- invoke both on location removal

Fixes CORE-1232
2023-03-15 09:12:46 +00:00
Philip Korsholm
fe9eea4c18 feat(medusa, admin-ui, medusa-react, medusa-js): Allow toggling of manage inventory (#3435)
**What**
- Toggle manage inventory in the inventory management modal

**How**
- Create/update/remove inventory item based on if `manage_inventory` is set and if an inventory item already exists
- Move all stock location updates to when the modal is submitted
- Add create-inventory-item endpoint in the core

Fixes CORE-1196

Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2023-03-14 16:14:31 +00:00
Philip Korsholm
30a3203640 Fix(medusa): Missing location id on fulfillments (#3462)
**What**
- include location id when creating a fulfillment
- Allow location updates to reservations without passing along quantity

**Why**
- location_id on fulfillment was null after creation

Fixes CORE-1242, CORE-1243
2023-03-14 11:08:52 +00:00
olivermrbl
24604f1b71 chore: Merge conflicts with master 2023-03-14 11:43:31 +01:00
Philip Korsholm
55a1f232a3 Feat(admin-ui, medusa): request return with location (#3451)
* add location_id to request_return endpoint to support "receive_now" returns

* changeset

* admin request return

* add locations to recieving returns

* cleanup test

* add check for inventory service
2023-03-14 10:35:59 +01:00
Adrien de Peretti
f0a1355feb feat(medusa): Bulk emit events (#3407) 2023-03-13 15:28:51 +01:00
Philip Korsholm
5eb61fa0ef fix(medusa): update create fulfillment flow (#3172)
* update create fulfillment flow

* move transaction service creation close to where it's used

* integration tests

* fix feedback

* use transformBody

* add changeset
2023-02-28 16:28:11 +01:00
Philip Korsholm
a1e59313c9 feat(medusa, stock-location): Sales channel filtering when listing locations (#3324)
* only add ordering select if not already selected

* add integration test

* add changeset

* remove catch

* linting and suggestion from adrien

* add sales channel filtering when listing locations

* add changeset

* add exception back into sales channel location service

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-02-28 10:41:59 +01:00
Philip Korsholm
08c8aa46c5 fix(medusa): Only add ordering select if not already present (#3319) 2023-02-26 13:08:06 +01:00
olivermrbl
e1b92e9b04 fix: Merge conflicts with master 2023-02-22 17:38:49 +01:00
Oliver Windall Juhl
f88af0c28d fix(medusa): Received quantity on return lines (#3267) 2023-02-17 10:13:50 +00:00
Rares Stefan
12d304307a feat(medusa-js, medusa-react, medusa): Prepare API for admin implementations (#3110)
********What********
Add `joinSalesChannels util to stock locations

Add the following endpoints to medusa-react
- inventory items
    - mutations
        - update
        - delete
        - update location level
        - delete location level
        - create location level
    - queries
        - list inventory items
        - get inventory item
        - list location levels
- Stock locations
    - mutations
        - create stock location
        - update stock location
        - delete stock location
    - queries
        - list stock locations
        - get stock locatoin
- Variants
    - queries
        - get inventory
- Reservations
    - mutations
        - create reservation
        - update reservation
        - delete reservation
    - queries
        - list reservations
        - get reservation
- sales channels 
  - mutations
    - associate location with sc
    - remove location association

**Why**
- Update clients to reflect new api endpoints in the core with inventory modules

Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
2023-02-16 08:49:48 +00:00
Riqwan Thamir
121b42acfe chore(medusa): Typeorm upgrade to 0.3.11 (#3041) 2023-02-15 16:25:30 +01:00
Carlos R. L. Rodrigues
d859ccf551 Feat(medusa) - delete cascade modules associations (#3190)
* delete cascade sales channel x locations, variant x inventory item
2023-02-08 17:23:47 -03:00
Carlos R. L. Rodrigues
923ccece24 feat(medusa,stock-location,inventory): Integration tests (#3149) 2023-02-06 09:02:43 -03:00
Oliver Windall Juhl
9e3beaf531 chore(feature-flags): Remove OrderEditing feature flag (#3006) 2023-01-13 11:10:09 +00:00
Oliver Windall Juhl
3308766389 chore(feature-flags): Sales Channels enabled by default (#2966) 2023-01-10 16:45:23 +00:00