Commit Graph

1129 Commits

Author SHA1 Message Date
Frane Polić
259d050e53 feat: customer bulk endpoint form managing customer groups (#9761)
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2024-10-25 11:55:57 +02:00
docloulou
bb6d7c6641 feat: Allow customer metadata update (#9780)
* Allow customer metadata update 

See issue 9779
https://github.com/medusajs/medusa/issues/9779

* add integration tests for customer metadata

- Implemented integration tests to verify customer creation with metadata.
2024-10-25 11:28:34 +02:00
Adrien de Peretti
f295596df2 fix(orchestration): Ids wrongly processed when using operators map (#9781)
* fix(orchestration): Ids processing when using operators map

* fix(orchestration): Ids processing when using operators map

* address feedback

* address feedback
2024-10-25 11:10:35 +02:00
olivermrbl
2fbebb60e3 chore: Release 2024-10-22 20:43:47 +02:00
Oli Juhl
c3418a2b93 chore: Prepare versions + changeset (#9707)
* chore: Prepare version + changeset

* chore: Bump dependencies

* chore: Update lock-file
2024-10-22 20:31:33 +02:00
Riqwan Thamir
d1ce6d4321 Revert "feat(core-flows,medusa): Add customer validation on cart update" (#9724) 2024-10-22 18:26:01 +00:00
Adrien de Peretti
6b989353ac fix: API validation management issues (#9693)
**What**
Currently, the API validation layer is broken in both responsibilities and validation itself.
This pr introduce the following fixes and patterns:
- Always create a `*Fields` schema that only takes care of defining the schema validation without `effect`
- Use the previous point into the API schema validator including `$and` and `$or` capabilities plus the recursive effects
- remove `normalizeArray` which does not have to exists since array are already treated as they should
- Add recursive transformation to take into account `$and` and `$or` as well or any other similar operators
- New util `applyAndAndOrOperators` to wrap the management of those operators and to be merged to an existing schema

Tasks
- [x] store domain
- [ ] admin domain
2024-10-22 15:16:36 +00:00
Riqwan Thamir
0d803b3f2d feat(core-flows,medusa): Add customer validation on cart update (#9662) 2024-10-22 12:19:12 +02:00
Carlos R. L. Rodrigues
6fa98b6a4d chore(orchestration): modules method context (#9669)
** What **
* Test to check if the MedusaContext is being injected when calling a Module's method
2024-10-18 21:08:06 +00:00
Christian
a0b747e117 feat: allow html content for notifications (#9613)
* feat: allow passing provider specific metadata to notification module

* changed providerContext to snake cased

* rename provider_context to content
2024-10-18 11:36:22 +02:00
Carlos R. L. Rodrigues
2a98be6b65 feat(medusa): ordem items endpoint (#9646) 2024-10-18 05:59:24 -03:00
Carlos R. L. Rodrigues
902ac12f73 chore: remove internal module resources option (#9582)
What:
* removes resouces type "shared" or "isolated" from internal modules.
* modules can have an isolated database connection by providing a database config as part of their options on `medusa-config`

CLOSES: FRMW-2593
2024-10-17 21:31:46 +00:00
Riqwan Thamir
3b50c6d019 feat(core-flows,types,medusa): Add tax region update API (#9634)
* feat(core-flows,types,medusa): Add tax region update API

* chore: added specs
2024-10-17 14:19:29 +02:00
Oli Juhl
0be50059f2 fix: Add free text search on reservations (#9621) 2024-10-17 10:21:24 +02:00
Harminder Virk
68560787e5 breaking: rename package names to be consistent and under @medusajs scope (#9580) 2024-10-16 22:28:09 +05:30
Carlos R. L. Rodrigues
4a03bdbb86 feat(providers): locking redis (#9544) 2024-10-15 12:40:24 -03:00
Riqwan Thamir
537567b679 chore: add compare_at_unit_price when price list price is retrieved (#9564)
* chore: add compare_at_unit_price when price list price is retrieved

* chore: add test for update item + more fixes along the way

* chore: fix tests

* chore: add refresh spec

* Apply suggestions from code review

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>

* chore: use undefined checker

* chore: switch to map

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
2024-10-15 13:05:14 +02:00
Frane Polić
48cc00e991 feat(core-flows, product): options checks on product create/update (#9171)
**What**
- validate that variants are unique with respect to options on product update/create and variant update/create
- validate that the product has options upon creation
- ensure variants have the same number of option values as the product has options
- admin error handling
- update tests

---

FIXES FRMW-2707 CC-556
2024-10-15 09:06:51 +00:00
Frane Polić
809c851865 fix(core-flows, link-module): product <> inventory delete cascades (#9528)
**What**
- remove cascade delete of inventory items on product delete
- implement inventory deletion in product/variant delete workflows with checks:
  - product/variant cannot be deleted if there are reservations associated with their inventory items
  - inventory item will be cascade deleted if it's not used by other variants (that are not being deleted in the current flow)

---

FIXES CC-581 CC-582
2024-10-14 16:22:31 +00:00
Oli Juhl
43324b9294 fix: Add shipping method data validation (#9542)
* fix: Add shipping method data validation

* fix: return type
2024-10-14 12:55:01 +02:00
Adrien de Peretti
1d8939df3a chore(): Allow to register modules through array (#9522) 2024-10-11 15:17:00 +02:00
Adrien de Peretti
34d57870ad chore: workflow internals improvementss (#9455) 2024-10-10 09:11:56 +02:00
Harminder Virk
1560d7ed5f breaking: Standalone builds (#9496)
Fixes: FRMW-2742

In this PR, we fix the build output of the backend source code, which eliminates a lot of magic between the development and production environments.

Right now, we only compile the source files from the `src` directory and write them within the `dist` directory.

**Here's how the `src` directory with a custom module looks like**

```
src
├── modules
│   └── hello
│       ├── index.ts
```

**Here's the build output**

```
dist
├── modules
│   └── hello
│       ├── index.js
```

Let's imagine a file at the root of your project (maybe the `medusa-config.js` file) that wants to import the `modules/hello/index` file. How can we ensure that the import will work in both the development and production environments?

If we write the import targeting the `src` directory, it will break in production because it should target the `dist` directory.

## Solution
The solution is to compile everything within the project and mimic the file structure in the build output, not just the `src` directory.

**Here's how the fixed output should look like**

```
dist
├── src
│  ├── modules
│  │   └── hello
│  │       ├── index.js
├── medusa-config.js
├── yarn.lock
├── package.json
```

If you notice carefully, we also have `medusa-config.js`, `yarn.lock`, and `package.json` within the `dist` directory. We do so to create a standalone built application, something you can copy/paste to your server and run without relying on the original source code.

- This results in small containers since you are not copying unnecessary files.
- Clear distinction between the development and the production code. If you want to run the production server, then `cd` into the `dist` directory and run it from there.

## Changes in the PR

- Breaking: Remove the `dist` and `build` folders. Instead, write them production artefacts within the `.medusa` directory as `.medusa/admin` and `.medusa/server`.
- Breaking: Change the output of the `.medusa/server` folder to mimic the root project structure.
- Refactor: Remove `Symbol.for("ts-node.register.instance")]` check to find from where to load the source code.
- Refactor: Use `tsc` for creating the production build. This ensures we respect `tsconfig` settings when creating the build and also perform type-checking.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-09 15:59:08 +00:00
Sebastian Rindom
aeaedc8539 fix: add metadata to collection resp (#9514)
**What**
- Adds `metadata` to the default response for `/admin/collection` endpoints.
- Fixes tests to expect correct shape and not use objectContaining.

Fixes CC-551
2024-10-09 15:52:59 +00:00
Sebastian Rindom
7ec174309a fix: add metadata to product type resp (#9515) 2024-10-09 16:22:51 +02:00
Oli Juhl
853187410e fix(product): Always add q if defined (#9505) 2024-10-09 11:52:02 +02:00
Carlos R. L. Rodrigues
8fbef8a667 fix(order): searchable fields (#9493)
FIXES: TRI-353
2024-10-07 17:45:20 +00:00
Oli Juhl
67e08dc989 fix(payment): Capture payment (#9469)
What
- Add missing `captured_at` field to payment retrieval
- Properly delete Medusa captures in case 3rd party capture call fails
2024-10-04 15:15:10 +00:00
Oli Juhl
f7472a6fa6 fix: Idempotent cart completion (#9231)
What
- Store result of cart-completion workflow for three days by default
  - This enables the built-in idempotency mechanism to kick-in, provided the same transaction ID is used on workflow executions
- Return order from cart-completion workflow if the cart has already been completed
  - In case transaction ID is not used on workflow executions, we still only want to complete a cart once
2024-10-04 12:01:09 +00:00
Oli Juhl
6055f4c9cf fix: If country on cart has no tax region, clear tax lines (#9447)
**What**

If the country on the shipping address changes to a country without an associated tax region, we clear the tax lines on shipping methods and line items.
2024-10-04 11:55:53 +00:00
Oli Juhl
a114f90358 fix: Handle region updates on cart (1/n) (#9369)
**What**

On cart creation:
- If region only has one country -> create cart with country code

On cart updates:
- If shipping address country code is provided in input ->
  - If cart region doesn't include that country -> throw
  - If cart includes the country -> update shipping address
- If region is provided in input and is different from the one currently on the cart -> 
  - If there is a shipping address on the cart -> clear the address
    - If the region only has one country -> set country code of address
  - If there is not a shipping address on the cart ->
    - If the region only has one country -> set country code of address


Closes CC-545
2024-10-04 11:33:36 +00:00
Adrien de Peretti
225d00cd09 chore: improve mikro orm serializer circular ref and link serialization (#9411) 2024-10-03 08:22:11 +02:00
Riqwan Thamir
fbbfb0cb62 feat(framework,medusa): Ensure publishable key middleware is set for all store endpoints (#9429)
* feat(framework,medusa): Ensure publishable key middleware is set for all store endpoints

* chore: fix tests
2024-10-02 18:01:50 +02:00
Oli Juhl
732f64177d fix: Validate identifier payload for reset password (#9302)
Closes CC-526
2024-10-01 13:30:23 +00:00
Oli Juhl
8851ae7b51 fix: Update tax lines on cart when region changes (#9367)
**What**
- Removes broken cart retrieval step `retrieveWithCartLinks` in favor of `useRemoteQueryStep` in `updateTaxLinesWorkflows`

**Why**
- Filters variables in the step were passed with an incorrect shape
  - I removed the step, since it's only used once and the behavior is identical to the generic remote query step

**Note**
- Because the filters were passed incorrectly, the, now-removed, step has always returned the first cart in the database. As a result all tax calculations so far have been based on whatever the shape of that cart has. It basically ignores all input to this workflow
2024-09-30 11:55:54 +00:00
Sebastian Rindom
852df3f764 fix(medusa,dashboard): don't send price updates for deleted regions/currencies (#9361)
**What**
- Fixes an issue where the admin dashboard would send region prices for deleted regions.
- Also, includes the implementation for `GET /admin/shipping-options/:id` and its corresponding SDK function.

**Why**
- When a region price for a deleted region was sent to the backend it would result in the insert hitting a not null constraint on the currency_code for prices. To avoid this the dashboard should not send region prices for deleted regions. 

**Additional context**
- Prices for deleted regions should ideally not be returned when fetching shipping option prices. However, we don't yet have a mechanism for cleaning up region prices after a region is deleted.

Fixes CC-540
2024-09-30 11:51:55 +00:00
Adrien de Peretti
7e73fe4794 chore: Improve jest config and deps (#9318) 2024-09-30 10:50:59 +02:00
Harminder Virk
a578313db9 feature: bundle all modules (#9324) 2024-09-30 09:04:03 +02:00
Oli Juhl
1b4372ae71 fix: Tax region + rates clean up (#9279)
What
- Require `code` on Tax Rates
- Update dashboard to account for non-nullable code on Tax Rates

- Include `automatic_taxes` in API Route response

Closes CC-524 CC-525
2024-09-29 10:25:33 +00:00
Sebastian Rindom
0efbcd2344 fix: validate regions exist for shipping option price update (#9364)
**What**
- Adds a step to `updateShippingOptionsWorkflow` and `createShippingOptionsWorkflow` that validates if the region prices being updated have corresponding regions configured.

**Why**
- Previously, if you tried to send a region price update for a region that had been deleted the backend would throw an error when attempting to insert the region price. The error comes from a not-null constraint in the db, but it is better to validate that the regions we are trying to create prices for exist. 

Fixes CC-542
2024-09-29 09:52:16 +00:00
Sebastian Rindom
17b2868a50 feat(medusa,fulfillment): pass stock location data to fulfillment provider (#9322)
**What**
- Fetches the stock location's details when creating a fulfillment and return fulfillment.
- Passes the data to the fulfillment module, which in turn passes it to the fulfillment provider.

**Why**
- When creating a fulfillment in a multi-location setup the fulfillment provider will need to know where the package is being sent from (so the shipping service can pick it up). 
- Previously, we didn't pass anything but the location id to the fulfillment provider. Because the fulfillment provider can't have a dependency on the stock location module this was not sufficient. 
- This change ensures there is enough data passed to the fulfillment provider to build integrations properly.
2024-09-28 14:01:48 +00:00
Carlos R. L. Rodrigues
19bc8d7f61 fix(core-flows): shipping options for cart (#9343)
FIXES: CC-536

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
2024-09-27 12:32:32 +00:00
Adrien de Peretti
38778b37e2 fix: remove dist access for modules in integration tests (#9336) 2024-09-27 09:11:03 +02:00
Adrien de Peretti
a8e19faf8d chore: use framework sub paths everywhere (#9253) 2024-09-26 16:38:38 +05:30
Adrien de Peretti
ae320ac73f fix: base tsconfig (#9309)
* fix: base tsconfig

* WIP

* wi[]

* update integration typescript version

* update lock file

* fix deps

* fix medusa tests runner
2024-09-25 16:31:57 +02:00
Stevche Radevski
7c4960a4d1 fix: Add actor type to password reset event (#9301) 2024-09-25 12:26:45 +02:00
Adrien de Peretti
802f204d31 fix(orchestration): Throw if not exists using filters (#9275) 2024-09-24 17:12:04 +02:00
Carlos R. L. Rodrigues
b4b1a48987 feat(utils): define read only link (#9254) 2024-09-24 12:00:38 -03:00
Riqwan Thamir
69f6645716 feat(core-flows,dashboard,types,fulfillment,medusa): uses requires shipping throughout lifecycle (#9170)
what:

- uses requires shipping throughout lifecycle

https://github.com/user-attachments/assets/d5ba89d3-5ea0-49c4-b2d5-490c4764933e
2024-09-24 08:26:22 +00:00
Adrien de Peretti
3084008fc9 feat(index): Provide a similar API to Query (#9193)
**What**
Align the index engine API to be similar to the Query API

## Example

```ts
        // Benefit from the same level of typing like the remote query

        const { data, metadata } = await indexEngine.query<'product'>({
          fields: [
            "product.*",
            "product.variants.*",
            "product.variants.prices.*",
          ],
          filters: {
            product: {
              variants: {
                prices: {
                  amount: { $gt: 50 },
                },
              },
            },
          },
          pagination: {
            order: {
              product: {
                variants: {
                  prices: {
                    amount: "DESC",
                  },
                },
              },
            },
          },
        })
```
2024-09-20 10:02:42 +00:00