Commit Graph
100 Commits
Author SHA1 Message Date
Oli Juhl bc081a7777 feat: Create product category flow (#7034)
* feat: Create product category

* address PR comments
2024-04-15 17:11:42 +02:00
Oli Juhl 3882cac622 feat: Admin V2 customer group (#7000) 2024-04-09 12:32:27 +02:00
Oli Juhl dbddfc12ed feat: Admin Shipping Profiles API (#7019) 2024-04-09 11:03:37 +02:00
Oli Juhl c03216efbf fix: Delete service zone (#7017) 2024-04-08 20:24:59 +02:00
Oli Juhl 6cc9a5e469 feat: Categories retrieve + list API (#7009) 2024-04-08 19:26:34 +02:00
Oli Juhl 4f88743591 feat: Admin V2 Customers (#6998) 2024-04-07 21:38:50 +02:00
Oli Juhl a24d6e6c97 feat: Update service zone (#6990) 2024-04-07 17:30:55 +02:00
Oli Juhl 31b07aea3d feat: Add tax regions table (#6983) 2024-04-07 15:02:48 +02:00
Oli Juhl d1728990e9 feat: Delete service zone (#6984) 2024-04-07 10:59:08 +02:00
Oli Juhl 81ea044f31 feat(medusa, core-flows): Create service zones (#6979) 2024-04-06 21:31:23 +02:00
Oli Juhl 5724d80286 feat: Bring back API key sales channel management (#6976)
- Add API key sales channel management
- Add HTTP responses for API keys and sales channels
- Use HTTP responses in `dashboard` and remove now redundant types
2024-04-06 16:30:27 +00:00
Oli Juhl c31dea02eb feat: Add generic link filter middleware (#6969) 2024-04-06 11:18:03 +02:00
Oli Juhl 94146e4bfe chore: Trigger pipeline on merge to develop (#6954) 2024-04-06 11:02:47 +02:00
Oli Juhl 626aa09497 feat: Add create location fulfillment set flow + API (#6945) 2024-04-05 19:27:38 +02:00
Oli Juhl 8ecfa4b6f5 fix: Add count to stock-locations response (#6965) 2024-04-05 18:28:03 +02:00
Oli Juhl 5ba74ec5fc feat: Add zod middleware (#6961) 2024-04-05 16:24:31 +02:00
Oli Juhl eadc5e8a79 feat: Admin V2 API keys (#6883)
Add API key management UI for V2

This PR only adds publishable API key UI. Secret API key management will come in a follow-up PR.
2024-04-05 09:55:59 +00:00
Oli Juhl 7895ff3849 feat: add sales channel management (#6761)
Add V2 sales channel management to admin

`@medusajs/medusa`
- Add `POST /admin/sales-channels/:id/products/batch/remove`
- Refactor cross-module filter middleware to comply with the latest convention

`@medusajs/admin-next`
- Add all sales channel routes
- Moves the following sales channel UI to shared components in `modules/sales-channel`:
  - sales-channel-list
  - sales-channel-edit
  - sales-channel-details
    - sales-channel-general-section
  - sales-channel-create

The sales-channel-product-section is not shared because the API in V2 will change.
The sales-channel-add-products component is not shared because the API in V2 will change.

`@medusajs/core-flows`
- Add `detachProductsFromSalesChannelsStep`
- Add `removeProductsFromSalesChannelsWorkflow`
2024-04-02 13:38:33 +00:00
Oli Juhl 9fdced2c27 feat: Admin V2 users domain (#6844) 2024-04-01 15:03:48 +02: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
Oli Juhl d97af91a8d feat(admin-next): Email password invite flow in admin 2.0 (#6821) 2024-03-29 08:05:11 +01:00
Oli Juhl ea8d9d4d42 feat: API key sales channel link (#6851)
What
- Add link between API key and sales channels
- Add API route for batch adding sales channels to a publishable API key
- Clean up API key API routes responses
- Move API key test suite from `integration-tests/modules` to `integration-tests/api`
2024-03-28 10:15:11 +00:00
Oli Juhl 0b23e7efb8 feat: Support invites in CLI for V2 (#6798)
**What**

- Add invite support to cli for 2.0
- Allow email to be passed upon accepting an invite
2024-03-26 20:02:56 +00:00
Oli Juhl a843b121cd chore: Change minor bump to patch in changesets (#6826) 2024-03-26 12:45:44 +01:00
Oli Juhl ef58826dd2 fix(admin-ui, admin): Add missing regions relation (#6824) 2024-03-26 11:37:21 +01:00
Oli Juhl 7bc7adeeb4 feat: Create user account (#6819) 2024-03-26 10:07:38 +01:00
Oli Juhl 0deb2776ad feat: Add successRedirectUrl to auth options (#6792) 2024-03-25 08:55:21 +01:00
Oli Juhl 9e25e0c42e feat: List products middleware (#6769) 2024-03-22 14:59:21 +01:00
Oli Juhl 8f5d94b23a chore: Update CODEOWNERS 2024-03-21 11:23:03 +01:00
Oli Juhl 8155e2cfad feat: Init. v2 implementation in admin (#6715) 2024-03-20 14:28:28 +01:00
Oli Juhl a859b7895e docs: Upgrade guide for v1.20.3 (#6753) 2024-03-20 11:12:53 +00:00
Oli Juhl 3062605bce feat: Add products to sales channel (#6725)
Depends on #6722
2024-03-19 10:24:37 +00:00
Oli Juhl 0219a8677b feat: Sales Channels API routes + workflows (#6722)
**What**
- Admin sales channels API routes
- Workflows for creating, updating, and deleting sales channels
- Align `ISalesChannelModuleService` interface with update + upsert conventions
- Integrate v2 tests into v1 sales channels integration test suite
- Add metadata to sales channel entity

Sales channel <> Product management will come in a follow-up PR.

On the integration tests, creating, updating, and deleting are passing with the V2 flag enabled. You'll have to take my word for it (or run them yourself), as they are not included in the CI.
2024-03-18 20:57:29 +00:00
Oli Juhl 1eb90f739b chore: Update version bump from minor to patch (#6699) 2024-03-14 21:19:55 +01:00
Oli Juhl 8f8a4f9b13 chore: Bump all modules (#6700) 2024-03-14 21:11:12 +01:00
Oli Juhl 02e784ce78 feat: Confirm inventory in create cart workflow (#6635) 2024-03-13 18:24:08 +01:00
Oli Juhl 5f6d128613 chore: Update CODEOWNERS (#6682)
Prepare CODEOWNERS file for reviewer auto-assignment by isolating the ownership of the engineering team to packages. Without this, the team would be asked to review docs PRs too.
2024-03-13 12:52:16 +01:00
Oli Juhl 25d176b851 feat: List shipping options for cart (#6677) 2024-03-13 09:08:47 +00:00
Oli Juhl db26dafa85 chore: Use module test runner in Carts API test suite (#6679)
Nothing but migrating to our new module test runner. Hopefully, that'll make the actual test PRs easier to digest.
2024-03-13 07:32:58 +00:00
Oli Juhl f0c8142635 feat: Add shipping method to cart (#6661) 2024-03-12 17:52:48 +01:00
Oli Juhl e82b4788ec fix(fulfillment): Fulfillment set file name typo (#6671) 2024-03-12 10:08:39 +01:00
Oli Juhl c51a67a421 feat: Add payment + promotion refreshing to cart workflows (#6654)
Add payment collection refreshing to:
- Add to cart
- Create cart
- Update line item in cart

Add promotion creation to:
- Create cart
2024-03-11 12:32:41 +00:00
Oli Juhl 4136b9da5f feat: Add Sales Channel Stock Location link (#6634) 2024-03-08 15:26:26 +01:00
Oli Juhl 272fb6d328 fix(tests): Cart links (#6628)
Not sure how this test snuck past our CI check, but this fixes it :)
2024-03-08 11:12:05 +00:00
Oli Juhl badfb7c819 test: Introduce V2 tests in Admin Payments API (#6621) 2024-03-08 09:04:57 +01:00
Oli JuhlandAdrien de Peretti 8c57e61cb8 feat: Refresh payment collection + delete session (#6594)
### What
Add workflow for refreshing a payment collection. 

The idea is that on all cart updates, we want two things to happen (in the context of payments) 1. the currently active payment sessions should be destroyed, and 2. the payment collection should be updated with the new cart total.

We do this to ensure that we always collect the correct payment amount. 

From a customer perspective, this would mean that every time something on the cart is updated, the customer would need to enter their payment details anew. 

To me, this is a good tradeoff to avoid inconsistencies with payment collection.

Additionally, I updated the Payment Module interface with `upsert` and `updated` following our established convention.

### Note
This PR depends on a fix to the `remoteJoiner` that @carlos-r-l-rodrigues is working on.

Update: Fix merged in #6602 

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-03-07 13:32:20 +00:00
Oli Juhl a516e7bcba chore: Use new test runner in admin payments API (#6611)
No changes to the tests. Only replacing the test runner.

Awaiting #6610
2024-03-07 12:51:59 +00:00
Oli Juhl e5cbe28d54 feat: Refund payment (#6610)
Essentially the same as #6601 but for refunds
2024-03-07 12:34:36 +00:00
Oli Juhl 3d0da980cf feat: Capture payment (#6601)
* feat: Capture payment

* add amount to workflow input
2024-03-07 11:02:26 +01:00
Oli Juhl a5a2395622 chore: Revert #6548 (#6598)
Until a more elegant solution for allowing contributor forks to run workflows, we need to revert to using a plain text pg password
2024-03-06 13:41:53 +00:00
Oli Juhl 7d69e6068e feat: Region PaymentProvider link (#6577)
**What**

- Introduce link between Region and PaymentProvider
- Introduce API endpoint `GET /store/regions/:id/payment-providers` for retrieving providers by region
- Add tests for both
2024-03-05 09:40:25 +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
Oli Juhl 883cb0dca7 feat: Add payment collection creation for cart (#6527) 2024-03-04 09:02:01 +01:00
Oli Juhl 55275f0eba chore(actions): Use PG pass secret (#6548) 2024-02-29 22:10:56 +01: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 296d7faad4 chore: V2 core loader + modules integration-tests (#6544) 2024-02-29 16:46:30 +01:00
Oli Juhl c5d35ec7f2 chore(cart): Use module native soft-delete/delete methods (#6491) 2024-02-28 10:45:56 +00:00
Oli Juhl 70aeb602c9 feat(payment): Add migration (#6509) 2024-02-27 19:05:52 +01:00
Oli Juhl 3ee0f599c1 feat: Line Items API Routes (#6478)
**What**
- `POST /store/carts/:id/line-items`
- `POST /store/carts/:id/line-items/:id`
- `DELETE /store/carts/:id/line-items/:id`

**Outstanding**
- Integration tests
- Module integrations: Payment, Fulfillment, Promotions

Depends on #6475 and #6449.
2024-02-27 12:47:00 +00:00
Oli Juhl ce39b9b66e feat(payment, payment-stripe): Add Stripe module provider (#6311) 2024-02-26 19:48:15 +01:00
Oli JuhlandAdrien de Peretti 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
Oli Juhl d9636f4631 chore(cart): Make all cart entities soft-deletable (#6475) 2024-02-23 08:59:02 +01: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
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
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
Oli Juhl 1ed5f918c3 feat(cart): POST /store/carts/:id (#6274)
Depends on:
- #6262 
- #6273
2024-02-14 15:03:02 +00:00
Oli Juhl 7ce15916ca feat(region): Create region with countries (#6372) 2024-02-14 12:48:43 +01:00
Oli Juhl ae79ff46f4 feat(region): Add store region get + list endpoints (#6342) 2024-02-13 15:29:29 +01:00
Oli JuhlandAdrien de Peretti 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
Oli Juhl 82c728bec7 feat(medusa): Allow configuring of staged job polling batch size (#6333) 2024-02-07 10:35:49 +01:00
Oli Juhl e2cb72efd8 feat(region): Add migration (#6320) 2024-02-06 19:58:16 +01:00
Oli Juhl 823b98aaa1 feat: Region Module (basic CRUD) (#6315) 2024-02-05 16:03:26 +00:00
Oli Juhl ede221d4f7 feat(cart): POST /store/carts (#6273)
Depends on #6262
2024-02-05 15:15:15 +00:00
Oli Juhl 3a103f0c36 feat(modules-sdk): Module provider plugin loader (#6286) 2024-02-01 17:03:31 +01:00
Oli Juhl d5e4707084 feat(medusa): Use remote query in get cart API route (#6285) 2024-01-31 19:20:48 +01:00
Oli Juhl 374b9b1fee feat(cart): GET /store/carts/:id (#6262) 2024-01-30 12:52:54 +01:00
Oli Juhl 1c27f7cb34 chore(cart): Clean up data models (#6256)
Clean up data models in Cart Module according to latest established conventions
2024-01-29 18:22:13 +00:00
Oli Juhl c15438c744 feat(cart): Migration file (#6156)
* feat(cart): Migration file

* fixup migration

* Add indexes on cart table for currency, region, and sales channel

* fix indexes

* address PR comments
2024-01-29 12:49:48 +01:00
Oli Juhl 8f9a12c895 chore: PR team labeler (#6249) 2024-01-29 08:11:39 +01:00
Oli Juhl 5c4a5a1454 feat(cart): JoinerConfig (#6157) 2024-01-28 11:10:40 +01:00
Oli Juhl 489b7effb0 fix(medusa): Support q search in currencies (#6201)
Closes #6175
2024-01-24 12:31:17 +00:00
Oli Juhl 8ad7539ebc fix(medusa): Support q search and order in list regions (#6202) 2024-01-24 12:52:39 +01:00
Oli Juhl 2b35700dbc feat(cart): Item tax lines + shipping method tax lines (#6136) 2024-01-24 11:42:27 +00:00
Oli Juhl fd78f5e242 feat(cart): Shipping method adjustments (#6119) 2024-01-22 11:29:20 +01:00
Oli Juhl 06b33a9b45 feat(cart): Line item adjustments (#6112) 2024-01-22 09:55:47 +01:00
Oli Juhl b132ff7669 feat(cart): Add line items in cart-creation (#6114) 2024-01-18 14:39:40 +01:00
Oli Juhl 7f7cb2a263 feat(cart): Shipping methods (#6101) 2024-01-18 12:16:15 +01:00
Oli Juhl 4d1653b4e7 chore: Update CODEOWNERS 2024-01-17 11:03:16 +01:00
Oli Juhl cc6a1a8d7c chore: Update CODEOWNERS 2024-01-17 10:32:01 +01:00
Oli Juhl 90328ca02b chore: Update CODEOWNERS 2024-01-16 17:38:12 +01:00
Oli Juhl a5e8bf06c6 feat(cart): Line items operations (#6066) 2024-01-16 15:44:49 +01:00
Oli Juhl 192bc336cc feat(cart): Partial module service implementation (#6012)
Awaiting #6000 #6008  

**What**
- CRUD for Address in Cart Module service
- Tests for CRUD Carts + Address

**Not**
- Line items, shipping methods, tax lines, adjustment lines
2024-01-12 10:30:57 +00:00
Oli Juhl ce81cade88 feat(cart): Cart + Address services (#6055)
Duplicate of #6008, but I messed up my git history big time :'(

**What**
- CartService and CartRepository + tests
- AddressService and AddressRepository + tests
- CartModuleService skeleton. Full implementation + tests will be added in a separate PR
2024-01-11 14:40:13 +00:00
Oli Juhl ef5024980d feat(cart): Public-facing DTOs + (partial) module interface (#6000) 2024-01-10 13:27:58 +01:00
Oli Juhl b57ad67d2f feat(cart): Data models (#5986)
**What**
Adds Cart Module data models
2024-01-05 17:32:36 +00:00
Oli Juhl 99a4f94db5 feat(medusa-payment-stripe): Add delay to Stripe webhook (#5838)
**What**
- Migrate Stripe plugin to use API Routes + Subscribers
- Change the behaviour of Stripe webhook
Instead of processing webhook events immediately, we fire an event to perform the work in the background. The primary reason for changing the webhook is that the previous implementation led to occasional conflicts due to a race condition between the client's and the webhook's request to complete a cart. Now, we emit an event with a configurable delay (defaults to 2s) to prevent this from happening

This approach was preferred over adding a timeout directly to the webhook execution, as it is generally best practice to respond to a webhook event immediately after receiving it.
2024-01-05 12:37:53 +00:00
Oli Juhl cd2855182e docs: Update minimum node version requirement (#5994) 2024-01-04 13:13:41 +01:00