Commit Graph

1240 Commits

Author SHA1 Message Date
github-actions[bot]
68a796d300 chore: Version Packages (#12583)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-05 20:33:53 +02:00
Carlos R. L. Rodrigues
490bd7647f fix(core-flows): complete cart improvements (#12646)
* fix(core-flows): use cartId as transactionId and acquire lock to complete cart

* fix cart update compensation
2025-05-30 14:15:08 +01:00
Shahed Nasser
3d65807d99 fix(utils): export payment events in core flows events (#12636) 2025-05-29 10:10:26 +03:00
Harminder Virk
cf0297f74a feat: implement stream based processing of the files (#12574)
Fixes: FRMW-2960

This PR adds support for processing large CSV files by breaking them into chunks and processing one chunk at a time. This is how it works in nutshell.

- The CSV file is read as a stream and each chunk of the stream is one CSV row.
- We read upto 1000 rows (plus a few more to ensure product variants of a product are not split into multiple chunks).
- Each chunk is then normalized using the `CSVNormalizer` and validated using zod schemas. If there is an error, the entire process will be aborted and the existing chunks will be deleted.
- Each chunk is written to a JSON file, so that we can process them later (after user confirms) without re-processing or validating the CSV file.
- The confirmation process will start consuming one chunk at a time and create/update products using the `batchProducts` workflow.

## Resume or not to resume processing of chunks

Let's imagine during processing of chunks, we find that chunk 3 leads to a database error. However, till this time we have processed the first two chunks already. How do we deal with this situation? Options are:

- We store at which chunk we failed and then during the re-upload we ignore chunks before the failed one. In my conversation with @olivermrbl we discovered that resuming will have to work with certain assumptions if we decide to implement it.
   - What if a user updates the CSV rows which are part of the already processed chunks? These changes will be ignored and they will never notice it.
   - Resuming works if the file name is still the same. What if they made changes and saved the file with "Save as - New name". In that case we will anyways process the entire file.
   - We will have to fetch the old workflow from the workflow engine using some `ilike` search, so that we can see at which chunk the last run failed for the given file.

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-05-29 05:42:16 +00:00
Frane Polić
9866baa852 feat(core-flows,js-sdk,medusa,types): draft order delete (#12172) 2025-05-28 14:37:00 +02:00
Frane Polić
c4dd290461 fix(core-flows): reservation management on order edit and draft order confirm (#12546) 2025-05-28 09:52:01 +02:00
Shahed Nasser
d155f492be chore(core-flows, types): change base64 comment fo files in TSDocs to binary (#12627)
* chore(core-flows, types): change base64 comment fo files in TSDocs to binary

* add in generatd
2025-05-27 18:35:39 +03:00
Shahed Nasser
528ab9f8a8 chore(types): fix example for createProductOptionValues in TSDocs and docs (#12623) 2025-05-27 12:45:21 +03:00
Harminder Virk
791276e80f feat: introduce bulkDelete method for IFileProvider (#12614)
Fixes: FRMW-2974

Currently during the product imports, we create multiple chunks that must be deleted after the import has finished (either successfully or with an error). Deleting files one by one leads to multiple network calls and slows down everything.

The `bulkDelete` method deletes multiple files (with their fileKey) in one go
2025-05-27 06:52:11 +00:00
Harminder Virk
1f5f50010a fix: expand method ALL for bodyparser config and additional validator (#12612)
Fixes: FRMW-2969
2025-05-26 10:22:26 +00:00
Shahed Nasser
7b3b4ff68a chore(core-flows): ignore hooks in complete cart workflow (#12600) 2025-05-23 18:48:46 +03:00
Harminder Virk
117fc25aea feat: run workflow hooks inside a when/then block (#11963)
* feat: run workflow hooks inside a when/then block

* fix conditionals and add test

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-05-23 09:52:18 -03:00
Harminder Virk
f6f34cc0e4 fix: module import paths to contain unix slash (#12592)
Currently when types are generated on Windows, they result in using Windows slash for relative imports. This PR, fixes that to always use Unix imports
2025-05-23 08:09:34 +00:00
Adrien de Peretti
da5e278a78 chore(modules-sdk): Log full error when a loader fail to run (#12584)
* chore(modules-sdk): Log full error when a loader fail to run

* Create blue-ties-bow.md
2025-05-22 16:54:09 +02:00
Adrien de Peretti
7685d66c07 fix(framework): Fix compiler to create the dist after clean-up (#12582)
* fix(framework): Fix compiler to create the dist after clean-up

* Create angry-stingrays-fetch.md
2025-05-22 15:30:39 +02:00
Stevche Radevski
98798f305c fix: Correctly list files for all ids that are passed (#12575) 2025-05-22 14:52:05 +02:00
github-actions[bot]
5ad3615830 chore: Version Packages (#12576)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-22 14:04:27 +02:00
Christian
ca9ffcc80b feat: add presignedUrl method to upload sdk (#12569) 2025-05-21 22:21:50 +02:00
Frane Polić
c5a6573e26 fix(product, utils): handle metadata key deletion on product update (#12478) 2025-05-21 21:32:12 +02:00
Shahed Nasser
4e49cebcf0 fix(core-flows, types): export steps and types related to credit lines (#12567)
- Export steps that are used in credit-line related workflows
- Move workflow's input type to the `workflows.ts` type file
- Add and update TSDocs
2025-05-21 19:18:29 +00:00
Shahed Nasser
e6b6c0d3b7 chore(types, utils): update TSDocs related to analytics module (#12564) 2025-05-21 14:43:09 +00:00
Frane Polić
3071d09a03 fix(core-flows): skip location check if inventory is not managed (#12540)
* fix: skip location check if inventory is not managed

* fix: rm todo

* chore: changeset
2025-05-21 15:37:43 +02:00
Shahed Nasser
db33616cf9 chore(core-flows): add tsdocs for hooks in complete cart (#12555) 2025-05-21 14:25:53 +03:00
Shahed Nasser
9f376ff1f1 fix(js-sdk): allow passing custom request body parameters in auth.register method (#12545)
The `auth.login` method of the JS SDK allows passing custom, which is useful for custom authentication providers. For example:

```ts
const response = await sdk.auth.login("customer", "phone-auth", {
      phone
    })
```

However, the `auth.register` method doesn't allow that, so we can't do the following:

```ts
const response = await sdk.auth.register("customer", "phone-auth", {
      phone
    })
```

Instead, we'd have to use the `client.fetch` method.

This PR fixes the input type of the payload passed to the `register` method to be similar to that of `login`,  which would allow using it with custom authentication providers
2025-05-20 16:27:13 +00:00
Carlos R. L. Rodrigues
ebe5cc7acd chore(index): return ids only (#12543) 2025-05-20 11:16:02 -03:00
Harminder Virk
fca5ad77b4 feat: process import from pre-processed chunks (#12527)
Fixes: FRMW-2968

In this PR we have done two major things.

- First, we remove storing CSV contents within the workflow storage and neither store the JSON payloads to be created/updated in workflows. Earlier, they all were workflow inputs, hence were stored in the workflow
- Introduce a naive concept of chunks and process chunks one by one. The next PR making chunking a bit more robust while using streams, adding ability to resume from the failed chunk and so on.

> [!IMPORTANT]  
> The new endpoint `/admin/product/imports` is not in use yet. But it will be after the next (final) PR.

## Old context in workflow storage

![CleanShot 2025-05-19 at 17 11 08@2x](https://github.com/user-attachments/assets/798bdcc9-a368-4c1f-afdd-2a77f5ce43e0)

## New context in workflow storage

![CleanShot 2025-05-19 at 17 15 08@2x](https://github.com/user-attachments/assets/0463d035-403f-4600-a9cd-5af24d5fee7c)
2025-05-20 12:33:18 +00:00
Carlos R. L. Rodrigues
59bbff62d8 fix(index): Apply various fixes to the index engine (#12501) 2025-05-19 15:14:25 -03:00
Stevche Radevski
b9a51e217d feat: Add an analytics module and local and posthog providers (#12505)
* feat: Add an analytics module and local and posthog providers

* fix: Add tests and wire up in missing places

* fix: Address feedback and add missing module typing

* fix: Address feedback and add missing module typing

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-05-19 19:57:13 +02:00
Adrien de Peretti
52bd9f9a53 chore(product, modules-sdk): Add missing index for select-in strategy + allow to pass top level strategy to force the behaviour (#12508)
**What**
- Add missing index for query that falls in select in strategy, specifically the heaviest one with variant IN filtering
- Allow to force the strategy to be sent to the entry point module when using the graph API. It is useful with big dataset where filtering is enough without pagination and select in can offer better performances

e.g
```ts
       await query.graph({
            entity: 'product',
            fields,
            filters,
            strategy: 'select-in' // <-- this will force the module to use receive this value and apply it accordingly 
        })
```
2025-05-19 15:57:58 +00:00
Adrien de Peretti
85d2b3c992 fix(utils): Missing zod deps (#12518) 2025-05-18 15:49:59 +02:00
olivermrbl
8c0b49fed4 chore: Version packages 2025-05-16 11:04:39 +02:00
Frane Polić
9f4d32b220 fix(core-flows): fulfilment cancelation with shared inventory kit item (#12503)
* fix(core-flows): fulfilment cancelation with shared inventory kit item

* fix: typos, check if iitem exists

* chore: typo
2025-05-16 10:50:10 +02:00
Harminder Virk
e149a99886 feat: define validators and use normalize-products step (#12473)
Fixes: FRMW-2965

In this PR we replace/remove the existing step to normalize a CSV file with the newly written CSV normalizer and also we validate the file contents further using a Zod schema.

I have duplicated the schema for now. But it is makes sense to re-use the schema for CSV validating and `/admin/products/batch`, then I can keep one source of truth under utils and re-export it. WDYT?

**Screenshots of some errors after validating the file strictly**

![CleanShot 2025-05-15 at 16 36 46@2x](https://github.com/user-attachments/assets/c7fa424f-b947-4898-9b94-47c48617c129)

![CleanShot 2025-05-15 at 16 36 34@2x](https://github.com/user-attachments/assets/0fefef79-148b-4eeb-8ef0-3077e8063ea8)
2025-05-16 08:37:25 +00:00
Shahed Nasser
e91aa2493a chore(types, utils): TSDoc improvements for providers (#12498)
* chore(types, utils): TSDoc improvements for providers

* small iteration
2025-05-15 18:40:33 +03:00
Shahed Nasser
b2984f48f5 fix(types): change update signature of IAuthProvider (#12496)
Change the signature of the `update` method in `IAuthProvider` to match other methods. this is necessary as in the generated references `update` was being inferred as a property rather than a method.
2025-05-15 11:02:05 +00:00
olivermrbl
d2dd2e7c72 chore: Version packages 2025-05-15 09:49:09 +02:00
Pedro Guzman
142a1f0a5b fix(product): returned updates order in upsertWithReplace (#12486)
* add failing test for upsertWithReplace order

* reproduce prices update shuffling issue

* fix: fix order of returned updates in updateMany

* fix: fix order of returned updates in ProductService

* fix: reset test count to 1

* Create tame-insects-marry.md

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-05-15 09:22:24 +02:00
Adrien de Peretti
7fdbf2a965 fix(workflows-sdk): Miss match context usage within run as step (#12449)
**What**

Currently, runAsStep keep reference of the workflow context that is being run as step, except that the step is composed for the current workflow composition and not the workflow being run as a step. Therefore, the context are currently miss matched leading to wrong configuration being used in case of async workflows.

**BUG**
This fix allow the runAsStep to use the current composition context to configure the step for the sub workflow to be run

**BUG BREAKING**
fix the step config wrongly used to wrap async step handlers. Now steps configured async through .config that returns a new step response will indeed marked itself as success without the need for background execution or calling setStepSuccess (as it was expected originally)

**FEATURE**
This pr also add support for cancelling running transaction, the transaction will be marked as being cancelled, once the current step finished, it will cancel the transaction to start compensating all previous steps including itself

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-05-14 13:28:16 +00:00
Shahed Nasser
851c81fd4b chore(types,utils): add featureFlag and version tags (#12464) 2025-05-13 19:12:19 +03:00
Harminder Virk
4602163b56 feat: create CSV normalizer to normalize a CSV file (#12396) 2025-05-13 18:04:59 +05:30
olivermrbl
d3a5868e8b chore: Version packages 2025-05-13 12:56:07 +02:00
Frane Polić
39e5eadefc fix(core-flows, dashboard): reservation recreation on fulfilment cancel + allocation button display (#12447)
**What**
- fix recreation of reservations on fulfilment cancel
- fix allocate items button display

---

CLOSES CMRC-1018
2025-05-12 17:09:23 +00:00
Frane Polić
5fe0e8250d fix(core-flows): Refund and recreate payment session on cart complete failure (#12263) 2025-05-11 19:53:49 +02:00
Casey Harper
9d4bc81d0f fix(plugins, utils): Plugin admin folder loading with backslash on Windows (#12418)
* fix: Plugin admin folder loading with backslash on Windows

* fix: Plugin admin folder loading with backslash on Windows - Add changeset

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-05-11 18:46:12 +02:00
Riqwan Thamir
cc5af67c48 fix(core-flows): use transform as input to account holder step (#12430)
* fix(core-flows): use transform as input to account holder step

* chore: add a simple test

* chore: add comment

* chore: Fix tests

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: olivermrbl <oliver@mrbltech.com>
2025-05-11 18:45:44 +02:00
Adrien de Peretti
fff285f8d2 feat(core-flows): Emit cart trasnferred customer (#12425)
**What**
When a cart is transferred emit an event notifying of the action with the cart id and the customer id
2025-05-11 15:17:19 +00:00
Frane Polić
47700899ed fix(core-flows): use product title for line item title (#12397)
* fix(core-flows): use prduct title for line item title

* fix: module tests

* fix: http tests

* fix: display item subtitle instead of prod title as secondary text in line item

* fix: claim/exchange items
2025-05-11 17:05:46 +02:00
Adrien de Peretti
9d29078b0d fix(workflow-engine-*): q text search (#12435) 2025-05-11 16:21:41 +02:00
Shahed Nasser
0f802a977a chore(js-sdk, types): update TSDocs related to tax provider changes (#12428) 2025-05-09 14:34:45 +03:00
Shahed Nasser
6032f3ec40 chore(js-sdk,types,utils): updates to file TSDocs (#12426)
* chore(js-sdk,types,utils): updates to file TSDocs

* remove ignore tag for file provider

* update file service tsdocs
2025-05-09 14:34:31 +03:00