Commit Graph

1872 Commits

Author SHA1 Message Date
Riqwan Thamir
8ed4eab73a feat(medusa): added admin create endpoint for nested categories (#2985)
What:

Introduces an admin endpoint that allows a user to create a product category

Why:

This is part of a greater goal of allowing products to be added to multiple categories.

How:

- Creates a route on the admin scope to create category
- Creates a method in product category services to create a category

RESOLVES CORE-958
2023-01-11 13:29:02 +00:00
Oliver Windall Juhl
39c3513b2c fix(medusa): Rename location migration (#2987) 2023-01-11 14:06:12 +01:00
Adrien de Peretti
6239fa0704 feat(medusa): Migrate setPaymentSession to use new session flow (#2982)
**What**
When selecting a payment session, we do not necessarily run setPaymentSessions. manage the previously selected session.m accordingly.
2023-01-11 10:43:54 +00:00
olivermrbl
abb98f99dd Merge branch 'master' into develop 2023-01-10 19:23:34 +01:00
Carlos R. L. Rodrigues
93ee248493 feat(medusa, inventory): Inventory Management module (#2956)
* feat: inventory module
2023-01-10 14:38:30 -03:00
Adrien de Peretti
a2df11fc10 fix(medusa-payment-manual): Correct wrongly used input data (#2979) 2023-01-10 18:23:24 +01:00
Oliver Windall Juhl
3308766389 chore(feature-flags): Sales Channels enabled by default (#2966) 2023-01-10 16:45:23 +00:00
Adrien de Peretti
cac81749ea feat(medusa): Update payment session management (#2937) 2023-01-10 16:33:24 +01:00
Riqwan Thamir
71fa60892c feat(medusa): Nested Categories Admin Delete Endpoint (#2975)
**What:**

Introduces an admin endpoint that allows a user to delete a product category, given an ID.

Why:

This is part of a greater goal of allowing products to be added to multiple categories.

How:

- Creates a route on the admin scope to delete category
- Creates a method in product category services to delete a category

RESOLVES CORE-957
2023-01-10 14:28:46 +00:00
Kasper Fabricius Kristensen
f6c81dab9e feat(medusa-js): Bundle package using Rollup (#2964) 2023-01-10 14:44:25 +01:00
Riqwan Thamir
f3ced106ad feat(medusa): Nested Categories Admin List Endpoint (#2973)
* chore: added get route for admin categories API

* chore: add tree method to mock repository

* chore: added changeset to the PR

* chore: rename id to productCategoryId in service

* chore: switch cli option to string

* chore: lint fixes, tests for parent category

* chore: move Nested Categories behind feature flag

* chore: use transformQuery hook in api

* chore: add feature flag in migrations

* chore: remove migration FF, fix FF name

* chore: add free text search + count repo function

* chore: added list endpoint for admin

* chore: added changeset for feature

* chore: address pr review comments

* chore: change oas comment

* chore: add nullable parent category filter + test
2023-01-10 12:52:31 +01:00
Adrien de Peretti
4a50786fbc feat(medusa): Introduce Payment Processor API (#2737) 2023-01-10 12:15:42 +01:00
Adrien de Peretti
1817b810fc fix(medusa): Cancel order missing refunds relation (#2976)
**What**

The order cancelation does not include the refunds relation. It means that the check of the length of the refund is never true and therefore no errors are thrown if the order contains the refunds.

**How**

Add the refunds relation and tests

FIXES CORE-976

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-01-10 09:38:59 +00:00
Riqwan Thamir
47d075351f feat(medusa): Get route for admin product categories API (#2961) 2023-01-10 10:08:16 +01:00
Oliver Windall Juhl
33b3e5f16d chore(feature-flags): Publishable Keys enabled by default (#2967) 2023-01-10 08:59:57 +01:00
Philip Korsholm
16716f5a4f feat(medusa): Create fulfillment with location (#2931)
* remove duplicate key from oas

* changeset

* initial suggestion for adding locations to fulfillments

* update migration

* re-add functionality for removing entire reservations

* fix tests

* add location when adjusting reserved inventory of a line_item

* add changest

* handle multiple reservations for a product in the same channel

* confirm inventory in stock location previous to creating the fulfillment

* fix tests after updating create-fulfillment to confirm inventory prior to creating fulfillment

* remove bugged code

* initial validation

* initial changes for review

* chekcpoint

* update validate inventory at location

* redo some unwanted changes

* typing

* update snapshots

* redo change for eslintrc

* add eslint disable

* re-order methods in interface

* assert no_notification

* iterate one time less

* add test for validation of correct inventory adjustments in case of no inventory service installation

* ensure correct adjustments for order cancellations

* remove comment

* fix tests

* fix but with coalescing

* remove location id from confirm inventory

* don't throw when adjusting reservations for a line item without reservations

* move reservation adjustments to the api

* add multiplication for updating a reservation quantity

* move inventory adjustments from the service layer to the api

* delete reservation if quantity is adjusted to 0

* rename updateReservation to updateReservationItem

* update dto fields

* reference the correct fields

* update with transaction

* add jsdocs

* force boolean cast

* context-ize cancel and create fulfillment transaction methods

* undo notification cast

* update with changes

* refactor withTransaction to variable

* use maps

* fix service mocks
2023-01-09 14:44:34 +01:00
Adrien de Peretti
28bec599ae fix(medusa): Repository util mention of entity specifics (#2965) 2023-01-09 14:18:55 +01:00
Oliver Windall Juhl
32b038fc3f feat(medusa): Reliable retrying of jobs (#2947) 2023-01-09 11:56:29 +01:00
Adrien de Peretti
e4af968531 fix(medusa): Custom repository take/skip when called without relations (#2962)
**What**
The actual behavior is that the skip/take is applied in a first query returning the correct number of results. When there is no relations, we are calling findByIds with the previously retrieved ids, but we also pass skip/take which means that no result are returned after the first increment of the skip.

The skip/take should not be applied in that case as it has already been applied.

FIXES CORE-970
2023-01-09 09:54:25 +00:00
Adrien de Peretti
baeacd1cc5 feat(medusa): Disable subscriber when no search engine is installed (#2958) 2023-01-07 15:58:06 +01:00
Sebastian Rindom
a93d5d437c chore: star prompt (#2955)
Shows a prompt to star Medusa after killing the develop server the first time:
![CleanShot 2023-01-06 at 2 30 19](https://user-images.githubusercontent.com/7554214/211022169-8a0d753e-1628-485e-9037-0e817adf5d3f.png)

The prompt will not reappear on subsequent kills.
2023-01-06 15:12:47 +00:00
Oliver Windall Juhl
8ba0addea3 chore(integration-tests): Add test for database options (#2707)
**What**
- Add integration test suite for database options
- Expose integration tests DB to additional options
- Add test for `idle_in_transaction_session_timeout`
2023-01-06 13:41:05 +00:00
Philip Korsholm
077e4d9606 remove duplicate key from oas (#2953)
**What**
- remove duplicate oas key

**Why**
- oas generation fails when duplicate keys are present
2023-01-06 09:46:23 +00:00
Riqwan Thamir
3f44abe01a feat(medusa): Add ProductCategory model (#2945) 2023-01-05 19:10:46 +01:00
Philip Korsholm
a153289ba3 feat(medusa): Pass location upon receiving returns (#2949) 2023-01-05 19:09:27 +01:00
Oliver Windall Juhl
0b14814d5a fix(medusa): Remove redundant redis delete call when invalidating cache entryies (#2943) 2023-01-05 19:08:14 +01:00
Adrien de Peretti
3d200c41f9 chore: refactor payment collection setPaymentSession (#2928)
**What**

Only use `setPaymentSessionsBatch` in `setPaymentSession` to reuse the logic as it is the same behavior. One for a unique session and the other one for multiple sessions.
This refactoring reduce the risk of introducing bugs when working around payment session if it needs to be changed (which is currently happening as part of the payment refactoring) and having to change it in less places instead of more and more places
2023-01-05 15:22:12 +00:00
Carlos R. L. Rodrigues
c07ffb6165 feat(medusa): Stock location module (#2907)
* feat: stock location module
2023-01-04 13:11:59 -03:00
Shahed Nasser
8263dc1906 docs: fixed oas tag of price list products endpoint (#2933) 2023-01-03 16:10:15 +02:00
Shahed Nasser
19d7be31eb docs: added missing oas tag of uploads endpoints (#2924) 2023-01-03 10:30:23 +02:00
Alex Chiu
cc10c20f35 feat(medusa): Include external_id in CreateProductInput type (#2498) 2023-01-02 10:18:10 +01:00
olivermrbl
7bc5454810 Merge branch 'master' into develop 2023-01-02 09:45:20 +01:00
Philip Korsholm
b9680b641f feat(medusa): Add ProductVariantInventoryService (#2883)
* add mw feature flag

* add services

* add types

* add module interfaces

* add interface export

* add models for mw

* to be ammended

* remove featureflag

* use correct count

* update cart completion strategy

* swap service conversion

* update return service

* update order service

* update claim service

* add exception to claim item

* update cart service

* add indicies

* add changeset

* nullable changes in store

* store model update

* fix unit tests

* remove old inventory service

* format integration test

* update snapshots

* remove old inventory service tests

* update snapshots

* remove old code

* option updates

* naming

* add jsdoc to pv inventory service

* rename class variables

* pr feedback

* rename option to context

* if(variant_id) instead of if(typeof varia...)

* update tests

* add jsdoc

* go for custom

* update code for readability
2022-12-30 11:30:04 +01:00
Oliver Windall Juhl
eda26f6e81 fix(medusa): Add tax inclusive flag to return lines from line item (#2909) 2022-12-29 19:32:04 +01:00
Philip Korsholm
645e0d0ec5 Feat(medusa): search orders by customer phone and name (#2913)
* add support for customer first- and last names and phone

* test for querying customer first_name, last_name and phone

* add customer as prop for querying orders

* polishing before pr

* changeset
2022-12-29 15:20:18 +01:00
github-actions[bot]
d93d337df7 chore(docs): Updated API Reference (#2903)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2022-12-26 16:30:38 +00:00
Shahed Nasser
1f1b85afbb docs: shortened summaries in API reference (#2902) 2022-12-26 18:09:22 +02:00
olivermrbl
8cbd627fb7 chore(release): Publish 2022-12-23 08:56:46 +01:00
Oliver Windall Juhl
d843bc1023 hotfix(medusa): Assign jobSchedulerService in EventBus (#2889)
Solves #2886
2022-12-22 20:16:31 +00:00
Carlos R. L. Rodrigues
726858d847 chore: complete payment collection on order edit even if confirmed (#2877) 2022-12-22 13:07:41 -03:00
olivermrbl
233d6904f8 chore(release): Publish 2022-12-22 15:54:20 +01:00
Philip Korsholm
3f097b7987 allow module definitions to have no default package (#2878)
* allow module definitions to have no default package

* remove duplicated test

* update modulesresponse type
2022-12-22 14:51:24 +01:00
Philip Korsholm
37aaca0da4 feat(medusa): Extend Module Resolution configuration (#2864)
**What**
update module definitions in `ConfigModule` to support the following module configuration methods:
- none: defaults are loaded
- boolean `inventoryService: true|false`, if true the defaults are loaded, false throws if it's a required module, if the module is not required it's not loaded 
- string: `inventoryService: "..."`, treats the string as a path to the overriding module, (we dont handle the case where a string is given but the module is not overridable, we just load the default in that case)
- `ConfigurableModuleDeclaration = { resolve?: string, options?: Record } `, like plugins, options can be used to pass configs to the main service of the module, if not defined no options are passed. Resolve is like string, if defined it's used to look for a custom module, otherwise the default is loaded.

Testing: 
- Added unit tests for: 
  - `loaders/modules.ts`
  - `loaders/module-definitions/index.ts`

Fixes CORE-932
2022-12-22 12:20:57 +00:00
Adrien de Peretti
463f83ffdd feat(medusa): Ordering products on retrieval (#2815)
**What**

Move to transformQuery which adds a default ordering and also allows to order the product list from the store API

**How**
Among other things, fix the product repo to allow ordering by either a key from the product or a key from a relation

FIXES CORE-911
FIXES CORE-901
2022-12-22 10:33:53 +00:00
Adrien de Peretti
e27b1940c7 fix(medusa): Include items.variant relation in order calculation (#2869)
**What**

When an order require to decorate the totals, the variant relation should be added

FIXES CORE-930
2022-12-22 09:32:49 +00:00
Patrick
b700c6ba5b chore(oas): replace requestBody with $ref to req class JSDoc OAS (#2867)
### What

Move inline OAS requestBody schema declaration under their respective class-validator classes in order to expose them through  `#/components/schemas`. Replace inline OAS requestBody schema with a `$ref` reference pointing to the newly declared schema.

### Why

Having requestBody declared as its own "named" schema will allow OAS code generators to output typed entities/DTO that can be manipulate without having to reference the route/operation.

### How

Declare a new @schema JSDoc for each class-validator used to parse and validate request body. Move the current inline requestBody to the new @schema.

### Test

- Ran OAS validator.
- Ran docs build script.

Expect no visible changes to the documentation.

### Out-of-scope

requestBody of type `multipart/form-data` used for file uploads. These will be address as part of CORE-934
- [create-upload.ts](58d23a7b45/packages/medusa/src/api/routes/admin/uploads/create-upload.ts (L87-L90))
- [create-protected-upload.ts](58d23a7b45/packages/medusa/src/api/routes/admin/uploads/create-protected-upload.ts (L87-L90))

Path Parameter and Query Parameter. These will need more research and experimentation, part of CORE-931

---

Resolves CORE-853
2022-12-21 14:08:16 +00:00
Riqwan Thamir
8a60a73389 fix(medusa): gift card values & taxes are calculated correctly (#2777)
* chore: tax_rate is added to giftcards

* chore: minor

* chore: update gift card tax calculations to look at giftCard.tax_rate

* chore: gift card transactions use tax rate from gift card for legacy

* fix: gift cart total check for transaction should check the length

* chore: use tax exclusive cost + use giftcard tax rate for gctransactions + refactor

* chore: fix integration test

* chore: address issues brought up in comments

* chore: move gift card creation as a part of order service on order placed

* chore: add type handling for gift card creation

* chore: fix specs

* chore: use taxLines to calculate tax of a gift card

* chore: specs for line items containing gift cards and without

* chore: add integration specs + fix tax rate bug

* chore: round totaling + add GC application specs

* chore: cleanup trialables

* chore: write migration script to backfill gift cards with null tax_rate

* chore: update legacy totals service for gift cards

* chore: add changeset

* chore: address PR review changes

* chore: fix tests based on new totals calc

* chore: address review comments

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2022-12-20 22:24:25 +01:00
josetr
3113d8024f feat(medusa): Allow creating DraftOrders without items (#2719) 2022-12-20 18:37:42 +01:00
Patrick
a027d5ff9e chore(oas): PascalCase for schemas + remove x-resourceId (#2847)
### What

Rename all JSDoc OAS `@schema` and `$ref: #/components/schemas/` from snake_case to PascalCase, `foo_bar -> FooBar`

Extra scope: Remove `x-resourceId` from JSDoc OAS.

### Why

Classes use PascalCase as a convention but the OAS @schemas describing them were using snake_case. OAS code generators tend to use the schema name when generating typed models.

In order to avoid mismatch between source code, the OAS, and the generated client code, it is advised to align OAS @schemas formatting to the classes they represent.

Extra scope: x-resourceId is not a widely used OAS property. It's current usage in our OAS does not provide additional value. Therefore, we recommend to remove it in order to have one less item to maintain.

### How

Good old search & replace. Regex search to further make sure we didn't miss any.

The scope is limited to `@schema` definition and their usage in `$ref: #/components/schemas/`.

### Test

* Ran OAS validator.
* Ran docs build script.

Expect no visible changes to the documentation.

Resolves: CORE-852, CORE-859
2022-12-20 10:58:57 +00:00
josetr
2e5ceb7950 feat(medusa): Allow custom database schema (#2819) 2022-12-20 10:04:47 +01:00