diff --git a/.eslintignore b/.eslintignore index 48204cf49f..b6737aa072 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,19 +5,19 @@ /packages/medusa/src/subscribers/notification.js /packages/medusa/src/subscribers/order.js /packages/medusa/src/subscribers/product.js -/packages/medusa/src/loaders/api.js -/packages/medusa/src/loaders/database.js -/packages/medusa/src/loaders/defaults.js -/packages/medusa/src/loaders/express.js -/packages/medusa/src/loaders/index.js -/packages/medusa/src/loaders/logger.js -/packages/medusa/src/loaders/models.js -/packages/medusa/src/loaders/passport.js -/packages/medusa/src/loaders/plugins.js -/packages/medusa/src/loaders/redis.js -/packages/medusa/src/loaders/repositories.js -/packages/medusa/src/loaders/services.js -/packages/medusa/src/loaders/subscribers.js +/packages/medusa/src/loaders/api.ts +/packages/medusa/src/loaders/database.ts +/packages/medusa/src/loaders/defaults.ts +/packages/medusa/src/loaders/express.ts +/packages/medusa/src/loaders/index.ts +/packages/medusa/src/loaders/logger.ts +/packages/medusa/src/loaders/models.ts +/packages/medusa/src/loaders/passport.ts +/packages/medusa/src/loaders/plugins.ts +/packages/medusa/src/loaders/redis.ts +/packages/medusa/src/loaders/repositories.ts +/packages/medusa/src/loaders/services.ts +/packages/medusa/src/loaders/subscribers.ts /packages/medusa/src/api/routes/admin/auth /packages/medusa/src/api/routes/admin/collections /packages/medusa/src/api/routes/store/carts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97fca34996..e3019cf472 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Thank you for considering contributing to Medusa! This document will outline how ## Issues before PRs -1. Before you start working on a change please make sure that there is an issue for what you will be working on. You can either find and [existing issue](https://github.com/medusajs/medusa/issues) or [open a new issue](https://github.com/medusajs/medusa/issues/new) if none exists. Doing this makes sure that others can contribute with thoughts or suggest alternatives, ultimately making sure that we only add changes that make +1. Before you start working on a change please make sure that there is an issue for what you will be working on. You can either find and [existing issue](https://github.com/medusajs/medusa/issues) or [open a new issue](https://github.com/medusajs/medusa/issues/new) if none exists. Doing this makes sure that others can contribute with thoughts or suggest alternatives, ultimately making sure that we only add changes that make 2. When you are ready to start working on a change you should first [fork the Medusa repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) and [branch out](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository) from the `develop` branch. 3. Make your changes. @@ -21,17 +21,21 @@ Thank you for considering contributing to Medusa! This document will outline how ### Branches All changes should be part of a branch and submitted as a pull request - your branches should be prefixed with one of: + - `fix/` for bug fixes - `feat/` for features - `docs/` for documentation changes ### Commits + Strive towards keeping your commits small and isolated - this helps the reviewer understand what is going on and makes it easier to process your requests. ### Pull Requests -Once your changes are ready you must submit your branch as a pull request. Your pull request should be opened against the `develop` branch in the main Medusa repo. + +Once your changes are ready you must submit your branch as a pull request. Your pull request should be opened against the `develop` branch in the main Medusa repo. In your PR's description you should follow the structure: + - **What** - what changes are in this PR - **Why** - why are these changes relevant - **How** - how have the changes been implemented @@ -52,8 +56,8 @@ All PRs should include tests for the changes that are included. We have two type ### Documentation -- We generally encourage to document your changes through comments in your code. -- If you alter user-facing behaviour you must provide documentation for such changes. +- We generally encourage to document your changes through comments in your code. +- If you alter user-facing behaviour you must provide documentation for such changes. - All methods and endpoints should be documented using [JSDoc](https://jsdoc.app/) and [`swagger-inline`](https://www.npmjs.com/package/swagger-inline) ### Release diff --git a/README.md b/README.md index 566e93a411..cb63e7a0d3 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Write-ups for all features will be made available in [Github discussions](https: - [ ] Sales Channel API - [ ] Multi-warehouse support - [ ] GraphQL API - + ## Setting up a storefront for your Medusa project Medusa is a headless commerce engine which means that it can be used for any type of digital commerce experience - you may use it as the backend for an app, a voice application, social commerce experiences or a traditional e-commerce website, you may even want to integrate Medusa into your own software to enable commerce functionality. All of these are use cases that Medusa supports - to learn more read the documentation or reach out. diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index a9c4648621..fd11e6d96c 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -38,7 +38,7 @@ tags: - name: Product Variant x-resourceId: product_variant servers: - - url: 'https://api.medusa-commerce.com/store' + - url: "https://api.medusa-commerce.com/store" paths: /auth: post: @@ -51,14 +51,14 @@ paths: tags: - Auth responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" requestBody: content: application/json: @@ -81,7 +81,7 @@ paths: tags: - Auth responses: - '200': + "200": description: OK get: operationId: GetAuth @@ -91,15 +91,15 @@ paths: tags: - Auth responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' - '/auth/{email}': + $ref: "#/components/schemas/customer" + "/auth/{email}": get: operationId: GetAuthEmail summary: Check if email has account @@ -114,7 +114,7 @@ paths: tags: - Auth responses: - '200': + "200": description: OK content: application/json: @@ -122,7 +122,7 @@ paths: properties: exists: type: boolean - '/collections/{id}': + "/collections/{id}": get: operationId: GetCollectionsCollection summary: Retrieve a Product Collection @@ -137,14 +137,14 @@ paths: tags: - Collection responses: - '200': + "200": description: OK content: application/json: schema: properties: collection: - $ref: '#/components/schemas/product_collection' + $ref: "#/components/schemas/product_collection" /collections: get: operationId: GetCollections @@ -168,14 +168,14 @@ paths: tags: - Collection responses: - '200': + "200": description: OK content: application/json: schema: properties: collection: - $ref: '#/components/schemas/product_collection' + $ref: "#/components/schemas/product_collection" /customers/me/addresses: post: operationId: PostCustomersCustomerAddresses @@ -192,18 +192,18 @@ paths: address: description: The Address to add to the Customer. anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" tags: - Customer responses: - '200': + "200": description: A successful response content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" /customers: post: operationId: PostCustomers @@ -213,14 +213,14 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" requestBody: content: application/json: @@ -247,7 +247,7 @@ paths: phone: type: string description: The Customer's phone number. - '/customers/me/addresses/{address_id}': + "/customers/me/addresses/{address_id}": delete: operationId: DeleteCustomersCustomerAddressesAddress summary: Delete an Address @@ -263,14 +263,14 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" post: operationId: PostCustomersCustomerAddressesAddress summary: Update a Shipping Address @@ -291,18 +291,18 @@ paths: address: description: The updated Address. anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" tags: - Customer responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" /customers/me: get: operationId: GetCustomersCustomer @@ -314,14 +314,14 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" post: operationId: PostCustomersCustomer summary: Update Customer details @@ -341,7 +341,7 @@ paths: billing_address: description: The Address to be used for billing purposes. anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" password: description: The Customer's password. type: string @@ -357,14 +357,14 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" /customers/me/payment-methods: get: operationId: GetCustomersCustomerPaymentMethods @@ -377,7 +377,7 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: @@ -431,7 +431,7 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: @@ -444,12 +444,12 @@ paths: description: The offset for pagination. type: integer limit: - description: 'The maxmimum number of Orders to return,' + description: "The maxmimum number of Orders to return," type: integer orders: type: array items: - $ref: '#/components/schemas/order' + $ref: "#/components/schemas/order" /customers/password-token: post: operationId: PostCustomersCustomerPasswordToken @@ -462,7 +462,7 @@ paths: tags: - Customer responses: - '204': + "204": description: OK requestBody: content: @@ -486,14 +486,14 @@ paths: tags: - Customer responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" requestBody: content: application/json: @@ -513,7 +513,7 @@ paths: password: type: string description: The new password to set for the Customer. - '/gift-cards/{code}': + "/gift-cards/{code}": get: operationId: GetGiftCardsCode summary: Retrieve Gift Card by Code @@ -528,7 +528,7 @@ paths: tags: - Gift Card responses: - '200': + "200": description: OK content: application/json: @@ -543,8 +543,8 @@ paths: balance: description: The current balanace of the Gift Card region: - $ref: '#/components/schemas/region' - '/carts/{id}/shipping-methods': + $ref: "#/components/schemas/region" + "/carts/{id}/shipping-methods": post: operationId: PostCartsCartShippingMethod description: Adds a Shipping Method to the Cart. @@ -559,14 +559,14 @@ paths: schema: type: string responses: - '200': + "200": description: A successful response content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" requestBody: content: application/json: @@ -585,7 +585,7 @@ paths: process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send. - '/carts/{id}/taxes': + "/carts/{id}/taxes": post: summary: Calculate Cart Taxes operationId: PostCartsCartTaxes @@ -602,7 +602,7 @@ paths: tags: - Cart responses: - '200': + "200": description: A cart object with the tax_total field populated content: application/json: @@ -611,8 +611,8 @@ paths: - type: object properties: cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/complete': + $ref: "#/components/schemas/cart" + "/carts/{id}/complete": post: summary: Complete a Cart operationId: PostCartsCartComplete @@ -633,7 +633,7 @@ paths: tags: - Cart responses: - '200': + "200": description: >- If a cart was successfully authorized, but requires further action from the user the response body will contain the cart with an @@ -646,15 +646,15 @@ paths: - type: object properties: order: - $ref: '#/components/schemas/order' + $ref: "#/components/schemas/order" - type: object properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" - type: object properties: cart: - $ref: '#/components/schemas/swap' + $ref: "#/components/schemas/swap" /carts: post: summary: Create a Cart @@ -700,15 +700,15 @@ paths: tags: - Cart responses: - '200': + "200": description: Successfully created a new Cart content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items': + $ref: "#/components/schemas/cart" + "/carts/{id}/line-items": post: operationId: PostCartsCartLineItems summary: Add a Line Item @@ -725,14 +725,14 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" requestBody: content: application/json: @@ -755,7 +755,7 @@ paths: description: >- An optional key-value map with additional details about the Line Item. - '/carts/{id}/payment-sessions': + "/carts/{id}/payment-sessions": post: operationId: PostCartsCartPaymentSessions summary: Initialize Payment Sessions @@ -772,15 +772,15 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/discounts/{code}': + $ref: "#/components/schemas/cart" + "/carts/{id}/discounts/{code}": delete: operationId: DeleteCartsCartDiscountsDiscount description: Removes a Discount from a Cart. @@ -801,15 +801,15 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items/{line_id}': + $ref: "#/components/schemas/cart" + "/carts/{id}/line-items/{line_id}": delete: operationId: DeleteCartsCartLineItemsItem summary: Delete a Line Item @@ -830,14 +830,14 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" post: operationId: PostCartsCartLineItemsItem summary: Update a Line Item @@ -858,14 +858,14 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" requestBody: content: application/json: @@ -877,7 +877,7 @@ paths: quantity: type: integer description: The quantity to set the Line Item to. - '/carts/{id}/payment-sessions/{provider_id}': + "/carts/{id}/payment-sessions/{provider_id}": delete: operationId: DeleteCartsCartPaymentSessionsSession summary: Delete a Payment Session @@ -902,14 +902,14 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" post: operationId: PostCartsCartPaymentSessionUpdate summary: Update a Payment Session @@ -930,14 +930,14 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" requestBody: content: application/json: @@ -949,7 +949,7 @@ paths: data: type: object description: The data to update the payment session with. - '/carts/{id}': + "/carts/{id}": get: operationId: GetCartsCart summary: Retrieve a Cart @@ -964,15 +964,15 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-sessions/{provider_id}/refresh': + $ref: "#/components/schemas/cart" + "/carts/{id}/payment-sessions/{provider_id}/refresh": post: operationId: PostCartsCartPaymentSessionsSession summary: Refresh a Payment Session @@ -997,15 +997,15 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-session': + $ref: "#/components/schemas/cart" + "/carts/{id}/payment-session": post: operationId: PostCartsCartPaymentSession summary: Select a Payment Session @@ -1022,14 +1022,14 @@ paths: tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' + $ref: "#/components/schemas/cart" requestBody: content: application/json: @@ -1041,7 +1041,7 @@ paths: provider_id: type: string description: The id of the Payment Provider. - '/store/carts/{id}': + "/store/carts/{id}": post: operationId: PostCartsCartPaymentMethodUpdate summary: Update a Cart" @@ -1065,19 +1065,19 @@ paths: description: The id of the Payment Provider. data: type: object - description: '' + description: "" tags: - Cart responses: - '200': + "200": description: OK content: application/json: schema: properties: cart: - $ref: '#/components/schemas/cart' - '/orders/cart/{cart_id}': + $ref: "#/components/schemas/cart" + "/orders/cart/{cart_id}": get: operationId: GetOrdersOrderCartId summary: Retrieves Order by Cart id @@ -1094,15 +1094,15 @@ paths: tags: - Order responses: - '200': + "200": description: OK content: application/json: schema: properties: order: - $ref: '#/components/schemas/order' - '/orders/{id}': + $ref: "#/components/schemas/order" + "/orders/{id}": get: operationId: GetOrdersOrder summary: Retrieves an Order @@ -1117,14 +1117,14 @@ paths: tags: - Order responses: - '200': + "200": description: OK content: application/json: schema: properties: customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" /orders: get: operationId: GetOrders @@ -1149,15 +1149,15 @@ paths: tags: - Order responses: - '200': + "200": description: OK content: application/json: schema: properties: order: - $ref: '#/components/schemas/order' - '/products/{id}': + $ref: "#/components/schemas/order" + "/products/{id}": get: operationId: GetProductsProduct summary: Retrieves a Product @@ -1172,14 +1172,14 @@ paths: tags: - Product responses: - '200': + "200": description: OK content: application/json: schema: properties: product: - $ref: '#/components/schemas/product' + $ref: "#/components/schemas/product" /products: get: operationId: GetProducts @@ -1265,7 +1265,7 @@ paths: tags: - Product responses: - '200': + "200": description: OK content: application/json: @@ -1278,13 +1278,13 @@ paths: description: The offset for pagination. type: integer limit: - description: 'The maxmimum number of Products to return,' + description: "The maxmimum number of Products to return," type: integer products: type: array items: - $ref: '#/components/schemas/product' - '/regions/{id}': + $ref: "#/components/schemas/product" + "/regions/{id}": get: operationId: GetRegionsRegion summary: Retrieves a Region @@ -1299,14 +1299,14 @@ paths: tags: - Region responses: - '200': + "200": description: OK content: application/json: schema: properties: region: - $ref: '#/components/schemas/region' + $ref: "#/components/schemas/region" /regions: get: operationId: GetRegions @@ -1315,7 +1315,7 @@ paths: tags: - Region responses: - '200': + "200": description: OK content: application/json: @@ -1328,13 +1328,13 @@ paths: description: The offset for pagination. type: integer limit: - description: 'The maxmimum number of regions to return,' + description: "The maxmimum number of regions to return," type: integer regions: type: array items: - $ref: '#/components/schemas/region' - '/return-reasons/{id}': + $ref: "#/components/schemas/region" + "/return-reasons/{id}": get: operationId: GetReturnReasonsReason summary: Retrieve a Return Reason @@ -1349,14 +1349,14 @@ paths: tags: - Return Reason responses: - '200': + "200": description: OK content: application/json: schema: properties: return_reason: - $ref: '#/components/schemas/return_reason' + $ref: "#/components/schemas/return_reason" /return-reasons: get: operationId: GetReturnReasons @@ -1365,7 +1365,7 @@ paths: tags: - Return Reason responses: - '200': + "200": description: OK content: application/json: @@ -1374,7 +1374,7 @@ paths: return_reasons: type: array items: - $ref: '#/components/schemas/return_reason' + $ref: "#/components/schemas/return_reason" /returns: post: operationId: PostReturns @@ -1422,14 +1422,14 @@ paths: tags: - Return responses: - '200': + "200": description: OK content: application/json: schema: properties: return: - $ref: '#/components/schemas/return' + $ref: "#/components/schemas/return" /shipping-options: get: operationId: GetShippingOptions @@ -1456,7 +1456,7 @@ paths: tags: - Shipping Option responses: - '200': + "200": description: OK content: application/json: @@ -1465,8 +1465,8 @@ paths: shipping_options: type: array items: - $ref: '#/components/schemas/shipping_option' - '/shipping-options/{cart_id}': + $ref: "#/components/schemas/shipping_option" + "/shipping-options/{cart_id}": get: operationId: GetShippingOptionsCartId summary: Retrieve Shipping Options for Cart @@ -1481,7 +1481,7 @@ paths: tags: - Shipping Option responses: - '200': + "200": description: OK content: application/json: @@ -1490,7 +1490,7 @@ paths: shipping_options: type: array items: - $ref: '#/components/schemas/shipping_option' + $ref: "#/components/schemas/shipping_option" /swaps: post: operationId: PostSwaps @@ -1552,15 +1552,15 @@ paths: tags: - Swap responses: - '200': + "200": description: OK content: application/json: schema: properties: swap: - $ref: '#/components/schemas/swap' - '/swaps/{cart_id}': + $ref: "#/components/schemas/swap" + "/swaps/{cart_id}": get: operationId: GetSwapsSwapCartId summary: Retrieve Swap by Cart id @@ -1575,15 +1575,15 @@ paths: tags: - Swap responses: - '200': + "200": description: OK content: application/json: schema: properties: swap: - $ref: '#/components/schemas/swap' - '/variants/{variant_id}': + $ref: "#/components/schemas/swap" + "/variants/{variant_id}": get: operationId: GetVariantsVariant summary: Retrieve a Product Variant @@ -1598,14 +1598,14 @@ paths: tags: - Product Variant responses: - '200': + "200": description: OK content: application/json: schema: properties: variant: - $ref: '#/components/schemas/product_variant' + $ref: "#/components/schemas/product_variant" /variants: get: operationId: GetVariants @@ -1634,7 +1634,7 @@ paths: tags: - Product Variant responses: - '200': + "200": description: OK content: application/json: @@ -1643,7 +1643,7 @@ paths: variants: type: array items: - $ref: '#/components/schemas/product_variant' + $ref: "#/components/schemas/product_variant" components: schemas: address: @@ -1670,7 +1670,7 @@ components: country_code: type: string country: - $ref: '#/components/schemas/country' + $ref: "#/components/schemas/country" cart: title: Cart description: Represents a user cart @@ -1683,43 +1683,43 @@ components: billing_address_id: type: string billing_address: - $ref: '#/components/schemas/address' + $ref: "#/components/schemas/address" shipping_address_id: type: string shipping_address: - $ref: '#/components/schemas/address' + $ref: "#/components/schemas/address" items: type: array items: - $ref: '#/components/schemas/line_item' + $ref: "#/components/schemas/line_item" region_id: type: string region: - $ref: '#/components/schemas/region' + $ref: "#/components/schemas/region" discounts: type: array items: - $ref: '#/components/schemas/region' + $ref: "#/components/schemas/region" gift_cards: type: array items: - $ref: '#/components/schemas/gift_card' + $ref: "#/components/schemas/gift_card" customer_id: type: string customer: - $ref: '#/components/schemas/customer' + $ref: "#/components/schemas/customer" payment_session: - $ref: '#/components/schemas/payment_session' + $ref: "#/components/schemas/payment_session" payment_sessions: type: array items: - $ref: '#/components/schemas/payment_session' + $ref: "#/components/schemas/payment_session" payment: - $ref: '#/components/schemas/payment' + $ref: "#/components/schemas/payment" shipping_methods: type: array items: - $ref: '#/components/schemas/shipping_method' + $ref: "#/components/schemas/shipping_method" type: type: string enum: @@ -1786,19 +1786,19 @@ components: images: type: array items: - $ref: '#/components/schemas/claim_image' + $ref: "#/components/schemas/claim_image" claim_order_id: type: string item_id: type: string item: description: The Line Item that the claim refers to - $ref: '#/components/schemas/line_item' + $ref: "#/components/schemas/line_item" variant_id: type: string variant: description: The Product Variant that is claimed. - $ref: '#/components/schemas/product_variant' + $ref: "#/components/schemas/product_variant" reason: description: The reason for the claim type: string @@ -1808,7 +1808,7 @@ components: - production_failure - other note: - description: 'An optional note about the claim, for additional information' + description: "An optional note about the claim, for additional information" type: string quantity: description: >- @@ -1819,7 +1819,7 @@ components: description: User defined tags for easy filtering and grouping. type: array items: - $ref: '#/components/schemas/claim_tag' + $ref: "#/components/schemas/claim_tag" created_at: type: string format: date-time @@ -1868,36 +1868,36 @@ components: description: The items that have been claimed type: array items: - $ref: '#/components/schemas/claim_item' + $ref: "#/components/schemas/claim_item" additional_items: description: >- Refers to the new items to be shipped when the claim order has the type `replace` type: array items: - $ref: '#/components/schemas/line_item' + $ref: "#/components/schemas/line_item" order_id: description: The id of the order that the claim comes from. type: string return_order: description: Holds information about the return if the claim is to be returned - $ref: '#/components/schemas/return' + $ref: "#/components/schemas/return" shipping_address_id: description: The id of the address that the new items should be shipped to type: string shipping_address: description: The address that the new items should be shipped to - $ref: '#/components/schemas/address' + $ref: "#/components/schemas/address" shipping_methods: description: The shipping methods that the claim order will be shipped with. type: array items: - $ref: '#/components/schemas/shipping_method' + $ref: "#/components/schemas/shipping_method" fulfillments: description: The fulfillments of the new items to be shipped type: array items: - $ref: '#/components/schemas/fulfillment' + $ref: "#/components/schemas/fulfillment" refund_amount: description: The amount that will be refunded in conjunction with the claim type: integer @@ -2012,11 +2012,11 @@ components: The id of the Shipping Option that the custom shipping option overrides anyOf: - - $ref: '#/components/schemas/shipping_option' + - $ref: "#/components/schemas/shipping_option" cart_id: description: The id of the Cart that the custom shipping option is attached to anyOf: - - $ref: '#/components/schemas/cart' + - $ref: "#/components/schemas/cart" created_at: description: The date with timezone at which the resource was created. type: string @@ -2070,11 +2070,11 @@ components: billing_address: description: The Customer's billing address. anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" shipping_addresses: type: array items: - $ref: '#/components/schemas/address' + $ref: "#/components/schemas/address" first_name: type: string last_name: @@ -2132,7 +2132,7 @@ components: description: A set of Products that the discount can be used for. type: array items: - $ref: '#/components/schemas/product' + $ref: "#/components/schemas/product" created_at: description: The date with timezone at which the resource was created. type: string @@ -2171,7 +2171,7 @@ components: rule: description: The Discount Rule that governs the behaviour of the Discount anyOf: - - $ref: '#/components/schemas/discount_rule' + - $ref: "#/components/schemas/discount_rule" is_disabled: description: >- Whether the Discount has been disabled. Disabled discounts cannot be @@ -2194,7 +2194,7 @@ components: description: The Regions in which the Discount can be used type: array items: - $ref: '#/components/schemas/region' + $ref: "#/components/schemas/region" usage_limit: description: The maximum number of times that a discount can be used. type: integer @@ -2234,12 +2234,12 @@ components: type: string cart: anyOf: - - $ref: '#/components/schemas/cart' + - $ref: "#/components/schemas/cart" order_id: type: string order: anyOf: - - $ref: '#/components/schemas/order' + - $ref: "#/components/schemas/order" canceled_at: type: string format: date-time @@ -2277,7 +2277,7 @@ components: item: description: The Line Item that the Fulfillment Item references. anyOf: - - $ref: '#/components/schemas/line_item' + - $ref: "#/components/schemas/line_item" quantity: description: The quantity of the Line Item that is included in the Fulfillment. type: integer @@ -2332,7 +2332,7 @@ components: about how many of each Line Item has been fulfilled. type: array items: - $ref: '#/components/schemas/fulfillment_item' + $ref: "#/components/schemas/fulfillment_item" tracking_links: description: >- The Tracking Links that can be used to track the status of the @@ -2340,7 +2340,7 @@ components: Provider. type: array items: - $ref: '#/components/schemas/tracking_link' + $ref: "#/components/schemas/tracking_link" tracking_numbers: deprecated: true description: >- @@ -2391,7 +2391,7 @@ components: gift_card: description: The Gift Card that was used in the transaction. anyOf: - - $ref: '#/components/schemas/gift_card' + - $ref: "#/components/schemas/gift_card" order_id: description: The id of the Order that the Gift Card was used to pay for. type: string @@ -2429,7 +2429,7 @@ components: region: description: The Region in which the Gift Card is available. anyOf: - - $ref: '#/components/schemas/region' + - $ref: "#/components/schemas/region" order_id: description: The id of the Order that the Gift Card was purchased in. type: string @@ -2577,7 +2577,7 @@ components: variant: description: The Product Variant contained in the Line Item. anyOf: - - $ref: '#/components/schemas/product_variant' + - $ref: "#/components/schemas/product_variant" quantity: description: The quantity of the content in the Line Item. type: integer @@ -2642,7 +2642,7 @@ components: region: description: The Region that the Money Amount is defined for. anyOf: - - $ref: '#/components/schemas/region' + - $ref: "#/components/schemas/region" created_at: description: The date with timezone at which the resource was created. type: string @@ -2678,7 +2678,7 @@ components: author: description: The author of the note. anyOf: - - $ref: '#/components/schemas/user' + - $ref: "#/components/schemas/user" created_at: description: The date with timezone at which the resource was created. type: string @@ -2737,7 +2737,7 @@ components: customer: description: The Customer that the Notification was sent to. anyOf: - - $ref: '#/components/schemas/customer' + - $ref: "#/components/schemas/customer" to: description: >- The address that the Notification was sent to. This will usually be @@ -2758,7 +2758,7 @@ components: Notification. type: array items: - $ref: '#/components/schemas/notification_resend' + $ref: "#/components/schemas/notification_resend" provider_id: description: The id of the Notification Provider that handles the Notification. type: string @@ -2877,76 +2877,76 @@ components: discounts: type: array items: - $ref: '#/components/schemas/discount' + $ref: "#/components/schemas/discount" email: type: string billing_address_id: type: string billing_address: anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" shipping_address_id: type: string shipping_address: anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" items: type: array items: - $ref: '#/components/schemas/line_item' + $ref: "#/components/schemas/line_item" region_id: type: string region: anyOf: - - $ref: '#/components/schemas/region' + - $ref: "#/components/schemas/region" gift_cards: type: array items: - $ref: '#/components/schemas/gift_card' + $ref: "#/components/schemas/gift_card" customer_id: type: string customer: anyOf: - - $ref: '#/components/schemas/customer' + - $ref: "#/components/schemas/customer" payment_session: anyOf: - - $ref: '#/components/schemas/payment_session' + - $ref: "#/components/schemas/payment_session" payment_sessions: type: array items: - $ref: '#/components/schemas/payment_session' + $ref: "#/components/schemas/payment_session" payments: type: array items: - $ref: '#/components/schemas/payment' + $ref: "#/components/schemas/payment" shipping_methods: type: array items: - $ref: '#/components/schemas/shipping_method' + $ref: "#/components/schemas/shipping_method" fulfillments: type: array items: - $ref: '#/components/schemas/fulfillment' + $ref: "#/components/schemas/fulfillment" returns: type: array items: - $ref: '#/components/schemas/return' + $ref: "#/components/schemas/return" claims: type: array items: - $ref: '#/components/schemas/claim_order' + $ref: "#/components/schemas/claim_order" refunds: type: array items: - $ref: '#/components/schemas/refund' + $ref: "#/components/schemas/refund" swaps: type: array items: - $ref: '#/components/schemas/refund' + $ref: "#/components/schemas/refund" gift_card_transactions: type: array items: - $ref: '#/components/schemas/gift_card_transaction' + $ref: "#/components/schemas/gift_card_transaction" canceled_at: type: string format: date-time @@ -3212,7 +3212,7 @@ components: description: The Product Option Values that are defined for the Product Option. type: array items: - $ref: '#/components/schemas/product_option_value' + $ref: "#/components/schemas/product_option_value" product_id: description: The id of the Product that the Product Option is defined for. type: string @@ -3372,7 +3372,7 @@ components: Region. type: array items: - $ref: '#/components/schemas/money_amount' + $ref: "#/components/schemas/money_amount" sku: description: >- The unique stock keeping unit used to identify the Product Variant. @@ -3453,7 +3453,7 @@ components: description: The Product Option Values specified for the Product Variant. type: array items: - $ref: '#/components/schemas/product_option_value' + $ref: "#/components/schemas/product_option_value" created_at: description: The date with timezone at which the resource was created. type: string @@ -3511,7 +3511,7 @@ components: description: Images of the Product type: array items: - $ref: '#/components/schemas/image' + $ref: "#/components/schemas/image" thumbnail: description: A URL to an image file that can be used to identify the Product. type: string @@ -3522,14 +3522,14 @@ components: Option Values. type: array items: - $ref: '#/components/schemas/product_option' + $ref: "#/components/schemas/product_option" variants: description: >- The Product Variants that belong to the Product. Each will have a unique combination of Product Option Values. type: array items: - $ref: '#/components/schemas/product_variant' + $ref: "#/components/schemas/product_variant" profile_id: description: >- The id of the Shipping Profile that the Product belongs to. Shipping @@ -3583,16 +3583,16 @@ components: type: description: The Product Type of the Product (e.g. "Clothing") anyOf: - - $ref: '#/components/schemas/product_type' + - $ref: "#/components/schemas/product_type" collection: description: The Product Collection that the Product belongs to (e.g. "SS20") anyOf: - - $ref: '#/components/schemas/product_collection' + - $ref: "#/components/schemas/product_collection" tags: description: The Product Tags assigned to the Product. type: array items: - $ref: '#/components/schemas/product_tag' + $ref: "#/components/schemas/product_tag" created_at: description: The date with timezone at which the resource was created. type: string @@ -3684,21 +3684,21 @@ components: description: The countries that are included in the Region. type: array items: - $ref: '#/components/schemas/country' + $ref: "#/components/schemas/country" payment_providers: description: >- The Payment Providers that can be used to process Payments in the Region. type: array items: - $ref: '#/components/schemas/payment_provider' + $ref: "#/components/schemas/payment_provider" fulfillment_providers: description: >- The Fulfillment Providers that can be used to fulfill orders in the Region. type: array items: - $ref: '#/components/schemas/fulfillment_provider' + $ref: "#/components/schemas/fulfillment_provider" created_at: description: The date with timezone at which the resource was created. type: string @@ -3730,7 +3730,7 @@ components: item: description: The Line Item that the Return Item references. anyOf: - - $ref: '#/components/schemas/line_item' + - $ref: "#/components/schemas/line_item" quantity: description: The quantity of the Line Item that is included in the Return. type: integer @@ -3748,7 +3748,7 @@ components: reason: description: The reason for returning the item. anyOf: - - $ref: '#/components/schemas/return_reason' + - $ref: "#/components/schemas/return_reason" note: description: An optional note with additional details about the Return. type: string @@ -3810,7 +3810,7 @@ components: items: description: >- The Return Items that will be shipped back to the warehouse. type: - array items: $ref: + array items: $ref: swap_id: description: The id of the Swap that the Return is a part of. type: string @@ -3825,7 +3825,7 @@ components: The Shipping Method that will be used to send the Return back. Can be null if the Customer facilitates the return shipment themselves. anyOf: - - $ref: '#/components/schemas/shipping_method' + - $ref: "#/components/schemas/shipping_method" shipping_data: description: >- Data about the return shipment as provided by the Fulfilment @@ -3876,7 +3876,7 @@ components: shipping_option: description: The Shipping Option that the Shipping Method is built from. anyOf: - - $ref: '#/components/schemas/shipping_option' + - $ref: "#/components/schemas/shipping_option" order_id: description: The id of the Order that the Shipping Method is used on. type: string @@ -3962,7 +3962,7 @@ components: region: description: The id of the Region that the Shipping Option belongs to. anyOf: - - $ref: '#/components/schemas/region' + - $ref: "#/components/schemas/region" profile_id: description: >- The id of the Shipping Profile that the Shipping Option belongs to. @@ -4000,7 +4000,7 @@ components: be available for a Cart. type: array items: - $ref: '#/components/schemas/shipping_option_requirement' + $ref: "#/components/schemas/shipping_option_requirement" data: description: >- The data needed for the Fulfillment Provider to identify the @@ -4051,7 +4051,7 @@ components: description: The Products that the Shipping Profile defines Shipping Options for. type: array items: - $ref: '#/components/schemas/product' + $ref: "#/components/schemas/product" shipping_options: description: >- The Shipping Options that can be used to fulfill the Products in the @@ -4059,7 +4059,7 @@ components: type: array items: anyOf: - - $ref: '#/components/schemas/shipping_option' + - $ref: "#/components/schemas/shipping_option" created_at: description: The date with timezone at which the resource was created. type: string @@ -4105,7 +4105,7 @@ components: type: object store: title: Store - description: 'Holds settings for the Store, such as name, currencies, etc.' + description: "Holds settings for the Store, such as name, currencies, etc." x-resourceId: store properties: id: @@ -4123,7 +4123,7 @@ components: description: The currencies that are enabled for the Store. type: array items: - $ref: '#/components/schemas/currency' + $ref: "#/components/schemas/currency" swap_link_template: description: >- A template to generate Swap links from use {{cart_id}} to include @@ -4189,22 +4189,22 @@ components: description: The new Line Items to ship to the Customer. type: array items: - $ref: '#/components/schemas/line_item' + $ref: "#/components/schemas/line_item" return_order: description: The Return that is issued for the return part of the Swap. anyOf: - - $ref: '#/components/schemas/return' + - $ref: "#/components/schemas/return" fulfillments: description: The Fulfillments used to send the new Line Items. type: array items: - $ref: '#/components/schemas/fulfillment' + $ref: "#/components/schemas/fulfillment" payment: description: >- The Payment authorized when the Swap requires an additional amount to be charged from the Customer. anyOf: - - $ref: '#/components/schemas/payment' + - $ref: "#/components/schemas/payment" difference_due: description: >- The difference that is paid or refunded as a result of the Swap. May @@ -4216,17 +4216,17 @@ components: The Address to send the new Line Items to - in most cases this will be the same as the shipping address on the Order. anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" shipping_methods: description: The Shipping Methods used to fulfill the addtional items purchased. type: array items: - $ref: '#/components/schemas/shipping_method' + $ref: "#/components/schemas/shipping_method" cart_id: description: The id of the Cart that the Customer will use to confirm the Swap. type: string allow_backorder: - description: 'If true, swaps can be completed with items out of stock' + description: "If true, swaps can be completed with items out of stock" type: boolean confirmed_at: description: >- @@ -4247,7 +4247,7 @@ components: type: string format: date-time no_notification: - description: 'If set to true, no notification will be sent related to this swap' + description: "If set to true, no notification will be sent related to this swap" type: boolean metadata: description: An optional key-value map with additional information. @@ -4385,7 +4385,7 @@ components: last_name: description: The Customer's billing address. anyOf: - - $ref: '#/components/schemas/address' + - $ref: "#/components/schemas/address" created_at: type: string format: date-time diff --git a/docs/content/add-plugins/algolia.md b/docs/content/add-plugins/algolia.md index a5d13f5c62..c6de15bff7 100644 --- a/docs/content/add-plugins/algolia.md +++ b/docs/content/add-plugins/algolia.md @@ -57,7 +57,7 @@ And that's all! You've now enabled Algolia for your Medusa store engine. The plu **Usage** -This article will not go too much into depth about how the search functionality works under the hood when querying the API. We refer to the [previous article on MeiliSearch](https://www.medusajs.com/post/meilisearch-and-medusa) if this is of your interest. In there, you will find a quick showcase using Postman as well as a thorough walkthrough of how you can display the results in your storefront using ReactJS (GatsbyJS). +This article will not go too much into depth about how the search functionality works under the hood when querying the API. We refer to the [previous article on MeiliSearch](https://medusajs.com/blog/meilisearch-medusa) if this is of your interest. In there, you will find a quick showcase using Postman as well as a thorough walkthrough of how you can display the results in your storefront using ReactJS (GatsbyJS). Instead, to illustrate the power of our Search API and search engine plugins, we'll switch out a MeiliSearch plugin with our new Algolia plugin in a store with existing products. Upon restarting the server with the new configuration, your products will automatically be fed into Algolia and the search functionality in your frontend will remain unchanged. diff --git a/docs/content/add-plugins/sendgrid.mdx b/docs/content/add-plugins/sendgrid.mdx index 233302951f..9f602f1601 100644 --- a/docs/content/add-plugins/sendgrid.mdx +++ b/docs/content/add-plugins/sendgrid.mdx @@ -297,7 +297,7 @@ You don’t have to create a template for every type in the reference. You can s ``` -### Order Cancelled +### Order Canceled **Key in plugin options:** `order_canceled_template` diff --git a/docs/content/advanced/backend/endpoints/add-admin.md b/docs/content/advanced/backend/endpoints/add-admin.md index cc57d4c72a..3a85231e7f 100644 --- a/docs/content/advanced/backend/endpoints/add-admin.md +++ b/docs/content/advanced/backend/endpoints/add-admin.md @@ -24,7 +24,7 @@ export default () => { router.get("/admin/hello", (req, res) => { res.json({ - message: "Welcome to Your Store!" + message: "Welcome to Your Store!", }) }) @@ -61,8 +61,8 @@ Then, create an object that will hold the CORS configurations: ```js const corsOptions = { - origin: projectConfig.admin_cors.split(","), - credentials: true, + origin: projectConfig.admin_cors.split(","), + credentials: true, } ``` @@ -72,7 +72,7 @@ Finally, for each route you add, create an `OPTIONS` request: router.options("/admin/hello", cors(corsOptions)) router.get("/admin/hello", (req, res) => { //... -}); +}) ``` ## Multiple Endpoints @@ -84,13 +84,13 @@ You can add more than one endpoints in `src/api/index.js`: ```js router.get("/admin/hello", (req, res) => { res.json({ - message: "Welcome to Your Store!" + message: "Welcome to Your Store!", }) }) router.get("/admin/bye", (req, res) => { res.json({ - message: "Come back again!" + message: "Come back again!", }) }) ``` @@ -105,7 +105,7 @@ To do that with the previous example, first, create the file `src/api/hello.js` export default (router) => { router.get("/admin/hello", (req, res) => { res.json({ - message: "Welcome to Your Store!" + message: "Welcome to Your Store!", }) }) } @@ -119,7 +119,7 @@ Next, create the file `src/api/bye.js` with the following content: export default (router) => { router.get("/admin/bye", (req, res) => { res.json({ - message: "Come back again!" + message: "Come back again!", }) }) } @@ -156,17 +156,15 @@ You can retrieve any registered service in your endpoint using `req.scope.resolv Here’s an example of an endpoint that retrieves the count of products in your store: ```js -router.get('/admin/products/count', (req, res) => { - const productService = req.scope.resolve('productService') +router.get("/admin/products/count", (req, res) => { + const productService = req.scope.resolve("productService") - productService - .count() - .then((count) => { - res.json({ - count - }) - }) + productService.count().then((count) => { + res.json({ + count, + }) }) +}) ``` The `productService` has a `count` method that returns a Promise. This Promise resolves to the count of the products. You return a JSON of the product count. @@ -178,13 +176,13 @@ Protected routes are routes that should be accessible by logged-in users only. To make a route protected, first, import the `authenticate` middleware: ```js -import authenticate from '@medusajs/medusa/dist/api/middlewares/authenticate' +import authenticate from "@medusajs/medusa/dist/api/middlewares/authenticate" ``` Then, add the middleware to your route: ```js -router.get('/store/products/count', authenticate(), (req, res) => { +router.get("/store/products/count", authenticate(), (req, res) => { //... }) ``` diff --git a/docs/content/advanced/backend/endpoints/add-storefront.md b/docs/content/advanced/backend/endpoints/add-storefront.md index 251e8b6584..7f67980631 100644 --- a/docs/content/advanced/backend/endpoints/add-storefront.md +++ b/docs/content/advanced/backend/endpoints/add-storefront.md @@ -24,7 +24,7 @@ export default () => { router.get("/store/hello", (req, res) => { res.json({ - message: "Welcome to My Store!" + message: "Welcome to My Store!", }) }) @@ -55,13 +55,13 @@ You can add more than one endpoints in `src/api/index.js`: ```js router.get("/store/hello", (req, res) => { res.json({ - message: "Welcome to My Store!" + message: "Welcome to My Store!", }) }) router.get("/store/bye", (req, res) => { res.json({ - message: "Come back again!" + message: "Come back again!", }) }) ``` @@ -76,7 +76,7 @@ To do that with the previous example, first, create the file `src/api/hello.js` export default (router) => { router.get("/store/hello", (req, res) => { res.json({ - message: "Welcome to My Store!" + message: "Welcome to My Store!", }) }) } @@ -90,7 +90,7 @@ Next, create the file `src/api/bye.js` with the following content: export default (router) => { router.get("/store/bye", (req, res) => { res.json({ - message: "Come back again!" + message: "Come back again!", }) }) } @@ -127,17 +127,15 @@ You can retrieve any registered service in your endpoint using `req.scope.resolv Here’s an example of an endpoint that retrieves the count of products in your store: ```js -router.get('/store/products/count', (req, res) => { - const productService = req.scope.resolve('productService') +router.get("/store/products/count", (req, res) => { + const productService = req.scope.resolve("productService") - productService - .count() - .then((count) => { - res.json({ - count - }) - }) + productService.count().then((count) => { + res.json({ + count, + }) }) +}) ``` The `productService` has a `count` method that returns a Promise. This Promise resolves to the count of the products. You return a JSON of the product count. @@ -149,13 +147,13 @@ Protected routes are routes that should be accessible by logged-in customers onl To make a route protected, first, import the `authenticate` middleware: ```js -import authenticate from '@medusajs/medusa/dist/api/middlewares/authenticate' +import authenticate from "@medusajs/medusa/dist/api/middlewares/authenticate" ``` Then, add the middleware to your route: ```jsx -router.get('/store/products/count', authenticate(), (req, res) => { +router.get("/store/products/count", authenticate(), (req, res) => { //... }) ``` diff --git a/docs/content/advanced/backend/migrations.md b/docs/content/advanced/backend/migrations.md new file mode 100644 index 0000000000..e5949b7176 --- /dev/null +++ b/docs/content/advanced/backend/migrations.md @@ -0,0 +1,97 @@ +# Migrations + +In this document, you’ll learn about what Migrations are, their purpose, how you can run them, and how you can create your own Migrations. + +:::note + +Medusa’s Migrations do not work with SQLite databases. They are intended to be used with PostgreSQL databases, which is the recommended Database for your Medusa production server. + +::: + +## Overview + +Migrations are scripts that are used to make additions or changes to your database schema. In Medusa, they are essential for both when you first install your server and for subsequent server upgrades later on. + +When you first create your Medusa server, the database schema used must have all the tables necessary for the server to run. + +When a new Medusa version introduces changes to the database schema, you'll have to run migrations to apply them to your own database. + +:::tip + +Migrations are used to apply changes to the database schema. However, there are some version updates of Medusa that require updating the data in your database to fit the new schema. Those are specific to each version and you should check out the version under Upgrade Guides for details on the steps. + +::: + +## How to Run Migrations + +Migrations in Medusa can be done in one of two ways: + +### Migrate Command + +Using the Medusa CLI tool, you can run migrations with the following command: + +```bash +medusa migrations run +``` + +This will check for any migrations that contain changes to your database schema that aren't applied yet and run them on your server. + +### Seed Command + +Seeding is the process of filling your database with data that is either essential or for testing and demo purposes. In Medusa, the `seed` command will run the migrations to your database if necessary before it seeds your database with dummy data. + +You can use the following command to seed your database: + +```bash npm2yarn +npm run seed +``` + +This will use the underlying `seed` command provided by Medusa's CLI to seed your database with data from the file `data/seed.json` on your Medusa server. + +## How to Create Migrations + +In this section, you’ll learn how to create your own migrations using [Typeorm](https://typeorm.io). This will allow you to modify Medusa’s predefined tables or create your own tables. + +### Create Migration + +To create a migration that makes changes to your Medusa schema, run the following command: + +```bash +npx typeorm migration:create -n src/path/to/UserChanged +``` + +:::tip + +The migration file should be inside the src directory to make sure it is built when the build command is run next. + +::: + +This will create the migration file in the path you specify. You can use this without the need to install Typeorm's CLI tool. You can then go ahead and make changes to it as necessary. + +:::tip + +You can learn more about writing migrations in [Typeorm’s Documentation](https://typeorm.io/migrations). + +::: + +### Build Files + +Before you can run the migrations you need to run the build command to transpile the TypeScript files to JavaScript files: + +```bash npm2yarn +npm run build +``` + +### Run Migration + +The last step is to run the migration with the command detailed earlier + +```bash +medusa migrations run +``` + +If you check your database now you should see that the change defined by the migration has been applied successfully. + +## What’s Next 🚀 + +- Learn more about [setting up your development server](../../tutorial/0-set-up-your-development-environment.md). diff --git a/docs/content/advanced/backend/payment/how-to-create-payment-provider.md b/docs/content/advanced/backend/payment/how-to-create-payment-provider.md index 53295890ce..8037f3374f 100644 --- a/docs/content/advanced/backend/payment/how-to-create-payment-provider.md +++ b/docs/content/advanced/backend/payment/how-to-create-payment-provider.md @@ -6,7 +6,7 @@ In this document, you’ll learn how to add a Payment Provider to your Medusa se A Payment Provider is the payment method used to authorize, capture, and refund payment, among other actions. An example of a Payment Provider is Stripe. -By default, Medusa has a [manual payment provider](https://github.com/medusajs/medusa/tree/2e6622ec5d0ae19d1782e583e099000f0a93b051/packages/medusa-fulfillment-manual) that has minimal implementation. It can be synonymous with a Cash on Delivery payment method. It allows store operators to manage the payment themselves but still keep track of its different stages on Medusa. +By default, Medusa has a [manual payment provider](https://github.com/medusajs/medusa/tree/master/packages/medusa-payment-manual) that has minimal implementation. It can be synonymous with a Cash on Delivery payment method. It allows store operators to manage the payment themselves but still keep track of its different stages on Medusa. Adding a Payment Provider is as simple as creating a [service](../services/create-service.md) file in `src/services`. A Payment Provider is essentially a service that extends `PaymentService` from `medusa-interfaces`. @@ -42,9 +42,9 @@ These methods are used at different points in the Checkout flow as well as when ![Payment Flows.jpg](https://i.imgur.com/WeDr0ph.jpg) -## Create a Fulfillment Provider +## Create a Payment Provider -The first step to create a fulfillment provider is to create a file in `src/services` with the following content: +The first step to create a payment provider is to create a file in `src/services` with the following content: ```jsx import { PaymentService } from "medusa-interfaces" diff --git a/docs/content/advanced/backend/services/create-service.md b/docs/content/advanced/backend/services/create-service.md index 5615872889..6ddfc01017 100644 --- a/docs/content/advanced/backend/services/create-service.md +++ b/docs/content/advanced/backend/services/create-service.md @@ -1,7 +1,5 @@ --- - title: Create a Service - --- # Create a Service @@ -31,7 +29,7 @@ To create a service, you should create a JavaScript file in `src/services` to ho For example, if you want to create a service `helloService`, create the file `hello.js` in `src/services` with the following content: ```js -import { BaseService } from "medusa-interfaces"; +import { BaseService } from "medusa-interfaces" class HelloService extends BaseService { getMessage() { @@ -39,7 +37,7 @@ class HelloService extends BaseService { } } -export default HelloService; +export default HelloService ``` ## Service Constructor @@ -85,10 +83,10 @@ constructor({ helloService }) { To use your custom service in an endpoint, you can use `req.scope.resolve` passing it the service’s registration name: ```js -const helloService = req.scope.resolve('helloService'); +const helloService = req.scope.resolve("helloService") res.json({ - message: helloService.getMessage() + message: helloService.getMessage(), }) ``` diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-1.md b/docs/content/advanced/backend/upgrade-guides/1-3-1.md new file mode 100644 index 0000000000..818b0c6175 --- /dev/null +++ b/docs/content/advanced/backend/upgrade-guides/1-3-1.md @@ -0,0 +1,51 @@ +# v1.3.1 + +Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API. The changes do not affect the public APIs and require only running necessary data migrations. + +## Prerequisites + +Both the actions required for this update need you to set the following environment variables: + +```bash +TYPEORM_CONNECTION=postgres +TYPEORM_URL= +TYPEORM_LOGGING=true +TYPEORM_ENTITIES=./node_modules/@medusajs/medusa/dist/models/*.js +TYPEORM_MIGRATIONS=./node_modules/@medusajs/medusa/dist/migrations/*.js +``` + +These environment variables are used in the data migration scripts in this upgrade. Make sure to replace `` with your PostgreSQL database URL. + +## Line Item Adjustments + +This new version of Medusa allows store operators to adjust line items in an order or a swap which provides more customization capabilities. + +It introduces a new model `LineItemAdjustment` which gives more flexibility to adjust the pricing of line items in a cart, order, or swap. A discount can be added, removed, or modified and the price will reflect on the total calculation of the cart, order, or swap. + +This also introduces an optimization to the calculation of totals, as it is no longer necessary to calculate the discounts every time the totals are retrieved. + +### Actions Required + +This new version adds a new data migration script that will go through your list of existing orders and add line item adjustments for each of the line items in the order. + +For that reason, it’s essential to run the data migration script after upgrading your server and before starting your Medusa server: + +```bash +node ./node_modules/@medusajs/medusa/dist/scripts/line-item-adjustment-migration.js +``` + +## Advanced Discount Conditions + +This new version of Medusa holds advanced promotions functionalities to provide store operators with even more customization capabilities when creating discounts. You can now add even more conditions to your discounts to make them specific for a set of products, collections, customer groups, and more. + +This change required creating a new model `DiscountCondition` which belongs to `DiscountRule` and includes a few relationships with other models to make the aforementioned feature possible. + +### Actions Required + +To ensure your old discount rules play well with the new Promotions API and schema, this version includes a migration script that will go through your existing discount rules, create discount conditions for these rules, and move the former direct relationship between discount rules and products to become between discount conditions and products. + +For that reason, it’s essential to run the data migration script after upgrading your server and before starting your Medusa server: + +```bash +node ./node_modules/@medusajs/medusa/dist/scripts/discount-rule-migration.js +``` diff --git a/docs/content/how-to/create-medusa-app.md b/docs/content/how-to/create-medusa-app.md index ef514a8678..27c78a2267 100644 --- a/docs/content/how-to/create-medusa-app.md +++ b/docs/content/how-to/create-medusa-app.md @@ -55,7 +55,7 @@ For the walkthrough purposes, we assume that the selected starter is `medusa-sta ### Selecting a Storefront -After selecting your Medusa starter you will be given the option to install one of our storefront starters. At the moment we have starters for Gatsby and Next.js: +After selecting your Medusa starter, you will be given the option to install one of our storefront starters. At the moment, we have starters for Gatsby and Next.js: ```bash Which storefront starter would you like to install? … @@ -74,7 +74,7 @@ Creating new project from git: https://github.com/medusajs/medusa-starter-defaul Installing packages... ``` -Once the installation has been completed you will have a Medusa backend, a demo storefront, and an admin dashboard. +Once the installation has been completed, you will have a Medusa backend, a Demo storefront, and an Admin dashboard. ## What's inside @@ -87,7 +87,7 @@ Inside the root folder which was specified at the beginning of the installation /admin // Medusa admin panel ``` -`create-medusa-app` prints out the commands that are available to you after installation. When each project is started you can visit your storefront, complete the order, and view the order in Medusa admin. +`create-medusa-app` prints out the commands that are available to you after installation. When each project is started, you can visit your storefront, complete the order, and view the order in Medusa admin. ```bash ⠴ Installing packages... @@ -112,10 +112,10 @@ Create initial git commit in my-medusa-store/admin ## **What's next?** -To learn more about Medusa to go through our docs to get some inspiration and guidance for the next steps and further development: +To learn more about Medusa, go through our docs to get some inspiration and guidance for the next steps and further development: - [Find out how to set up a Medusa project with Gatsby and Contentful](https://docs.medusajs.com/how-to/headless-ecommerce-store-with-gatsby-contentful-medusa) - [Move your Medusa setup to the next level with some custom functionality](https://docs.medusajs.com/tutorial/adding-custom-functionality) - [Create your own Medusa plugin](https://docs.medusajs.com/guides/plugins) -If you have any follow-up questions or want to chat directly with our engineering team we are always happy to meet you at our [Discord](https://discord.gg/DSHySyMu). +If you have any follow-up questions or want to chat directly with our engineering team, we are always happy to meet you at our [Discord](https://discord.gg/DSHySyMu). diff --git a/docs/content/how-to/deploying-on-heroku.md b/docs/content/how-to/deploying-on-heroku.md index 7695b94217..204032730d 100644 --- a/docs/content/how-to/deploying-on-heroku.md +++ b/docs/content/how-to/deploying-on-heroku.md @@ -4,7 +4,7 @@ title: "Deploying on Heroku" # Deploying on Heroku -This is a guide for deploying a Medusa project on Heroku. Heroku is at PaaS that allows you to easily deploy your applications in the cloud. +This is a guide for deploying a Medusa project on Heroku. Heroku is a PaaS (Platform as a Service) that allows you to easily deploy your applications in the cloud.