Commit Graph

333 Commits

Author SHA1 Message Date
Riqwan Thamir
bacfa3e17b feat(medusa-payment-paypal,medusa-payment-stripe): speed up unit tests in CI (#6806)
* chore: shard unit tests

* chore: move paypal and stripe to swc

* chore: update actions

* chore: refactor http paypal client

* chore: added changeset

* chore: remove medusa changes
2024-03-25 15:27:40 +01:00
Riqwan Thamir
4c98545ab3 feat: shard modules and API integration tests (#6775)
what:

- runs module and api integration tests in matrix strategy
  - v28 of jest comes with sharding support, which we can utilize when we upgrade
- splits the tests by number of matrix jobs and run them in parallel
  - This introduced some flakiness in some specs, but couldn't reproduce locally. Those have been skipped for now.
- uses swc/jest for added performance
  - Locally, a chunk took 90 seconds with babel and 30 seconds with swc. 
  - This translated to 2 mins saved per shard in CI, but haven't tested this enough.
2024-03-22 11:15:01 +00:00
olivermrbl
95738804cd chore: Release 2024-03-20 10:35:07 +01:00
Sebastian Rindom
873c21355c feat: make it possible to use subscribers in v2 (#6731) 2024-03-19 18:31:58 +00:00
Philip Korsholm
84b8836cbf Feat(core-flows, inventory-next, medusa, types): Add create location level endpoint (#6695)
* initialize create location levels

* add enough from pr to make code build and test

* fix integration tests

* pr feedback

* fix errors

* rm dto

* Update packages/core-flows/src/inventory/steps/validate-inventory-locations.ts

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

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-03-18 10:28:57 +01:00
Kasper Fabricius Kristensen
ee4ea796f6 chore: align version of dotenv (#6657) 2024-03-11 12:34:17 +01:00
Kasper Fabricius Kristensen
2d00625729 feat(dashboard): Workflow executions (#6564)
**What**
- v1 of executions domain

**TODO in follow up PR**
I think it might be a good idea for Carlos or Adrien to go over the design with Ludvig, and make sure we are displaying what is relevant to developers, and how things should be displayed. So this PR is just the initial implementation, and does not handle displaying things like compensation steps (not part of the current design), step input (not supported by the API but part of the design), etc.

Closes CORE-1751, CORE-1755
2024-03-09 18:46:10 +00:00
Sebastian Rindom
a838ebae1b fix: make v2 with modules run (#6636) 2024-03-09 15:09:06 +00:00
Oli Juhl
4136b9da5f feat: Add Sales Channel Stock Location link (#6634) 2024-03-08 15:26:26 +01:00
Philip Korsholm
c19d276458 feat(inventory-next, types): inventory module conversion (#6596)
* init

* create new interface

* prep integration tests

* update denpencies

* inventory service partial tests

* finalize integration tests

* add events

* align events

* adjust inventory level reservation levels

* add test validating reserved quantity after reseration item update

* fix nits

* rename to inventory-next

* update yarn.lock

* remove changelog

* remove fixtures

* remove unused files

* ready for review

* Update packages/inventory-next/package.json

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

* pr feedback

* add tests and docs for partition-array util

* remote decorators from private method

* fix unit tests

* add migrations

* add foreign keys

* fix build

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-03-08 14:09:05 +01:00
Philip Korsholm
8406eb5a35 feat(stock-location): Convert module to use mikro-orm (#6616)
* convert module

* fix migration

* cleanup module service

* fix pr feedback
2024-03-08 13:15:15 +01:00
Oli Juhl
3d0da980cf feat: Capture payment (#6601)
* feat: Capture payment

* add amount to workflow input
2024-03-07 11:02:26 +01: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
Kasper Fabricius Kristensen
e5dc918be5 feat(dashboard): Order details page (#6538)
**What**
- Adds the different display cards to the order details page. This does not include any of the different forms for editing various aspects of an order.
2024-03-05 13:06:50 +00:00
Adrien de Peretti
62a7bcc30c Feat(fulfillment): service provider registration + fulfillment management (#6524)
**What**
- Create the fulfillment manual package with a first iteration API 
- Create a new `AbstractFulfillmentProviderService` and `IFulfillmentProvider`
- Modify the module service interface to add new methods to manipulate the fulfillment and the communication with the external provider
  - create (no bulk)
  - cancel (no bulk)
  - update (no bulk)
  - list
  - listAndCount
  - retrieve
- Add new methods to the service provider service to include communication with the third party provider
  - get options
  - create
  - cancel
  - validate data
  - validate option
- Update/create interfaces and DTO's
- fix repository serializer to allow non entity to be passed without throwing
- split module tests into multiple files to simplify navigation
- Add integration tests to validate fulfillments manipulation and external provider loading + communication

FIXES CORE-1729
FIXES CORE-1785
FIXES CORE-1784
FIXES CORE-1766
2024-03-05 11:11:14 +00:00
Oli Juhl
84208aafc1 feat: Create payment sessions (#6549)
~~Opening a draft PR to discuss a couple of implementation details that we should align on~~

**What**

Add workflow and API endpoint for creating payment sessions for a payment collection. Endpoint is currently `POST /store/payment-collection/:id/payment-sessions`. I suggested an alternative in a comment below.

Please note, we intentionally do not want to support creating payment sessions in bulk, as this would become a mess when having to manage multiple calls to third-party providers.
2024-03-05 08:40:47 +00:00
Riqwan Thamir
8dad2b51a2 feat(medusa-react,medusa,utils): add users/me endpoint + add missing specs (#6441)
**what:**

- adds /me endpoint
- adds fixes to routes
- adds specs for auth endpoint
- updates dotenv package versions


Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
2024-03-04 09:07:47 +00:00
Oli Juhl
296d7faad4 chore: V2 core loader + modules integration-tests (#6544) 2024-02-29 16:46:30 +01: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
Kasper Fabricius Kristensen
44a5567d0d feat(dashboard): Regions domain (#6534)
**What**
- Implements new Region domain design
- Adds new SplitView component for managing adding nested relations in FocusModals, eg. adding countries to a region.
- Adds new Combobox component for multi select fields in forms

**medusajs/ui**
- Fix styling of RadioGroup.Choicebox component

CLOSES CORE-1650, CORE-1671
2024-02-29 13:16:14 +00:00
Sebastian Rindom
adad66e13f feat(tax): migration file (#6523)
**What**
- Tax Module Migration file.
- Skeleton for API routes and integrations tests for tax API in v2
2024-02-28 14:40:35 +00:00
Stevche Radevski
d60f3adc03 feat: Add basic endpoints and workflows for Store module (#6515) 2024-02-28 10:08:11 +00:00
Oli Juhl
ce39b9b66e feat(payment, payment-stripe): Add Stripe module provider (#6311) 2024-02-26 19:48:15 +01:00
Stevche Radevski
63be07031b feat: Add skeleton for Store module (#6506) 2024-02-26 12:00:48 +00:00
Stevche Radevski
0582545065 feat(api-key): Add the endpoints and workflows for api key module 2024-02-23 11:01:08 +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
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
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
7df4947ecf feat(tax): tax module scaffolding (#6417)
**What**
- Scaffolds the tax module
2024-02-16 13:24:23 +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
Philip Korsholm
4d51f095b3 feat(user, types): add invite and user properties + migration (#6327)
**What**
- Add invite model 
- Populate user model
2024-02-14 13:58:14 +00:00
Carlos R. L. Rodrigues
0c2a460751 feat(medusa): workflow engine api (#6330)
What:

   Workflow Engine API.
   Endpoints for:
     - List workflow executions
     - Run a workflow
     - Set async steps as success or failure
     - Retrieve the details of a workflow run
2024-02-13 15:19:10 +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
Oli Juhl
94062d28be feat: Add BigNumber implementation (#6253)
> This is a proposal - not necessarily the end result - to kick off the discussion about the implementation of the new totals utilities

### What
Introduces a BigNumber class implementation, enabling us to work with high-precision numeric values.

**Scope**
- Introduce the BigNumber class
- Remain somewhat backward-compatible (in behavior)
- Establish a foundation for handling high-precision values in more complex scenarios

**Not in scope**
- The implementation will not address complex use cases. However, the concept introduced now should be open for extensibility, so this can be added later without major changes to the calculation logic

### How
There are significant changes to three areas in this PR:
- Schemas
- (De)-Serialization
- Totals calculations

**Schemas**

Domains that need high-precision values will have two DB columns for each value in the database: a standard numeric column and a raw value column.

The standard column is for basic operations like sorting and filtering in the database and is what should be publicly exposed in our API.

The raw value is initially used solely for precise calculations and is stored as a JSONB column. Keeping it as JSONB is flexible and will allow us to extend the concept in future iterations. As of now, the raw value will only require a single property `value`.

**(De)-Serialization**

We cast the raw JSONB value to a `BigNumberRawValue` when reading from the database. 

We serialize the standard value to a `BigNumber` when reading from the database. 

We use the standard numeric value to construct the raw value upon writing to the database.

For example, the unit price and raw unit price on line items will be inserted as follows:
```ts
@BeforeCreate()
onCreate() {
  this.id = generateEntityId(this.id, "cali")
  
  const asBigNumber = new BigNumber(this.raw_unit_price ?? this.unit_price)
  
  this.unit_price = asBigNumber.numeric
  this.raw_unit_price = asBigNumber.raw
}
```

**Totals calculations**

For totals calculations, we will use the [`bignumber.js`](https://github.com/MikeMcl/bignumber.js/) library. The library ships with a `BigNumber` class with arithmetic methods for precise calculations. 

When we need to perform a calculation, we construct the BigNumber class from the library using the raw value from the database.

Let's have a look at an oversimplified example:
```ts
// create cart with line items
const [createdCart] = await service.create([
  {
    currency_code: "eur",
    items: [
      // li_1234
      {
        title: "test",
        quantity: 2,
        unit_price: 100,
      },
      // li_4321
      {
        title: "test",
        quantity: 3,
        // raw price creation
        unit_price: 200,
      },
    ],
  },
])
```

```ts
// calculating line item totals
import BN from "bignumber.js"

const lineItem1 = await service.retrieveLineItem("li_1234")
const lineItem2 = await service.retrieveLineItem("li_4321")

const bnUnitPrice1 = new BN(lineItem1.unit_price.raw)
const bnUnitPrice2 = new BN(lineItem2.unit_price.raw)

const line1Total = bnUnitPrice1.multipliedBy(lineItem1.quantity)
const line2Total = bnUnitPrice2.multipliedBy(lineItem2.quantity)

const total = line1Total.plus(line2Total)
```

**A note on backward compatibility**
Our BigNumber implementation is built to support the existing behavior of numeric values in the database. So even though we serialize the value to a BigNumber, you will still be able to treat it as a standard number, as we've always done.

For example, the following works perfectly fine:
```ts
const lineItem = await service.createLineItem({
  title: "test",
  quantity: 2,
  unit_price: 100,
})

console.log(lineItem.unit_price) // will print `100`
```

However, the type of `unit_price` will be `number | BigNumber`.
2024-02-09 10:56:50 +00:00
olivermrbl
dc88fd3507 chore: Release 2024-02-09 10:28:12 +01:00
olivermrbl
512ac1e6ed chore: Release 2024-02-08 16:26:40 +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
Kasper Fabricius Kristensen
73fd92a1af feat(dashboard): Log in, reset password, and accept invite pages (#6310) 2024-02-05 11:16:10 +01:00
Kasper Fabricius Kristensen
8cbf6c60fe feat(dashboard): DataTable component (#6297) 2024-02-02 21:56:55 +01:00
Philip Korsholm
9fda6a6824 feat(auth): add authentication endpoints (#6265)
**What**
- Add authentication endpoints: 
  - `/auth/[scope]/[provider]` 
  - `/auth/[scope]/[provider]/callback`
- update authenticate-middleware handler
- Add scope field to user
- Add unique constraint on scope and entity_id

note: there's still some remaining work related to jwt auth to be handled, this is mainly focussed on session auth with endpoints



Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
2024-02-02 10:45:32 +00:00
Sebastian Rindom
7903a15e0f feat(customer): Add create and retrieve customer from store side (#6267)
**What**
- GET /store/customers/me
- POST /store/customers
- Workflow for customer account creation
- Authentication middleware on customer routes
2024-01-31 11:58:29 +00:00
Sebastian Rindom
87390704be feat(customer): list customer (#6206)
**What**

- GET /admin/customers
- GET /admin/customer-groups
2024-01-29 16:56:39 +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
olivermrbl
c27bb2a61d chore: Release 2024-01-25 16:27:55 +01:00
olivermrbl
7b30512a65 chore: Remove workspace range in deps 2024-01-25 14:08:25 +01:00
Shahed Nasser
e84847be36 feat(medusa-oas-cli): updated redocly-cli to v1.7 (#6211)
## What

Updates `@redocly/cli` to v1.7. This resolves the bug of TypeScript and tsx code samples in the OAS being generated as undefined files (see files under `www/apps/api-reference/specs/admin/code_samples/tsx` and `www/apps/api-reference/specs/store/code_samples/tsx`

I avoided re-generating OAS so that this PR doesn't have a huge diff. When the next release is out, an automated PR will be opened to update the OAS files, replacing the undefined files with `.tsx` files.

### Other Changes

- Small fixes to `medusa-oas-cli` README for clarity
2024-01-25 07:53:58 +00:00