Commit Graph
100 Commits
Author SHA1 Message Date
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
Oli Juhl 1468646b99 chore(workflows): Use Node 16.14 in CLI workflow (#5993)
* make packages private

* add changeset

* Update test-cli-with-database.yml

* revert
2024-01-04 08:40:45 +01:00
Oli Juhl 925feea04a feat(cart): Add cart module package (#5982)
* feat: Add CartModule foundation

* remove migration

* fix ts issue

* Create hot-dingos-pay.md
2024-01-02 15:59:23 +01:00
Oli Juhl 487067fb48 fix(medusa): Resolve babel executable with npx (#5952) 2024-01-02 10:13:54 +01:00
Oli Juhl f25ca30b3a fix(medusa, medusa-js): publishable api key bugs (#5926)
* fix: publishable api key bugs

* Create old-meals-run.md
2023-12-20 12:57:13 +01:00
Oli Juhl 428331a653 feat(medusa): Respond with order when cart is already completed (#5766) 2023-12-01 09:17:12 +01:00
Oli Juhl 02e2ee4e8a docs: cache-redis breaking changes (#5590)
* docs: cache-redis breaking changes

* remove section
2023-11-10 11:00:22 +01:00
Oli Juhl 65639cb8c1 fix(integration-tests): Add missing deps + timeout to repos test (#5506) 2023-10-31 12:18:55 +01:00
Oli Juhl 397da6c2ba fix(admin-ui): TIP in shipping option creation (#5356)
* fix(admin-ui): TIP in shipping option creation

* Create six-pigs-return.md
2023-10-30 15:17:34 +01:00
Oli Juhl 8f5b5b51a9 chore: Ignore markdown + yaml in repo language scan (#5486) 2023-10-30 09:19:39 +01:00
Oli Juhl ebba93e03d fix(medusa): Revert status type in API (#5428) 2023-10-26 08:11:01 +02:00
Oli Juhl a0963f0edf fix(admin-ui): Remove t() on product.status update (#5394)
* fix(admin-ui): Remove t() on product.status update

* Create tidy-games-drum.md
2023-10-18 13:50:47 +02:00
Oli Juhl 9c362f7214 chore(integration-tests): Add jest timeout to workflow tests (#5401) 2023-10-18 08:45:50 +02:00
Oli JuhlandPhilip Korsholm 3b45fdf135 fix(admin-ui): Create analytics if FF is enabled (#5367)
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
2023-10-16 08:01:39 +02:00
Oli Juhl d45e3e83d3 docs: v1.17.0 upgrade guide (#5254)
* docs: Add v1.17.0 upgrade guide

* Use note
2023-09-29 14:40:04 -04:00
Oli JuhlandKasper Fabricius Kristensen a9972d7d6f fix(medusa-react): @medusajs/medusa-js import (#5207)
* fix(medusa-react): @medusajs/medusa-js import

* Create short-wolves-breathe.md

---------

Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>
2023-09-26 16:27:50 -04:00
Oli Juhl adb6fb3f7d fix(admin-ui): Allow nullish values in update variant (#5173)
* fix(admin-ui): Allow nullish values in update variant

* Create moody-poems-carry.md
2023-09-22 11:34:54 +02:00
Oli Juhl 78b50ac0c4 fix(admin-ui): Add hook to customer group table (#5163)
* fix(admin-ui): Add hook to customer group table

* Create many-trains-sort.md
2023-09-20 18:40:51 +02:00
Oli Juhl ef2a12e451 fix(admin-ui): Undefined vars in admin (#5162)
* fix(admin-ui): Undefined vars in admin

* Create short-hairs-fold.md
2023-09-20 17:03:47 +02:00
Oli Juhl 54531e38bc fix(admin-ui): Patch admin path issue (#5154) 2023-09-20 16:31:15 +02:00
Oli Juhl 299b98c401 fix(admin-ui): Wraps invite route correctly with analytics (#5118) 2023-09-18 18:07:54 +02:00
Oli Juhl 8772a0722e fix(admin-ui): Wrap invite route in AnalyticsProvider (#5111)
* fix(admin-ui): Wrap invite route in AnalyticsProvider

* Create nervous-keys-impress.md
2023-09-18 15:25:12 +02:00
Oli JuhlandShahed Nasser 5bd7311393 docs: Add upgrade guide for 1.16.0 (#5051)
* docs: Add upgrade guide for 1.16.0

* Update www/docs/content/upgrade-guides/medusa-core/1-16-0.md

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>

* Update www/docs/content/upgrade-guides/medusa-core/1-16-0.md

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>

---------

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-09-15 17:20:27 +02:00
Oli Juhl 2a2108fe56 fix(admin-ui): Case sensitive locale detection in prod (#5082)
* fix(admin-ui): Admin path in i18n

* lowercase locale
2023-09-15 17:08:01 +02:00
Oli Juhl a7459029fe chore(admin-ui): Add pt-BR to supported languages (#5080) 2023-09-15 15:23:17 +02:00
Oli JuhlandKasper c722440c30 fix(admin-ui): Load translations from path (#5064)
* fix(admin-ui): Load translations from path

* Create big-oranges-battle.md

* fix: resolve public folder path in dev

---------

Co-authored-by: Kasper <kasper@medusajs.com>
2023-09-15 13:19:24 +02:00
Oli Juhl dc94f053d3 fix(medusa): Support fields param in list-variants (#5053)
* fix(medusa): Support fields param in list-variants

* Create cuddly-pigs-tease.md

* address pr comments
2023-09-15 09:08:04 +02:00
Oli Juhl d4432dd183 feat(admin-ui): Add display name + pull supported languages from config (#5028) 2023-09-13 09:45:26 +02:00
Oli JuhlandShahed Nasser c2423cf715 docs: Add 1.2.0 upgrade guide for Product Module (#4981)
* docs: Add 1.2.0 upgrade guide for Product Module

* Update docs/content/upgrade-guides/modules/product/1-2-0.md

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>

* Update docs/content/upgrade-guides/modules/product/1-2-0.md

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>

* Address pr comments

* address pr comments

* fix lint issue

---------

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-09-08 14:38:16 +02:00
Oli Juhl d3d8f0bf58 chore(admin, medusa-payment-stripe): Fix deps (#4987) 2023-09-08 13:55:03 +02:00
Oli Juhl 17d91c276a feat(medusa): Add AbstractFulfillmentService (#4922)
* feat(medusa): Add abstract fulfillment service

* add data types

* add loaders

* Create nine-glasses-allow.md

* address pr comments
2023-09-03 20:05:36 +02:00
Oli Juhl 4897040c92 fix(ci): Increase memory allocation for plugin tests (#4898) 2023-08-29 11:58:17 +02:00
Oli Juhl af09a4b7b4 fix(medusa-file-*): Add types as devDeps (#4871) 2023-08-27 16:32:59 +02:00
Oli JuhlandShahed Nasser ae6dd17ca8 chore: v1.15.0 upgrade guide (#4862)
* chore: v1.15.0 upgrade guide

* Update 1-15-0.md

* eslint fixes

---------

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-08-25 17:04:38 +02:00
Oli Juhl f28fa6a7b3 chore(admin): Add caret range to peer deps (#4865) 2023-08-25 16:07:43 +02:00
Oli Juhl 16249ec280 fix(actions): Disable OAS unit tests + add flags to test commands (#4767)
* wip

* skip models test

* ignore plugins loader test
2023-08-15 14:32:58 +02:00
Oli Juhl 1d2637572b chore: Remove rimraf from prepare (#4741) 2023-08-11 22:55:59 +02:00
Oli Juhl 9469063f64 fix(medusa-js): return type of collection hook + export (#4747) 2023-08-11 13:37:54 +02:00
Oli Juhl 86c314eb2a chore: Update FUNDING.yml 2023-08-09 10:28:53 +02:00
Oli Juhl df3b0c673a chore: Update FUNDING.yml 2023-08-09 10:26:22 +02:00
Oli Juhl a2d7540e40 fix(medusa): Remove shipping on updates to cart.items (#4715)
* rm shipping on line item updates

* Add tests

* remove verbose flag

* Create real-items-rhyme.md
2023-08-08 14:53:47 +02:00
Oli Juhlandcarlos-r-l-rodrigues d1e298f5dc chore: Remove FlagRouter from core (#4710)
* Allow nested feature flags

* clean up

* Create loud-wombats-shave.md

* add warning

* Add more tests

* Address PR comments

* add back boolean check

* Replace core flag router with utils one

* lol - actually remove it

* Create eleven-doors-roll.md

---------

Co-authored-by: carlos-r-l-rodrigues <rodrigolr@gmail.com>
2023-08-08 13:05:50 +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
Oli Juhl bb534e0453 fix(admin-ui): Customer Groups in Pricing + TIP (#4670)
* Use NextSelect

* Ensure boolean value of includes taxa

* Create thin-kings-grab.md
2023-08-02 13:45:27 +02:00
Oli Juhl 6e4d160251 docs: Upgrade guide for 1.13.0 (#4614) 2023-07-27 15:52:24 +00:00
Oli Juhl f561601bf6 fix(admin): Exclude prices from PriceLists overview (#4536)
* fix(admin): Exclude Prices from PriceLists overiew

* Create polite-vans-hide.md
2023-07-27 08:45:54 +02:00
Oliver Windall Juhl aab890174d fix(admin-ui): Add missing SO relation (#4594)
* fix(admin-ui): Add missing SO relation

* Create hungry-carrots-bathe.md
2023-07-25 17:28:21 +02:00
Oliver Windall Juhl 221f62dc4c fix(admin-ui): Omit PriceList prices from variant update (#4552)
* fix(admin-ui): Omit PriceList prices from variant update

* Create poor-insects-complain.md
2023-07-19 13:44:15 +02:00
Oliver Windall Juhl 4e2e58881a chore: Update CONTRIBUTING.md 2023-07-16 21:00:18 +02:00
Oliver Windall Juhl fe6586e560 fix(medusa-plugin-sendgrid): Use correct SendGrid client (#4524)
* fix(medusa-plugin-sendgrid): Use correct SendGrid instance

* Create loud-fans-own.md

* Adds tests

* Use logger
2023-07-13 14:23:07 +02:00
Oliver Windall Juhl cfd3e396cf chore(workflows): Force Node v16.10 version in CI (#4523) 2023-07-13 08:42:43 +02:00
Oliver Windall Juhl 708a55199a fix(medusa-js): Remove unused options from tsconfig (#4501)
* fix(medusa-js): Update ambigious type export

* Create ninety-hornets-drive.md

* Add to import too

* Revert + update tsconfig
2023-07-11 14:54:04 +02:00
Oliver Windall Juhl 78a1f3943b chore(admin-ui): Remove new badges from inventory + categories (#4444)
* chore(admin-ui): Remove new badges from inventory + categories

* Create early-poets-drum.md
2023-07-10 12:23:27 +02:00
Oliver Windall Juhl 85eb12883e feat(medusa): Improve error messaging in plugin loader (#4410)
* feat(medusa): Improve error messaging in plugin loader

* Create fair-kids-tease.md

* pr comments

* pr comments
2023-06-26 13:33:40 +02:00
Oliver Windall Juhl 579fcb8cd6 chore: Update issue template 2023-06-26 10:41:36 +02:00
Oliver Windall Juhl 14bfe6d514 add @medusajs/product readme (#4368) 2023-06-21 11:28:54 +02:00
Oliver Windall Juhl 9b42387fd3 chore: Add missing deps (#4317) 2023-06-15 18:27:31 +02:00
Oliver Windall Juhl afd1b67f1c chore: Clean up deps, devDeps, and peerDeps across all packages (#4276)
* chore: Use caret for all Medusa deps

* Create wild-balloons-push.md

* Address PR feedback

* force build order

* add missing dep

* add missing dev deps

* addresses last comments
2023-06-14 15:18:11 +02:00
Oliver Windall Juhl 260dc55b6f chore(medusa,medusa-cli): Clean up new command + fix CI (#4214)
* chore(workflows): Use default starter template in action

* Use postgres by default in new

* Add skip DB flag

* Create thirty-tomatoes-hug.md

* address PR comments
2023-05-31 12:38:44 +02:00
Oliver Windall JuhlandShahed Nasser f3920730dc docs: Add 1.12.0 upgrade guide (#4204)
* docs: Add 1.12.0 upgrade guide

* Add note on breaking changes

* added new action required

* eslint fixes

* Add another breaking change note

---------

Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-05-30 21:00:49 +02:00
Oliver Windall Juhl 0f87d3d642 chore(medusa,admin-ui): Add reservations FF (#4184)
* chore(medusa,admin-ui): Add reservations FF

* Create five-ways-care.md

* Tweak description
2023-05-29 22:02:01 +02:00
Oliver Windall Juhl 783c16ebf6 chore: Update local file plugin package (#4198) 2023-05-29 20:38:26 +02:00