Commit Graph

4697 Commits

Author SHA1 Message Date
Philip Korsholm
e747f9d4aa feat: Refresh invite (#6469) 2024-02-27 07:16:52 +00:00
Philip Korsholm
7bddb58542 feat: Update authentication middleware (#6447)
* authentication middleware update

* disable customer authentication

* call correct feature flag method

* fix authentication middleware for store/customers

* fix integration tests and add middleware for admin customers

* update seeders

* customer groups fix

* add authentication middleware for all admin endpoints

* Feat(medusa, user): require authentication for invite accept (#6448)

* initial invite token validation for authentication invocation

* remove invite auth

* remove unused import

* cleanup tests

* refactor to auth instead of auth_user

* pr feedback

* update authenticatedRequest type

* update store authenticated endpoints

* update routes with type

* fix build

* fix build

* fix build

* use auth middleware for api-keys
2024-02-27 13:50:18 +08:00
Sebastian Rindom
63aea44e06 feat(tax): add tax provider support (#6492)
**What**
- Adds Tax Provider model
- Adds loader to get Tax Provider from module options
- Adds System Tax provider which forwards tax rates as is
2024-02-26 19:29:26 +00:00
Oli Juhl
ce39b9b66e feat(payment, payment-stripe): Add Stripe module provider (#6311) 2024-02-26 19:48:15 +01:00
Adrien de Peretti
ac829fc67f feat(fulfillment): List shipping options filtered by context anmd rules (#6507)
**What**
Should be able to list the shipping options with or without a context, when a context is provided all the rules of the shipping options must be valid for the shipping options to be returned.

FIXES CORE-1765
2024-02-26 14:59:55 +00:00
Stevche Radevski
b13c669528 feat: Add basic CRUD functionality to store module (#6510)
Adds the core model and basic CRUD around it.

Note: The store model is not complete, but I prefer doing smaller PRs so it's easier to do a proper review. Adding currencies will be a follow-up PR.
2024-02-26 14:23:48 +00:00
Oli Juhl
7ebe885ec9 feat: Create cart with line items (#6449)
**What**
- Add support for creating a cart with items
- Add endpoint `POST /store/carts/:id/line-items`
- Add `CreateCartWorkflow`
- Add `AddToCartWorkflow`
- Add steps for both workflows

**Testing**
- Endpoints
- Workflows

I would still call this a first iteration, as we are missing a few pieces of the full flow, such as payment sessions, discounts, and taxes.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-02-26 13:32:16 +00:00
Riqwan Thamir
ac86362e81 feat(workflows-sdk,core-flows,medusa,types): add workflow to update promotions to cart (#6474)
what:

- adds API + workflow to add/remove promotions in a cart
- minor fixes in promotions module
- minor type fixes in cart module
- typing fix in workflows-sdk (Thanks @adrien2p)
- fix step result in workflows-sdk (Thanks @adrien2p)

RESOLVES CORE-1768

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-02-26 12:43:57 +00:00
Stevche Radevski
63be07031b feat: Add skeleton for Store module (#6506) 2024-02-26 12:00:48 +00:00
Riqwan Thamir
8ea37d03c9 fix(utils): bignumber util considers nullable options when setting value (#6499)
what:

- when setting null for nullable columns, big number utils should not throw error
- remove circular soft delete depenedencies for cart module
- trims zeros on big number values
2024-02-26 11:29:36 +00:00
Adrien de Peretti
56cbf88115 chore(utils): Soft delete should allow self referencing circular deps (#6504)
**What**
Self referencing circular dep should not be an error and should be accepted
2024-02-26 09:37:46 +00:00
Sebastian Rindom
d983329481 feat(tax): soft deletes (#6486)
**What**
- Adds soft deletes
2024-02-26 08:34:46 +00:00
Shahed Nasser
3b18f399c1 docs(ui): show icon tooltip on small devices (#6407) 2024-02-26 08:31:36 +01:00
Sebastian Rindom
3c5b020c5e feat(tax): singular creates and deletes of regions, rates, rules (#6464)
**What**
- Adds support for creating single rates, regions, rules.
- Adds delete methods.
2024-02-25 21:38:41 +00:00
Adrien de Peretti
168f02f138 chore(util): Detect circular dependencies on soft delete (#6489) 2024-02-24 14:21:43 +01:00
Stevche Radevski
5b85c3103e feat: Update signature of region module to match latest spec (#6487) 2024-02-23 15:56:16 +00:00
Shahed Nasser
c86e27bd0d chore: generated tsdocs (#6352)
Generated TSDocs for the past release.

Note: I haven't updated examples as the examples are for modules without a public reference yet, so the examples can wait.
2024-02-23 15:21:16 +00:00
Adrien de Peretti
788c4a1e36 feat(fulfillment): Shipping options, rules CRUD + rules based context filtering (#6455)
**What**
- Update shipping options with its rules and type
- create/update rules independently
- context based validation fundation
- 🔴 list shipping options with context rules fitlering will come in a separate pr to keep this one smaller

FIXES CORE-1743
FIXES CORE-1764
2024-02-23 11:14:33 +00:00
Stevche Radevski
78b6d46584 Merge pull request #6471 from medusajs/feat/add-api-endpoints-api-key
feat(api-key): Add the endpoints and workflows for api key module
2024-02-23 11:35:31 +01:00
Stevche Radevski
0582545065 feat(api-key): Add the endpoints and workflows for api key module 2024-02-23 11:01:08 +01:00
Oli Juhl
d9636f4631 chore(cart): Make all cart entities soft-deletable (#6475) 2024-02-23 08:59:02 +01: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
Adrien de Peretti
36a61658f9 feat(utils): Fix big number decorator and cleanup (#6473)
**What**
- Fix big number decorator and cleanup
2024-02-22 16:58:41 +00:00
Sebastian Rindom
598ee6f49c feat(tax): adds getItemTaxLines (#6440)
**What**
- Selects the correct tax line for an item given a calculation context.

**For later PR**
- Consider optimizations. Some thoughts:
  - Even with global sales the number of rates in the DB is not likely to grow beyond ~1000.
  - Can large orders with hundreds of items optimize somehow?
  - Does it make sense to write a custom SQL query to do this?
- Support combined rate.

**Test cases covered**
The selection of tax rates take the following priority:

1. specific product rules - province
2. specific product type rules - province
3. default province rules
4. specific product rules - country
5. specific product type rules - country
6. default country rules

There are test cases for each of them under the following data seed structure:

### **US** 
- **Default Rate**: 2%
- **Sub-Regions**
  - CA 
    - Default Rate: 5%
    - Overrides
      - Reduced rate (for 3 product ids): 3%
      - Reduced rate (for product type): 1%
  - NY 
    - Default rate: 6%
  - FL 
    - Default rate: 4%
- **Overrides**
  - None

### **Denmark** 
- **Default rate:** 25% 
- **Sub-Regions**
  - None
- **Overrides**
  -  None

### **Germany** 
- **Default Rate:** 19%
- **Sub-Regions**
  - None
- **Overrides:**
  - Reduced Rate (for product type) - 7%

### **Canada** 
- **Default rate**: 5%
- **Sub-Regions**
  - QC 
    - Default rate: 2%
    - Overrides:
      - Reduced rate (for same product type as country reduced rate): 1%
  - BC 
    - Default rate: 2%
- **Overrides**
  - Reduced rate (for product id) - 3%
  - Reduced rate (for product type) - 3.5%
2024-02-22 16:28:55 +00:00
invalid w
58943e83fd fix(medusa): unable to delete downloaded files (#6169)
resolve #6168
2024-02-22 12:13:42 +00:00
Shahed Nasser
52afc619b3 docs: typo fix in create event module reference (#6470) 2024-02-22 12:16:18 +01:00
Adrien de Peretti
f611865553 fix(workflows-sdk): Fix StepFunction typings and custom step name (#6468)
* fix(workflows=sdk): Fix StepFunction typings and custom step name

* Create smart-nails-switch.md

* fixes

* fixes

* fixes

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-02-22 11:59:53 +01:00
Kasper Fabricius Kristensen
72a17d6cd7 feat(dashboard): Rework route modals (#6459)
**What**
- Reworks how RouteModals are setup.

**Why**
- With the current implementation it was possible to create a race-condition in the logic that handled displaying a prompt if the user tried to close a modal, while a child form was dirty. The race condition would cause a new prompt to spawn each time the user clicked the screen, making it impossible to dismiss the prompt. This only occurred in a few specific cases.

**How**
- Creates two new components: RouteFocusModal and RouteDrawer. The component shares logic for handling their own open/closed state, and now accept a form prop, that allows the modals to keep track of whether their child form is dirty. This change ensures that race conditions cannot occur, and that the prompt always only renders once when needed.
2024-02-22 09:03:40 +00:00
Stevche Radevski
add861d205 chore(utils): Move generic utils from region module to utils (#6466)
Moves some generic utilities from the region module to the top-level utils package
2024-02-22 08:06:46 +00:00
Stevche Radevski
5a15e039ec Merge pull request #6463 from medusajs/feat/implement-crud-api-key-module
feat(api-key): Add CRUD functionalities to the api key module
2024-02-21 16:36:31 +01:00
Stevche Radevski
ec6351b363 chore: Updates based on PR feedback 2024-02-21 16:05:51 +01:00
Stevche Radevski
c99ca5cc22 feat(api-key): Add CRUD functionalities to the api key module 2024-02-21 15:45:40 +01:00
Adrien de Peretti
e0750bae40 chore(medusa-test-utils): Add debug option to the module test runner (#6462)
**What**
Add a debug options to the test runner, for now it will only switch the db to log the query but it could evolve to do more debug.
2024-02-21 13:01:03 +00:00
Frane Polić
8ff838970e fix(medusa): register logger when running migrations (#6415) 2024-02-21 13:28:58 +01:00
Kasper Fabricius Kristensen
44d43e8155 feat(dashboard, medusa, medusa-js, medusa-react, icons): DataGrid, partial Product domain, and ProductVariant hook (#6428)
The PR for the Products section is growing quite large, so I would like to merge this PR that contains a lot of the ground work before moving onto finalizing the rest of the domain.

**Note**
Since the PR contains changes to the core, that the dashboard depends on, the staging env will not work. To preview this PR, you will need to run it locally. 

## `@medusajs/medusa`

**What**
- Adds missing query params to `GET /admin/products/:id/variants`
- `options.values` has been added to the default relations of admin product endpoints.

## `medusa-react`

**What**
- Adds missing hook for `GET /admin/products/:id/variants`

## `@medusajs/dashboard`
- Adds base implementation for `DataGrid` component (formerly `BulkEditor`) (WIP)
- Adds `/products` overview page
- Adds partial `/products/create` page for creating new products (WIP - need to go over design w/ Ludvig before continuing)
- Adds `/products/:id` details page
- Adds `/products/:id/gallery` page for inspecting a products images in fullscreen.
- Adds `/products/:id/edit` page for editing the general information of a product
- Adds `/products/:id/attributes` page for editing the attributes information of a product
- Adds `/products/:id/sales-channels` page for editing which sales channels a product is available in
- Fixes a bug in `DataTable` where a table with two fixed columns would not display correctly

For the review its not important to test the DataGrid, as it is still WIP, and I need to go through some minor changes to the behaviour with Ludvig, as virtualizing it adds some constraints.

## `@medusajs/icons`

**What**
- Pulls latest icons from Figma

## TODO in next PR
- [ ] Fix the typing of POST /admin/products/:id as it is currently not possible to delete any of the nullable fields once they have been added. Be aware of this when reviewing this PR.
- [ ] Wrap up `/products/create` page
- [ ] Add `/products/:id/media` page for managing media associated with the product.
- [ ] Add `/products/id/options` for managing product options (need Ludvig to rethink this as the current API is very limited and we can implement the current design as is.)
- [ ] Add `/products/:id/variants/:id` page for editing a variant. (Possibly concat all of these into one BulkEditor page?)
2024-02-21 11:29:35 +00:00
Shahed Nasser
c3e30224c7 docs: add missing widget props for collections injection zones (#6452)
* docs: add missing widget props for collections injection zones

Adds missing widget props for the `product_collection.details.before` and `product_collection.details.after` injection zones.

* fix lint error
2024-02-21 07:49:30 +01:00
Stevche Radevski
30dbb86ef4 chore: Update CONTRIBUTING.md to include information on changesets (#6454) 2024-02-21 07:48:04 +01:00
Carlos R. L. Rodrigues
56b0b45304 Feat(order): order changes (#6435)
What:
 - Order DB schema migration
 - BigNumberField Decorator
  
![order_schema](https://github.com/medusajs/medusa/assets/37986729/64ec82ca-5c28-46ef-9a57-614c5a4d25f6)
2024-02-20 23:07:57 +00:00
Sebastian Rindom
137cc0ebf8 feat(tax): introduce tax override data models (#6422)
**What**
- Adds Tax rules to allow overrides of tax rates for certain products, product types or shipping options.

**Punted to future PR**
- Currently, the creation methods only support bulk operations. A later PR will include support for singular operations, too.
- It should be possible to add products, types, and shipping options to a tax rate after creating it. Add, remove, update will come in a later PR.
2024-02-20 16:50:19 +00:00
Riqwan Thamir
43ed6a990d fix: fix fulfillment spec (#6456) 2024-02-20 15:53:18 +01:00
Mohammed Faiyyaz Khatri
76ff9e87b6 fix(utils): Symbol for Indian Currency (#6453) 2024-02-20 15:45:01 +01: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
Stevche Radevski
cfefd59249 feat(regions): Add support for updating countries in a region (#6432)
**What**
Add missing support for updating countries on the POST /admin/regions/:id route.
Furthermore, the PR refactors how the normalization and validation was handled in both create and update scenarios.
Finally, the PR adds a unique index on the country entity, which ensures at the DB level that we cannot have a duplicate country in the DB for a single region.
2024-02-20 11:46:42 +00:00
Adrien de Peretti
c319edb8e0 chore(utils): Add default ordering to the internal service factory list/listAndCount (#6436)
**What**
Default ordering. By default, only the top level entity ordering is applied using the primary keys, the relations are default ordered by the foreign keys.

It include tests fixing for deterministic data ordering
2024-02-20 11:07:39 +00:00
Oli Juhl
691f68c3b8 feat(region): Region create, delete, update admin endpoints (#6332)
**What**
Add `POST /admin/regions`
Add `POST /admin/regions/:id`
Add `DELETE /admin/regions/:id`

All are added for v2 using API Routes and workflows.

In follow-up PRs, I will add support for passing countries in update and create.

Update: First follow-up PR is #6372
2024-02-20 10:19:07 +00:00
Adrien de Peretti
1d91b7429b feat(fulfillment): implementation part 2 (#6408)
**What**

> [!NOTE]  
> I can see this pr becoming huge, so I d like to get this partial one merged 👍 


- Fixes shared connection usage (mikro orm compare the instance to its own package and therefore was resulting in not trully reusing the provided connection leading to exhausting the connection pool as multiple connections was created and end up not being all destroyed properly under the hood, discovered in my integration tests)
- Create shipping options method implementation
- DTO's definition and service interface update
- integration tests 
- Re work of the indexes with new util update
- Test runner utils to remove a big chunk of the boilerplate of the packages integrations

FIXES CORE-1742
2024-02-19 12:33:46 +00:00
Oli Juhl
680dfcdad3 feat(core-flow, medusa): Create cart with Sales Channel (#6427) 2024-02-19 09:42:11 +01:00
Oli Juhl
5db3ec09e2 feat: Cart Customer link + create cart with customer (#6426) 2024-02-19 08:28:44 +01:00
Philip Korsholm
f6d38163bb Feat(medusa, user, core-flows): User creation with invites (#6413)
**What**
- add accept invite endpoint 

**Invite accept flow**
- authenticate using the auth endpoint to create and auth-user
- invoke accept endpoint with token and info to create user
2024-02-19 05:29:15 +00:00
Sebastian Rindom
5977a38ef4 feat(tax): Add TaxRegion (#6421)
**What**
- Adds a TaxRegion entity.

**For context: High-level design of the Tax module**
- A TaxRegion scopes tax rates to a geographical place.
- You can define tax regions on two levels: country-level, province-level (this corresponds to state in US contexts)
- Each Tax Region can have a default Tax Rate.
-  [not yet done] - Each Tax Region can also have granularly defined tax rates for different products and shipping rates. For example, California can have a base rate for default products, but a reduced rate for groceries.
- Tax Rates specify if they can be combined with other rates - it's always the lowest level rate that wins.

The above allows a merchant to define their tax settings along the lines of this:

- Denmark (Region)
  - Default rate: 25% (TaxRate)
- Germany (Region)
  - Default rate: 19% (TaxRate)
  - Reduced rate (books): 9% (TaxRate w. rule)
- United States (Region)
  - Default rate: 0% (TaxRate)
  - California: (Region)
    - Default rate: 7.25% (TaxRate)
  - Arkansas: (Region)
    - Default rate: 6.5%
    - Reduced rate (groceries): 0.125% (TaxRate w. rule)

The TaxModule can then receive a list of products and the shipping address to determine what tax rates apply to the line items.
2024-02-18 13:31:50 +00:00