From 689c9ee79ee14d284d6ecd3d7f7ad047fe5438c0 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 19 May 2022 10:55:47 +0300 Subject: [PATCH 1/9] added paypal documentation --- docs/content/add-plugins/paypal.md | 519 ++++++++++++++++++++++++++++- 1 file changed, 517 insertions(+), 2 deletions(-) diff --git a/docs/content/add-plugins/paypal.md b/docs/content/add-plugins/paypal.md index 99fec4b931..926adf74c9 100644 --- a/docs/content/add-plugins/paypal.md +++ b/docs/content/add-plugins/paypal.md @@ -1,3 +1,518 @@ -# PayPal (Documentation coming soon) +# PayPal -[View plugin here](https://github.com/medusajs/medusa/tree/master/packages/medusa-payment-paypal) +This document guides you through setting up PayPal as a payment provider in your Medusa server, admin, and storefront using the [PayPal plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-payment-paypal). + +## Overview + +[PayPal](https://www.paypal.com) is a payment provider used by millions around the world. It allows customers to purchase orders from your website using their PayPal account rather than the need to enter their card details. + +As a developer, you can use PayPal’s SDKs and APIs to integrate PayPal as a payment method into your ecommerce store. You can test out the payment method in sandbox mode before going live with it as a payment method. + +Using the `medusa-payment-paypal` plugin, this guide shows you how to set up your Medusa server with PayPal as a payment provider. + +## Prerequisites + +Before you proceed with this guide, make sure you create a [PayPal account](https://www.paypal.com). You also need a PayPal Developer account and retrieve the Client ID and Client Secret. You can learn more about how to do that in [PayPal’s documentation](https://developer.paypal.com/api/rest/). + +In addition, you need to configure a webhook listener on your PayPal Developer Dashboard and obtain the webhook ID. This is necessary for Webhooks to work. + +Webhooks are used in scenarios where the customer might leave the page during the authorization and before the checkout flow is fully complete. It will then create the order or swap after the payment is authorized if they weren’t created + +Additionally, you need a Medusa server installed and set up. If not, you can follow our [quickstart guide](https://docs.medusajs.com/quickstart/quick-start) to get started. + +You also need [Medusa Admin](../admin/quickstart.md) installed to enable PayPal as a payment provider. You can alternatively use our [REST APIs](https://docs.medusajs.com/api/admin/auth). + +## Plugin Installation + +In the root of your Medusa server, run the following command to install the PayPal plugin: + +```bash npm2yarn +npm install medusa-payment-paypal +``` + +### Plugin Configuration + +Next, you need to add configurations for your PayPal plugin. + +In the `.env` file add the following new environment variables: + +```bash +PAYPAL_SANDBOX=true +PAYPAL_CLIENT_ID= +PAYPAL_CLIENT_SECRET= +PAYPAL_AUTH_WEBHOOK_ID= +``` + +Where ``, ``, and `` are the keys you retrieved from the PayPal Developer dashboard as explained in the [Prerequisites](#prerequisites) section. + +Notice that during development it’s highly recommended to set `PAYPAL_SANDBOX` to `true` and ensure you have [sandbox accounts set up in PayPal](https://developer.paypal.com/api/rest/sandbox/). + +Then, in `medusa-config.js`, add the PayPal plugin to the `plugins` array with the configurations necessary: + +```jsx +const plugins = [ + //other plugins... + { + resolve: `medusa-payment-paypal`, + options: { + sandbox: process.env.PAYPAL_SANDBOX, + client_id: process.env.PAYPAL_CLIENT_ID, + client_secret: process.env.PAYPAL_CLIENT_SECRET, + auth_webhook_id: process.env.PAYPAL_AUTH_WEBHOOK_ID + } + } +]; +``` + +That’s all you need to install PayPal on your Medusa server! + +## Admin Setup + +The next step is to enable PayPal as a payment provider in at least one region from the Medusa Admin. + +Run your Medusa server and Medusa admin, then open the Medusa admin and login. + +Choose Settings from the Sidebar. Then, choose Regions. + +![Region Settings](https://i.imgur.com/wRkmbLY.png) + +Then, choose the regions you want to add PayPal as a payment provider. In the right-side settings, scroll down to “Payment Providers” and choose “paypal”. + +![Choose PayPal](https://i.imgur.com/AJ2Yez8.png) + +Once you’re done, click Save. PayPal is now a payment provider in your store in the regions you added it to. + +## Storefront Setup + +This section will take you through the steps to add PayPal as a payment method on the storefront. It includes the steps necessary when using one of Medusa’s official storefronts as well as your own custom React-based storefront. + +:::note + +It is recommended to read through the [Frontend Checkout Flow](/advanced/storefront/how-to-implement-checkout-flow) first to fully understand how payment is implemented on the storefront. + +::: + +### Process Overview + +Although the 3 next sections have different implementations to add PayPal into your storefront, they essentially follow the same process: + +1. Show PayPal’s button if the PayPal provider is available for the current cart. +2. When the button is clicked, open PayPal’s payment portal and wait for the customer to authorize the payment. +3. If the payment is authorized successfully, set PayPal’s [Payment Session](../advanced/backend/payment/overview.md#payment-session) as the session used to perform the payment for the current cart, then update the Payment Session on the server with the data received from PayPal’s payment portal. This data is essential to the server to verify the authorization and perform additional payment processing later such as capturing payment. +4. Complete the cart to create the order. + +:::note + +In Medusa, by default, payments are authorized during checkout, but the payment is not captured right away. The payment should be manually [captured from the Medusa Admin](#capture-payment). + +::: + +## Next.js Storefront + +Medusa has a Next.js storefront that you can easily use with your Medusa server. If you don’t have the storefront installed, you can follow [this quickstart guide](../starters/nextjs-medusa-starter.md). + +In your `.env.local` file (or the file you’re using for your environment variables), add the following variable with its value set to the Client ID: + +```bash +NEXT_PUBLIC_PAYPAL_CLIENT_ID= +``` + +Then, install [PayPal’s React components](https://www.npmjs.com/package/@paypal/react-paypal-js) library: + +```bash npm2yarn +npm install @paypal/react-paypal-js +``` + +Next, create a new file `components/checkout/paypal.jsx` with the following content: + +```jsx +import { PayPalButtons, PayPalScriptProvider } from "@paypal/react-paypal-js"; +import React, { useContext, useState } from "react"; + +import { BiLeftArrowAlt } from "react-icons/bi"; +import DisplayContext from "../../context/display-context"; +import StoreContext from "../../context/store-context"; +import { createClient } from "../../utils/client" +import styles from "../../styles/injectable-payment-card.module.css"; +import { useRouter } from "next/router"; + +const paypalClientId = process.env.NEXT_PUBLIC_PAYPAL_CLIENT_ID || "" + +const Paypal = () => { + const [error, setError] = useState(null); + const [processing, setProcessing] = useState(""); + const { cart, setPaymentSession } = useContext(StoreContext); + const { updateCheckoutStep } = useContext(DisplayContext); + + const router = useRouter(); + + const client = createClient() + + const handleSubmit = async (data, actions) => { + actions.order.authorize().then(async (authorization) => { + if (authorization.status !== 'COMPLETED') { + setError(`An error occurred, status: ${authorization.status}`); + setProcessing(false); + return; + } + + const { cart } = await setPaymentSession("paypal") + + if (!cart) { + setProcessing(false) + return + } + + await client.carts.updatePaymentSession(cart.id, "paypal", { + data: { + data: { + ...authorization + } + } + }); + + setError(null); + setProcessing(false); + router.push(`/payment`); + }) + }; + + return ( + <> + + {error && ( + {error} + )} + + + + + ) +} + +export default Paypal +``` + +Here’s briefly what this code snippet does: + +1. This component renders a PayPal button to initialize the payment using PayPal. You use the components from the PayPal React components library to render the button and you pass the `PayPalScriptProvider` component the Client ID. +2. When the button is clicked, the `handleSubmit` function is executed. In this method, you initialize the payment authorization using `actions.order.authorize()`. It takes the customer to another page to log in with PayPal and authorize the payment. +3. After the payment is authorized successfully on PayPal’s portal, the fulfillment function passed to `actions.order.authorize().then` will be executed. +4. In the fulfillment function, you first ensure that the payment session for the PayPal payment provider is set as the [selected Payment Session in the cart](https://docs.medusajs.com/api/store/cart/select-a-payment-session). Then, you send a request to the server to [update the payment session](https://docs.medusajs.com/api/store/cart/update-a-payment-session) data with the authorization data received from PayPal. +5. After all that is done successfully, you navigate to the `/payment` page which will automatically [complete the cart and place the order](https://docs.medusajs.com/api/store/cart/complete-a-cart). + +The last step is to add this component as the component to render when PayPal is available as a payment provider. + +In `src/checkout/payment-step.jsx` you’ll find in the return statement a switch statement that checks the payment provider for each payment session and renders the component based on the ID. Add before the `default` case a case for `paypal`: + +```jsx +switch (ps.provider_id) { + case "stripe": + //.. + case "manual": + //... + case "paypal": + return ( +
+

PayPal Payment

+ +
+ ) + default: + return null; +} +``` + +Make sure to also import the `Paypal` component at the top of the file: + +```jsx +import Paypal from "./paypal"; +``` + +That’s all you need to integrate PayPal into the Next.js storefront. + +Now, start the Medusa server and the Next.js storefront server. Try adding an item into the cart and proceeding to checkout. When you reach the payment step, you should see the PayPal button. + +![PayPal Button](https://i.imgur.com/bDhBcV3.png) + +You can test out the payment with PayPal using your sandbox account. + +### Gatsby Storefront + +Medusa also has a Gatsby storefront that you can use as your ecommerce storefront. If you don’t have the storefront installed, you can follow [this quickstart guide](../starters/gatsby-medusa-starter.md). + +In your `.env.development` file (or the file you’re using for your environment variables) add the following variable with its value set to the Client ID: + +```bash +GATSBY_PAYPAL_CLIENT_ID= +``` + +Then, install [PayPal’s React components](https://www.npmjs.com/package/@paypal/react-paypal-js) library: + +```bash npm2yarn +npm install @paypal/react-paypal-js +``` + +Next, create a new file `src/components/payment/paypal-payment/index.jsx` with the following content: + +```jsx +import { PayPalButtons, PayPalScriptProvider } from "@paypal/react-paypal-js"; +import React, { useMemo, useState } from "react"; + +import { navigate } from "gatsby" +import { useCart } from "../../../hooks/use-cart" +import { useMedusa } from "../../../hooks/use-medusa"; + +const paypalClientId = process.env.GATSBY_PAYPAL_CLIENT_ID || "" + +const PaypalPayment = () => { + const { + cart, + actions: { completeCart, setPaymentSession }, + } = useCart() + const [errorMessage, setErrorMessage] = useState(undefined) + const [processing, setProcessing] = useState(false) + + const client = useMedusa() + + const paypalSession = useMemo(() => { + if (cart.payment_sessions) { + return cart.payment_sessions.find(s => s.provider_id === "paypal") + } + + return null + }, [cart.payment_sessions]) + + if (!paypalSession) { + return null + } + + const completeOrder = async (authorizationOrder) => { + const cart = await setPaymentSession("paypal") + + if (!cart) { + setProcessing(false) + return + } + + await client.carts.updatePaymentSession(cart.id, "paypal", { + data: { + data: { + ...authorizationOrder + } + } + }); + + const order = await completeCart(cart.id) + + if (!order || order.object !== "order") { + setProcessing(false) + return + } + + setProcessing(false) + navigate("/order-confirmed", { state: { order } }) + } + + const handlePayment = (data, actions) => { + actions.order.authorize().then((authorization) => { + if (authorization.status !== 'COMPLETED') { + setErrorMessage(`An error occurred, status: ${authorization.status}`); + setProcessing(false); + return; + } + + completeOrder(authorization) + }) + } + + return ( + + {errorMessage && ( + {errorMessage} + )} + + + ) +} + +export default PaypalPayment; +``` + +Here’s briefly what this code snippet does: + +1. This component renders a PayPal button to initialize the payment using PayPal. You use the components from the PayPal React components library to render the button and you pass the `PayPalScriptProvider` component the Client ID. +2. When the button is clicked, the `handlePayment` function is executed. In this method, you initialize the payment authorization using `actions.order.authorize()`. It takes the customer to another page to log in with PayPal and authorize the payment. +3. After the payment is authorized successfully on PayPal’s portal, the fulfillment function passed to `actions.order.authorize().then` will be executed which calls the `completeOrder` function. +4. In `completeOrder`, you first ensure that the payment session for the PayPal payment provider is set as the [selected Payment Session in the cart](https://docs.medusajs.com/api/store/cart/select-a-payment-session). Then, you send a request to the server to [update the payment session](https://docs.medusajs.com/api/store/cart/update-a-payment-session) data with the authorization data received from PayPal. +5. You then [complete the cart and place the order](https://docs.medusajs.com/api/store/cart/complete-a-cart). If that is done successfully, you navigate to the `/order-confirmed` page. + +The last step is to add this component as the component to render when PayPal is available as a payment provider. + +In `src/components/payment/index.js` you’ll find in the return statement a switch statement that checks the payment provider for each payment session and renders the component based on the ID. Add before the `default` case a case for `paypal`: + +```jsx +switch (ps.provider_id) { + case "stripe": + //... + case "manual": + //... + case "paypal": + return + default: + return null +} +``` + +Make sure to also import the `PayPalPayment` component at the top of the file: + +```jsx +import PaypalPayment from "./paypal-payment" +``` + +That’s all you need to integrate PayPal into the Gatsby storefront. + +Now, start the Medusa server and the Gatsby storefront server. Try adding an item into the cart and proceeding to checkout. When you reach the payment step, you should see the PayPal button. + +![PayPal Button](https://i.imgur.com/SMLrptP.png) + +You can test out the payment with PayPal using your sandbox account. + +### Custom Storefront + +This section guides you to add PayPal into a React-based framework. The instructions are general instructions that you can use in your storefront. + +In your storefront, you need to install the [PayPal React components library](https://www.npmjs.com/package/@paypal/react-paypal-js) and the [Medusa JS Client library](https://www.npmjs.com/package/@medusajs/medusa-js): + +```bash npm2yarn +npm install @paypal/react-paypal-js @medusajs/medusa-js +``` + +Then, add the Client ID as an environment variable based on the framework you’re using. + +Next, create the file that will hold the PayPal component with the following content: + +```jsx +import { PayPalButtons, PayPalScriptProvider } from "@paypal/react-paypal-js"; +import { useEffect, useState } from "react" + +import Medusa from "@medusajs/medusa-js" + +function Paypal() { + const client = new Medusa(); + const [errorMessage, setErrorMessage] = useState(undefined) + const [processing, setProcessing] = useState(false) + const cart //TODO retrieve the cart here + + const handlePayment = (data, actions) => { + actions.order.authorize().then(async (authorization) => { + if (authorization.status !== 'COMPLETED') { + setErrorMessage(`An error occurred, status: ${authorization.status}`); + setProcessing(false); + return; + } + + const response = await client.carts.setPaymentSession(cart.id, { + "provider_id": "paypal" + }); + + if (!response.cart) { + setProcessing(false) + return + } + + await client.carts.updatePaymentSession(cart.id, "paypal", { + data: { + data: { + ...authorization + } + } + }); + + const {data} = await client.carts.complete(cart.id) + + if (!data || data.object !== "order") { + setProcessing(false) + return + } + + //order successful + alert("success") + }) + } + + return ( +
+ {cart !== undefined && ( + , + "currency": "EUR", + "intent": "authorize" + }}> + {errorMessage && ( + {errorMessage} + )} + + + )} +
+ ); +} + +export default Paypal; +``` + +Here’s briefly what this code snippet does: + +1. At the beginning of the component, the Medusa client is initialized using the JS Client you installed. +2. You also need to retrieve the cart. Ideally, the cart should be managed through a context. So, every time the cart has been updated the cart should be updated in the context to be accessed from all components. +3. This component renders a PayPal button to initialize the payment using PayPal. You use the components from the PayPal React components library to render the button and you pass the `PayPalScriptProvider` component the Client ID. Make sure to replace `` with the environment variable you added. +4. When the button is clicked, the `handlePayment` function is executed. In this method, you initialize the payment authorization using `actions.order.authorize()`. It takes the customer to another page to log in with PayPal and authorize the payment. +5. After the payment is authorized successfully on PayPal’s portal, the fulfillment function passed to `actions.order.authorize().then` will be executed. +6. In the fulfillment function, you first ensure that the payment session for the PayPal payment provider is set as the [selected Payment Session in the cart](https://docs.medusajs.com/api/store/cart/select-a-payment-session). Then, you send a request to the server to [update the payment session](https://docs.medusajs.com/api/store/cart/update-a-payment-session) data with the authorization data received from PayPal. +7. You then [complete the cart and place the order](https://docs.medusajs.com/api/store/cart/complete-a-cart). If that is done successfully, you just show a success alert. You can change this based on the behavior you want in your storefront. + +You can then import this component where you want to show it in your storefront. + +If you run the Medusa server and the storefront server, you should see the PayPal button on checkout. + +![PayPal Button](https://i.imgur.com/PsibgPY.png) + +## Capture Payment + +After the customer places an order, you can see the order on the admin panel. In the payment information under the “Payment” section, you should see a “Capture” button. + +![Capture Payment](https://i.imgur.com/Mx357yY.png) + +Clicking this button lets you capture the payment for an order. You can also refund payments if an order has captured payments. + +Refunding or Capturing payments is reflected in your PayPal dashboard as well. + +## What's Next 🚀 + +- Check out [more plugins](https://github.com/medusajs/medusa/tree/master/packages) you can add to your store. \ No newline at end of file From 684f04e39523558ccf78d8cface852330270194e Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 24 May 2022 14:21:22 +0300 Subject: [PATCH 2/9] add upgrade guide for 1.3.0 --- .../advanced/backend/upgrade-guides/1-3-0.md | 43 +++++++++++++++++++ www/docs/sidebars.js | 5 +++ 2 files changed, 48 insertions(+) create mode 100644 docs/content/advanced/backend/upgrade-guides/1-3-0.md diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-0.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md new file mode 100644 index 0000000000..b6e9ec06b4 --- /dev/null +++ b/docs/content/advanced/backend/upgrade-guides/1-3-0.md @@ -0,0 +1,43 @@ +# v1.3.0 + +Version 1.3.0 of Medusa introduces new features to Medusa as well as prepares for a more important update to version 1.3.1. + +This version introduces a change in loading environment variables into your Medusa server. + +## Environment Variables + +In previous versions of Medusa, The server automatically loads all environment variables in the `.env` file at the root of the Medusa server. + +This new update removes loading it automatically and gives developers the freedom in how to load their environment variables. All environment variables will be loaded by default from the system’s environment variables. + +### Actions Required + +If you use a `.env` file to load environment variables on your server, you need to load the variables manually in `medusa-config.js`. + +You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment: + +```jsx +const dotenv = require('dotenv') + + let ENV_FILE_NAME = ''; + switch (process.env.NODE_ENV) { + case 'production': + ENV_FILE_NAME = '.env.production'; + break; + case 'staging': + ENV_FILE_NAME = '.env.staging'; + break; + case 'test': + ENV_FILE_NAME = '.env.test'; + break; + case 'development': + default: + ENV_FILE_NAME = '.env'; + break; + } + + try { + dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME }); + } catch (e) { + } +``` diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 7ede695603..210c426713 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -214,6 +214,11 @@ module.exports = { label: 'Upgrade Guides', collapsed: true, items: [ + { + type: "doc", + id: "advanced/backend/upgrade-guides/1-3-0", + label: "v1.3.0" + }, { type: "doc", id: "advanced/backend/upgrade-guides/1-3-1", From 9c47736f4ecceaec7905e529dc33ad4320fe3571 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 25 May 2022 14:47:42 +0300 Subject: [PATCH 3/9] Improve storefront quickstart documents --- ...xtjs-storefront-for-your-medusa-project.md | 58 --------- .../content/starters/gatsby-medusa-starter.md | 112 +++++++++++++----- .../content/starters/nextjs-medusa-starter.md | 89 ++++++++++---- www/docs/sidebars.js | 9 +- 4 files changed, 152 insertions(+), 116 deletions(-) delete mode 100644 docs/content/how-to/setting-up-a-nextjs-storefront-for-your-medusa-project.md diff --git a/docs/content/how-to/setting-up-a-nextjs-storefront-for-your-medusa-project.md b/docs/content/how-to/setting-up-a-nextjs-storefront-for-your-medusa-project.md deleted file mode 100644 index fc8b1faaeb..0000000000 --- a/docs/content/how-to/setting-up-a-nextjs-storefront-for-your-medusa-project.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: Setting up a Next.js storefront for your Medusa project ---- - -# Setting up a Next.js storefront for your Medusa project - -:::note - -Medusa is a headless open source commerce platform giving engineers the foundation for building unique and scalable digital commerce projects through our API-first engine. -Being headless, our starters serve as a good foundation for you to get coupled with a frontend in a matter of minutes. - -::: - -This article assumes you already have the Medusa project created and ready to be linked to your Next.js starter. - -## Getting started - -In order to get started, let's open the terminal and use the following command to create an instance of your storefront: - -```zsh - npx create-next-app -e https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront -``` - -Now we have a storefront codebase that is ready to be used with our Medusa server. - -Next, we have to complete two steps to make our new shiny storefront to speak with our server: **link storefront to a server** and **update the `STORE_CORS` variable**. - -Let's jump to these two. - -## Link storefront to a server - -For this part, we should navigate to a `client.js` file which you can find in the utils folder. - -We don't need to do much in here, but to make sure that our storefront is pointing to the port where the server is running - -```js -import Medusa from "@medusajs/medusa-js" -const BACKEND_URL = process.env.GATSBY_STORE_URL || "http://localhost:9000" // <--- That is the line we are looking for -export const createClient = () => new Medusa({ baseUrl: BACKEND_URL }) -``` - -By default, the Medusa server is running at port 9000. So if you didn't change that, we are good to go to our next step. - -## Update the `STORE_CORS` variable - -Here let's navigate to your Medusa server and open `medusa-config.js` - -Let's locate the `STORE_CORS` variable and make sure it's the right port (which is 3000 by default for Next.js projects). - -```js -/* - * CORS to avoid issues when consuming Medusa from a client. - * Should be pointing to the port where the storefront is running. - */ -const STORE_CORS = process.env.STORE_CORS || "http://localhost:3000" -``` - -Now we have a storefront that interacts with our Medusa server and with that we have a sweet and complete e-commerce setup with a Next.js storefront. diff --git a/docs/content/starters/gatsby-medusa-starter.md b/docs/content/starters/gatsby-medusa-starter.md index bd8153c092..f9effb6880 100644 --- a/docs/content/starters/gatsby-medusa-starter.md +++ b/docs/content/starters/gatsby-medusa-starter.md @@ -1,47 +1,101 @@ -# Quickstart: Gatsby +# Quickstart: Gatsby Storefront -**Create a new Gatsby project using the Medusa starter template** +This document guides you to install and set up the Gatsby Storefront for your Medusa Server. -```bash -gatsby new my-medusa-store https://github.com/medusajs/gatsby-starter-medusa +![Gatsby Storefront Quick Look](https://i.imgur.com/LcAsi8r.gif) + +## Prerequisites + +This document assumes you already have a Medusa server installed. If you don’t, please follow the [Quickstart guide for the Medusa server](../quickstart/quick-start.md) to learn how to do it. + +You should also have the Gatsby CLI installed: + +```bash npm2yarn +npm install gatsby-cli -g ``` -**Set up environment variables** -Navigate into your projects directory and get your environment variables ready: +## Installation -```shell +1\. Create a new Gatsby project using the [Medusa starter template](https://github.com/medusajs/gatsby-starter-medusa): + +```bash +gatsby new my-medusa-storefront https://github.com/medusajs/gatsby-starter-medusa +``` + +2\. Change to the newly created directory `my-medusa-storefront` and rename the template environment variable file to use environment variables in development: + +```bash mv .env.template .env.development ``` -**Install dependencies** -Use your favourite package manager to install dependencies: - -```bash npm2yarn -npm install -``` - -**Start developing.** -Start up the local server: +3\. Make sure the Medusa server is running, then run the local Gatsby server: ```bash npm2yarn npm run start ``` -Your site is now running at http://localhost:8000! +Your Gatsby storefront is now running at `localhost:8000`! -Edit `src/pages/index.js` to see your site update in real-time! +## Development Notes -**Learn more about Medusa** +### Customization -- [Website](https://www.medusajs.com/) -- [GitHub](https://github.com/medusajs) -- [Documentation](https://docs.medusajs.com/) +To customize the components, pages, and UI of your Gatsby storefront, just edit files under the `src` directory. -**Learn more about Gatsby** +### Data Refresh -- [Documentation](https://www.gatsbyjs.com/docs/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) -- [Tutorials](https://www.gatsbyjs.com/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) -- [Guides](https://www.gatsbyjs.com/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) -- [API Reference](https://www.gatsbyjs.com/docs/api-reference/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) -- [Plugin Library](https://www.gatsbyjs.com/plugins?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) -- [Cheat Sheet](https://www.gatsbyjs.com/docs/cheat-sheet/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) +The Gatsby storefront uses the [gatsby-source-medusa](https://github.com/medusajs/medusa/tree/master/packages/gatsby-source-medusa) plugin to source data from your Medusa server. This data includes products, collections, and regions, and as a result, you can query this data in the storefront starter using GraphQL queries. You can also explore the data in your store on `localhost:8000/___graphql`. + +Because of this, you must rebuild the site every time you update any of this data for it to be reflected in your storefront. We will soon be releasing a new version of the plugin which adds incremental builds, which will improve build times. + +### Change Port + +By default, the Gatsby storefront runs on port `8000`. + +To change the port, change the `develop` command in `package.json` to the following: + +```json +"scripts": { + //other scripts + "develop": "gatsby develop --port=" +} +``` + +Make sure to replace `` with the port number you want the storefront to run on. For example, `3000`. + +Then, on your server, update the environment variable `STORE_CORS` to the URL with the new port: + +```bash +STORE_CORS=http://localhost: +``` + +### Development Resources + +If you’re not familiar with Gatsby, you can learn more about it through the following resources: + +- [Documentation](https://www.gatsbyjs.com/docs) +- [Plugin Library](https://www.gatsbyjs.com/plugins/) +- [Cheat Sheet](https://www.gatsbyjs.com/docs/cheat-sheet/) + +## Storefront Features + +The Gatsby storefront comes with a lot of features out of the box including: + +- View all products and manage your cart. + + ![Products Page](https://i.imgur.com/P0Mpvxh.png) +- Customer authentication. + + ![Sign In Page](https://i.imgur.com/0sVcZeS.png) +- Full checkout workflow. + + ![One-Page Checkout](https://i.imgur.com/5wSs3yZ.png) +- Request swaps and returns using a customer’s order ID and Email. + + ![Request Return for Order](https://i.imgur.com/mAChp3f.png) + +## What’s Next 🚀 + +- Check the [Storefront API reference](https://docs.medusajs.com/api/store/auth) for a full list of REST APIs to use on your storefront. +- Learn how to [deploy the Gatsby storefront on Netlify](../how-to/deploying-gatsby-on-netlify.md). +- Learn how to add [Stripe as a payment provider](../add-plugins/stripe.md#gatsby-storefront). diff --git a/docs/content/starters/nextjs-medusa-starter.md b/docs/content/starters/nextjs-medusa-starter.md index ca682547ce..6894070c5b 100644 --- a/docs/content/starters/nextjs-medusa-starter.md +++ b/docs/content/starters/nextjs-medusa-starter.md @@ -1,42 +1,87 @@ -# Quickstart: Next.js +# Quickstart: Next.js Storefront -**Create a new Next.js project using the Medusa starter template** +This document guides you to install and set up the Next.js Storefront for your Medusa Server. + +:::info + +The Next.js storefront is meant as a starter storefront with basic features. We have an advanced Next.js storefront currently in the works with a better design and more functionalities coming soon! + +::: + +![Next.js Storefront Quick Look](https://i.imgur.com/HIVLwN4.gif) + +## Prerequisites + +This document assumes you already have a Medusa server installed. If you don’t, please follow the [Quickstart guide for the Medusa server](../quickstart/quick-start.md) to learn how to do it. + +## Installation + +1\. Create a new Next.js project using the [Medusa starter template](https://github.com/medusajs/nextjs-starter-medusa): ```bash npx create-next-app -e https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront ``` -**Set up environment variables** -Navigate into your projects directory and get your environment variables ready: +2\. Change to the newly created directory `my-medusa-storefront` and rename the template environment variable file to use environment variables in development: -```shell +```bash mv .env.template .env.local ``` -**Install dependencies** -Use your favourite package manager to install dependencies: - -```bash npm2yarn -npm install -``` - -**Start developing.** -Start up the local server: +3\. Make sure the Medusa server is running, then run the local Next.js server: ```bash npm2yarn npm run dev ``` -Your site is now running at http://localhost:8000! +Your Next.js storefront is now running at `localhost:8000`! -Edit `src/pages/index.js` to see your site update in real-time! +## Development Notes -**Learn more about Medusa** +### Customization -- [Website](https://www.medusajs.com/) -- [GitHub](https://github.com/medusajs) -- [Documentation](https://docs.medusajs.com/) +To customize the pages of the storefront, you can customize the files under the `pages` directory. -**Learn more about Next.js** +To customize the components used in the storefront, you can customize the files under the `components` directory. -- [Documentation](https://nextjs.org/docs) +To customize the styles of the storefront, you can customize the `styles` directory. + +### Change Port + +By default, the Next.js storefront runs on port `8000`. + +To change the port, change the `develop` command in `package.json` to the following: + +```json +"scripts": { + //other scripts + "dev": "next dev -p " +} +``` + +Make sure to replace `` with the port number you want the storefront to run on. For example, `3000`. + +Then, on your server, update the environment variable `STORE_CORS` to the URL with the new port: + +```bash +STORE_CORS=http://localhost: +``` + +### Development Resources + +You can learn more about development with Next.js through [their documentation](https://nextjs.org/docs/getting-started). + +## Storefront Features + +- View products and manage your cart. + +![Product Page](https://i.imgur.com/wCeWJio.png) + +- Full checkout workflow. + +![Shipping Details on Checkout](https://i.imgur.com/7la2KhW.png) + +## What’s Next 🚀 + +- Check the [Storefront API reference](https://docs.medusajs.com/api/store/auth) for a full list of REST APIs to use on your storefront. +- Learn how to add [Stripe as a payment provider](../add-plugins/stripe.md#nextjs-storefront). diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 7ede695603..7e581c5d20 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -49,17 +49,12 @@ module.exports = { { type: "doc", id: "starters/gatsby-medusa-starter", - label: "Quickstart: Gatsby", + label: "Gatsby Storefront Quickstart", }, { type: "doc", id: "starters/nextjs-medusa-starter", - label: "Quickstart: Next.js", - }, - { - type: "doc", - id: "how-to/setting-up-a-nextjs-storefront-for-your-medusa-project", - label: "Set Up a Next.js Storefront for your Medusa Project" + label: "Next.js Storefront Quickstart", }, ], }, From 22eeefba53e1c4a440634c5a798f7836cbca1259 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Fri, 27 May 2022 16:59:25 +0300 Subject: [PATCH 4/9] added events reference --- .../backend/subscribers/create-subscriber.md | 1 + .../backend/subscribers/events-list.md | 1865 +++++++++++++++++ www/docs/sidebars.js | 5 + www/docs/src/css/custom.css | 16 + 4 files changed, 1887 insertions(+) create mode 100644 docs/content/advanced/backend/subscribers/events-list.md diff --git a/docs/content/advanced/backend/subscribers/create-subscriber.md b/docs/content/advanced/backend/subscribers/create-subscriber.md index f8e711419d..2f9c057d9e 100644 --- a/docs/content/advanced/backend/subscribers/create-subscriber.md +++ b/docs/content/advanced/backend/subscribers/create-subscriber.md @@ -93,4 +93,5 @@ You can then use `this.productService` anywhere in your subscriber’s methods. ## What’s Next 🚀 +- [View the list of all events](events-list.md) - [Learn how to create a service.](/advanced/backend/services/create-service) diff --git a/docs/content/advanced/backend/subscribers/events-list.md b/docs/content/advanced/backend/subscribers/events-list.md new file mode 100644 index 0000000000..1f76d6fa2d --- /dev/null +++ b/docs/content/advanced/backend/subscribers/events-list.md @@ -0,0 +1,1865 @@ +# Events List + +This document details all events in Medusa, when they are triggered, and what data your handler method will receive when the event is triggered. + +## Prerequisites + +It is assumed you’re already familiar with [Subscribers in Medusa and how to listen to events](create-subscriber.md). You can then use the name of events from this documentation in your subscriber to listen to events. + +## Legend + +Events in this document are listed under the entity they’re associated with. They’re listed in a table of 3 columns: + +1. **Event Name:** The name you use to subscribe a handler for the event. +2. **Description:** When this event is triggered. +3. **Event Data Payload**: The data your handler receives as a parameter. + +## Batch Jobs Events + +This section holds all events related to batch jobs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`batch.created` + + +Triggered when a batch job is created. + +Object of the following format: + +```js +{ + id //string ID of batch job +} +``` + +
+ +`batch.updated` + + +Triggered when a batch job is updated. + +Object of the following format: + +```js +{ + id //string ID of batch job +} +``` + +
+ +`batch.canceled` + + +Triggered when a batch job is canceled. + +Object of the following format: + +```js +{ + id //string ID of batch job +} +``` + +
+ +## Cart Events + +This section holds all events related to a cart. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`cart.customer_updated` + + +Triggered when a cart is associated with a different email than it was already associated with, or if a customer logs in after adding items to their cart as a guest. + +The cart ID passed as a string parameter. +
+ +`cart.created` + + +Triggered when a cart is created. + +Object of the following format: + +```js +{ + id //string ID of cart +} +``` + +
+ +`cart.updated` + + + +Triggered when a cart and data associated with it (payment sessions, shipping methods, user details, etc…) are updated. + + + +The entire cart as an object. You can refer to the [Cart model](https://github.com/medusajs/medusa/blob/master/packages/medusa/src/models/cart.ts) for an idea of what fields to expect. + +
+ +## Claim Events + +This section holds all events related to claims. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`claim.created` + + + +Triggered when a claim is created. + + + +Object of the following format: + +```js +{ + id, //string ID of claim + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`claim.updated` + + + +Triggered when a claim is updated. + + + +Object of the following format: + +```js +{ + id, //string ID of claim + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`claim.canceled` + + + +Triggered when a claim is canceled. + + + +Object of the following format: + +```js +{ + id, //string ID of claim + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`claim.fulfillment_created` + + + +Triggered when fulfillment is created for a claim. + + + +Object of the following format: + +```js +{ + id, //string ID of claim + fulfillment_id, //string ID of the fulfillment created + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`claim.shipment_created` + + + +Triggered when a claim fulfillment is set as “shipped”. + + + +Object of the following format: + +```js +{ + id, //string ID of claim + fulfillment_id, //string ID of the fulfillment created + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`claim.refund_processed` + + + +Triggered when a claim of type “refunded” has been refunded. + + + +Object of the following format: + +```js +{ + id, //string ID of claim + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +## Claim Item Events + +This section holds all events related to claim items. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`claim_item.created` + + + +Triggered when claim items are created and associated with a claim. This happens during the creation of claims. + + + +Object of the following format: + +```js +{ + id //string ID of claim item +} +``` + +
+ +`claim_item.updated` + + + +Triggered when a claim item is updated. This happens when a claim is updated. + + + +Object of the following format: + +```js +{ + id //string ID of claim item +} +``` + +
+ +`claim_item.canceled` + + + +Triggered when a claim is canceled. + + + +Object of the following format: + +```js +{ + id //string ID of claim item +} +``` + +
+ +## Customer Events + +This section holds all events related to customers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`customer.created` + + + +Triggered when a customer is created. + + + +The entire customer passed as an object. You can refer to the [Customer model](https://github.com/medusajs/medusa/blob/master/packages/medusa/src/models/customer.ts) for an idea of what fields to expect. + +
+ +`customer.updated` + + + +Triggered when a customer is updated including their information or password, or when a customer account is created that is associated with an existing email (for example, if a customer placed an order with their email as a guest, then created an account with that email). + + + +The entire customer passed as an object. You can refer to the [Customer model](https://github.com/medusajs/medusa/blob/master/packages/medusa/src/models/customer.ts) for an idea of what fields to expect. + +
+ +`customer.password_reset` + + + +Triggered when a customer requests to reset their password. + + + +Object of the following format: + +```js +{ + id, //string ID of customer + email, //string email of the customer + first_name, //string first name of the customer + last_name, //string last name of the customer + token //string reset password token +} +``` + +
+ +## Draft Order Events + +This section holds all events related to draft orders. + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`draft_order.created` + + + +Triggered when a draft order is created. + + + +Object of the following format: + +```js +{ + id //string ID of draft order +} +``` + +
+ +`draft_order.updated` + + + +Triggered when a draft order and data associated with it (email, billing address, discount, etc…) are updated. + + + +Object of the following format: + +```js +{ + id //string ID of draft order +} +``` + +
+ +## Gift Card Events + +This section holds all events related to gift cards. + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`gift_card.created` + + + +Triggered when a gift card is created. + + + +Object of the following format: + +``` +{ + id //string ID of gift card +} +``` + +
+ +## Invite Events + +This section holds all events related to invites. + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`invite.created` + + + +Triggered when an invite is created for a user to join the admin team. + + + +Object of the following format: + +```js +{ + id //string ID of invite + token, //string token generated to validate the invited user + user_email //string email of invited user +} +``` + +
+ +## Note Events + +This section holds all events related to notes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`note.created` + + + +Triggered when a note is created. + + + +Object of the following format: + +```js +{ + id //string ID of note +} +``` + +
+ +`note.updated` + + + +Triggered when a note is updated. + + + +Object of the following format: + +```js +{ + id //string ID of note +} +``` + +
+ +`note.deleted` + + + +Triggered when a note is deleted. + + + +Object of the following format: + +```js +{ + id //string ID of note +} +``` + +
+ +## App Authentication Events + +This section holds all events related to app authentications. + +:::note + +Event names of app authentication are scoped specifically towards each application. When listening to these events, you must replace `` with the name of the application you’re targeting. + +::: + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`oauth.token_generated.` + + + +Triggered when a token is generated for an application. + + + +The returned data from the method `generateToken` in the auth handler service of the application. + +
+ +`oauth.token_refreshed.` + + + +Triggered when the token of an application is refreshed. + + + +The returned data from the method `refreshToken` in the auth handler service of the application. + +
+ +## Order Events + +This section holds all events related to orders. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`order.placed` + + + +Triggered when a new order is placed. + + + +Object of the following format: + +```js +{ + id, //string ID of order + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.updated` + + + +Triggered when an order and data associated with it (shipping method, shipping address, etc…) are updated. + + + +Object of the following format: + +```js +{ + id, //string ID of order + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.canceled` + + + +Triggered when an order is canceled. + + + +Object of the following format: + +```js +{ + id, //string ID of order + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.completed` + + + +Triggered when an order is completed. + + + +Object of the following format: + +```js +{ + id, //string ID of order + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.gift_card_created` + + + +Triggered when a gift card in an order is created. + + + +Object of the following format: + +```js +{ + id //string ID of order +} +``` + +
+ +`order.payment_captured` + + + +Triggered when the payment of an order is captured. + + + +Object of the following format: + +```js +{ + id, //string ID of order + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.payment_capture_failed` + + + +Triggered when capturing the payment of an order fails. + + + +Object of the following format: + +```js +{ + id, //string ID of order + payment_id, //string ID of Payment + error, //string error message + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.fulfillment_created` + + + +Triggered when fulfillment is created for an order. + + + +Object of the following format: + +```js +{ + id, //string ID of order + fulfillment_id, //string ID of fulfillment + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.shipment_created` + + + +Triggered when a shipment is created for fulfillment and the fulfillment is registered as “shipped”. + + + +Object of the following format: + +```js +{ + id, //string ID of order + fulfillment_id, //string ID of fulfillment + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.fulfillment_canceled` + + + +Triggered when fulfillment of an order is canceled. + + + +Object of the following format: + +```js +{ + id, //string ID of order + fulfillment_id, //string ID of fulfillment + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.return_requested` + + + +Triggered when a return of an order is requested. + + + +Object of the following format: + +```js +{ + id, //string ID of order + return_id, //string ID of return + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.items_returned` + + + +Triggered when the items of an order have been returned and the order has been registered as “returned”. + + + +Object of the following format: + +```js +{ + id, //string ID of order + return_id, //string ID of return + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.return_action_required` + + + +Triggered when the order is being registered as “returned” but there are additional actions required related to refunding the payment. + + + +Object of the following format: + +```js +{ + id, //string ID of order + return_id, //string ID of return + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.refund_created` + + + +Triggered when the order’s payment is refunded. + + + +Object of the following format: + +```js +{ + id, //string ID of order + refund_id, //string ID of refund + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`order.refund_failed` + + + +Triggered when the refund of the order’s payment fails. + + + +Object of the following format: + +```js +{ + id, //string ID of order +} +``` + +
+ +`order.swap_created` + + + +Triggered when a swap for an order is created. + + + +Object of the following format: + +```js +{ + id, //string ID of order +} +``` + +
+ +## Product Events + +This section holds all events related to products. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`product.created` + + + +Triggered when a product is created. + + + +Object of the following format: + +```js +{ + id //string ID of product +} +``` + +
+ +`product.updated` + + + +Triggered when a product and data associated with it (options, variant orders, etc…) is updated. + + + +The entire product passed as an object. You can refer to the [Product model](https://github.com/medusajs/medusa/blob/master/packages/medusa/src/models/product.ts) for an idea of what fields to expect. + +
+ +`product.deleted` + + + +Triggered when a product is deleted. + + + +Object of the following format: + +```js +{ + id //string ID of product +} +``` + +
+ +## Product Variant Events + +This section holds all events related to product variants. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`product-variant.created` + + + +Triggered when a product variant is created. + + + +Object of the following format: + +```js +{ + id, //string ID of variant + product_id //string ID of product +} +``` + +
+ +`product-variant.updated` + + + +Triggered when a product variant is updated. + + + +Object of the following format: + +```js +{ + id, //string ID of variant + product_id, //string ID of product + fields //array of names of updated fields +} +``` + +
+ +`product-variant.deleted` + + + +Triggered when a product variant is deleted. + + + +Object of the following format: + +```js +{ + id, //string ID of variant + product_id, //string ID of product + metadata //object of additional data +} +``` + +
+ +## Region Events + +This section holds all events related to regions. + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`region.created` + + + +Triggered when a region is created. + + + +Object of the following format: + +```js +{ + id //string ID of region +} +``` + +
+ +`region.updated` + + + +Triggered when a region or data associated with it (countries, fulfillment providers, etc…) are updated. + + + +Object of the following format: + +```js +{ + id, //string ID of region + fields //array of names of updated fields +} +``` + +
+ +`region.deleted` + + + +Triggered when a region is deleted. + + + +Object of the following format: + +```js +{ + id //string ID of region +} +``` + +
+ +## Swap Events + +This section holds all events related to swaps. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`swap.created` + + + +Triggered when a swap is created. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.received` + + + +Triggered when a swap is registered as received. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + order_id, //string ID of order + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.fulfillment_created` + + + +Triggered when fulfillment is created for a swap. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + fulfillment_id, //string ID of fulfillment + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.shipment_created` + + + +Triggered when a shipment is created for a swap and the fulfillment associated with it is set as “shipped”. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + fulfillment_id, //string ID of fulfillment + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.payment_completed` + + + +Triggered when payment is completed for a swap which happens when the cart associated with the swap is registered as completed. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.payment_captured` + + + +Triggered when the payment is captured for a swap. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.payment_capture_failed` + + + +Triggered when the capturing of the payment of a swap fails. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.refund_processed` + + + +Triggered when a swap’s amount difference is processed and refunded. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +`swap.process_refund_failed` + + + +Triggered when processing and refunding a swap’s amount difference fails. + + + +Object of the following format: + +```js +{ + id, //string ID of swap + no_notification //boolean indicating whether a notification should be sent or not +} +``` + +
+ +## User Events + +This section holds all events related to users. + + + + + + + + + + + + + + + + +
+Event Name + +Description + +Event Data Payload +
+ +`user.password_reset` + + + +Triggered when a user requests to reset their password. + + + +Object of the following format: + +```js +{ + email, //string email of user requesting to reset their password + token //token create to reset the password +} +``` + +
+ +## What’s Next 🚀 + +- Learn how you can [use services in subscribers](create-subscriber.md#using-services-in-subscribers). +- Learn how to [create notifications](../../../how-to/notification-api.md) in Medusa. diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 7ede695603..9c887d75b5 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -153,6 +153,11 @@ module.exports = { id: "advanced/backend/subscribers/create-subscriber", label: "Create a Subscriber" }, + { + type: "doc", + id: "advanced/backend/subscribers/events-list", + label: "List of Events" + }, ] }, { diff --git a/www/docs/src/css/custom.css b/www/docs/src/css/custom.css index b1e3d96e5c..9a0128dc2c 100644 --- a/www/docs/src/css/custom.css +++ b/www/docs/src/css/custom.css @@ -301,4 +301,20 @@ details summary { .DocSearch-Container { z-index: 1001 !important; +} + +.reference-table th:nth-child(2), +.reference-table td:nth-child(2) { + width: 40%; +} + +.reference-table th:nth-child(3), +.reference-table td:nth-child(3) { + width: 50%; +} + +.reference-table .theme-code-block span { + max-width: 100%; + word-break: break-word; + white-space: break-spaces; } \ No newline at end of file From a20261b3197356dca937a237a68b3dcd9add28c8 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 14:15:17 +0300 Subject: [PATCH 5/9] Update 1-3-0.md --- docs/content/advanced/backend/upgrade-guides/1-3-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-0.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md index b6e9ec06b4..769e3312e9 100644 --- a/docs/content/advanced/backend/upgrade-guides/1-3-0.md +++ b/docs/content/advanced/backend/upgrade-guides/1-3-0.md @@ -1,6 +1,6 @@ # v1.3.0 -Version 1.3.0 of Medusa introduces new features to Medusa as well as prepares for a more important update to version 1.3.1. +Version 1.3.0 of Medusa introduces new features and enhancements to Medusa's core. This version introduces a change in loading environment variables into your Medusa server. From b75867b119f5d49ef927131f3a0201879d8686b7 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 19:16:26 +0300 Subject: [PATCH 6/9] merge 1.3.0 with 1.3.1 --- .../advanced/backend/upgrade-guides/1-3-0.md | 43 ------------------- .../advanced/backend/upgrade-guides/1-3-1.md | 40 ++++++++++++++++- www/docs/sidebars.js | 5 --- 3 files changed, 39 insertions(+), 49 deletions(-) delete mode 100644 docs/content/advanced/backend/upgrade-guides/1-3-0.md diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-0.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md deleted file mode 100644 index 769e3312e9..0000000000 --- a/docs/content/advanced/backend/upgrade-guides/1-3-0.md +++ /dev/null @@ -1,43 +0,0 @@ -# v1.3.0 - -Version 1.3.0 of Medusa introduces new features and enhancements to Medusa's core. - -This version introduces a change in loading environment variables into your Medusa server. - -## Environment Variables - -In previous versions of Medusa, The server automatically loads all environment variables in the `.env` file at the root of the Medusa server. - -This new update removes loading it automatically and gives developers the freedom in how to load their environment variables. All environment variables will be loaded by default from the system’s environment variables. - -### Actions Required - -If you use a `.env` file to load environment variables on your server, you need to load the variables manually in `medusa-config.js`. - -You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment: - -```jsx -const dotenv = require('dotenv') - - let ENV_FILE_NAME = ''; - switch (process.env.NODE_ENV) { - case 'production': - ENV_FILE_NAME = '.env.production'; - break; - case 'staging': - ENV_FILE_NAME = '.env.staging'; - break; - case 'test': - ENV_FILE_NAME = '.env.test'; - break; - case 'development': - default: - ENV_FILE_NAME = '.env'; - break; - } - - try { - dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME }); - } catch (e) { - } -``` diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-1.md b/docs/content/advanced/backend/upgrade-guides/1-3-1.md index 818b0c6175..1bc901819d 100644 --- a/docs/content/advanced/backend/upgrade-guides/1-3-1.md +++ b/docs/content/advanced/backend/upgrade-guides/1-3-1.md @@ -1,6 +1,6 @@ # 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. +Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API, as well as a change in loading environment variables into your Medusa server. The changes do not affect the public APIs and require only running necessary data migrations. ## Prerequisites @@ -16,6 +16,44 @@ 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. +## Environment Variables + +In previous versions of Medusa, The server automatically loads all environment variables in the `.env` file at the root of the Medusa server. + +This new update removes loading it automatically and gives developers the freedom in how to load their environment variables. All environment variables will be loaded by default from the system’s environment variables. + +### Actions Required + +If you use a `.env` file to load environment variables on your server, you need to load the variables manually in `medusa-config.js`. + +You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment: + +```jsx +const dotenv = require('dotenv') + + let ENV_FILE_NAME = ''; + switch (process.env.NODE_ENV) { + case 'production': + ENV_FILE_NAME = '.env.production'; + break; + case 'staging': + ENV_FILE_NAME = '.env.staging'; + break; + case 'test': + ENV_FILE_NAME = '.env.test'; + break; + case 'development': + default: + ENV_FILE_NAME = '.env'; + break; + } + + try { + dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME }); + } catch (e) { + } +``` + ## 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. diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 210c426713..7ede695603 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -214,11 +214,6 @@ module.exports = { label: 'Upgrade Guides', collapsed: true, items: [ - { - type: "doc", - id: "advanced/backend/upgrade-guides/1-3-0", - label: "v1.3.0" - }, { type: "doc", id: "advanced/backend/upgrade-guides/1-3-1", From 239de7dfddd2ff96cc2f644f61f011c3712e2081 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 19:20:25 +0300 Subject: [PATCH 7/9] rename to 1.3.0 --- .../advanced/backend/upgrade-guides/{1-3-1.md => 1-3-0.md} | 4 ++-- www/docs/sidebars.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename docs/content/advanced/backend/upgrade-guides/{1-3-1.md => 1-3-0.md} (98%) diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-1.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md similarity index 98% rename from docs/content/advanced/backend/upgrade-guides/1-3-1.md rename to docs/content/advanced/backend/upgrade-guides/1-3-0.md index 1bc901819d..8c34f81a2b 100644 --- a/docs/content/advanced/backend/upgrade-guides/1-3-1.md +++ b/docs/content/advanced/backend/upgrade-guides/1-3-0.md @@ -1,6 +1,6 @@ -# v1.3.1 +# v1.3.0 -Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API, as well as a change in loading environment variables into your Medusa server. The changes do not affect the public APIs and require only running necessary data migrations. +Version 1.3.0 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API, as well as a change in loading environment variables into your Medusa server. The changes do not affect the public APIs and require only running necessary data migrations. ## Prerequisites diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 7ede695603..7a6ac76f11 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -216,8 +216,8 @@ module.exports = { items: [ { type: "doc", - id: "advanced/backend/upgrade-guides/1-3-1", - label: "v1.3.1" + id: "advanced/backend/upgrade-guides/1-3-0", + label: "v1.3.0" }, ] }, From c87ddd73ffe000eb780bf3441ce070a774b0006a Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 19:33:08 +0300 Subject: [PATCH 8/9] docs: Add Services reference (#1548) --- .github/workflows/generate-reference.yml | 43 + .yarnrc | 5 + .../backend/services/create-service.md | 1 + docs/content/references/services/.nojekyll | 1 + .../services/classes/AuthService.md | 136 ++ .../services/classes/CartService.md | 1210 +++++++++++++++++ .../services/classes/ClaimItemService.md | 219 +++ .../services/classes/ClaimService.md | 438 ++++++ .../classes/CustomShippingOptionService.md | 126 ++ .../services/classes/CustomerGroupService.md | 275 ++++ .../services/classes/CustomerService.md | 452 ++++++ .../services/classes/DiscountService.md | 637 +++++++++ .../services/classes/DraftOrderService.md | 266 ++++ .../services/classes/EventBusService.md | 332 +++++ .../classes/FulfillmentProviderService.md | 266 ++++ .../services/classes/FulfillmentService.md | 234 ++++ .../services/classes/GiftCardService.md | 245 ++++ .../services/classes/IdempotencyKeyService.md | 182 +++ .../services/classes/InventoryService.md | 99 ++ .../services/classes/LineItemService.md | 305 +++++ .../services/classes/MiddlewareService.md | 248 ++++ .../services/classes/NoteService.md | 194 +++ .../services/classes/NotificationService.md | 326 +++++ .../services/classes/OauthService.md | 227 ++++ .../services/classes/OrderService.md | 759 +++++++++++ .../classes/PaymentProviderService.md | 497 +++++++ .../classes/ProductCollectionService.md | 264 ++++ .../services/classes/ProductService.md | 662 +++++++++ .../services/classes/ProductTypeService.md | 145 ++ .../services/classes/ProductVariantService.md | 631 +++++++++ .../services/classes/QueryBuilderService.md | 79 ++ .../services/classes/RegionService.md | 457 +++++++ .../services/classes/ReturnReasonService.md | 156 +++ .../services/classes/ReturnService.md | 355 +++++ .../services/classes/SearchService.md | 222 +++ .../services/classes/ShippingOptionService.md | 478 +++++++ .../classes/ShippingProfileService.md | 392 ++++++ .../services/classes/StoreService.md | 216 +++ .../services/classes/SwapService.md | 465 +++++++ .../classes/SystemPaymentProviderService.md | 237 ++++ .../services/classes/TaxProviderService.md | 442 ++++++ .../services/classes/TaxRateService.md | 392 ++++++ .../services/classes/TotalsService.md | 607 +++++++++ .../services/classes/TransactionService.md | 35 + .../services/classes/UserService.md | 384 ++++++ docs/content/references/services/index.md | 45 + package.json | 7 +- typedoc.js | 4 + typedoc.services.js | 13 + www/docs/docusaurus.config.js | 12 +- www/docs/sidebars.js | 19 +- yarn.lock | 63 +- 52 files changed, 14489 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/generate-reference.yml create mode 100644 .yarnrc create mode 100644 docs/content/references/services/.nojekyll create mode 100644 docs/content/references/services/classes/AuthService.md create mode 100644 docs/content/references/services/classes/CartService.md create mode 100644 docs/content/references/services/classes/ClaimItemService.md create mode 100644 docs/content/references/services/classes/ClaimService.md create mode 100644 docs/content/references/services/classes/CustomShippingOptionService.md create mode 100644 docs/content/references/services/classes/CustomerGroupService.md create mode 100644 docs/content/references/services/classes/CustomerService.md create mode 100644 docs/content/references/services/classes/DiscountService.md create mode 100644 docs/content/references/services/classes/DraftOrderService.md create mode 100644 docs/content/references/services/classes/EventBusService.md create mode 100644 docs/content/references/services/classes/FulfillmentProviderService.md create mode 100644 docs/content/references/services/classes/FulfillmentService.md create mode 100644 docs/content/references/services/classes/GiftCardService.md create mode 100644 docs/content/references/services/classes/IdempotencyKeyService.md create mode 100644 docs/content/references/services/classes/InventoryService.md create mode 100644 docs/content/references/services/classes/LineItemService.md create mode 100644 docs/content/references/services/classes/MiddlewareService.md create mode 100644 docs/content/references/services/classes/NoteService.md create mode 100644 docs/content/references/services/classes/NotificationService.md create mode 100644 docs/content/references/services/classes/OauthService.md create mode 100644 docs/content/references/services/classes/OrderService.md create mode 100644 docs/content/references/services/classes/PaymentProviderService.md create mode 100644 docs/content/references/services/classes/ProductCollectionService.md create mode 100644 docs/content/references/services/classes/ProductService.md create mode 100644 docs/content/references/services/classes/ProductTypeService.md create mode 100644 docs/content/references/services/classes/ProductVariantService.md create mode 100644 docs/content/references/services/classes/QueryBuilderService.md create mode 100644 docs/content/references/services/classes/RegionService.md create mode 100644 docs/content/references/services/classes/ReturnReasonService.md create mode 100644 docs/content/references/services/classes/ReturnService.md create mode 100644 docs/content/references/services/classes/SearchService.md create mode 100644 docs/content/references/services/classes/ShippingOptionService.md create mode 100644 docs/content/references/services/classes/ShippingProfileService.md create mode 100644 docs/content/references/services/classes/StoreService.md create mode 100644 docs/content/references/services/classes/SwapService.md create mode 100644 docs/content/references/services/classes/SystemPaymentProviderService.md create mode 100644 docs/content/references/services/classes/TaxProviderService.md create mode 100644 docs/content/references/services/classes/TaxRateService.md create mode 100644 docs/content/references/services/classes/TotalsService.md create mode 100644 docs/content/references/services/classes/TransactionService.md create mode 100644 docs/content/references/services/classes/UserService.md create mode 100644 docs/content/references/services/index.md create mode 100644 typedoc.js create mode 100644 typedoc.services.js diff --git a/.github/workflows/generate-reference.yml b/.github/workflows/generate-reference.yml new file mode 100644 index 0000000000..3410689cc2 --- /dev/null +++ b/.github/workflows/generate-reference.yml @@ -0,0 +1,43 @@ +name: Generate References +on: + push: + branches: + - 'master' + paths: + - packages/medusa/src/services/** +jobs: + services: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - name: Checkout + uses: actions/checkout@v2.3.5 + with: + fetch-depth: 0 + + - name: Setup Node.js environment + uses: actions/setup-node@v2.4.1 + with: + node-version: "14" + cache: "yarn" + + - name: Bootstrap packages + uses: ./.github/actions/cache-bootstrap + with: + extension: unit-tests + + - name: Build Packages + run: yarn build + + - name: Generate Services Reference + run: yarn generate:services + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Automatically Generated Services Reference + file_pattern: docs/content/* + skip_dirty_check: false diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 0000000000..65496704d2 --- /dev/null +++ b/.yarnrc @@ -0,0 +1,5 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +yarn-path ".yarn/releases/yarn-1.19.0.cjs" diff --git a/docs/content/advanced/backend/services/create-service.md b/docs/content/advanced/backend/services/create-service.md index 6ddfc01017..d7b2e692b1 100644 --- a/docs/content/advanced/backend/services/create-service.md +++ b/docs/content/advanced/backend/services/create-service.md @@ -102,4 +102,5 @@ constructor({ helloService, eventBusService }) { ## What’s Next 🚀 +- Check out the [Services Reference](/references/services/classes/AuthService) to see a list of all services in Medusa. - [Learn How to Create an Endpoint.](/advanced/backend/endpoints/add-storefront) diff --git a/docs/content/references/services/.nojekyll b/docs/content/references/services/.nojekyll new file mode 100644 index 0000000000..e2ac6616ad --- /dev/null +++ b/docs/content/references/services/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/docs/content/references/services/classes/AuthService.md b/docs/content/references/services/classes/AuthService.md new file mode 100644 index 0000000000..5c2f9742d4 --- /dev/null +++ b/docs/content/references/services/classes/AuthService.md @@ -0,0 +1,136 @@ +# Class: AuthService + +Can authenticate a user based on email password combination + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`AuthService`** + +## Constructors + +### constructor + +• **new AuthService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/auth.ts:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L12) + +## Methods + +### authenticate + +▸ **authenticate**(`email`, `password`): `Promise`<`AuthenticateResult`\> + +Authenticates a given user based on an email, password combination. Uses +scrypt to match password with hashed value. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `email` | `string` | the email of the user | +| `password` | `string` | the password of the user | + +#### Returns + +`Promise`<`AuthenticateResult`\> + + success: whether authentication succeeded + user: the user document if authentication succeded + error: a string with the error message + +#### Defined in + +[services/auth.ts:78](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L78) + +___ + +### authenticateAPIToken + +▸ **authenticateAPIToken**(`token`): `Promise`<`AuthenticateResult`\> + +Authenticates a given user with an API token + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `token` | `string` | the api_token of the user to authenticate | + +#### Returns + +`Promise`<`AuthenticateResult`\> + + success: whether authentication succeeded + user: the user document if authentication succeded + error: a string with the error message + +#### Defined in + +[services/auth.ts:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L41) + +___ + +### authenticateCustomer + +▸ **authenticateCustomer**(`email`, `password`): `Promise`<`AuthenticateResult`\> + +Authenticates a customer based on an email, password combination. Uses +scrypt to match password with hashed value. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `email` | `string` | the email of the user | +| `password` | `string` | the password of the user | + +#### Returns + +`Promise`<`AuthenticateResult`\> + + success: whether authentication succeeded + user: the user document if authentication succeded + error: a string with the error message + +#### Defined in + +[services/auth.ts:123](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L123) + +___ + +### comparePassword\_ + +▸ **comparePassword_**(`password`, `hash`): `Promise`<`boolean`\> + +Verifies if a password is valid given the provided password hash + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `password` | `string` | the raw password to check | +| `hash` | `string` | the hash to compare against | + +#### Returns + +`Promise`<`boolean`\> + +the result of the comparison + +#### Defined in + +[services/auth.ts:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/auth.ts#L28) diff --git a/docs/content/references/services/classes/CartService.md b/docs/content/references/services/classes/CartService.md new file mode 100644 index 0000000000..107bae439b --- /dev/null +++ b/docs/content/references/services/classes/CartService.md @@ -0,0 +1,1210 @@ +# Class: CartService + +## Hierarchy + +- `TransactionBaseService`<[`CartService`](CartService.md)\> + + ↳ **`CartService`** + +## Constructors + +### constructor + +• **new CartService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `InjectedDependencies` | + +#### Overrides + +TransactionBaseService<CartService\>.constructor + +#### Defined in + +[services/cart.ts:106](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L106) + +## Properties + +### addressRepository\_ + +• `Protected` `Readonly` **addressRepository\_**: typeof `AddressRepository` + +#### Defined in + +[services/cart.ts:86](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L86) + +___ + +### cartRepository\_ + +• `Protected` `Readonly` **cartRepository\_**: typeof `CartRepository` + +#### Defined in + +[services/cart.ts:85](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L85) + +___ + +### configModule + +• `Protected` `Optional` `Readonly` **configModule**: `Record`<`string`, `unknown`\> + +#### Inherited from + +TransactionBaseService.configModule + +___ + +### container + +• `Protected` `Readonly` **container**: `unknown` + +#### Inherited from + +TransactionBaseService.container + +___ + +### customShippingOptionService\_ + +• `Protected` `Readonly` **customShippingOptionService\_**: [`CustomShippingOptionService`](CustomShippingOptionService.md) + +#### Defined in + +[services/cart.ts:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L102) + +___ + +### customerService\_ + +• `Protected` `Readonly` **customerService\_**: [`CustomerService`](CustomerService.md) + +#### Defined in + +[services/cart.ts:95](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L95) + +___ + +### discountService\_ + +• `Protected` `Readonly` **discountService\_**: [`DiscountService`](DiscountService.md) + +#### Defined in + +[services/cart.ts:97](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L97) + +___ + +### eventBus\_ + +• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md) + +#### Defined in + +[services/cart.ts:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L89) + +___ + +### giftCardService\_ + +• `Protected` `Readonly` **giftCardService\_**: [`GiftCardService`](GiftCardService.md) + +#### Defined in + +[services/cart.ts:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L98) + +___ + +### inventoryService\_ + +• `Protected` `Readonly` **inventoryService\_**: [`InventoryService`](InventoryService.md) + +#### Defined in + +[services/cart.ts:101](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L101) + +___ + +### lineItemAdjustmentService\_ + +• `Protected` `Readonly` **lineItemAdjustmentService\_**: `LineItemAdjustmentService` + +#### Defined in + +[services/cart.ts:104](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L104) + +___ + +### lineItemRepository\_ + +• `Protected` `Readonly` **lineItemRepository\_**: typeof `LineItemRepository` + +#### Defined in + +[services/cart.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L88) + +___ + +### lineItemService\_ + +• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md) + +#### Defined in + +[services/cart.ts:93](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L93) + +___ + +### manager\_ + +• `Protected` **manager\_**: `EntityManager` + +#### Overrides + +TransactionBaseService.manager\_ + +#### Defined in + +[services/cart.ts:81](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L81) + +___ + +### paymentProviderService\_ + +• `Protected` `Readonly` **paymentProviderService\_**: [`PaymentProviderService`](PaymentProviderService.md) + +#### Defined in + +[services/cart.ts:94](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L94) + +___ + +### paymentSessionRepository\_ + +• `Protected` `Readonly` **paymentSessionRepository\_**: typeof `PaymentSessionRepository` + +#### Defined in + +[services/cart.ts:87](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L87) + +___ + +### priceSelectionStrategy\_ + +• `Protected` `Readonly` **priceSelectionStrategy\_**: `IPriceSelectionStrategy` + +#### Defined in + +[services/cart.ts:103](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L103) + +___ + +### productService\_ + +• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md) + +#### Defined in + +[services/cart.ts:91](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L91) + +___ + +### productVariantService\_ + +• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md) + +#### Defined in + +[services/cart.ts:90](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L90) + +___ + +### regionService\_ + +• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md) + +#### Defined in + +[services/cart.ts:92](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L92) + +___ + +### shippingMethodRepository\_ + +• `Protected` `Readonly` **shippingMethodRepository\_**: typeof `ShippingMethodRepository` + +#### Defined in + +[services/cart.ts:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L84) + +___ + +### shippingOptionService\_ + +• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md) + +#### Defined in + +[services/cart.ts:96](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L96) + +___ + +### taxProviderService\_ + +• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md) + +#### Defined in + +[services/cart.ts:99](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L99) + +___ + +### totalsService\_ + +• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md) + +#### Defined in + +[services/cart.ts:100](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L100) + +___ + +### transactionManager\_ + +• `Protected` **transactionManager\_**: `undefined` \| `EntityManager` + +#### Overrides + +TransactionBaseService.transactionManager\_ + +#### Defined in + +[services/cart.ts:82](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L82) + +___ + +### Events + +▪ `Static` `Readonly` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `CUSTOMER_UPDATED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/cart.ts:75](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L75) + +## Methods + +### addLineItem + +▸ **addLineItem**(`cartId`, `lineItem`): `Promise`<`Cart`\> + +Adds a line item to the cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart that we will add to | +| `lineItem` | `LineItem` | the line item to add. | + +#### Returns + +`Promise`<`Cart`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:528](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L528) + +___ + +### addShippingMethod + +▸ **addShippingMethod**(`cartId`, `optionId`, `data?`): `Promise`<`Cart`\> + +Adds the shipping method to the list of shipping methods associated with +the cart. Shipping Methods are the ways that an order is shipped, whereas a +Shipping Option is a possible way to ship an order. Shipping Methods may +also have additional details in the data field such as an id for a package +shop. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to add shipping method to | +| `optionId` | `string` | id of shipping option to add as valid method | +| `data` | `Record`<`string`, `unknown`\> | the fulmillment data for the method | + +#### Returns + +`Promise`<`Cart`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:1522](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1522) + +___ + +### adjustFreeShipping\_ + +▸ `Protected` **adjustFreeShipping_**(`cart`, `shouldAdd`): `Promise`<`void`\> + +Ensures shipping total on cart is correct in regards to a potential free +shipping discount +If a free shipping is present, we set shipping methods price to 0 +if a free shipping was present, we set shipping methods to original amount + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the the cart to adjust free shipping for | +| `shouldAdd` | `boolean` | flag to indicate, if we should add or remove | + +#### Returns + +`Promise`<`void`\> + +void + +#### Defined in + +[services/cart.ts:680](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L680) + +___ + +### applyDiscount + +▸ **applyDiscount**(`cart`, `discountCode`): `Promise`<`void`\> + +Updates the cart's discounts. +If discount besides free shipping is already applied, this +will be overwritten +Throws if discount regions does not include the cart region + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart to update | +| `discountCode` | `string` | the discount code | + +#### Returns + +`Promise`<`void`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:1044](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1044) + +___ + +### applyGiftCard\_ + +▸ `Protected` **applyGiftCard_**(`cart`, `code`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cart` | `Cart` | +| `code` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/cart.ts:1008](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1008) + +___ + +### atomicPhase\_ + +▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\> + +Wraps some work within a transactional block. If the service already has +a transaction manager attached this will be reused, otherwise a new +transaction manager is created. + +#### Type parameters + +| Name | +| :------ | +| `TResult` | +| `TError` | + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done | +| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. | +| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler | + +#### Returns + +`Promise`<`TResult`\> + +the result of the transactional work + +#### Inherited from + +TransactionBaseService.atomicPhase\_ + +#### Defined in + +[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/interfaces/transaction-base-service.ts#L53) + +___ + +### authorizePayment + +▸ **authorizePayment**(`cartId`, `context?`): `Promise`<`Cart`\> + +Authorizes a payment for a cart. +Will authorize with chosen payment provider. This will return +a payment object, that we will use to update our cart payment with. +Additionally, if the payment does not require more or fails, we will +set the payment on the cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to authorize payment for | +| `context` | `Record`<`string`, `unknown`\> | object containing whatever is relevant for authorizing the payment with the payment provider. As an example, this could be IP address or similar for fraud handling. | + +#### Returns + +`Promise`<`Cart`\> + +the resulting cart + +#### Defined in + +[services/cart.ts:1183](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1183) + +___ + +### create + +▸ **create**(`data`): `Promise`<`Cart`\> + +Creates a cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `CartCreateProps` | the data to create the cart with | + +#### Returns + +`Promise`<`Cart`\> + +the result of the create operation + +#### Defined in + +[services/cart.ts:329](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L329) + +___ + +### createOrFetchUserFromEmail\_ + +▸ `Protected` **createOrFetchUserFromEmail_**(`email`): `Promise`<`Customer`\> + +Creates or fetches a user based on an email. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `email` | `string` | the email to use | + +#### Returns + +`Promise`<`Customer`\> + +the resultign customer object + +#### Defined in + +[services/cart.ts:886](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L886) + +___ + +### createTaxLines + +▸ **createTaxLines**(`id`): `Promise`<`Cart`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | + +#### Returns + +`Promise`<`Cart`\> + +#### Defined in + +[services/cart.ts:1919](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1919) + +___ + +### decorateTotals\_ + +▸ `Protected` **decorateTotals_**(`cart`, `totalsToSelect`, `options?`): `Promise`<`Cart`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cart` | `Cart` | +| `totalsToSelect` | `TotalField`[] | +| `options` | `TotalsConfig` | + +#### Returns + +`Promise`<`Cart`\> + +#### Defined in + +[services/cart.ts:207](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L207) + +___ + +### delete + +▸ **delete**(`cartId`): `Promise`<`Cart`\> + +Deletes a cart from the database. Completed carts cannot be deleted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to delete | + +#### Returns + +`Promise`<`Cart`\> + +the deleted cart or undefined if the cart was not found. + +#### Defined in + +[services/cart.ts:1834](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1834) + +___ + +### deleteMetadata + +▸ **deleteMetadata**(`cartId`, `key`): `Promise`<`Cart`\> + +Dedicated method to delete metadata for a cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the cart to delete metadata from. | +| `key` | `string` | key for metadata field | + +#### Returns + +`Promise`<`Cart`\> + +resolves to the updated result. + +#### Defined in + +[services/cart.ts:1972](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1972) + +___ + +### deletePaymentSession + +▸ **deletePaymentSession**(`cartId`, `providerId`): `Promise`<`Cart`\> + +Removes a payment session from the cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to remove from | +| `providerId` | `string` | the id of the provider whoose payment session should be removed. | + +#### Returns + +`Promise`<`Cart`\> + +the resulting cart. + +#### Defined in + +[services/cart.ts:1430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1430) + +___ + +### findCustomShippingOption + +▸ **findCustomShippingOption**(`cartCustomShippingOptions`, `optionId`): `undefined` \| `CustomShippingOption` + +Finds the cart's custom shipping options based on the passed option id. +throws if custom options is not empty and no shipping option corresponds to optionId + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartCustomShippingOptions` | `CustomShippingOption`[] | the cart's custom shipping options | +| `optionId` | `string` | id of the normal or custom shipping option to find in the cartCustomShippingOptions | + +#### Returns + +`undefined` \| `CustomShippingOption` + +custom shipping option + +#### Defined in + +[services/cart.ts:1626](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1626) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`Cart`[]\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableCartProps` | the query object for find | +| `config` | `FindConfig`<`Cart`\> | config object | + +#### Returns + +`Promise`<`Cart`[]\> + +the result of the find operation + +#### Defined in + +[services/cart.ts:254](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L254) + +___ + +### refreshAdjustments\_ + +▸ `Protected` **refreshAdjustments_**(`cart`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cart` | `Cart` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/cart.ts:1946](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1946) + +___ + +### refreshPaymentSession + +▸ **refreshPaymentSession**(`cartId`, `providerId`): `Promise`<`Cart`\> + +Refreshes a payment session on a cart + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to remove from | +| `providerId` | `string` | the id of the provider whoose payment session should be removed. | + +#### Returns + +`Promise`<`Cart`\> + +the resulting cart. + +#### Defined in + +[services/cart.ts:1478](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1478) + +___ + +### removeDiscount + +▸ **removeDiscount**(`cartId`, `discountCode`): `Promise`<`Cart`\> + +Removes a discount based on a discount code. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to remove from | +| `discountCode` | `string` | the discount code to remove | + +#### Returns + +`Promise`<`Cart`\> + +the resulting cart + +#### Defined in + +[services/cart.ts:1104](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1104) + +___ + +### removeLineItem + +▸ **removeLineItem**(`cartId`, `lineItemId`): `Promise`<`Cart`\> + +Removes a line item from the cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart that we will remove from | +| `lineItemId` | `string` | the line item to remove. | + +#### Returns + +`Promise`<`Cart`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:432](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L432) + +___ + +### retrieve + +▸ **retrieve**(`cartId`, `options?`, `totalsConfig?`): `Promise`<`Cart`\> + +Gets a cart by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to get. | +| `options` | `FindConfig`<`Cart`\> | the options to get a cart | +| `totalsConfig` | `TotalsConfig` | configuration for retrieval of totals | + +#### Returns + +`Promise`<`Cart`\> + +the cart document. + +#### Defined in + +[services/cart.ts:277](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L277) + +___ + +### setMetadata + +▸ **setMetadata**(`cartId`, `key`, `value`): `Promise`<`Cart`\> + +Dedicated method to set metadata for a cart. +To ensure that plugins does not overwrite each +others metadata fields, setMetadata is provided. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the cart to apply metadata to. | +| `key` | `string` | key for metadata field | +| `value` | `string` \| `number` | value for metadata field. | + +#### Returns + +`Promise`<`Cart`\> + +resolves to the updated result. + +#### Defined in + +[services/cart.ts:1877](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1877) + +___ + +### setPaymentSession + +▸ **setPaymentSession**(`cartId`, `providerId`): `Promise`<`Cart`\> + +Sets a payment method for a cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to add payment method to | +| `providerId` | `string` | the id of the provider to be set to the cart | + +#### Returns + +`Promise`<`Cart`\> + +result of update operation + +#### Defined in + +[services/cart.ts:1249](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1249) + +___ + +### setPaymentSessions + +▸ **setPaymentSessions**(`cartOrCartId`): `Promise`<`void`\> + +Creates, updates and sets payment sessions associated with the cart. The +first time the method is called payment sessions will be created for each +provider. Additional calls will ensure that payment sessions have correct +amounts, currencies, etc. as well as make sure to filter payment sessions +that are not available for the cart's region. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrCartId` | `string` \| `Cart` | the id of the cart to set payment session for | + +#### Returns + +`Promise`<`void`\> + +the result of the update operation. + +#### Defined in + +[services/cart.ts:1322](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1322) + +___ + +### setRegion\_ + +▸ `Protected` **setRegion_**(`cart`, `regionId`, `countryCode`): `Promise`<`void`\> + +Set's the region of a cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart to set region on | +| `regionId` | `string` | the id of the region to set the region to | +| `countryCode` | ``null`` \| `string` | the country code to set the country to | + +#### Returns + +`Promise`<`void`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:1705](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1705) + +___ + +### shouldRetryTransaction\_ + +▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } | + +#### Returns + +`boolean` + +#### Inherited from + +TransactionBaseService.shouldRetryTransaction\_ + +#### Defined in + +[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/interfaces/transaction-base-service.ts#L34) + +___ + +### transformQueryForTotals\_ + +▸ `Protected` **transformQueryForTotals_**(`config`): `FindConfig`<`Cart`\> & { `totalsToSelect`: `TotalField`[] } + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | `FindConfig`<`Cart`\> | + +#### Returns + +`FindConfig`<`Cart`\> & { `totalsToSelect`: `TotalField`[] } + +#### Defined in + +[services/cart.ts:157](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L157) + +___ + +### update + +▸ **update**(`cartId`, `data`): `Promise`<`Cart`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cartId` | `string` | +| `data` | `CartUpdateProps` | + +#### Returns + +`Promise`<`Cart`\> + +#### Defined in + +[services/cart.ts:716](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L716) + +___ + +### updateBillingAddress\_ + +▸ `Protected` **updateBillingAddress_**(`cart`, `addressOrId`, `addrRepo`): `Promise`<`void`\> + +Updates the cart's billing address. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart to update | +| `addressOrId` | `string` \| `AddressPayload` \| `Partial`<`Address`\> | the value to set the billing address to | +| `addrRepo` | `AddressRepository` | the repository to use for address updates | + +#### Returns + +`Promise`<`void`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:919](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L919) + +___ + +### updateCustomerId\_ + +▸ `Protected` **updateCustomerId_**(`cart`, `customerId`): `Promise`<`void`\> + +Sets the customer id of a cart + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart to add email to | +| `customerId` | `string` | the customer to add to cart | + +#### Returns + +`Promise`<`void`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:868](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L868) + +___ + +### updateLineItem + +▸ **updateLineItem**(`cartId`, `lineItemId`, `lineItemUpdate`): `Promise`<`Cart`\> + +Updates a cart's existing line item. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to update | +| `lineItemId` | `string` | the id of the line item to update. | +| `lineItemUpdate` | `LineItemUpdate` | the line item to update. Must include an id field. | + +#### Returns + +`Promise`<`Cart`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:615](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L615) + +___ + +### updatePaymentSession + +▸ **updatePaymentSession**(`cartId`, `update`): `Promise`<`Cart`\> + +Updates the currently selected payment session. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | the id of the cart to update the payment session for | +| `update` | `object` | the data to update the payment session with | + +#### Returns + +`Promise`<`Cart`\> + +the resulting cart + +#### Defined in + +[services/cart.ts:1148](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1148) + +___ + +### updateShippingAddress\_ + +▸ `Protected` **updateShippingAddress_**(`cart`, `addressOrId`, `addrRepo`): `Promise`<`void`\> + +Updates the cart's shipping address. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart to update | +| `addressOrId` | `string` \| `AddressPayload` \| `Partial`<`Address`\> | the value to set the shipping address to | +| `addrRepo` | `AddressRepository` | the repository to use for address updates | + +#### Returns + +`Promise`<`void`\> + +the result of the update operation + +#### Defined in + +[services/cart.ts:959](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L959) + +___ + +### updateUnitPrices\_ + +▸ `Protected` **updateUnitPrices_**(`cart`, `regionId?`, `customer_id?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cart` | `Cart` | +| `regionId?` | `string` | +| `customer_id?` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/cart.ts:1645](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L1645) + +___ + +### validateLineItemShipping\_ + +▸ `Protected` **validateLineItemShipping_**(`shippingMethods`, `lineItem`): `boolean` + +Checks if a given line item has a shipping method that can fulfill it. +Returns true if all products in the cart can be fulfilled with the current +shipping methods. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `shippingMethods` | `ShippingMethod`[] | the set of shipping methods to check from | +| `lineItem` | `LineItem` | the line item | + +#### Returns + +`boolean` + +boolean representing wheter shipping method is validated + +#### Defined in + +[services/cart.ts:498](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/cart.ts#L498) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager?`): [`CartService`](CartService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager?` | `EntityManager` | + +#### Returns + +[`CartService`](CartService.md) + +#### Inherited from + +TransactionBaseService.withTransaction + +#### Defined in + +[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/interfaces/transaction-base-service.ts#L16) diff --git a/docs/content/references/services/classes/ClaimItemService.md b/docs/content/references/services/classes/ClaimItemService.md new file mode 100644 index 0000000000..405bc7c645 --- /dev/null +++ b/docs/content/references/services/classes/ClaimItemService.md @@ -0,0 +1,219 @@ +# Class: ClaimItemService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ClaimItemService`** + +## Constructors + +### constructor + +• **new ClaimItemService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/claim-item.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L11) + +## Properties + +### claimImageRepository\_ + +• **claimImageRepository\_**: `any` + +#### Defined in + +[services/claim-item.js:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L27) + +___ + +### claimTagRepository\_ + +• **claimTagRepository\_**: `any` + +#### Defined in + +[services/claim-item.js:26](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L26) + +___ + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CANCELED` | `string` | +| `CREATED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/claim-item.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L5) + +## Methods + +### cancel + +▸ **cancel**(`id`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/claim-item.js:212](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L212) + +___ + +### create + +▸ **create**(`data`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `data` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/claim-item.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L55) + +___ + +### deleteMetadata + +▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\> + +Dedicated method to delete metadata for an order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the order to delete metadata from. | +| `key` | `string` | key for metadata field | + +#### Returns + +`Promise`<`any`\> + +resolves to the updated result. + +#### Defined in + +[services/claim-item.js:259](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L259) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config object for find | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/claim-item.js:219](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L219) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`Order`\> + +Gets a claim item by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | id of ClaimItem to retrieve | +| `config` | `any` | configuration for the find operation | + +#### Returns + +`Promise`<`Order`\> + +the ClaimItem + +#### Defined in + +[services/claim-item.js:234](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L234) + +___ + +### update + +▸ **update**(`id`, `data`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | +| `data` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/claim-item.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L135) + +___ + +### withTransaction + +▸ **withTransaction**(`manager`): [`ClaimItemService`](ClaimItemService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `manager` | `any` | + +#### Returns + +[`ClaimItemService`](ClaimItemService.md) + +#### Defined in + +[services/claim-item.js:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim-item.js#L36) diff --git a/docs/content/references/services/classes/ClaimService.md b/docs/content/references/services/classes/ClaimService.md new file mode 100644 index 0000000000..2fb72f5a45 --- /dev/null +++ b/docs/content/references/services/classes/ClaimService.md @@ -0,0 +1,438 @@ +# Class: ClaimService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ClaimService`** + +## Constructors + +### constructor + +• **new ClaimService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/claim.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L14) + +## Properties + +### addressRepo\_ + +• **addressRepo\_**: `any` + +#### Defined in + +[services/claim.js:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L36) + +___ + +### claimItemService\_ + +• **claimItemService\_**: `any` + +#### Defined in + +[services/claim.js:37](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L37) + +___ + +### claimRepository\_ + +• **claimRepository\_**: `any` + +#### Defined in + +[services/claim.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L38) + +___ + +### eventBus\_ + +• **eventBus\_**: `any` + +#### Defined in + +[services/claim.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L39) + +___ + +### fulfillmentProviderService\_ + +• **fulfillmentProviderService\_**: `any` + +#### Defined in + +[services/claim.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L40) + +___ + +### fulfillmentService\_ + +• **fulfillmentService\_**: `any` + +#### Defined in + +[services/claim.js:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L41) + +___ + +### inventoryService\_ + +• **inventoryService\_**: `any` + +#### Defined in + +[services/claim.js:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L42) + +___ + +### lineItemService\_ + +• **lineItemService\_**: `any` + +#### Defined in + +[services/claim.js:43](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L43) + +___ + +### paymentProviderService\_ + +• **paymentProviderService\_**: `any` + +#### Defined in + +[services/claim.js:44](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L44) + +___ + +### regionService\_ + +• **regionService\_**: `any` + +#### Defined in + +[services/claim.js:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L45) + +___ + +### returnService\_ + +• **returnService\_**: `any` + +#### Defined in + +[services/claim.js:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L46) + +___ + +### shippingOptionService\_ + +• **shippingOptionService\_**: `any` + +#### Defined in + +[services/claim.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L47) + +___ + +### taxProviderService\_ + +• **taxProviderService\_**: `any` + +#### Defined in + +[services/claim.js:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L48) + +___ + +### totalsService\_ + +• **totalsService\_**: `any` + +#### Defined in + +[services/claim.js:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L49) + +___ + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CANCELED` | `string` | +| `CREATED` | `string` | +| `FULFILLMENT_CREATED` | `string` | +| `REFUND_PROCESSED` | `string` | +| `SHIPMENT_CREATED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/claim.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L5) + +## Methods + +### cancel + +▸ **cancel**(`id`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/claim.js:644](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L644) + +___ + +### cancelFulfillment + +▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `fulfillmentId` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/claim.js:512](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L512) + +___ + +### create + +▸ **create**(`data`): `any` + +Creates a Claim on an Order. Claims consists of items that are claimed and +optionally items to be sent as replacement for the claimed items. The +shipping address that the new items will be shipped to + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `any` | the object containing all data required to create a claim | + +#### Returns + +`any` + +created claim + +#### Defined in + +[services/claim.js:159](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L159) + +___ + +### createFulfillment + +▸ **createFulfillment**(`id`, `config?`): `Claim` + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the object containing all data required to create a claim | +| `config` | `Object` | config object | +| `config.metadata` | `any` | config metadata | +| `config.no_notification` | `undefined` \| `boolean` | config no notification | + +#### Returns + +`Claim` + +created claim + +#### Defined in + +[services/claim.js:378](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L378) + +___ + +### createShipment + +▸ **createShipment**(`id`, `fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `id` | `any` | `undefined` | +| `fulfillmentId` | `any` | `undefined` | +| `trackingLinks` | `any` | `undefined` | +| `config` | `Object` | `undefined` | +| `config.metadata` | `Object` | `{}` | +| `config.no_notification` | `undefined` | `undefined` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/claim.js:577](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L577) + +___ + +### deleteMetadata + +▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\> + +Dedicated method to delete metadata for an order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the order to delete metadata from. | +| `key` | `string` | key for metadata field | + +#### Returns + +`Promise`<`any`\> + +resolves to the updated result. + +#### Defined in + +[services/claim.js:734](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L734) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config object containing query settings | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/claim.js:696](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L696) + +___ + +### processRefund + +▸ **processRefund**(`id`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/claim.js:535](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L535) + +___ + +### retrieve + +▸ **retrieve**(`claimId`, `config?`): `Promise`<`Order`\> + +Gets an order by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `claimId` | `string` | id of order to retrieve | +| `config` | `any` | the config object containing query settings | + +#### Returns + +`Promise`<`Order`\> + +the order document + +#### Defined in + +[services/claim.js:711](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L711) + +___ + +### update + +▸ **update**(`id`, `data`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | +| `data` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/claim.js:80](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L80) + +___ + +### withTransaction + +▸ **withTransaction**(`manager`): [`ClaimService`](ClaimService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `manager` | `any` | + +#### Returns + +[`ClaimService`](ClaimService.md) + +#### Defined in + +[services/claim.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/claim.js#L52) diff --git a/docs/content/references/services/classes/CustomShippingOptionService.md b/docs/content/references/services/classes/CustomShippingOptionService.md new file mode 100644 index 0000000000..c9c34eb9b9 --- /dev/null +++ b/docs/content/references/services/classes/CustomShippingOptionService.md @@ -0,0 +1,126 @@ +# Class: CustomShippingOptionService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`CustomShippingOptionService`** + +## Constructors + +### constructor + +• **new CustomShippingOptionService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/custom-shipping-option.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L5) + +## Methods + +### create + +▸ **create**(`data`, `config?`): `Promise`<`CustomShippingOption`\> + +Creates a custom shipping option associated with a given author + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `any` | the custom shipping option to create | +| `config` | `any` | any configurations if needed, including meta data | + +#### Returns + +`Promise`<`CustomShippingOption`\> + +resolves to the creation result + +#### Defined in + +[services/custom-shipping-option.js:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L88) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`CustomShippingOption`[]\> + +Fetches all custom shipping options related to the given selector + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. | + +#### Returns + +`Promise`<`CustomShippingOption`[]\> + +custom shipping options matching the query + +#### Defined in + +[services/custom-shipping-option.js:65](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L65) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`CustomShippingOption`\> + +Retrieves a specific shipping option. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the custom shipping option to retrieve. | +| `config` | `any` | any options needed to query for the result. | + +#### Returns + +`Promise`<`CustomShippingOption`\> + +which resolves to the requested custom shipping option. + +#### Defined in + +[services/custom-shipping-option.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L40) + +___ + +### withTransaction + +▸ **withTransaction**(`manager`): [`CustomShippingOptionService`](CustomShippingOptionService.md) + +Sets the service's manager to a given transaction manager + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `manager` | `EntityManager` | the manager to use | + +#### Returns + +[`CustomShippingOptionService`](CustomShippingOptionService.md) + +a cloned CustomShippingOption service + +#### Defined in + +[services/custom-shipping-option.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/custom-shipping-option.js#L20) diff --git a/docs/content/references/services/classes/CustomerGroupService.md b/docs/content/references/services/classes/CustomerGroupService.md new file mode 100644 index 0000000000..a94630945d --- /dev/null +++ b/docs/content/references/services/classes/CustomerGroupService.md @@ -0,0 +1,275 @@ +# Class: CustomerGroupService + +Provides layer to manipulate discounts. + +**`implements`** {BaseService} + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`CustomerGroupService`** + +## Constructors + +### constructor + +• **new CustomerGroupService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `CustomerGroupConstructorProps` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/customer-group.ts:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L31) + +## Properties + +### customerGroupRepository\_ + +• `Private` **customerGroupRepository\_**: typeof `CustomerGroupRepository` + +#### Defined in + +[services/customer-group.ts:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L27) + +___ + +### customerService\_ + +• `Private` **customerService\_**: [`CustomerService`](CustomerService.md) + +#### Defined in + +[services/customer-group.ts:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L29) + +___ + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/customer-group.ts:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L25) + +## Methods + +### addCustomers + +▸ **addCustomers**(`id`, `customerIds`): `Promise`<`CustomerGroup`\> + +Add a batch of customers to a customer group at once + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | id of the customer group to add customers to | +| `customerIds` | `string` \| `string`[] | customer id's to add to the group | + +#### Returns + +`Promise`<`CustomerGroup`\> + +the customer group after insertion + +#### Defined in + +[services/customer-group.ts:113](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L113) + +___ + +### create + +▸ **create**(`group`): `Promise`<`CustomerGroup`\> + +Creates a customer group with the provided data. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `group` | `DeepPartial`<`CustomerGroup`\> | the customer group to create | + +#### Returns + +`Promise`<`CustomerGroup`\> + +the result of the create operation + +#### Defined in + +[services/customer-group.ts:86](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L86) + +___ + +### delete + +▸ **delete**(`groupId`): `Promise`<`void`\> + +Remove customer group + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `groupId` | `string` | id of the customer group to delete | + +#### Returns + +`Promise`<`void`\> + +a promise + +#### Defined in + +[services/customer-group.ts:194](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L194) + +___ + +### list + +▸ **list**(`selector?`, `config`): `Promise`<`CustomerGroup`[]\> + +List customer groups. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableCustomerGroupProps` | the query object for find | +| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find | + +#### Returns + +`Promise`<`CustomerGroup`[]\> + +the result of the find operation + +#### Defined in + +[services/customer-group.ts:217](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L217) + +___ + +### listAndCount + +▸ **listAndCount**(`selector?`, `config`): `Promise`<[`CustomerGroup`[], `number`]\> + +Retrieve a list of customer groups and total count of records that match the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableCustomerGroupProps` | the query object for find | +| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find | + +#### Returns + +`Promise`<[`CustomerGroup`[], `number`]\> + +the result of the find operation + +#### Defined in + +[services/customer-group.ts:236](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L236) + +___ + +### removeCustomer + +▸ **removeCustomer**(`id`, `customerIds`): `Promise`<`CustomerGroup`\> + +Remove list of customers from a customergroup + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | id of the customer group from which the customers are removed | +| `customerIds` | `string` \| `string`[] | id's of the customer to remove from group | + +#### Returns + +`Promise`<`CustomerGroup`\> + +the customergroup with the provided id + +#### Defined in + +[services/customer-group.ts:271](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L271) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`CustomerGroup`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `config` | `Object` | + +#### Returns + +`Promise`<`CustomerGroup`\> + +#### Defined in + +[services/customer-group.ts:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L62) + +___ + +### update + +▸ **update**(`customerGroupId`, `update`): `Promise`<`CustomerGroup`[]\> + +Update a customer group. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customerGroupId` | `string` | id of the customer group | +| `update` | `CustomerGroupUpdate` | customer group partial data | + +#### Returns + +`Promise`<`CustomerGroup`[]\> + +resulting customer group + +#### Defined in + +[services/customer-group.ts:162](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L162) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`CustomerGroupService`](CustomerGroupService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`CustomerGroupService`](CustomerGroupService.md) + +#### Defined in + +[services/customer-group.ts:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer-group.ts#L46) diff --git a/docs/content/references/services/classes/CustomerService.md b/docs/content/references/services/classes/CustomerService.md new file mode 100644 index 0000000000..52fc81ca74 --- /dev/null +++ b/docs/content/references/services/classes/CustomerService.md @@ -0,0 +1,452 @@ +# Class: CustomerService + +Provides layer to manipulate customers. + +**`implements`** {BaseService} + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`CustomerService`** + +## Constructors + +### constructor + +• **new CustomerService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/customer.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L20) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `PASSWORD_RESET` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/customer.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L14) + +## Methods + +### addAddress + +▸ **addAddress**(`customerId`, `address`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `customerId` | `any` | +| `address` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/customer.js:479](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L479) + +___ + +### count + +▸ **count**(): `Promise`<`any`\> + +Return the total number of documents in database + +#### Returns + +`Promise`<`any`\> + +the result of the count operation + +#### Defined in + +[services/customer.js:192](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L192) + +___ + +### create + +▸ **create**(`customer`): `Promise`<`any`\> + +Creates a customer from an email - customers can have accounts associated, +e.g. to login and view order history, etc. If a password is provided the +customer will automatically get an account, otherwise the customer is just +used to hold details of customers. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customer` | `any` | the customer to create | + +#### Returns + +`Promise`<`any`\> + +the result of create + +#### Defined in + +[services/customer.js:290](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L290) + +___ + +### decorate + +▸ **decorate**(`customer`, `fields?`, `expandFields?`): `Customer` + +Decorates a customer. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `customer` | `Customer` | `undefined` | the cart to decorate. | +| `fields` | `string`[] | `[]` | the fields to include. | +| `expandFields` | `string`[] | `[]` | fields to expand. | + +#### Returns + +`Customer` + +return the decorated customer. + +#### Defined in + +[services/customer.js:547](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L547) + +___ + +### delete + +▸ **delete**(`customerId`): `Promise`<`any`\> + +Deletes a customer from a given customer id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customerId` | `string` | the id of the customer to delete. Must be castable as an ObjectId | + +#### Returns + +`Promise`<`any`\> + +the result of the delete operation. + +#### Defined in + +[services/customer.js:523](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L523) + +___ + +### generateResetPasswordToken + +▸ **generateResetPasswordToken**(`customerId`): `string` + +Generate a JSON Web token, that will be sent to a customer, that wishes to +reset password. +The token will be signed with the customer's current password hash as a +secret a long side a payload with userId and the expiry time for the token, +which is always 15 minutes. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customerId` | `string` | the customer to reset the password for | + +#### Returns + +`string` + +the generated JSON web token + +#### Defined in + +[services/customer.js:67](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L67) + +___ + +### hashPassword\_ + +▸ **hashPassword_**(`password`): `Promise`<`string`\> + +Hashes a password + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `password` | `string` | the value to hash | + +#### Returns + +`Promise`<`string`\> + +hashed password + +#### Defined in + +[services/customer.js:277](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L277) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config object containing query settings | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/customer.js:106](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L106) + +___ + +### listAndCount + +▸ **listAndCount**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `FindConfig`<`Customer`\> | the config object containing query settings | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/customer.js:147](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L147) + +___ + +### removeAddress + +▸ **removeAddress**(`customerId`, `addressId`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `customerId` | `any` | +| `addressId` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/customer.js:460](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L460) + +___ + +### retrieve + +▸ **retrieve**(`customerId`, `config?`): `Promise`<`Customer`\> + +Gets a customer by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customerId` | `string` | the id of the customer to get. | +| `config` | `any` | the config object containing query settings | + +#### Returns + +`Promise`<`Customer`\> + +the customer document. + +#### Defined in + +[services/customer.js:205](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L205) + +___ + +### retrieveByEmail + +▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`Customer`\> + +Gets a customer by email. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `email` | `string` | the email of the customer to get. | +| `config` | `any` | the config object containing query settings | + +#### Returns + +`Promise`<`Customer`\> + +the customer document. + +#### Defined in + +[services/customer.js:230](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L230) + +___ + +### retrieveByPhone + +▸ **retrieveByPhone**(`phone`, `config?`): `Promise`<`Customer`\> + +Gets a customer by phone. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `phone` | `string` | the phone of the customer to get. | +| `config` | `any` | the config object containing query settings | + +#### Returns + +`Promise`<`Customer`\> + +the customer document. + +#### Defined in + +[services/customer.js:254](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L254) + +___ + +### update + +▸ **update**(`customerId`, `update`): `Promise`<`any`\> + +Updates a customer. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customerId` | `string` | the id of the variant. Must be a string that can be casted to an ObjectId | +| `update` | `any` | an object with the update values. | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/customer.js:346](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L346) + +___ + +### updateAddress + +▸ **updateAddress**(`customerId`, `addressId`, `address`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `customerId` | `any` | +| `addressId` | `any` | +| `address` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/customer.js:441](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L441) + +___ + +### updateBillingAddress\_ + +▸ **updateBillingAddress_**(`customer`, `addressOrId`, `addrRepo`): `Promise`<`any`\> + +Updates the customers' billing address. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `customer` | `Customer` | the Customer to update | +| `addressOrId` | `any` | the value to set the billing address to | +| `addrRepo` | `any` | address repository | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/customer.js:408](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L408) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`CustomerService`](CustomerService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`CustomerService`](CustomerService.md) + +#### Defined in + +[services/customer.js:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/customer.js#L41) diff --git a/docs/content/references/services/classes/DiscountService.md b/docs/content/references/services/classes/DiscountService.md new file mode 100644 index 0000000000..af988e0694 --- /dev/null +++ b/docs/content/references/services/classes/DiscountService.md @@ -0,0 +1,637 @@ +# Class: DiscountService + +Provides layer to manipulate discounts. + +**`implements`** {BaseService} + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`DiscountService`** + +## Constructors + +### constructor + +• **new DiscountService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/discount.ts:59](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L59) + +## Properties + +### discountConditionRepository\_ + +• `Private` **discountConditionRepository\_**: typeof `DiscountConditionRepository` + +#### Defined in + +[services/discount.ts:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L52) + +___ + +### discountConditionService\_ + +• `Private` **discountConditionService\_**: `DiscountConditionService` + +#### Defined in + +[services/discount.ts:53](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L53) + +___ + +### discountRepository\_ + +• `Private` **discountRepository\_**: typeof `DiscountRepository` + +#### Defined in + +[services/discount.ts:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L49) + +___ + +### discountRuleRepository\_ + +• `Private` **discountRuleRepository\_**: typeof `DiscountRuleRepository` + +#### Defined in + +[services/discount.ts:50](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L50) + +___ + +### eventBus\_ + +• `Private` **eventBus\_**: [`EventBusService`](EventBusService.md) + +#### Defined in + +[services/discount.ts:57](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L57) + +___ + +### giftCardRepository\_ + +• `Private` **giftCardRepository\_**: typeof `GiftCardRepository` + +#### Defined in + +[services/discount.ts:51](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L51) + +___ + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/discount.ts:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L48) + +___ + +### productService\_ + +• `Private` **productService\_**: [`ProductService`](ProductService.md) + +#### Defined in + +[services/discount.ts:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L55) + +___ + +### regionService\_ + +• `Private` **regionService\_**: [`RegionService`](RegionService.md) + +#### Defined in + +[services/discount.ts:56](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L56) + +___ + +### totalsService\_ + +• `Private` **totalsService\_**: [`TotalsService`](TotalsService.md) + +#### Defined in + +[services/discount.ts:54](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L54) + +## Methods + +### addRegion + +▸ **addRegion**(`discountId`, `regionId`): `Promise`<`Discount`\> + +Adds a region to the discount regions array. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | id of discount | +| `regionId` | `string` | id of region to add | + +#### Returns + +`Promise`<`Discount`\> + +the result of the update operation + +#### Defined in + +[services/discount.ts:521](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L521) + +___ + +### calculateDiscountForLineItem + +▸ **calculateDiscountForLineItem**(`discountId`, `lineItem`, `cart`): `Promise`<`number`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discountId` | `string` | +| `lineItem` | `LineItem` | +| `cart` | `Cart` | + +#### Returns + +`Promise`<`number`\> + +#### Defined in + +[services/discount.ts:624](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L624) + +___ + +### canApplyForCustomer + +▸ **canApplyForCustomer**(`discountRuleId`, `customerId`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discountRuleId` | `string` | +| `customerId` | `undefined` \| `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Defined in + +[services/discount.ts:762](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L762) + +___ + +### create + +▸ **create**(`discount`): `Promise`<`Discount`\> + +Creates a discount with provided data given that the data is validated. +Normalizes discount code to uppercase. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discount` | `CreateDiscountInput` | the discount data to create | + +#### Returns + +`Promise`<`Discount`\> + +the result of the create operation + +#### Defined in + +[services/discount.ts:220](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L220) + +___ + +### createDynamicCode + +▸ **createDynamicCode**(`discountId`, `data`): `Promise`<`Discount`\> + +Creates a dynamic code for a discount id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | the id of the discount to create a code for | +| `data` | `CreateDynamicDiscountInput` | the object containing a code to identify the discount by | + +#### Returns + +`Promise`<`Discount`\> + +the newly created dynamic code + +#### Defined in + +[services/discount.ts:446](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L446) + +___ + +### delete + +▸ **delete**(`discountId`): `Promise`<`void`\> + +Deletes a discount idempotently + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | id of discount to delete | + +#### Returns + +`Promise`<`void`\> + +the result of the delete operation + +#### Defined in + +[services/discount.ts:583](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L583) + +___ + +### deleteDynamicCode + +▸ **deleteDynamicCode**(`discountId`, `code`): `Promise`<`void`\> + +Deletes a dynamic code for a discount id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | the id of the discount to create a code for | +| `code` | `string` | the code to identify the discount by | + +#### Returns + +`Promise`<`void`\> + +the newly created dynamic code + +#### Defined in + +[services/discount.ts:498](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L498) + +___ + +### hasExpired + +▸ **hasExpired**(`discount`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discount` | `Discount` | + +#### Returns + +`boolean` + +#### Defined in + +[services/discount.ts:733](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L733) + +___ + +### hasNotStarted + +▸ **hasNotStarted**(`discount`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discount` | `Discount` | + +#### Returns + +`boolean` + +#### Defined in + +[services/discount.ts:729](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L729) + +___ + +### hasReachedLimit + +▸ **hasReachedLimit**(`discount`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discount` | `Discount` | + +#### Returns + +`boolean` + +#### Defined in + +[services/discount.ts:723](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L723) + +___ + +### isDisabled + +▸ **isDisabled**(`discount`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discount` | `Discount` | + +#### Returns + +`boolean` + +#### Defined in + +[services/discount.ts:741](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L741) + +___ + +### isValidForRegion + +▸ **isValidForRegion**(`discount`, `region_id`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discount` | `Discount` | +| `region_id` | `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Defined in + +[services/discount.ts:745](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L745) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`Discount`[]\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableDiscountProps` | the query object for find | +| `config` | `FindConfig`<`Discount`\> | the config object containing query settings | + +#### Returns + +`Promise`<`Discount`[]\> + +the result of the find operation + +#### Defined in + +[services/discount.ts:156](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L156) + +___ + +### listAndCount + +▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`Discount`[], `number`]\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableDiscountProps` | the query object for find | +| `config` | `FindConfig`<`Discount`\> | the config object containing query settings | + +#### Returns + +`Promise`<[`Discount`[], `number`]\> + +the result of the find operation + +#### Defined in + +[services/discount.ts:173](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L173) + +___ + +### removeRegion + +▸ **removeRegion**(`discountId`, `regionId`): `Promise`<`Discount`\> + +Removes a region from the discount regions array. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | id of discount | +| `regionId` | `string` | id of region to remove | + +#### Returns + +`Promise`<`Discount`\> + +the result of the update operation + +#### Defined in + +[services/discount.ts:557](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L557) + +___ + +### retrieve + +▸ **retrieve**(`discountId`, `config?`): `Promise`<`Discount`\> + +Gets a discount by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | id of discount to retrieve | +| `config` | `FindConfig`<`Discount`\> | the config object containing query settings | + +#### Returns + +`Promise`<`Discount`\> + +the discount + +#### Defined in + +[services/discount.ts:285](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L285) + +___ + +### retrieveByCode + +▸ **retrieveByCode**(`discountCode`, `config?`): `Promise`<`Discount`\> + +Gets a discount by discount code. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountCode` | `string` | discount code of discount to retrieve | +| `config` | `FindConfig`<`Discount`\> | the config object containing query settings | + +#### Returns + +`Promise`<`Discount`\> + +the discount document + +#### Defined in + +[services/discount.ts:313](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L313) + +___ + +### update + +▸ **update**(`discountId`, `update`): `Promise`<`Discount`\> + +Updates a discount. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountId` | `string` | discount id of discount to update | +| `update` | `UpdateDiscountInput` | the data to update the discount with | + +#### Returns + +`Promise`<`Discount`\> + +the result of the update operation + +#### Defined in + +[services/discount.ts:348](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L348) + +___ + +### validateDiscountForCartOrThrow + +▸ **validateDiscountForCartOrThrow**(`cart`, `discount`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cart` | `Cart` | +| `discount` | `Discount` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/discount.ts:665](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L665) + +___ + +### validateDiscountForProduct + +▸ **validateDiscountForProduct**(`discountRuleId`, `productId`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `discountRuleId` | `string` | +| `productId` | `undefined` \| `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Defined in + +[services/discount.ts:599](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L599) + +___ + +### validateDiscountRule\_ + +▸ **validateDiscountRule_**<`T`\>(`discountRule`): `T` + +Creates a discount rule with provided data given that the data is validated. + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | extends `Object` | + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discountRule` | `T` | the discount rule to create | + +#### Returns + +`T` + +the result of the create operation + +#### Defined in + +[services/discount.ts:138](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L138) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`DiscountService`](DiscountService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`DiscountService`](DiscountService.md) + +#### Defined in + +[services/discount.ts:108](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/discount.ts#L108) diff --git a/docs/content/references/services/classes/DraftOrderService.md b/docs/content/references/services/classes/DraftOrderService.md new file mode 100644 index 0000000000..747f1e5ebc --- /dev/null +++ b/docs/content/references/services/classes/DraftOrderService.md @@ -0,0 +1,266 @@ +# Class: DraftOrderService + +Handles draft orders + +**`implements`** {BaseService} + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`DraftOrderService`** + +## Constructors + +### constructor + +• **new DraftOrderService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/draft-order.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L15) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/draft-order.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L10) + +## Methods + +### create + +▸ **create**(`data`): `Promise`<`DraftOrder`\> + +Creates a draft order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `any` | data to create draft order from | + +#### Returns + +`Promise`<`DraftOrder`\> + +the created draft order + +#### Defined in + +[services/draft-order.js:233](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L233) + +___ + +### delete + +▸ **delete**(`draftOrderId`): `Promise`<`any`\> + +Deletes draft order idempotently. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `draftOrderId` | `string` | id of draft order to delete | + +#### Returns + +`Promise`<`any`\> + +empty promise + +#### Defined in + +[services/draft-order.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L135) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`DraftOrder`\> + +Lists draft orders + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | query object for find | +| `config` | `any` | configurable attributes for find | + +#### Returns + +`Promise`<`DraftOrder`\> + +list of draft orders + +#### Defined in + +[services/draft-order.js:215](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L215) + +___ + +### listAndCount + +▸ **listAndCount**(`selector`, `config?`): `Promise`<`DraftOrder`[]\> + +Lists draft orders alongside the count + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | query selector to filter draft orders | +| `config` | `any` | query config | + +#### Returns + +`Promise`<`DraftOrder`[]\> + +draft orders + +#### Defined in + +[services/draft-order.js:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L161) + +___ + +### registerCartCompletion + +▸ **registerCartCompletion**(`doId`, `orderId`): `Promise`<`any`\> + +Registers a draft order as completed, when an order has been completed. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `doId` | `string` | id of draft order to complete | +| `orderId` | `string` | id of order completed from draft order cart | + +#### Returns + +`Promise`<`any`\> + +the created order + +#### Defined in + +[services/draft-order.js:336](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L336) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`DraftOrder`\> + +Retrieves a draft order with the given id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | id of the draft order to retrieve | +| `config` | `any` | query object for findOne | + +#### Returns + +`Promise`<`DraftOrder`\> + +the draft order + +#### Defined in + +[services/draft-order.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L84) + +___ + +### retrieveByCartId + +▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`DraftOrder`\> + +Retrieves a draft order based on its associated cart id + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | cart id that the draft orders's cart has | +| `config` | `any` | query object for findOne | + +#### Returns + +`Promise`<`DraftOrder`\> + +the draft order + +#### Defined in + +[services/draft-order.js:111](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L111) + +___ + +### update + +▸ **update**(`doId`, `data`): `Promise`<`DraftOrder`\> + +Updates a draft order with the given data + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `doId` | `string` | id of the draft order | +| `data` | `DraftOrder` | values to update the order with | + +#### Returns + +`Promise`<`DraftOrder`\> + +the updated draft order + +#### Defined in + +[services/draft-order.js:357](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L357) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`DraftOrderService`](DraftOrderService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`DraftOrderService`](DraftOrderService.md) + +#### Defined in + +[services/draft-order.js:56](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/draft-order.js#L56) diff --git a/docs/content/references/services/classes/EventBusService.md b/docs/content/references/services/classes/EventBusService.md new file mode 100644 index 0000000000..3d16aefaa8 --- /dev/null +++ b/docs/content/references/services/classes/EventBusService.md @@ -0,0 +1,332 @@ +# Class: EventBusService + +Can keep track of multiple subscribers to different events and run the +subscribers when events happen. Events will run asynchronously. + +## Constructors + +### constructor + +• **new EventBusService**(`__namedParameters`, `config`, `singleton?`) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `__namedParameters` | `Object` | `undefined` | +| `config` | `any` | `undefined` | +| `singleton` | `boolean` | `true` | + +#### Defined in + +[services/event-bus.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L10) + +## Properties + +### config\_ + +• **config\_**: `any` + +#### Defined in + +[services/event-bus.js:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L31) + +___ + +### enRun\_ + +• **enRun\_**: `undefined` \| `boolean` + +#### Defined in + +[services/event-bus.js:182](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L182) + +___ + +### enqueue\_ + +• **enqueue\_**: `undefined` \| `Promise`<`void`\> + +#### Defined in + +[services/event-bus.js:183](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L183) + +___ + +### redisClient\_ + +• **redisClient\_**: `any` + +#### Defined in + +[services/event-bus.js:51](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L51) + +___ + +### redisSubscriber\_ + +• **redisSubscriber\_**: `any` + +#### Defined in + +[services/event-bus.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L52) + +___ + +### stagedJobRepository\_ + +• **stagedJobRepository\_**: `any` + +#### Defined in + +[services/event-bus.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L39) + +## Methods + +### createCronJob + +▸ **createCronJob**(`eventName`, `data`, `cron`, `handler`): `void` + +Registers a cron job. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | the name of the event | +| `data` | `any` | the data to be sent with the event | +| `cron` | `string` | the cron pattern | +| `handler` | `Function` | the handler to call on each cron job | + +#### Returns + +`void` + +#### Defined in + +[services/event-bus.js:280](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L280) + +___ + +### cronWorker\_ + +▸ **cronWorker_**(`job`): `Promise`<`any`\> + +Handles incoming jobs. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `job` | `any` | The job object | + +#### Returns + +`Promise`<`any`\> + +resolves to the results of the subscriber calls. + +#### Defined in + +[services/event-bus.js:255](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L255) + +___ + +### emit + +▸ **emit**(`eventName`, `data`, `options?`): `BullJob` + +Calls all subscribers when an event occurs. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | the name of the event to be process. | +| `data` | `any` | the data to send to the subscriber. | +| `options` | `any` | options to add the job with | + +#### Returns + +`BullJob` + +- the job from our queue + +#### Defined in + +[services/event-bus.js:154](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L154) + +___ + +### enqueuer\_ + +▸ **enqueuer_**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/event-bus.js:191](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L191) + +___ + +### registerCronHandler\_ + +▸ **registerCronHandler_**(`event`, `subscriber`): `void` + +Adds a function to a list of event subscribers. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `event` | `string` | the event that the subscriber will listen for. | +| `subscriber` | `func` | the function to be called when a certain event happens. Subscribers must return a Promise. | + +#### Returns + +`void` + +#### Defined in + +[services/event-bus.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L135) + +___ + +### sleep + +▸ **sleep**(`ms`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `ms` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/event-bus.js:175](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L175) + +___ + +### startEnqueuer + +▸ **startEnqueuer**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/event-bus.js:181](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L181) + +___ + +### stopEnqueuer + +▸ **stopEnqueuer**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/event-bus.js:186](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L186) + +___ + +### subscribe + +▸ **subscribe**(`event`, `subscriber`): `void` + +Adds a function to a list of event subscribers. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `event` | `string` | the event that the subscriber will listen for. | +| `subscriber` | `func` | the function to be called when a certain event happens. Subscribers must return a Promise. | + +#### Returns + +`void` + +#### Defined in + +[services/event-bus.js:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L98) + +___ + +### unsubscribe + +▸ **unsubscribe**(`event`, `subscriber`): `void` + +Adds a function to a list of event subscribers. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `event` | `string` | the event that the subscriber will listen for. | +| `subscriber` | `func` | the function to be called when a certain event happens. Subscribers must return a Promise. | + +#### Returns + +`void` + +#### Defined in + +[services/event-bus.js:116](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L116) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`EventBusService`](EventBusService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`EventBusService`](EventBusService.md) + +#### Defined in + +[services/event-bus.js:69](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L69) + +___ + +### worker\_ + +▸ **worker_**(`job`): `Promise`<`any`\> + +Handles incoming jobs. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `job` | `any` | The job object | + +#### Returns + +`Promise`<`any`\> + +resolves to the results of the subscriber calls. + +#### Defined in + +[services/event-bus.js:226](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/event-bus.js#L226) diff --git a/docs/content/references/services/classes/FulfillmentProviderService.md b/docs/content/references/services/classes/FulfillmentProviderService.md new file mode 100644 index 0000000000..9ea592843e --- /dev/null +++ b/docs/content/references/services/classes/FulfillmentProviderService.md @@ -0,0 +1,266 @@ +# Class: FulfillmentProviderService + +Helps retrive fulfillment providers + +## Constructors + +### constructor + +• **new FulfillmentProviderService**(`container`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `container` | `any` | + +#### Defined in + +[services/fulfillment-provider.js:7](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L7) + +## Methods + +### calculatePrice + +▸ **calculatePrice**(`option`, `data`, `cart`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `option` | `any` | +| `data` | `any` | +| `cart` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:79](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L79) + +___ + +### canCalculate + +▸ **canCalculate**(`option`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `option` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:64](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L64) + +___ + +### cancelFulfillment + +▸ **cancelFulfillment**(`fulfillment`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `fulfillment` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:74](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L74) + +___ + +### createFulfillment + +▸ **createFulfillment**(`method`, `items`, `order`, `fulfillment`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `method` | `any` | +| `items` | `any` | +| `order` | `any` | +| `fulfillment` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:59](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L59) + +___ + +### createReturn + +▸ **createReturn**(`returnOrder`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `returnOrder` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L89) + +___ + +### list + +▸ **list**(): `Promise`<`any`\> + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L23) + +___ + +### listFulfillmentOptions + +▸ **listFulfillmentOptions**(`providers`): `Promise`<`any`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `providers` | `any` | + +#### Returns + +`Promise`<`any`[]\> + +#### Defined in + +[services/fulfillment-provider.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L30) + +___ + +### registerInstalledProviders + +▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `providers` | `any` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/fulfillment-provider.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L12) + +___ + +### retrieveDocuments + +▸ **retrieveDocuments**(`providerId`, `fulfillmentData`, `documentType`): `Promise`<`any`\> + +Fetches documents from the fulfillment provider + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `providerId` | `string` | the id of the provider | +| `fulfillmentData` | `any` | the data relating to the fulfillment | +| `documentType` | ``"invoice"`` \| ``"label"`` | the typ of document to fetch | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L102) + +___ + +### retrieveProvider + +▸ **retrieveProvider**(`provider_id`): `FulfillmentService` + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `provider_id` | `string` | the provider id | + +#### Returns + +`FulfillmentService` + +the payment fulfillment provider + +#### Defined in + +[services/fulfillment-provider.js:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L48) + +___ + +### validateFulfillmentData + +▸ **validateFulfillmentData**(`option`, `data`, `cart`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `option` | `any` | +| `data` | `any` | +| `cart` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:69](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L69) + +___ + +### validateOption + +▸ **validateOption**(`option`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `option` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/fulfillment-provider.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment-provider.js#L84) diff --git a/docs/content/references/services/classes/FulfillmentService.md b/docs/content/references/services/classes/FulfillmentService.md new file mode 100644 index 0000000000..c9a8b9b7a8 --- /dev/null +++ b/docs/content/references/services/classes/FulfillmentService.md @@ -0,0 +1,234 @@ +# Class: FulfillmentService + +Handles Fulfillments + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`FulfillmentService`** + +## Constructors + +### constructor + +• **new FulfillmentService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/fulfillment.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L9) + +## Methods + +### cancelFulfillment + +▸ **cancelFulfillment**(`fulfillmentOrId`): `Promise`<`any`\> + +Cancels a fulfillment with the fulfillment provider. Will decrement the +fulfillment_quantity on the line items associated with the fulfillment. +Throws if the fulfillment has already been shipped. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fulfillmentOrId` | `any` | the fulfillment object or id. | + +#### Returns + +`Promise`<`any`\> + +the result of the save operation + +#### Defined in + +[services/fulfillment.js:223](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L223) + +___ + +### createFulfillment + +▸ **createFulfillment**(`order`, `itemsToFulfill`, `custom?`): `Fulfillment`[] + +Creates an order fulfillment +If items needs to be fulfilled by different provider, we make +sure to partition those items, and create fulfillment for +those partitions. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | order to create fulfillment for | +| `itemsToFulfill` | { `item_id`: `string` ; `quantity`: `number` }[] | - | +| `custom` | `any` | potential custom values to add | + +#### Returns + +`Fulfillment`[] + +the created fulfillments + +#### Defined in + +[services/fulfillment.js:171](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L171) + +___ + +### createShipment + +▸ **createShipment**(`fulfillmentId`, `trackingLinks`, `config?`): `Fulfillment` + +Creates a shipment by marking a fulfillment as shipped. Adds +tracking links and potentially more metadata. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fulfillmentId` | `Order` | the fulfillment to ship | +| `trackingLinks` | `TrackingLink`[] | tracking links for the shipment | +| `config` | `any` | potential configuration settings, such as no_notification and metadata | + +#### Returns + +`Fulfillment` + +the shipped fulfillment + +#### Defined in + +[services/fulfillment.js:270](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L270) + +___ + +### getFulfillmentItems\_ + +▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\> + +Retrieves the order line items, given an array of items. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to get line items from | +| `items` | `Object` | the items to get | +| `items.item_id` | `string` | - | +| `items.quantity` | `number` | - | +| `transformer` | `Function` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. | + +#### Returns + +`Promise`<`LineItem`[]\> + +the line items generated by the transformer. + +#### Defined in + +[services/fulfillment.js:94](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L94) + +___ + +### partitionItems\_ + +▸ **partitionItems_**(`shippingMethods`, `items`): { `shipping_method`: `any` = method }[] + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `shippingMethods` | `any` | +| `items` | `any` | + +#### Returns + +{ `shipping_method`: `any` = method }[] + +#### Defined in + +[services/fulfillment.js:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L62) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Fulfillment` + +Retrieves a fulfillment by its id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the fulfillment to retrieve | +| `config` | `any` | optional values to include with fulfillmentRepository query | + +#### Returns + +`Fulfillment` + +the fulfillment + +#### Defined in + +[services/fulfillment.js:142](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L142) + +___ + +### validateFulfillmentLineItem\_ + +▸ **validateFulfillmentLineItem_**(`item`, `quantity`): `LineItem` + +Checks that a given quantity of a line item can be fulfilled. Fails if the +fulfillable quantity is lower than the requested fulfillment quantity. +Fulfillable quantity is calculated by subtracting the already fulfilled +quantity from the quantity that was originally purchased. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `item` | `LineItem` | the line item to check has sufficient fulfillable quantity. | +| `quantity` | `number` | the quantity that is requested to be fulfilled. | + +#### Returns + +`LineItem` + +a line item that has the requested fulfillment quantity + set. + +#### Defined in + +[services/fulfillment.js:116](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L116) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`FulfillmentService`](FulfillmentService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`FulfillmentService`](FulfillmentService.md) + +#### Defined in + +[services/fulfillment.js:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/fulfillment.js#L42) diff --git a/docs/content/references/services/classes/GiftCardService.md b/docs/content/references/services/classes/GiftCardService.md new file mode 100644 index 0000000000..ba148cf93a --- /dev/null +++ b/docs/content/references/services/classes/GiftCardService.md @@ -0,0 +1,245 @@ +# Class: GiftCardService + +Provides layer to manipulate gift cards. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`GiftCardService`** + +## Constructors + +### constructor + +• **new GiftCardService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/gift-card.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L15) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | + +#### Defined in + +[services/gift-card.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L11) + +## Methods + +### create + +▸ **create**(`giftCard`): `Promise`<`GiftCard`\> + +Creates a gift card with provided data given that the data is validated. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `giftCard` | `GiftCard` | the gift card data to create | + +#### Returns + +`Promise`<`GiftCard`\> + +the result of the create operation + +#### Defined in + +[services/gift-card.js:134](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L134) + +___ + +### createTransaction + +▸ **createTransaction**(`data`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `data` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/gift-card.js:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L120) + +___ + +### delete + +▸ **delete**(`giftCardId`): `Promise`<`any`\> + +Deletes a gift card idempotently + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `giftCardId` | `string` | id of gift card to delete | + +#### Returns + +`Promise`<`any`\> + +the result of the delete operation + +#### Defined in + +[services/gift-card.js:288](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L288) + +___ + +### generateCode\_ + +▸ **generateCode_**(): `string` + +Generates a 16 character gift card code + +#### Returns + +`string` + +the generated gift card code + +#### Defined in + +[services/gift-card.js:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L62) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/gift-card.js:78](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L78) + +___ + +### retrieve + +▸ **retrieve**(`giftCardId`, `config?`): `Promise`<`GiftCard`\> + +Gets a gift card by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `giftCardId` | `string` | id of gift card to retrieve | +| `config` | `any` | optional values to include with gift card query | + +#### Returns + +`Promise`<`GiftCard`\> + +the gift card + +#### Defined in + +[services/gift-card.js:175](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L175) + +___ + +### retrieveByCode + +▸ **retrieveByCode**(`code`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `code` | `any` | +| `config` | `Object` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/gift-card.js:209](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L209) + +___ + +### update + +▸ **update**(`giftCardId`, `update`): `Promise`<`any`\> + +Updates a giftCard. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `giftCardId` | `string` | giftCard id of giftCard to update | +| `update` | `GiftCard` | the data to update the giftCard with | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/gift-card.js:247](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L247) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`GiftCardService`](GiftCardService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`GiftCardService`](GiftCardService.md) + +#### Defined in + +[services/gift-card.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/gift-card.js#L40) diff --git a/docs/content/references/services/classes/IdempotencyKeyService.md b/docs/content/references/services/classes/IdempotencyKeyService.md new file mode 100644 index 0000000000..2a97726c9b --- /dev/null +++ b/docs/content/references/services/classes/IdempotencyKeyService.md @@ -0,0 +1,182 @@ +# Class: IdempotencyKeyService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`IdempotencyKeyService`** + +## Constructors + +### constructor + +• **new IdempotencyKeyService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/idempotency-key.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L8) + +## Methods + +### create + +▸ **create**(`payload`): `Promise`<`IdempotencyKeyModel`\> + +Creates an idempotency key for a request. +If no idempotency key is provided in request, we will create a unique +identifier. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `payload` | `any` | payload of request to create idempotency key for | + +#### Returns + +`Promise`<`IdempotencyKeyModel`\> + +the created idempotency key + +#### Defined in + +[services/idempotency-key.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L55) + +___ + +### initializeRequest + +▸ **initializeRequest**(`headerKey`, `reqMethod`, `reqParams`, `reqPath`): `Promise`<`IdempotencyKeyModel`\> + +Execute the initial steps in a idempotent request. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `headerKey` | `string` | potential idempotency key from header | +| `reqMethod` | `string` | method of request | +| `reqParams` | `string` | params of request | +| `reqPath` | `string` | path of request | + +#### Returns + +`Promise`<`IdempotencyKeyModel`\> + +the existing or created idempotency key + +#### Defined in + +[services/idempotency-key.js:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L29) + +___ + +### lock + +▸ **lock**(`idempotencyKey`): `Promise`<`any`\> + +Locks an idempotency. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `idempotencyKey` | `string` | key to lock | + +#### Returns + +`Promise`<`any`\> + +result of the update operation + +#### Defined in + +[services/idempotency-key.js:94](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L94) + +___ + +### retrieve + +▸ **retrieve**(`idempotencyKey`): `Promise`<`IdempotencyKeyModel`\> + +Retrieves an idempotency key + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `idempotencyKey` | `string` | key to retrieve | + +#### Returns + +`Promise`<`IdempotencyKeyModel`\> + +idempotency key + +#### Defined in + +[services/idempotency-key.js:76](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L76) + +___ + +### update + +▸ **update**(`idempotencyKey`, `update`): `Promise`<`any`\> + +Locks an idempotency. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `idempotencyKey` | `string` | key to update | +| `update` | `any` | update object | + +#### Returns + +`Promise`<`any`\> + +result of the update operation + +#### Defined in + +[services/idempotency-key.js:121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L121) + +___ + +### workStage + +▸ **workStage**(`idempotencyKey`, `func`): `IdempotencyKeyModel` + +Performs an atomic work stage. +An atomic work stage contains some related functionality, that needs to be +transactionally executed in isolation. An idempotent request will +always consist of 2 or more of these phases. The required phases are +"started" and "finished". + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `idempotencyKey` | `string` | current idempotency key | +| `func` | `Function` | functionality to execute within the phase | + +#### Returns + +`IdempotencyKeyModel` + +new updated idempotency key + +#### Defined in + +[services/idempotency-key.js:148](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/idempotency-key.js#L148) diff --git a/docs/content/references/services/classes/InventoryService.md b/docs/content/references/services/classes/InventoryService.md new file mode 100644 index 0000000000..c4d60270a2 --- /dev/null +++ b/docs/content/references/services/classes/InventoryService.md @@ -0,0 +1,99 @@ +# Class: InventoryService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`InventoryService`** + +## Constructors + +### constructor + +• **new InventoryService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/inventory.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L5) + +## Methods + +### adjustInventory + +▸ **adjustInventory**(`variantId`, `adjustment`): `Promise`<`any`\> + +Updates the inventory of a variant based on a given adjustment. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the variant to update | +| `adjustment` | `number` | the number to adjust the inventory quantity by | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/inventory.js:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L36) + +___ + +### confirmInventory + +▸ **confirmInventory**(`variantId`, `quantity`): `Promise`<`boolean`\> + +Checks if the inventory of a variant can cover a given quantity. Will +return true if the variant doesn't have managed inventory or if the variant +allows backorders or if the inventory quantity is greater than `quantity`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the variant to check | +| `quantity` | `number` | the number of units to check availability for | + +#### Returns + +`Promise`<`boolean`\> + +true if the inventory covers the quantity + +#### Defined in + +[services/inventory.js:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L62) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`InventoryService`](InventoryService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`InventoryService`](InventoryService.md) + +#### Defined in + +[services/inventory.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/inventory.js#L15) diff --git a/docs/content/references/services/classes/LineItemService.md b/docs/content/references/services/classes/LineItemService.md new file mode 100644 index 0000000000..a9b05984aa --- /dev/null +++ b/docs/content/references/services/classes/LineItemService.md @@ -0,0 +1,305 @@ +# Class: LineItemService + +Provides layer to manipulate line items. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`LineItemService`** + +## Constructors + +### constructor + +• **new LineItemService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `InjectedDependencies` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/line-item.ts:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L38) + +## Properties + +### cartRepository\_ + +• `Protected` `Readonly` **cartRepository\_**: typeof `CartRepository` + +#### Defined in + +[services/line-item.ts:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L32) + +___ + +### itemTaxLineRepo\_ + +• `Protected` `Readonly` **itemTaxLineRepo\_**: typeof `LineItemTaxLineRepository` + +#### Defined in + +[services/line-item.ts:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L31) + +___ + +### lineItemAdjustmentService\_ + +• `Protected` `Readonly` **lineItemAdjustmentService\_**: `LineItemAdjustmentService` + +#### Defined in + +[services/line-item.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L36) + +___ + +### lineItemRepository\_ + +• `Protected` `Readonly` **lineItemRepository\_**: typeof `LineItemRepository` + +#### Defined in + +[services/line-item.ts:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L30) + +___ + +### manager\_ + +• `Protected` `Readonly` **manager\_**: `EntityManager` + +#### Defined in + +[services/line-item.ts:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L29) + +___ + +### productService\_ + +• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md) + +#### Defined in + +[services/line-item.ts:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L34) + +___ + +### productVariantService\_ + +• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md) + +#### Defined in + +[services/line-item.ts:33](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L33) + +___ + +### regionService\_ + +• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md) + +#### Defined in + +[services/line-item.ts:35](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L35) + +## Methods + +### create + +▸ **create**(`data`): `Promise`<`LineItem`\> + +Create a line item + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `Partial`<`LineItem`\> | the line item object to create | + +#### Returns + +`Promise`<`LineItem`\> + +the created line item + +#### Defined in + +[services/line-item.ts:261](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L261) + +___ + +### createReturnLines + +▸ **createReturnLines**(`returnId`, `cartId`): `Promise`<`LineItem`[]\> + +Creates return line items for a given cart based on the return items in a +return. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `returnId` | `string` | the id to generate return items from. | +| `cartId` | `string` | the cart to assign the return line items to. | + +#### Returns + +`Promise`<`LineItem`[]\> + +the created line items + +#### Defined in + +[services/line-item.ts:133](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L133) + +___ + +### delete + +▸ **delete**(`id`): `Promise`<`undefined` \| `LineItem`\> + +Deletes a line item. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the line item to delete | + +#### Returns + +`Promise`<`undefined` \| `LineItem`\> + +the result of the delete operation + +#### Defined in + +[services/line-item.ts:309](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L309) + +___ + +### generate + +▸ **generate**(`variantId`, `regionId`, `quantity`, `context?`): `Promise`<`LineItem`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `variantId` | `string` | +| `regionId` | `string` | +| `quantity` | `number` | +| `context` | `Object` | +| `context.cart?` | `Cart` | +| `context.customer_id?` | `string` | +| `context.metadata?` | `Record`<`string`, `unknown`\> | +| `context.unit_price?` | `number` | + +#### Returns + +`Promise`<`LineItem`\> + +#### Defined in + +[services/line-item.ts:186](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L186) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`LineItem`[]\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `selector` | `any` | `undefined` | +| `config` | `Object` | `undefined` | +| `config.order` | `Object` | `undefined` | +| `config.order.created_at` | `string` | `"DESC"` | +| `config.skip` | `number` | `0` | +| `config.take` | `number` | `50` | + +#### Returns + +`Promise`<`LineItem`[]\> + +#### Defined in + +[services/line-item.ts:81](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L81) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`LineItem`\> + +Retrieves a line item by its id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the line item to retrieve | +| `config` | `Object` | the config to be used at query building | + +#### Returns + +`Promise`<`LineItem`\> + +the line item + +#### Defined in + +[services/line-item.ts:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L102) + +___ + +### update + +▸ **update**(`id`, `data`): `Promise`<`LineItem`\> + +Updates a line item + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the line item to update | +| `data` | `Partial`<`LineItem`\> | the properties to update on line item | + +#### Returns + +`Promise`<`LineItem`\> + +the update line item + +#### Defined in + +[services/line-item.ts:280](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L280) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`LineItemService`](LineItemService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`LineItemService`](LineItemService.md) + +#### Defined in + +[services/line-item.ts:60](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/line-item.ts#L60) diff --git a/docs/content/references/services/classes/MiddlewareService.md b/docs/content/references/services/classes/MiddlewareService.md new file mode 100644 index 0000000000..df0846eecb --- /dev/null +++ b/docs/content/references/services/classes/MiddlewareService.md @@ -0,0 +1,248 @@ +# Class: MiddlewareService + +Orchestrates dynamic middleware registered through the Medusa Middleware API + +## Constructors + +### constructor + +• **new MiddlewareService**(`container`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `container` | `any` | + +#### Defined in + +[services/middleware.js:7](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L7) + +## Properties + +### postAuthentication\_ + +• **postAuthentication\_**: `any`[] + +#### Defined in + +[services/middleware.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L8) + +___ + +### preAuthentication\_ + +• **preAuthentication\_**: `any`[] + +#### Defined in + +[services/middleware.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L9) + +___ + +### preCartCreation\_ + +• **preCartCreation\_**: `any`[] + +#### Defined in + +[services/middleware.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L10) + +___ + +### routers + +• **routers**: `Object` + +#### Defined in + +[services/middleware.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L11) + +## Methods + +### addPostAuthentication + +▸ **addPostAuthentication**(`middleware`, `options`): `void` + +Adds a middleware function to be called after authentication is completed. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `middleware` | `Function` | the middleware function. Should return a middleware function. | +| `options` | `any` | the arguments that will be passed to the middleware | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L45) + +___ + +### addPreAuthentication + +▸ **addPreAuthentication**(`middleware`, `options`): `void` + +Adds a middleware function to be called before authentication is completed. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `middleware` | `Function` | the middleware function. Should return a middleware function. | +| `options` | `any` | the arguments that will be passed to the middleware | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:61](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L61) + +___ + +### addPreCartCreation + +▸ **addPreCartCreation**(`middleware`): `void` + +Adds a middleware function to be called before cart creation + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `middleware` | `Function` | the middleware function. Should return a middleware function. | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:75](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L75) + +___ + +### addRouter + +▸ **addRouter**(`path`, `router`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `path` | `any` | +| `router` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L14) + +___ + +### getRouters + +▸ **getRouters**(`path`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `path` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/middleware.js:19](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L19) + +___ + +### usePostAuthentication + +▸ **usePostAuthentication**(`app`): `void` + +Adds post authentication middleware to an express app. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `app` | `ExpressApp` | the express app to add the middleware to | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:85](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L85) + +___ + +### usePreAuthentication + +▸ **usePreAuthentication**(`app`): `void` + +Adds pre authentication middleware to an express app. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `app` | `ExpressApp` | the express app to add the middleware to | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:96](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L96) + +___ + +### usePreCartCreation + +▸ **usePreCartCreation**(): `any`[] + +#### Returns + +`any`[] + +#### Defined in + +[services/middleware.js:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L102) + +___ + +### validateMiddleware\_ + +▸ **validateMiddleware_**(`fn`): `void` + +Validates a middleware function, throws if fn is not of type function. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fn` | `Function` | the middleware function to validate. | + +#### Returns + +`void` + +#### Defined in + +[services/middleware.js:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/middleware.js#L28) diff --git a/docs/content/references/services/classes/NoteService.md b/docs/content/references/services/classes/NoteService.md new file mode 100644 index 0000000000..9a06939bb5 --- /dev/null +++ b/docs/content/references/services/classes/NoteService.md @@ -0,0 +1,194 @@ +# Class: NoteService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`NoteService`** + +## Constructors + +### constructor + +• **new NoteService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/note.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L12) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `DELETED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/note.js:6](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L6) + +## Methods + +### create + +▸ **create**(`data`, `config?`): `Promise`<`any`\> + +Creates a note associated with a given author + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `CreateNoteInput` | the note to create | +| `config` | `any` | any configurations if needed, including meta data | + +#### Returns + +`Promise`<`any`\> + +resolves to the creation result + +#### Defined in + +[services/note.js:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L98) + +___ + +### delete + +▸ **delete**(`noteId`): `Promise`<`any`\> + +Deletes a given note + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `noteId` | `any` | id of the note to delete | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/note.js:154](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L154) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`Note`[]\> + +Fetches all notes related to the given selector + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `Object` | the configuration used to find the objects. contains relations, skip, and take. | +| `config.relations` | `string`[] | Which relations to include in the resulting list of Notes. | +| `config.skip` | `number` | How many Notes to skip in the resulting list of Notes. | +| `config.take` | `number` | How many Notes to take in the resulting list of Notes. | + +#### Returns + +`Promise`<`Note`[]\> + +notes related to the given search. + +#### Defined in + +[services/note.js:77](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L77) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`Note`\> + +Retrieves a specific note. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the note to retrieve. | +| `config` | `any` | any options needed to query for the result. | + +#### Returns + +`Promise`<`Note`\> + +which resolves to the requested note. + +#### Defined in + +[services/note.js:51](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L51) + +___ + +### update + +▸ **update**(`noteId`, `value`): `Promise`<`any`\> + +Updates a given note with a new value + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `noteId` | `any` | the id of the note to update | +| `value` | `any` | the new value | + +#### Returns + +`Promise`<`any`\> + +resolves to the updated element + +#### Defined in + +[services/note.js:131](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L131) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`NoteService`](NoteService.md) + +Sets the service's manager to a given transaction manager + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionManager` | `EntityManager` | the manager to use | + +#### Returns + +[`NoteService`](NoteService.md) + +a cloned note service + +#### Defined in + +[services/note.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/note.js#L30) diff --git a/docs/content/references/services/classes/NotificationService.md b/docs/content/references/services/classes/NotificationService.md new file mode 100644 index 0000000000..fd439c77f9 --- /dev/null +++ b/docs/content/references/services/classes/NotificationService.md @@ -0,0 +1,326 @@ +# Class: NotificationService + +Provides layer to manipulate orchestrate notifications. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`NotificationService`** + +## Constructors + +### constructor + +• **new NotificationService**(`container`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `container` | `any` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/notification.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L9) + +## Properties + +### attachmentGenerator\_ + +• **attachmentGenerator\_**: `any` + +#### Defined in + +[services/notification.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L30) + +___ + +### container\_ + +• **container\_**: `any` + +#### Defined in + +[services/notification.js:19](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L19) + +___ + +### logger\_ + +• **logger\_**: `any` + +#### Defined in + +[services/notification.js:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L23) + +___ + +### notificationProviderRepository\_ + +• **notificationProviderRepository\_**: `any` + +#### Defined in + +[services/notification.js:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L27) + +___ + +### subscribers\_ + +• **subscribers\_**: `Object` + +#### Defined in + +[services/notification.js:29](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L29) + +## Methods + +### handleEvent + +▸ **handleEvent**(`eventName`, `data`): `Promise`<`any`\> + +Handles an event by relaying the event data to the subscribing providers. +The result of the notification send will be persisted in the database in +order to allow for resends. Will log any errors that are encountered. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | the event to handle | +| `data` | `any` | the data the event was sent with | + +#### Returns + +`Promise`<`any`\> + +- the result of notification subscribed + +#### Defined in + +[services/notification.js:166](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L166) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Notification`[] + +Retrieves a list of notifications. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the params to select the notifications by. | +| `config` | `any` | the configuration to apply to the query | + +#### Returns + +`Notification`[] + +the notifications that satisfy the query. + +#### Defined in + +[services/notification.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L84) + +___ + +### registerAttachmentGenerator + +▸ **registerAttachmentGenerator**(`service`): `void` + +Registers an attachment generator to the service. The generator can be +used to generate on demand invoices or other documents. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `service` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/notification.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L38) + +___ + +### registerInstalledProviders + +▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\> + +Takes a list of notification provider ids and persists them in the database. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `providers` | `string`[] | a list of provider ids | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/notification.js:68](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L68) + +___ + +### resend + +▸ **resend**(`id`, `config?`): `Notification` + +Resends a notification by retrieving a prior notification and calling the +underlying provider's resendNotification method. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the notification | +| `config` | `any` | any configuration that might override the previous send | + +#### Returns + +`Notification` + +the newly created notification + +#### Defined in + +[services/notification.js:237](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L237) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Notification` + +Retrieves a notification with a given id + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the notification | +| `config` | `any` | the configuration to apply to the query | + +#### Returns + +`Notification` + +the notification + +#### Defined in + +[services/notification.js:101](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L101) + +___ + +### retrieveProvider\_ + +▸ **retrieveProvider_**(`id`): `NotificationProvider` + +Finds a provider with a given id. Will throw a NOT_FOUND error if the +resolution fails. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the provider | + +#### Returns + +`NotificationProvider` + +the notification provider + +#### Defined in + +[services/notification.js:147](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L147) + +___ + +### send + +▸ **send**(`event`, `eventData`, `providerId`): `Notification` + +Sends a notification, by calling the given provider's sendNotification +method. Persists the Notification in the database. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `event` | `string` | the name of the event | +| `eventData` | `any` | the data the event was sent with | +| `providerId` | `string` | the provider that should hande the event. | + +#### Returns + +`Notification` + +the created notification + +#### Defined in + +[services/notification.js:195](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L195) + +___ + +### subscribe + +▸ **subscribe**(`eventName`, `providerId`): `void` + +Subscribes a given provider to an event. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | the event to subscribe to | +| `providerId` | `string` | the provider that the event will be sent to | + +#### Returns + +`void` + +#### Defined in + +[services/notification.js:126](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L126) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`NotificationService`](NotificationService.md) + +Sets the service's manager to a given transaction manager. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionManager` | `EntityManager` | the manager to use | + +#### Returns + +[`NotificationService`](NotificationService.md) + +a cloned notification service + +#### Defined in + +[services/notification.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/notification.js#L47) diff --git a/docs/content/references/services/classes/OauthService.md b/docs/content/references/services/classes/OauthService.md new file mode 100644 index 0000000000..8bc5a344b3 --- /dev/null +++ b/docs/content/references/services/classes/OauthService.md @@ -0,0 +1,227 @@ +# Class: OauthService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`OauthService`** + +## Constructors + +### constructor + +• **new OauthService**(`cradle`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cradle` | `any` | + +#### Overrides + +OauthService.constructor + +#### Defined in + +[services/oauth.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L10) + +## Properties + +### container\_ + +• **container\_**: `any` + +#### Defined in + +[services/oauth.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L15) + +___ + +### eventBus\_ + +• **eventBus\_**: `any` + +#### Defined in + +[services/oauth.js:17](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L17) + +___ + +### manager + +• **manager**: `any` + +#### Defined in + +[services/oauth.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L14) + +___ + +### oauthRepository\_ + +• **oauthRepository\_**: `any` + +#### Defined in + +[services/oauth.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L16) + +___ + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `TOKEN_GENERATED` | `string` | +| `TOKEN_REFRESHED` | `string` | + +#### Defined in + +[services/oauth.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L5) + +## Methods + +### create + +▸ **create**(`data`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `data` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/oauth.js:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L32) + +___ + +### generateToken + +▸ **generateToken**(`appName`, `code`, `state`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `appName` | `any` | +| `code` | `any` | +| `state` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/oauth.js:66](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L66) + +___ + +### list + +▸ **list**(`selector`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `selector` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/oauth.js:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L27) + +___ + +### refreshToken + +▸ **refreshToken**(`appName`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `appName` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/oauth.js:96](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L96) + +___ + +### registerOauthApp + +▸ **registerOauthApp**(`appDetails`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `appDetails` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/oauth.js:56](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L56) + +___ + +### retrieveByName + +▸ **retrieveByName**(`appName`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `appName` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/oauth.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L20) + +___ + +### update + +▸ **update**(`id`, `update`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | +| `update` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/oauth.js:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/oauth.js#L45) diff --git a/docs/content/references/services/classes/OrderService.md b/docs/content/references/services/classes/OrderService.md new file mode 100644 index 0000000000..6cbedafb36 --- /dev/null +++ b/docs/content/references/services/classes/OrderService.md @@ -0,0 +1,759 @@ +# Class: OrderService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`OrderService`** + +## Constructors + +### constructor + +• **new OrderService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/order.js:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L25) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CANCELED` | `string` | +| `COMPLETED` | `string` | +| `FULFILLMENT_CANCELED` | `string` | +| `FULFILLMENT_CREATED` | `string` | +| `GIFT_CARD_CREATED` | `string` | +| `ITEMS_RETURNED` | `string` | +| `PAYMENT_CAPTURED` | `string` | +| `PAYMENT_CAPTURE_FAILED` | `string` | +| `PLACED` | `string` | +| `REFUND_CREATED` | `string` | +| `REFUND_FAILED` | `string` | +| `RETURN_ACTION_REQUIRED` | `string` | +| `RETURN_REQUESTED` | `string` | +| `SHIPMENT_CREATED` | `string` | +| `SWAP_CREATED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/order.js:6](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L6) + +## Methods + +### addShippingMethod + +▸ **addShippingMethod**(`orderId`, `optionId`, `data`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `orderId` | `any` | +| `optionId` | `any` | +| `data` | `any` | +| `config` | `Object` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/order.js:806](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L806) + +___ + +### archive + +▸ **archive**(`orderId`): `Promise`<`any`\> + +Archives an order. It only alloved, if the order has been fulfilled +and payment has been captured. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the order to archive | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/order.js:1301](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1301) + +___ + +### cancel + +▸ **cancel**(`orderId`): `Promise`<`any`\> + +Cancels an order. +Throws if fulfillment process has been initiated. +Throws if payment process has been initiated. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | id of order to cancel. | + +#### Returns + +`Promise`<`any`\> + +result of the update operation. + +#### Defined in + +[services/order.js:952](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L952) + +___ + +### cancelFulfillment + +▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`any`\> + +Cancels a fulfillment (if related to an order) + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fulfillmentId` | `string` | the ID of the fulfillment to cancel | + +#### Returns + +`Promise`<`any`\> + +updated order + +#### Defined in + +[services/order.js:1242](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1242) + +___ + +### capturePayment + +▸ **capturePayment**(`orderId`): `Promise`<`any`\> + +Captures payment for an order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | id of order to capture payment for. | + +#### Returns + +`Promise`<`any`\> + +result of the update operation. + +#### Defined in + +[services/order.js:1021](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1021) + +___ + +### completeOrder + +▸ **completeOrder**(`orderId`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | id of the order to complete | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/order.js:429](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L429) + +___ + +### create + +▸ **create**(`data`): `Promise`<`any`\> + +Creates an order + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `any` | the data to create an order | + +#### Returns + +`Promise`<`any`\> + +resolves to the creation result. + +#### Defined in + +[services/order.js:723](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L723) + +___ + +### createFromCart + +▸ **createFromCart**(`cartId`): `Promise`<`any`\> + +Creates an order from a cart + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | id of the cart to create an order from | + +#### Returns + +`Promise`<`any`\> + +resolves to the creation result. + +#### Defined in + +[services/order.js:465](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L465) + +___ + +### createFulfillment + +▸ **createFulfillment**(`orderId`, `itemsToFulfill`, `config?`): `Promise`<`any`\> + +Creates fulfillments for an order. +In a situation where the order has more than one shipping method, +we need to partition the order items, such that they can be sent +to their respective fulfillment provider. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | id of order to cancel. | +| `itemsToFulfill` | `any` | items to fulfil. | +| `config` | `any` | the config to cancel. | + +#### Returns + +`Promise`<`any`\> + +result of the update operation. + +#### Defined in + +[services/order.js:1121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1121) + +___ + +### createRefund + +▸ **createRefund**(`orderId`, `refundAmount`, `reason`, `note`, `config?`): `Promise`<`any`\> + +Refunds a given amount back to the customer. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | id of the order to refund. | +| `refundAmount` | `float` | the amount to refund. | +| `reason` | `string` | the reason to refund. | +| `note` | `undefined` \| `string` | note for refund. | +| `config` | `any` | the config for refund. | + +#### Returns + +`Promise`<`any`\> + +the result of the refund operation. + +#### Defined in + +[services/order.js:1328](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1328) + +___ + +### createShipment + +▸ **createShipment**(`orderId`, `fulfillmentId`, `trackingLinks`, `config?`): `order` + +Adds a shipment to the order to indicate that an order has left the +warehouse. Will ask the fulfillment provider for any documents that may +have been created in regards to the shipment. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the id of the order that has been shipped | +| `fulfillmentId` | `string` | the fulfillment that has now been shipped | +| `trackingLinks` | `undefined` \| `TrackingLink`[] | array of tracking numebers associated with the shipment | +| `config` | `any` | the config of the order that has been shipped | + +#### Returns + +`order` + +the resulting order following the update. + +#### Defined in + +[services/order.js:643](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L643) + +___ + +### decorateTotals\_ + +▸ **decorateTotals_**(`order`, `totalsFields?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `order` | `any` | `undefined` | +| `totalsFields` | `any`[] | `[]` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/order.js:1377](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1377) + +___ + +### deleteMetadata + +▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\> + +Dedicated method to delete metadata for an order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the order to delete metadata from. | +| `key` | `string` | key for metadata field | + +#### Returns + +`Promise`<`any`\> + +resolves to the updated result. + +#### Defined in + +[services/order.js:1550](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1550) + +___ + +### existsByCartId + +▸ **existsByCartId**(`cartId`): `Promise`<`Order`\> + +Checks the existence of an order by cart id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | cart id to find order | + +#### Returns + +`Promise`<`Order`\> + +the order document + +#### Defined in + +[services/order.js:417](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L417) + +___ + +### getFulfillmentItems\_ + +▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\> + +Retrieves the order line items, given an array of items. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to get line items from | +| `items` | `Object` | the items to get | +| `items.item_id` | `string` | - | +| `items.quantity` | `number` | - | +| `transformer` | `Function` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. | + +#### Returns + +`Promise`<`LineItem`[]\> + +the line items generated by the transformer. + +#### Defined in + +[services/order.js:1284](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1284) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config to be used for find | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/order.js:148](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L148) + +___ + +### listAndCount + +▸ **listAndCount**(`selector`, `config?`): `Promise`<`any`[]\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `selector` | `any` | `undefined` | +| `config` | `Object` | `undefined` | +| `config.order` | `Object` | `undefined` | +| `config.order.created_at` | `string` | `"DESC"` | +| `config.skip` | `number` | `0` | +| `config.take` | `number` | `50` | + +#### Returns + +`Promise`<`any`[]\> + +#### Defined in + +[services/order.js:173](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L173) + +___ + +### registerReturnReceived + +▸ **registerReturnReceived**(`orderId`, `receivedReturn`, `customRefundAmount`): `Promise`<`any`\> + +Handles receiving a return. This will create a +refund to the customer. If the returned items don't match the requested +items the return status will be updated to requires_action. This behaviour +is useful in sitautions where a custom refund amount is requested, but the +retuned items are not matching the requested items. Setting the +allowMismatch argument to true, will process the return, ignoring any +mismatches. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the order to return. | +| `receivedReturn` | `any` | the received return | +| `customRefundAmount` | `float` | the custom refund amount return | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/order.js:1473](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1473) + +___ + +### retrieve + +▸ **retrieve**(`orderId`, `config?`): `Promise`<`Order`\> + +Gets an order by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | id of order to retrieve | +| `config` | `any` | config of order to retrieve | + +#### Returns + +`Promise`<`Order`\> + +the order document + +#### Defined in + +[services/order.js:305](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L305) + +___ + +### retrieveByCartId + +▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`Order`\> + +Gets an order by cart id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartId` | `string` | cart id to find order | +| `config` | `any` | the config to be used to find order | + +#### Returns + +`Promise`<`Order`\> + +the order document + +#### Defined in + +[services/order.js:343](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L343) + +___ + +### retrieveByExternalId + +▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Order`\> + +Gets an order by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `externalId` | `string` | id of order to retrieve | +| `config` | `any` | query config to get order by | + +#### Returns + +`Promise`<`Order`\> + +the order document + +#### Defined in + +[services/order.js:380](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L380) + +___ + +### transformQueryForTotals\_ + +▸ **transformQueryForTotals_**(`config`): { `relations`: `any` ; `select`: `any` ; `totalsToSelect`: `never`[] = [] } \| { `relations`: `any` ; `select`: `any`[] = toSelect; `totalsToSelect`: `any` } + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | `any` | + +#### Returns + +{ `relations`: `any` ; `select`: `any` ; `totalsToSelect`: `never`[] = [] } \| { `relations`: `any` ; `select`: `any`[] = toSelect; `totalsToSelect`: `any` } + +#### Defined in + +[services/order.js:234](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L234) + +___ + +### update + +▸ **update**(`orderId`, `update`): `Promise`<`any`\> + +Updates an order. Metadata updates should +use dedicated method, e.g. `setMetadata` etc. The function +will throw errors if metadata updates are attempted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderId` | `string` | the id of the order. Must be a string that can be casted to an ObjectId | +| `update` | `any` | an object with the update values. | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/order.js:864](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L864) + +___ + +### updateBillingAddress\_ + +▸ **updateBillingAddress_**(`order`, `address`): `Promise`<`any`\> + +Updates the order's billing address. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `any` | the order to update | +| `address` | `any` | the value to set the billing address to | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/order.js:744](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L744) + +___ + +### updateShippingAddress\_ + +▸ **updateShippingAddress_**(`order`, `address`): `Promise`<`any`\> + +Updates the order's shipping address. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `any` | the order to update | +| `address` | `any` | the value to set the shipping address to | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/order.js:779](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L779) + +___ + +### validateFulfillmentLineItem\_ + +▸ **validateFulfillmentLineItem_**(`item`, `quantity`): `LineItem` + +Checks that a given quantity of a line item can be fulfilled. Fails if the +fulfillable quantity is lower than the requested fulfillment quantity. +Fulfillable quantity is calculated by subtracting the already fulfilled +quantity from the quantity that was originally purchased. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `item` | `LineItem` | the line item to check has sufficient fulfillable quantity. | +| `quantity` | `number` | the quantity that is requested to be fulfilled. | + +#### Returns + +`LineItem` + +a line item that has the requested fulfillment quantity + set. + +#### Defined in + +[services/order.js:1091](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L1091) + +___ + +### validateId\_ + +▸ **validateId_**(`rawId`): `string` + +Used to validate order ids. Throws an error if the cast fails + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `rawId` | `string` | the raw order id to validate. | + +#### Returns + +`string` + +the validated id + +#### Defined in + +[services/order.js:139](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L139) + +___ + +### withTransaction + +▸ **withTransaction**(`manager`): [`OrderService`](OrderService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `manager` | `any` | + +#### Returns + +[`OrderService`](OrderService.md) + +#### Defined in + +[services/order.js:102](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/order.js#L102) diff --git a/docs/content/references/services/classes/PaymentProviderService.md b/docs/content/references/services/classes/PaymentProviderService.md new file mode 100644 index 0000000000..522266f119 --- /dev/null +++ b/docs/content/references/services/classes/PaymentProviderService.md @@ -0,0 +1,497 @@ +# Class: PaymentProviderService + +Helps retrive payment providers + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`PaymentProviderService`** + +## Constructors + +### constructor + +• **new PaymentProviderService**(`container`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `container` | `any` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/payment-provider.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L8) + +## Properties + +### manager\_ + +• **manager\_**: `any` + +#### Defined in + +[services/payment-provider.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L14) + +___ + +### paymentRepository\_ + +• **paymentRepository\_**: `any` + +#### Defined in + +[services/payment-provider.js:18](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L18) + +___ + +### paymentSessionRepository\_ + +• **paymentSessionRepository\_**: `any` + +#### Defined in + +[services/payment-provider.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L16) + +___ + +### refundRepository\_ + +• **refundRepository\_**: `any` + +#### Defined in + +[services/payment-provider.js:20](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L20) + +## Methods + +### authorizePayment + +▸ **authorizePayment**(`paymentSession`, `context`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `paymentSession` | `any` | +| `context` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:283](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L283) + +___ + +### cancelPayment + +▸ **cancelPayment**(`paymentObj`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `paymentObj` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:324](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L324) + +___ + +### capturePayment + +▸ **capturePayment**(`paymentObj`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `paymentObj` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:343](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L343) + +___ + +### createPayment + +▸ **createPayment**(`cart`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cart` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:246](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L246) + +___ + +### createSession + +▸ **createSession**(`providerId`, `cart`): `Promise`<`any`\> + +Creates a payment session with the given provider. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `providerId` | `string` | the id of the provider to create payment with | +| `cart` | `Cart` | a cart object used to calculate the amount, etc. from | + +#### Returns + +`Promise`<`any`\> + +the payment session + +#### Defined in + +[services/payment-provider.js:121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L121) + +___ + +### deleteSession + +▸ **deleteSession**(`paymentSession`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `paymentSession` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/payment-provider.js:202](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L202) + +___ + +### getStatus + +▸ **getStatus**(`payment`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `payment` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:338](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L338) + +___ + +### list + +▸ **list**(): `Promise`<`any`\> + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L47) + +___ + +### listPayments + +▸ **listPayments**(`selector`, `config?`): `any` + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `selector` | `any` | `undefined` | +| `config` | `Object` | `undefined` | +| `config.order` | `Object` | `undefined` | +| `config.order.created_at` | `string` | `"DESC"` | +| `config.skip` | `number` | `0` | +| `config.take` | `number` | `50` | + +#### Returns + +`any` + +#### Defined in + +[services/payment-provider.js:80](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L80) + +___ + +### refreshSession + +▸ **refreshSession**(`paymentSession`, `cart`): `Promise`<`any`\> + +Refreshes a payment session with the given provider. +This means, that we delete the current one and create a new. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `paymentSession` | `PaymentSession` | the payment session object to update | +| `cart` | `Cart` | a cart object used to calculate the amount, etc. from | + +#### Returns + +`Promise`<`any`\> + +the payment session + +#### Defined in + +[services/payment-provider.js:152](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L152) + +___ + +### refundPayment + +▸ **refundPayment**(`payObjs`, `amount`, `reason`, `note`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `payObjs` | `any` | +| `amount` | `any` | +| `reason` | `any` | +| `note` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:358](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L358) + +___ + +### registerInstalledProviders + +▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `providers` | `any` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/payment-provider.js:35](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L35) + +___ + +### retrievePayment + +▸ **retrievePayment**(`id`, `relations?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `id` | `any` | `undefined` | +| `relations` | `any`[] | `[]` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:54](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L54) + +___ + +### retrieveProvider + +▸ **retrieveProvider**(`providerId`): `PaymentService` + +Finds a provider given an id + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `providerId` | `string` | the id of the provider to get | + +#### Returns + +`PaymentService` + +the payment provider + +#### Defined in + +[services/payment-provider.js:228](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L228) + +___ + +### retrieveRefund + +▸ **retrieveRefund**(`id`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | +| `config` | `Object` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:422](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L422) + +___ + +### retrieveSession + +▸ **retrieveSession**(`id`, `relations?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `id` | `any` | `undefined` | +| `relations` | `any`[] | `[]` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L89) + +___ + +### updatePayment + +▸ **updatePayment**(`paymentId`, `update`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `paymentId` | `any` | +| `update` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:266](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L266) + +___ + +### updateSession + +▸ **updateSession**(`paymentSession`, `cart`): `Promise`<`any`\> + +Updates an existing payment session. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `paymentSession` | `PaymentSession` | the payment session object to update | +| `cart` | `Cart` | the cart object to update for | + +#### Returns + +`Promise`<`any`\> + +the updated payment session + +#### Defined in + +[services/payment-provider.js:188](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L188) + +___ + +### updateSessionData + +▸ **updateSessionData**(`paySession`, `update`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `paySession` | `any` | +| `update` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/payment-provider.js:308](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L308) + +___ + +### withTransaction + +▸ **withTransaction**(`manager`): [`PaymentProviderService`](PaymentProviderService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `manager` | `any` | + +#### Returns + +[`PaymentProviderService`](PaymentProviderService.md) + +#### Defined in + +[services/payment-provider.js:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/payment-provider.js#L23) diff --git a/docs/content/references/services/classes/ProductCollectionService.md b/docs/content/references/services/classes/ProductCollectionService.md new file mode 100644 index 0000000000..37245d6cc7 --- /dev/null +++ b/docs/content/references/services/classes/ProductCollectionService.md @@ -0,0 +1,264 @@ +# Class: ProductCollectionService + +Provides layer to manipulate product collections. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ProductCollectionService`** + +## Constructors + +### constructor + +• **new ProductCollectionService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/product-collection.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L11) + +## Methods + +### addProducts + +▸ **addProducts**(`collectionId`, `productIds`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `collectionId` | `any` | +| `productIds` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/product-collection.js:170](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L170) + +___ + +### create + +▸ **create**(`collection`): `Promise`<`ProductCollection`\> + +Creates a product collection + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `collection` | `any` | the collection to create | + +#### Returns + +`Promise`<`ProductCollection`\> + +created collection + +#### Defined in + +[services/product-collection.js:104](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L104) + +___ + +### delete + +▸ **delete**(`collectionId`): `Promise`<`any`\> + +Deletes a product collection idempotently + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `collectionId` | `string` | id of collection to delete | + +#### Returns + +`Promise`<`any`\> + +empty promise + +#### Defined in + +[services/product-collection.js:152](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L152) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`any`\> + +Lists product collections + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config to be used for find | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/product-collection.js:206](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L206) + +___ + +### listAndCount + +▸ **listAndCount**(`selector?`, `config?`): `Promise`<`any`\> + +Lists product collections and add count. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config to be used for find | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/product-collection.js:221](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L221) + +___ + +### removeProducts + +▸ **removeProducts**(`collectionId`, `productIds`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `collectionId` | `any` | +| `productIds` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/product-collection.js:188](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L188) + +___ + +### retrieve + +▸ **retrieve**(`collectionId`, `config?`): `Promise`<`ProductCollection`\> + +Retrieves a product collection by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `collectionId` | `string` | the id of the collection to retrieve. | +| `config` | `any` | the config of the collection to retrieve. | + +#### Returns + +`Promise`<`ProductCollection`\> + +the collection. + +#### Defined in + +[services/product-collection.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L55) + +___ + +### retrieveByHandle + +▸ **retrieveByHandle**(`collectionHandle`, `config?`): `Promise`<`ProductCollection`\> + +Retrieves a product collection by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `collectionHandle` | `string` | the handle of the collection to retrieve. | +| `config` | `any` | query config for request | + +#### Returns + +`Promise`<`ProductCollection`\> + +the collection. + +#### Defined in + +[services/product-collection.js:81](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L81) + +___ + +### update + +▸ **update**(`collectionId`, `update`): `Promise`<`ProductCollection`\> + +Updates a product collection + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `collectionId` | `string` | id of collection to update | +| `update` | `any` | update object | + +#### Returns + +`Promise`<`ProductCollection`\> + +update collection + +#### Defined in + +[services/product-collection.js:125](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L125) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ProductCollectionService`](ProductCollectionService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`ProductCollectionService`](ProductCollectionService.md) + +#### Defined in + +[services/product-collection.js:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-collection.js#L32) diff --git a/docs/content/references/services/classes/ProductService.md b/docs/content/references/services/classes/ProductService.md new file mode 100644 index 0000000000..cc57005922 --- /dev/null +++ b/docs/content/references/services/classes/ProductService.md @@ -0,0 +1,662 @@ +# Class: ProductService + +Provides layer to manipulate products. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ProductService`** + +## Constructors + +### constructor + +• **new ProductService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/product.js:19](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L19) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `DELETED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/product.js:13](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L13) + +___ + +### IndexName + +▪ `Static` **IndexName**: `string` + +#### Defined in + +[services/product.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L12) + +## Methods + +### addOption + +▸ **addOption**(`productId`, `optionTitle`): `Promise`<`any`\> + +Adds an option to a product. Options can, for example, be "Size", "Color", +etc. Will update all the products variants with a dummy value for the newly +created option. The same option cannot be added more than once. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product to apply the new option to | +| `optionTitle` | `string` | the display title of the option, e.g. "Size" | + +#### Returns + +`Promise`<`any`\> + +the result of the model update operation + +#### Defined in + +[services/product.js:707](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L707) + +___ + +### count + +▸ **count**(`selector?`): `Promise`<`any`\> + +Return the total number of documents in database + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the selector to choose products by | + +#### Returns + +`Promise`<`any`\> + +the result of the count operation + +#### Defined in + +[services/product.js:223](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L223) + +___ + +### create + +▸ **create**(`productObject`): `Promise`<`any`\> + +Creates a product. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productObject` | `any` | the product to create | + +#### Returns + +`Promise`<`any`\> + +resolves to the creation result. + +#### Defined in + +[services/product.js:483](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L483) + +___ + +### decorate + +▸ **decorate**(`productId`, `fields?`, `expandFields?`, `config?`): `Product` + +Decorates a product with product variants. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `productId` | `string` | `undefined` | the productId to decorate. | +| `fields` | `string`[] | `[]` | the fields to include. | +| `expandFields` | `string`[] | `[]` | fields to expand. | +| `config` | `any` | `{}` | retrieve config for price calculation. | + +#### Returns + +`Product` + +return the decorated product. + +#### Defined in + +[services/product.js:945](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L945) + +___ + +### delete + +▸ **delete**(`productId`): `Promise`<`any`\> + +Deletes a product from a given product id. The product's associated +variants will also be deleted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the id of the product to delete. Must be castable as an ObjectId | + +#### Returns + +`Promise`<`any`\> + +empty promise + +#### Defined in + +[services/product.js:673](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L673) + +___ + +### deleteOption + +▸ **deleteOption**(`productId`, `optionId`): `Promise`<`any`\> + +Delete an option from a product. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product to delete an option from | +| `optionId` | `string` | the option to delete | + +#### Returns + +`Promise`<`any`\> + +the updated product + +#### Defined in + +[services/product.js:881](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L881) + +___ + +### getFreeTextQueryBuilder\_ + +▸ **getFreeTextQueryBuilder_**(`productRepo`, `query`, `q`): `QueryBuilder`<`Product`\> + +Creates a QueryBuilder that can fetch products based on free text. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productRepo` | `ProductRepository` | an instance of a ProductRepositry | +| `query` | `FindOptions`<`Product`\> | the query to get products by | +| `q` | `string` | the text to perform free text search from | + +#### Returns + +`QueryBuilder`<`Product`\> + +a query builder that can fetch products + +#### Defined in + +[services/product.js:1014](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L1014) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`Product`[]\> + +Lists products based on the provided parameters. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | an object that defines rules to filter products by | +| `config` | `any` | object that defines the scope for what should be returned | + +#### Returns + +`Promise`<`Product`[]\> + +the result of the find operation + +#### Defined in + +[services/product.js:109](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L109) + +___ + +### listAndCount + +▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`Product`[], `number`]\> + +Lists products based on the provided parameters and includes the count of +products that match the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | an object that defines rules to filter products by | +| `config` | `any` | object that defines the scope for what should be returned | + +#### Returns + +`Promise`<[`Product`[], `number`]\> + +an array containing the products as + the first element and the total count of products that matches the query + as the second element. + +#### Defined in + +[services/product.js:164](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L164) + +___ + +### listTagsByUsage + +▸ **listTagsByUsage**(`count?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `count` | `number` | `10` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/product.js:412](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L412) + +___ + +### listTypes + +▸ **listTypes**(): `Promise`<`any`\> + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/product.js:404](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L404) + +___ + +### prepareListQuery\_ + +▸ **prepareListQuery_**(`selector`, `config`): `any` + +Creates a query object to be used for list queries. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the selector to create the query from | +| `config` | `any` | the config to use for the query | + +#### Returns + +`any` + +an object containing the query, relations and free-text + search param. + +#### Defined in + +[services/product.js:980](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L980) + +___ + +### reorderOptions + +▸ **reorderOptions**(`productId`, `optionOrder`): `Promise`<`any`\> + +Changes the order of a product's options. Will throw if the length of +optionOrder and the length of the product's options are different. Will +throw optionOrder contains an id not associated with the product. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product whose options we are reordering | +| `optionOrder` | `string`[] | the ids of the product's options in the new order | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/product.js:790](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L790) + +___ + +### reorderVariants + +▸ **reorderVariants**(`productId`, `variantOrder`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `productId` | `any` | +| `variantOrder` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/product.js:746](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L746) + +___ + +### retrieve + +▸ **retrieve**(`productId`, `config?`): `Promise`<`Product`\> + +Gets a product by id. +Throws in case of DB Error and if product was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | id of the product to get. | +| `config` | `any` | object that defines what should be included in the query response | + +#### Returns + +`Promise`<`Product`\> + +the result of the find one operation. + +#### Defined in + +[services/product.js:239](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L239) + +___ + +### retrieveByExternalId + +▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Product`\> + +Gets a product by external id. +Throws in case of DB Error and if product was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `externalId` | `string` | handle of the product to get. | +| `config` | `any` | details about what to get from the product | + +#### Returns + +`Promise`<`Product`\> + +the result of the find one operation. + +#### Defined in + +[services/product.js:342](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L342) + +___ + +### retrieveByHandle + +▸ **retrieveByHandle**(`productHandle`, `config?`): `Promise`<`Product`\> + +Gets a product by handle. +Throws in case of DB Error and if product was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productHandle` | `string` | handle of the product to get. | +| `config` | `any` | details about what to get from the product | + +#### Returns + +`Promise`<`Product`\> + +the result of the find one operation. + +#### Defined in + +[services/product.js:291](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L291) + +___ + +### retrieveVariants + +▸ **retrieveVariants**(`productId`, `config?`): `Promise`<`any`\> + +Gets all variants belonging to a product. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the id of the product to get variants from. | +| `config` | `FindConfig`<`Product`\> | The config to select and configure relations etc... | + +#### Returns + +`Promise`<`any`\> + +an array of variants + +#### Defined in + +[services/product.js:392](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L392) + +___ + +### setAdditionalPrices + +▸ **setAdditionalPrices**(`products`, `currency_code`, `region_id`, `cart_id`, `customer_id`, `include_discount_prices?`): `Promise`<`Product`[]\> + +Set additional prices on a list of products. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `products` | `any` | `undefined` | list of products on which to set additional prices | +| `currency_code` | `string` | `undefined` | currency code to fetch prices for | +| `region_id` | `string` | `undefined` | region to fetch prices for | +| `cart_id` | `string` | `undefined` | string of cart to use as a basis for getting currency and region | +| `customer_id` | `string` | `undefined` | id of potentially logged in customer, used to get prices valid for their customer groups | +| `include_discount_prices` | `boolean` | `false` | indication wether or not to include sales prices in result | + +#### Returns + +`Promise`<`Product`[]\> + +A list of products with variants decorated with "additional_prices" + +#### Defined in + +[services/product.js:1055](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L1055) + +___ + +### update + +▸ **update**(`productId`, `update`): `Promise`<`any`\> + +Updates a product. Product variant updates should use dedicated methods, +e.g. `addVariant`, etc. The function will throw errors if metadata or +product variant updates are attempted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the id of the product. Must be a string that can be casted to an ObjectId | +| `update` | `any` | an object with the update values. | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/product.js:573](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L573) + +___ + +### updateOption + +▸ **updateOption**(`productId`, `optionId`, `data`): `Promise`<`any`\> + +Updates a product's option. Throws if the call tries to update an option +not associated with the product. Throws if the updated title already exists. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product whose option we are updating | +| `optionId` | `string` | the id of the option we are updating | +| `data` | `any` | the data to update the option with | + +#### Returns + +`Promise`<`any`\> + +the updated product + +#### Defined in + +[services/product.js:831](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L831) + +___ + +### upsertImages\_ + +▸ **upsertImages_**(`images`): `Promise`<`any`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `images` | `any` | + +#### Returns + +`Promise`<`any`[]\> + +#### Defined in + +[services/product.js:542](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L542) + +___ + +### upsertProductTags\_ + +▸ **upsertProductTags_**(`tags`): `Promise`<`any`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tags` | `any` | + +#### Returns + +`Promise`<`any`[]\> + +#### Defined in + +[services/product.js:455](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L455) + +___ + +### upsertProductType\_ + +▸ **upsertProductType_**(`type`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `type` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/product.js:430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L430) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ProductService`](ProductService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`ProductService`](ProductService.md) + +#### Defined in + +[services/product.js:76](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product.js#L76) diff --git a/docs/content/references/services/classes/ProductTypeService.md b/docs/content/references/services/classes/ProductTypeService.md new file mode 100644 index 0000000000..5e78ac7d3a --- /dev/null +++ b/docs/content/references/services/classes/ProductTypeService.md @@ -0,0 +1,145 @@ +# Class: ProductTypeService + +Provides layer to manipulate products. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ProductTypeService`** + +## Constructors + +### constructor + +• **new ProductTypeService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/product-type.ts:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L16) + +## Properties + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/product-type.ts:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L14) + +___ + +### typeRepository\_ + +• `Private` **typeRepository\_**: typeof `ProductTypeRepository` + +#### Defined in + +[services/product-type.ts:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L15) + +## Methods + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`ProductType`[]\> + +Lists product types + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableProductTypeProps` | the query object for find | +| `config` | `FindConfig`<`ProductType`\> | the config to be used for find | + +#### Returns + +`Promise`<`ProductType`[]\> + +the result of the find operation + +#### Defined in + +[services/product-type.ts:72](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L72) + +___ + +### listAndCount + +▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`ProductType`[], `number`]\> + +Lists product tags and adds count. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableProductTypeProps` | the query object for find | +| `config` | `FindConfig`<`ProductType`\> | the config to be used for find | + +#### Returns + +`Promise`<[`ProductType`[], `number`]\> + +the result of the find operation + +#### Defined in + +[services/product-type.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L88) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`ProductType`\> + +Gets a product by id. +Throws in case of DB Error and if product was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | id of the product to get. | +| `config` | `FindConfig`<`ProductType`\> | object that defines what should be included in the query response | + +#### Returns + +`Promise`<`ProductType`\> + +the result of the find one operation. + +#### Defined in + +[services/product-type.ts:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L47) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ProductTypeService`](ProductTypeService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`ProductTypeService`](ProductTypeService.md) + +#### Defined in + +[services/product-type.ts:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-type.ts#L23) diff --git a/docs/content/references/services/classes/ProductVariantService.md b/docs/content/references/services/classes/ProductVariantService.md new file mode 100644 index 0000000000..ee869e2863 --- /dev/null +++ b/docs/content/references/services/classes/ProductVariantService.md @@ -0,0 +1,631 @@ +# Class: ProductVariantService + +Provides layer to manipulate product variants. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ProductVariantService`** + +## Constructors + +### constructor + +• **new ProductVariantService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/product-variant.ts:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L52) + +## Properties + +### cartRepository\_ + +• `Private` **cartRepository\_**: typeof `CartRepository` + +#### Defined in + +[services/product-variant.ts:50](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L50) + +___ + +### eventBus\_ + +• `Private` **eventBus\_**: [`EventBusService`](EventBusService.md) + +#### Defined in + +[services/product-variant.ts:45](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L45) + +___ + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/product-variant.ts:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L42) + +___ + +### moneyAmountRepository\_ + +• `Private` **moneyAmountRepository\_**: typeof `MoneyAmountRepository` + +#### Defined in + +[services/product-variant.ts:48](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L48) + +___ + +### priceSelectionStrategy\_ + +• `Private` **priceSelectionStrategy\_**: `IPriceSelectionStrategy` + +#### Defined in + +[services/product-variant.ts:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L47) + +___ + +### productOptionValueRepository\_ + +• `Private` **productOptionValueRepository\_**: typeof `ProductOptionValueRepository` + +#### Defined in + +[services/product-variant.ts:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L49) + +___ + +### productRepository\_ + +• `Private` **productRepository\_**: typeof `ProductRepository` + +#### Defined in + +[services/product-variant.ts:44](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L44) + +___ + +### productVariantRepository\_ + +• `Private` **productVariantRepository\_**: typeof `ProductVariantRepository` + +#### Defined in + +[services/product-variant.ts:43](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L43) + +___ + +### regionService\_ + +• `Private` **regionService\_**: [`RegionService`](RegionService.md) + +#### Defined in + +[services/product-variant.ts:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L46) + +___ + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `DELETED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/product-variant.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L36) + +## Methods + +### addOptionValue + +▸ **addOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\> + +Adds option value to a varaint. +Fails when product with variant does not exists or +if that product does not have an option with the given +option id. Fails if given variant is not found. +Option value must be of type string or number. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the variant to decorate. | +| `optionId` | `string` | the option from product. | +| `optionValue` | `string` | option value to add. | + +#### Returns + +`Promise`<`ProductOptionValue`\> + +the result of the update operation. + +#### Defined in + +[services/product-variant.ts:553](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L553) + +___ + +### create + +▸ **create**(`productOrProductId`, `variant`): `Promise`<`ProductVariant`\> + +Creates an unpublished product variant. Will validate against parent product +to ensure that the variant can in fact be created. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productOrProductId` | `string` \| `Product` | the product the variant will be added to | +| `variant` | `CreateProductVariantInput` | the variant to create | + +#### Returns + +`Promise`<`ProductVariant`\> + +resolves to the creation result. + +#### Defined in + +[services/product-variant.ts:207](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L207) + +___ + +### delete + +▸ **delete**(`variantId`): `Promise`<`void`\> + +Deletes variant. +Will never fail due to delete being idempotent. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the variant to delete. Must be castable as an ObjectId | + +#### Returns + +`Promise`<`void`\> + +empty promise + +#### Defined in + +[services/product-variant.ts:746](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L746) + +___ + +### deleteOptionValue + +▸ **deleteOptionValue**(`variantId`, `optionId`): `Promise`<`void`\> + +Deletes option value from given variant. +Will never fail due to delete being idempotent. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the variant to decorate. | +| `optionId` | `string` | the option from product. | + +#### Returns + +`Promise`<`void`\> + +empty promise + +#### Defined in + +[services/product-variant.ts:580](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L580) + +___ + +### getFreeTextQueryBuilder\_ + +▸ **getFreeTextQueryBuilder_**(`variantRepo`, `query`, `q?`): `SelectQueryBuilder`<`ProductVariant`\> + +Lists variants based on the provided parameters and includes the count of +variants that match the query. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantRepo` | `ProductVariantRepository` | the variant repository | +| `query` | `FindWithRelationsOptions` | object that defines the scope for what should be returned | +| `q?` | `string` | free text query | + +#### Returns + +`SelectQueryBuilder`<`ProductVariant`\> + +an array containing the products as the first element and the total + count of products that matches the query as the second element. + +#### Defined in + +[services/product-variant.ts:852](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L852) + +___ + +### getRegionPrice + +▸ **getRegionPrice**(`variantId`, `context`): `Promise`<`number`\> + +Gets the price specific to a region. If no region specific money amount +exists the function will try to use a currency price. If no default +currency price exists the function will throw an error. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the variant to get price from | +| `context` | `GetRegionPriceContext` | context for getting region price | + +#### Returns + +`Promise`<`number`\> + +the price specific to the region + +#### Defined in + +[services/product-variant.ts:428](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L428) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`ProductVariant`[]\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableProductVariantProps` | the query object for find | +| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval | + +#### Returns + +`Promise`<`ProductVariant`[]\> + +the result of the find operation + +#### Defined in + +[services/product-variant.ts:677](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L677) + +___ + +### listAndCount + +▸ **listAndCount**(`selector`, `config?`): `Promise`<[`ProductVariant`[], `number`]\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableProductVariantProps` | the query object for find | +| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval | + +#### Returns + +`Promise`<[`ProductVariant`[], `number`]\> + +the result of the find operation + +#### Defined in + +[services/product-variant.ts:607](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L607) + +___ + +### prepareListQuery\_ + +▸ **prepareListQuery_**(`selector`, `config`): `Object` + +Creates a query object to be used for list queries. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableProductVariantProps` | the selector to create the query from | +| `config` | `FindConfig`<`ProductVariant`\> | the config to use for the query | + +#### Returns + +`Object` + +an object containing the query, relations and free-text + search param. + +| Name | Type | +| :------ | :------ | +| `q?` | `string` | +| `query` | `FindWithRelationsOptions` | +| `relations` | `string`[] | + +#### Defined in + +[services/product-variant.ts:813](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L813) + +___ + +### retrieve + +▸ **retrieve**(`variantId`, `config?`): `Promise`<`ProductVariant`\> + +Gets a product variant by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the product to get. | +| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. | + +#### Returns + +`Promise`<`ProductVariant`\> + +the product document. + +#### Defined in + +[services/product-variant.ts:117](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L117) + +___ + +### retrieveBySKU + +▸ **retrieveBySKU**(`sku`, `config?`): `Promise`<`ProductVariant`\> + +Gets a product variant by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `sku` | `string` | The unique stock keeping unit used to identify the product variant. | +| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. | + +#### Returns + +`Promise`<`ProductVariant`\> + +the product document. + +#### Defined in + +[services/product-variant.ts:162](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L162) + +___ + +### setAdditionalPrices + +▸ **setAdditionalPrices**(`variant`, `currency_code`, `region_id`, `cart_id`, `customer_id`, `include_discount_prices?`): `Promise`<`ProductVariant` \| `ProductVariant`[]\> + +Set additional prices on a list of variants. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `variant` | `any` | `undefined` | variant on which to set additional prices | +| `currency_code` | `any` | `undefined` | currency code to fetch prices for | +| `region_id` | `any` | `undefined` | region to fetch prices for | +| `cart_id` | `any` | `undefined` | string of cart to use as a basis for getting currency and region | +| `customer_id` | `any` | `undefined` | id of potentially logged in customer, used to get prices valid for their customer groups | +| `include_discount_prices` | `boolean` | `false` | should result include discount pricing | + +#### Returns + +`Promise`<`ProductVariant` \| `ProductVariant`[]\> + +A list of variants with variants decorated with "additional_prices" + +#### Defined in + +[services/product-variant.ts:897](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L897) + +___ + +### setCurrencyPrice + +▸ **setCurrencyPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\> + +Sets the default price for the given currency. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the variant to set prices for | +| `price` | `ProductVariantPrice` | the price for the variant | + +#### Returns + +`Promise`<`MoneyAmount`\> + +the result of the update operation + +#### Defined in + +[services/product-variant.ts:494](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L494) + +___ + +### setMetadata\_ + +▸ **setMetadata_**(`variant`, `metadata`): `Record`<`string`, `unknown`\> + +Dedicated method to set metadata for a variant. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variant` | `ProductVariant` | the variant to set metadata for. | +| `metadata` | `object` | the metadata to set | + +#### Returns + +`Record`<`string`, `unknown`\> + +updated metadata object + +#### Defined in + +[services/product-variant.ts:781](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L781) + +___ + +### setRegionPrice + +▸ **setRegionPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\> + +Sets the default price of a specific region + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of the variant to update | +| `price` | `ProductVariantPrice` | the price for the variant. | + +#### Returns + +`Promise`<`MoneyAmount`\> + +the result of the update operation + +#### Defined in + +[services/product-variant.ts:457](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L457) + +___ + +### update + +▸ **update**(`variantOrVariantId`, `update`): `Promise`<`ProductVariant`\> + +Updates a variant. +Price updates should use dedicated methods. +The function will throw, if price updates are attempted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantOrVariantId` | `string` \| `Partial`<`ProductVariant`\> | variant or id of a variant. | +| `update` | `UpdateProductVariantInput` | an object with the update values. | + +#### Returns + +`Promise`<`ProductVariant`\> + +resolves to the update result. + +#### Defined in + +[services/product-variant.ts:312](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L312) + +___ + +### updateOptionValue + +▸ **updateOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\> + +Updates variant's option value. +Option value must be of type string or number. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the variant to decorate. | +| `optionId` | `string` | the option from product. | +| `optionValue` | `string` | option value to add. | + +#### Returns + +`Promise`<`ProductOptionValue`\> + +the result of the update operation. + +#### Defined in + +[services/product-variant.ts:515](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L515) + +___ + +### updateVariantPrices + +▸ **updateVariantPrices**(`variantId`, `prices`): `Promise`<`void`\> + +Updates a variant's prices. +Deletes any prices that are not in the update object, and is not associated with a price list. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `variantId` | `string` | the id of variant variant | +| `prices` | `ProductVariantPrice`[] | the update prices | + +#### Returns + +`Promise`<`void`\> + +empty promise + +#### Defined in + +[services/product-variant.ts:390](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L390) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ProductVariantService`](ProductVariantService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`ProductVariantService`](ProductVariantService.md) + +#### Defined in + +[services/product-variant.ts:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/product-variant.ts#L89) diff --git a/docs/content/references/services/classes/QueryBuilderService.md b/docs/content/references/services/classes/QueryBuilderService.md new file mode 100644 index 0000000000..42bbd08527 --- /dev/null +++ b/docs/content/references/services/classes/QueryBuilderService.md @@ -0,0 +1,79 @@ +# Class: QueryBuilderService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`QueryBuilderService`** + +## Constructors + +### constructor + +• **new QueryBuilderService**() + +#### Inherited from + +BaseService.constructor + +## Methods + +### buildFilterQuery + +▸ **buildFilterQuery**(`filters`): `undefined` \| {} + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `filters` | `any` | + +#### Returns + +`undefined` \| {} + +#### Defined in + +[services/query-builder.js:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/query-builder.js#L25) + +___ + +### buildQuery + +▸ **buildQuery**(`params`, `properties`): `Object` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `params` | `any` | +| `properties` | `any` | + +#### Returns + +`Object` + +#### Defined in + +[services/query-builder.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/query-builder.js#L5) + +___ + +### buildTextSearchQuery + +▸ **buildTextSearchQuery**(`search`, `searchProperties`): `undefined` \| { `$or`: `any` = searchQuery } + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `search` | `any` | +| `searchProperties` | `any` | + +#### Returns + +`undefined` \| { `$or`: `any` = searchQuery } + +#### Defined in + +[services/query-builder.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/query-builder.js#L39) diff --git a/docs/content/references/services/classes/RegionService.md b/docs/content/references/services/classes/RegionService.md new file mode 100644 index 0000000000..30d01a950a --- /dev/null +++ b/docs/content/references/services/classes/RegionService.md @@ -0,0 +1,457 @@ +# Class: RegionService + +Provides layer to manipulate regions. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`RegionService`** + +## Constructors + +### constructor + +• **new RegionService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/region.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L16) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `DELETED` | `string` | +| `UPDATED` | `string` | + +#### Defined in + +[services/region.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L10) + +## Methods + +### addCountry + +▸ **addCountry**(`regionId`, `code`): `Promise`<`any`\> + +Adds a country to the region. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to add a country to | +| `code` | `string` | a 2 digit alphanumeric ISO country code. | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:460](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L460) + +___ + +### addFulfillmentProvider + +▸ **addFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\> + +Adds a fulfillment provider that is available in the region. Fails if the +provider doesn't exist. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to add the provider to | +| `providerId` | `string` | the provider to add to the region | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:580](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L580) + +___ + +### addPaymentProvider + +▸ **addPaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\> + +Adds a payment provider that is available in the region. Fails if the +provider doesn't exist. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to add the provider to | +| `providerId` | `string` | the provider to add to the region | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:533](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L533) + +___ + +### create + +▸ **create**(`regionObject`): `Region` + +Creates a region. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionObject` | `Region` | the unvalidated region | + +#### Returns + +`Region` + +the newly created region + +#### Defined in + +[services/region.js:95](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L95) + +___ + +### delete + +▸ **delete**(`regionId`): `Promise`<`any`\> + +Deletes a region. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to delete | + +#### Returns + +`Promise`<`any`\> + +the result of the delete operation + +#### Defined in + +[services/region.js:430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L430) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`any`\> + +Lists all regions based on a query + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | query object for find | +| `config` | `any` | configuration settings | + +#### Returns + +`Promise`<`any`\> + +result of the find operation + +#### Defined in + +[services/region.js:418](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L418) + +___ + +### removeCountry + +▸ **removeCountry**(`regionId`, `code`): `Promise`<`any`\> + +Removes a country from a Region + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to remove from | +| `code` | `string` | a 2 digit alphanumeric ISO country code to remove | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:497](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L497) + +___ + +### removeFulfillmentProvider + +▸ **removeFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\> + +Removes a fulfillment provider from a region. Is idempotent. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to remove the provider from | +| `providerId` | `string` | the provider to remove from the region | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:658](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L658) + +___ + +### removePaymentProvider + +▸ **removePaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\> + +Removes a payment provider from a region. Is idempotent. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to remove the provider from | +| `providerId` | `string` | the provider to remove from the region | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:624](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L624) + +___ + +### retrieve + +▸ **retrieve**(`regionId`, `config?`): `Region` + +Retrieves a region by its id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the id of the region to retrieve | +| `config` | `any` | configuration settings | + +#### Returns + +`Region` + +the region + +#### Defined in + +[services/region.js:394](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L394) + +___ + +### retrieveByCountryCode + +▸ **retrieveByCountryCode**(`code`, `config?`): `Promise`<`Region`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `code` | `any` | +| `config` | `Object` | + +#### Returns + +`Promise`<`Region`\> + +#### Defined in + +[services/region.js:360](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L360) + +___ + +### update + +▸ **update**(`regionId`, `update`): `Promise`<`any`\> + +Updates a region + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `regionId` | `string` | the region to update | +| `update` | `any` | the data to update the region with | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/region.js:153](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L153) + +___ + +### validateCountry\_ + +▸ **validateCountry_**(`code`, `regionId`): `Promise`<`any`\> + +Validates a country code. Will normalize the code before checking for +existence. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `code` | `string` | a 2 digit alphanumeric ISO country code | +| `regionId` | `string` | the id of the current region to check against | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/region.js:323](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L323) + +___ + +### validateCurrency\_ + +▸ **validateCurrency_**(`currencyCode`): `Promise`<`void`\> + +Validates a currency code. Will throw if the currency code doesn't exist. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `currencyCode` | `string` | an ISO currency code | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/region.js:302](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L302) + +___ + +### validateFields\_ + +▸ **validateFields_**(`region`, `id?`): `any` + +Validates fields for creation and updates. If the region already exisits +the id can be passed to check that country updates are allowed. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `region` | `any` | `undefined` | the region data to validate | +| `id` | ``null`` \| `string` | `undefined` | optional id of the region to check against | + +#### Returns + +`any` + +the validated region data + +#### Defined in + +[services/region.js:213](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L213) + +___ + +### validateTaxRate\_ + +▸ **validateTaxRate_**(`taxRate`): `void` + +Validates a tax rate. Will throw if the tax rate is not between 0 and 1. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `taxRate` | `number` | a number representing the tax rate of the region | + +#### Returns + +`void` + +#### Defined in + +[services/region.js:289](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L289) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`RegionService`](RegionService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`RegionService`](RegionService.md) + +#### Defined in + +[services/region.js:65](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/region.js#L65) diff --git a/docs/content/references/services/classes/ReturnReasonService.md b/docs/content/references/services/classes/ReturnReasonService.md new file mode 100644 index 0000000000..1349f96137 --- /dev/null +++ b/docs/content/references/services/classes/ReturnReasonService.md @@ -0,0 +1,156 @@ +# Class: ReturnReasonService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ReturnReasonService`** + +## Constructors + +### constructor + +• **new ReturnReasonService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/return-reason.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L5) + +## Methods + +### create + +▸ **create**(`data`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `data` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/return-reason.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L30) + +___ + +### delete + +▸ **delete**(`returnReasonId`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `returnReasonId` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/return-reason.js:114](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L114) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | config object | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/return-reason.js:82](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L82) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`Order`\> + +Gets an order by id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | id of order to retrieve | +| `config` | `any` | config object | + +#### Returns + +`Promise`<`Order`\> + +the order document + +#### Defined in + +[services/return-reason.js:97](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L97) + +___ + +### update + +▸ **update**(`id`, `data`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `any` | +| `data` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/return-reason.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L52) + +___ + +### withTransaction + +▸ **withTransaction**(`manager`): [`ReturnReasonService`](ReturnReasonService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `manager` | `any` | + +#### Returns + +[`ReturnReasonService`](ReturnReasonService.md) + +#### Defined in + +[services/return-reason.js:15](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return-reason.js#L15) diff --git a/docs/content/references/services/classes/ReturnService.md b/docs/content/references/services/classes/ReturnService.md new file mode 100644 index 0000000000..7a5816facb --- /dev/null +++ b/docs/content/references/services/classes/ReturnService.md @@ -0,0 +1,355 @@ +# Class: ReturnService + +Handles Returns + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ReturnService`** + +## Constructors + +### constructor + +• **new ReturnService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/return.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L9) + +## Properties + +### inventoryService\_ + +• **inventoryService\_**: `any` + +#### Defined in + +[services/return.js:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L49) + +___ + +### returnReasonService\_ + +• **returnReasonService\_**: `any` + +#### Defined in + +[services/return.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L47) + +___ + +### taxProviderService\_ + +• **taxProviderService\_**: `any` + +#### Defined in + +[services/return.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L39) + +## Methods + +### cancel + +▸ **cancel**(`returnId`): `Promise`<`Return`\> + +Cancels a return if possible. Returns can be canceled if it has not been received. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `returnId` | `string` | the id of the return to cancel. | + +#### Returns + +`Promise`<`Return`\> + +the updated Return + +#### Defined in + +[services/return.js:134](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L134) + +___ + +### create + +▸ **create**(`data`): `Promise`<`Return`\> + +Creates a return request for an order, with given items, and a shipping +method. If no refund amount is provided the refund amount is calculated from +the return lines and the shipping cost. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `any` | data to use for the return e.g. shipping_method, items or refund_amount | + +#### Returns + +`Promise`<`Return`\> + +the created return + +#### Defined in + +[services/return.js:307](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L307) + +___ + +### fulfill + +▸ **fulfill**(`returnId`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `returnId` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/return.js:450](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L450) + +___ + +### getFulfillmentItems\_ + +▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\> + +Retrieves the order line items, given an array of items + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to get line items from | +| `items` | `Object` | the items to get | +| `items.item_id` | `string` | - | +| `items.quantity` | `number` | - | +| `transformer` | `Function` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. | + +#### Returns + +`Promise`<`LineItem`[]\> + +the line items generated by the transformer. + +#### Defined in + +[services/return.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L89) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config object for find | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/return.js:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L120) + +___ + +### receive + +▸ **receive**(`return_id`, `received_items`, `refund_amount`, `allow_mismatch?`): `Promise`<`any`\> + +Registers a previously requested return as received. This will create a +refund to the customer. If the returned items don't match the requested +items the return status will be updated to requires_action. This behaviour +is useful in sitautions where a custom refund amount is requested, but the +retuned items are not matching the requested items. Setting the +allowMismatch argument to true, will process the return, ignoring any +mismatches. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `return_id` | `string` | `undefined` | the orderId to return to | +| `received_items` | `Item`[] | `undefined` | the items received after return. | +| `refund_amount` | `undefined` \| `number` | `undefined` | the amount to return | +| `allow_mismatch` | `bool` | `false` | whether to ignore return/received product mismatch | + +#### Returns + +`Promise`<`any`\> + +the result of the update operation + +#### Defined in + +[services/return.js:524](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L524) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Return` + +Retrieves a return by its id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the return to retrieve | +| `config` | `any` | the config object | + +#### Returns + +`Return` + +the return + +#### Defined in + +[services/return.js:229](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L229) + +___ + +### retrieveBySwap + +▸ **retrieveBySwap**(`swapId`, `relations?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `swapId` | `any` | `undefined` | +| `relations` | `any`[] | `[]` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/return.js:248](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L248) + +___ + +### update + +▸ **update**(`returnId`, `update`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `returnId` | `any` | +| `update` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/return.js:271](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L271) + +___ + +### validateReturnLineItem\_ + +▸ **validateReturnLineItem_**(`item`, `quantity`, `additional`): `LineItem` + +Checks that a given quantity of a line item can be returned. Fails if the +item is undefined or if the returnable quantity of the item is lower, than +the quantity that is requested to be returned. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `item` | `any` | the line item to check has sufficient returnable quantity. | +| `quantity` | `number` | the quantity that is requested to be returned. | +| `additional` | `any` | the quantity that is requested to be returned. | + +#### Returns + +`LineItem` + +a line item where the quantity is set to the requested + return quantity. + +#### Defined in + +[services/return.js:191](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L191) + +___ + +### validateReturnStatuses\_ + +▸ **validateReturnStatuses_**(`order`): `void` + +Checks that an order has the statuses necessary to complete a return. +fulfillment_status cannot be not_fulfilled or returned. +payment_status must be captured. + +**`throws`** when statuses are not sufficient for returns. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to check statuses on | + +#### Returns + +`void` + +#### Defined in + +[services/return.js:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L161) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ReturnService`](ReturnService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`ReturnService`](ReturnService.md) + +#### Defined in + +[services/return.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L55) diff --git a/docs/content/references/services/classes/SearchService.md b/docs/content/references/services/classes/SearchService.md new file mode 100644 index 0000000000..1b3e67ea4c --- /dev/null +++ b/docs/content/references/services/classes/SearchService.md @@ -0,0 +1,222 @@ +# Class: SearchService + +Default class that implements SearchService but provides stuv implementation for all methods + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`SearchService`** + +## Constructors + +### constructor + +• **new SearchService**(`container`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `container` | `any` | + +#### Overrides + +SearchService.constructor + +#### Defined in + +[services/search.js:8](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L8) + +## Properties + +### isDefault + +• **isDefault**: `boolean` + +#### Defined in + +[services/search.js:11](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L11) + +___ + +### logger\_ + +• **logger\_**: `any` + +#### Defined in + +[services/search.js:13](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L13) + +## Methods + +### addDocuments + +▸ **addDocuments**(`indexName`, `documents`, `type`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | +| `documents` | `any` | +| `type` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:28](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L28) + +___ + +### createIndex + +▸ **createIndex**(`indexName`, `options`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | +| `options` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:16](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L16) + +___ + +### deleteAllDocuments + +▸ **deleteAllDocuments**(`indexName`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L46) + +___ + +### deleteDocument + +▸ **deleteDocument**(`indexName`, `document_id`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | +| `document_id` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L40) + +___ + +### getIndex + +▸ **getIndex**(`indexName`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:22](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L22) + +___ + +### replaceDocuments + +▸ **replaceDocuments**(`indexName`, `documents`, `type`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | +| `documents` | `any` | +| `type` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L34) + +___ + +### search + +▸ **search**(`indexName`, `query`, `options`): `Object` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | +| `query` | `any` | +| `options` | `any` | + +#### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `hits` | `never`[] | + +#### Defined in + +[services/search.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L52) + +___ + +### updateSettings + +▸ **updateSettings**(`indexName`, `settings`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexName` | `any` | +| `settings` | `any` | + +#### Returns + +`void` + +#### Defined in + +[services/search.js:59](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/search.js#L59) diff --git a/docs/content/references/services/classes/ShippingOptionService.md b/docs/content/references/services/classes/ShippingOptionService.md new file mode 100644 index 0000000000..268c468c55 --- /dev/null +++ b/docs/content/references/services/classes/ShippingOptionService.md @@ -0,0 +1,478 @@ +# Class: ShippingOptionService + +Provides layer to manipulate profiles. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ShippingOptionService`** + +## Constructors + +### constructor + +• **new ShippingOptionService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/shipping-option.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L9) + +## Methods + +### addRequirement + +▸ **addRequirement**(`optionId`, `requirement`): `Promise`<`any`\> + +Adds a requirement to a shipping option. Only 1 requirement of each type +is allowed. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optionId` | `string` | the option to add the requirement to. | +| `requirement` | `ShippingRequirement` | the requirement for the option. | + +#### Returns + +`Promise`<`any`\> + +the result of update + +#### Defined in + +[services/shipping-option.js:594](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L594) + +___ + +### create + +▸ **create**(`data`): `Promise`<`ShippingOption`\> + +Creates a new shipping option. Used both for outbound and inbound shipping +options. The difference is registered by the `is_return` field which +defaults to false. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `ShippingOption` | the data to create shipping options | + +#### Returns + +`Promise`<`ShippingOption`\> + +the result of the create operation + +#### Defined in + +[services/shipping-option.js:350](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L350) + +___ + +### createShippingMethod + +▸ **createShippingMethod**(`optionId`, `data`, `config`): `ShippingMethod` + +Creates a shipping method for a given cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optionId` | `string` | the id of the option to use for the method. | +| `data` | `any` | the optional provider data to use. | +| `config` | `any` | the cart to create the shipping method for. | + +#### Returns + +`ShippingMethod` + +the resulting shipping method. + +#### Defined in + +[services/shipping-option.js:231](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L231) + +___ + +### decorate + +▸ **decorate**(`optionId`, `fields?`, `expandFields?`): `ShippingOption` + +Decorates a shipping option. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `optionId` | `ShippingOption` | `undefined` | the shipping option to decorate using optionId. | +| `fields` | `string`[] | `[]` | the fields to include. | +| `expandFields` | `string`[] | `[]` | fields to expand. | + +#### Returns + +`ShippingOption` + +the decorated ShippingOption. + +#### Defined in + +[services/shipping-option.js:645](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L645) + +___ + +### delete + +▸ **delete**(`optionId`): `Promise`<`any`\> + +Deletes a profile with a given profile id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optionId` | `string` | the id of the profile to delete. Must be castable as an ObjectId | + +#### Returns + +`Promise`<`any`\> + +the result of the delete operation. + +#### Defined in + +[services/shipping-option.js:566](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L566) + +___ + +### deleteShippingMethods + +▸ **deleteShippingMethods**(`shippingMethods`): `Promise`<`any`\> + +Removes a given shipping method + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `shippingMethods` | `any` | the shipping method to remove | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/shipping-option.js:213](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L213) + +___ + +### getPrice\_ + +▸ **getPrice_**(`option`, `data`, `cart`): `Promise`<`number`\> + +Returns the amount to be paid for a shipping method. Will ask the +fulfillment provider to calculate the price if the shipping option has the +price type "calculated". + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `option` | `ShippingOption` | the shipping option to retrieve the price for. | +| `data` | `ShippingData` | the shipping data to retrieve the price. | +| `cart` | `any` | the context in which the price should be retrieved. | + +#### Returns + +`Promise`<`number`\> + +the price of the shipping option. + +#### Defined in + +[services/shipping-option.js:697](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L697) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | config object | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/shipping-option.js:123](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L123) + +___ + +### listAndCount + +▸ **listAndCount**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | config object | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/shipping-option.js:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L135) + +___ + +### removeRequirement + +▸ **removeRequirement**(`requirementId`): `Promise`<`any`\> + +Removes a requirement from a shipping option + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `requirementId` | `string` | the id of the requirement to remove | + +#### Returns + +`Promise`<`any`\> + +the result of update + +#### Defined in + +[services/shipping-option.js:620](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L620) + +___ + +### retrieve + +▸ **retrieve**(`optionId`, `options?`): `Promise`<`Product`\> + +Gets a profile by id. +Throws in case of DB Error and if profile was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optionId` | `string` | the id of the profile to get. | +| `options` | `any` | the options to get a profile | + +#### Returns + +`Promise`<`Product`\> + +the profile document. + +#### Defined in + +[services/shipping-option.js:149](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L149) + +___ + +### setMetadata\_ + +▸ **setMetadata_**(`option`, `metadata`): `Promise`<`any`\> + +Dedicated method to set metadata for a shipping option. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `option` | `any` | the option to set metadata for. | +| `metadata` | `any` | object for metadata field | + +#### Returns + +`Promise`<`any`\> + +resolves to the updated result. + +#### Defined in + +[services/shipping-option.js:664](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L664) + +___ + +### update + +▸ **update**(`optionId`, `update`): `Promise`<`any`\> + +Updates a profile. Metadata updates and product updates should use +dedicated methods, e.g. `setMetadata`, etc. The function +will throw errors if metadata or product updates are attempted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optionId` | `string` | the id of the option. Must be a string that can be casted to an ObjectId | +| `update` | `any` | an object with the update values. | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/shipping-option.js:464](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L464) + +___ + +### updateShippingMethod + +▸ **updateShippingMethod**(`id`, `update`): `Promise`<`ShippingMethod`\> + +Updates a shipping method's associations. Useful when a cart is completed +and its methods should be copied to an order/swap entity. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the shipping method to update | +| `update` | `any` | the values to update the method with | + +#### Returns + +`Promise`<`ShippingMethod`\> + +the resulting shipping method + +#### Defined in + +[services/shipping-option.js:184](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L184) + +___ + +### validateCartOption + +▸ **validateCartOption**(`option`, `cart`): `ShippingOption` + +Checks if a given option id is a valid option for a cart. If it is the +option is returned with the correct price. Throws when region_ids do not +match, or when the shipping option requirements are not satisfied. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `option` | `any` | the option object to check | +| `cart` | `Cart` | the cart object to check against | + +#### Returns + +`ShippingOption` + +the validated shipping option + +#### Defined in + +[services/shipping-option.js:309](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L309) + +___ + +### validatePriceType\_ + +▸ **validatePriceType_**(`priceType`, `option`): `Promise`<`ShippingOptionPrice`\> + +Validates a shipping option price + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `priceType` | `ShippingOptionPrice` | the price to validate | +| `option` | `ShippingOption` | the option to validate against | + +#### Returns + +`Promise`<`ShippingOptionPrice`\> + +the validated price + +#### Defined in + +[services/shipping-option.js:431](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L431) + +___ + +### validateRequirement\_ + +▸ **validateRequirement_**(`requirement`, `optionId`): `ShippingRequirement` + +Validates a requirement + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `requirement` | `ShippingRequirement` | the requirement to validate | +| `optionId` | `string` | the id to validate the requirement | + +#### Returns + +`ShippingRequirement` + +a validated shipping requirement + +#### Defined in + +[services/shipping-option.js:63](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L63) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ShippingOptionService`](ShippingOptionService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`ShippingOptionService`](ShippingOptionService.md) + +#### Defined in + +[services/shipping-option.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-option.js#L38) diff --git a/docs/content/references/services/classes/ShippingProfileService.md b/docs/content/references/services/classes/ShippingProfileService.md new file mode 100644 index 0000000000..c428c42a88 --- /dev/null +++ b/docs/content/references/services/classes/ShippingProfileService.md @@ -0,0 +1,392 @@ +# Class: ShippingProfileService + +Provides layer to manipulate profiles. + +**`implements`** {BaseService} + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`ShippingProfileService`** + +## Constructors + +### constructor + +• **new ShippingProfileService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/shipping-profile.js:12](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L12) + +## Methods + +### addProduct + +▸ **addProduct**(`profileId`, `productId`): `Promise`<`any`\> + +Adds a product to a profile. The method is idempotent, so multiple calls +with the same product variant will have the same result. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `profileId` | `string` | the profile to add the product to. | +| `productId` | `string` | the product to add. | + +#### Returns + +`Promise`<`any`\> + +the result of update + +#### Defined in + +[services/shipping-profile.js:343](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L343) + +___ + +### addShippingOption + +▸ **addShippingOption**(`profileId`, `optionId`): `Promise`<`any`\> + +Adds a shipping option to the profile. The shipping option can be used to +fulfill the products in the products field. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `profileId` | `string` | the profile to apply the shipping option to | +| `optionId` | `string` | the option to add to the profile | + +#### Returns + +`Promise`<`any`\> + +the result of the model update operation + +#### Defined in + +[services/shipping-profile.js:361](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L361) + +___ + +### create + +▸ **create**(`profile`): `Promise`<`any`\> + +Creates a new shipping profile. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `profile` | `ShippingProfile` | the shipping profile to create from | + +#### Returns + +`Promise`<`any`\> + +the result of the create operation + +#### Defined in + +[services/shipping-profile.js:235](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L235) + +___ + +### createDefault + +▸ **createDefault**(): `Promise`<`ShippingProfile`\> + +Creates a default shipping profile, if this does not already exist. + +#### Returns + +`Promise`<`ShippingProfile`\> + +the shipping profile + +#### Defined in + +[services/shipping-profile.js:167](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L167) + +___ + +### createGiftCardDefault + +▸ **createGiftCardDefault**(): `Promise`<`ShippingProfile`\> + +Creates a default shipping profile, for gift cards if unless it already +exists. + +#### Returns + +`Promise`<`ShippingProfile`\> + +the shipping profile + +#### Defined in + +[services/shipping-profile.js:209](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L209) + +___ + +### decorate + +▸ **decorate**(`profile`, `fields`, `expandFields?`): `Profile` + +Decorates a profile. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `profile` | `Profile` | `undefined` | the profile to decorate. | +| `fields` | `string`[] | `undefined` | the fields to include. | +| `expandFields` | `string`[] | `[]` | fields to expand. | + +#### Returns + +`Profile` + +return the decorated profile. + +#### Defined in + +[services/shipping-profile.js:379](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L379) + +___ + +### delete + +▸ **delete**(`profileId`): `Promise`<`any`\> + +Deletes a profile with a given profile id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `profileId` | `string` | the id of the profile to delete. Must be castable as an ObjectId | + +#### Returns + +`Promise`<`any`\> + +the result of the delete operation. + +#### Defined in + +[services/shipping-profile.js:317](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L317) + +___ + +### fetchCartOptions + +▸ **fetchCartOptions**(`cart`): [`ShippingOption`] + +Finds all the shipping profiles that cover the products in a cart, and +validates all options that are available for the cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart object to find shipping options for | + +#### Returns + +[`ShippingOption`] + +a list of the available shipping options + +#### Defined in + +[services/shipping-profile.js:425](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L425) + +___ + +### fetchOptionsByProductIds + +▸ **fetchOptionsByProductIds**(`productIds`, `filter`): `Promise`<`any`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `productIds` | `any` | +| `filter` | `any` | + +#### Returns + +`Promise`<`any`[]\> + +#### Defined in + +[services/shipping-profile.js:73](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L73) + +___ + +### getProfilesInCart\_ + +▸ **getProfilesInCart_**(`cart`): [`string`] + +Returns a list of all the productIds in the cart. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cart` | `Cart` | the cart to extract products from | + +#### Returns + +[`string`] + +a list of product ids + +#### Defined in + +[services/shipping-profile.js:406](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L406) + +___ + +### list + +▸ **list**(`selector?`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the config object for find | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/shipping-profile.js:64](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L64) + +___ + +### retrieve + +▸ **retrieve**(`profileId`, `options?`): `Promise`<`Product`\> + +Gets a profile by id. +Throws in case of DB Error and if profile was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `profileId` | `string` | the id of the profile to get. | +| `options` | `any` | options opf the query. | + +#### Returns + +`Promise`<`Product`\> + +the profile document. + +#### Defined in + +[services/shipping-profile.js:121](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L121) + +___ + +### retrieveDefault + +▸ **retrieveDefault**(): `Promise`<`any`\> + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/shipping-profile.js:151](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L151) + +___ + +### retrieveGiftCardDefault + +▸ **retrieveGiftCardDefault**(): `any` + +Retrieves the default gift card profile + +#### Returns + +`any` + +the shipping profile for gift cards + +#### Defined in + +[services/shipping-profile.js:192](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L192) + +___ + +### update + +▸ **update**(`profileId`, `update`): `Promise`<`any`\> + +Updates a profile. Metadata updates and product updates should use +dedicated methods, e.g. `setMetadata`, `addProduct`, etc. The function +will throw errors if metadata or product updates are attempted. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `profileId` | `string` | the id of the profile. Must be a string that can be casted to an ObjectId | +| `update` | `any` | an object with the update values. | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/shipping-profile.js:263](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L263) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`ShippingProfileService`](ShippingProfileService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`ShippingProfileService`](ShippingProfileService.md) + +#### Defined in + +[services/shipping-profile.js:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/shipping-profile.js#L41) diff --git a/docs/content/references/services/classes/StoreService.md b/docs/content/references/services/classes/StoreService.md new file mode 100644 index 0000000000..599d1af23a --- /dev/null +++ b/docs/content/references/services/classes/StoreService.md @@ -0,0 +1,216 @@ +# Class: StoreService + +Provides layer to manipulate store settings. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`StoreService`** + +## Constructors + +### constructor + +• **new StoreService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/store.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L10) + +## Methods + +### addCurrency + +▸ **addCurrency**(`code`): `Promise`<`any`\> + +Add a currency to the store + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `code` | `string` | 3 character ISO currency code | + +#### Returns + +`Promise`<`any`\> + +result after update + +#### Defined in + +[services/store.js:203](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L203) + +___ + +### create + +▸ **create**(): `Promise`<`Store`\> + +Creates a store if it doesn't already exist. + +#### Returns + +`Promise`<`Store`\> + +the store. + +#### Defined in + +[services/store.js:52](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L52) + +___ + +### decorate + +▸ **decorate**(`store`, `fields`, `expandFields?`): `Store` + +Decorates a store object. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `store` | `Store` | `undefined` | the store to decorate. | +| `fields` | `string`[] | `undefined` | the fields to include. | +| `expandFields` | `string`[] | `[]` | fields to expand. | + +#### Returns + +`Store` + +return the decorated Store. + +#### Defined in + +[services/store.js:266](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L266) + +___ + +### getDefaultCurrency\_ + +▸ **getDefaultCurrency_**(`code`): `Object` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `code` | `any` | + +#### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `code` | `any` | +| `name` | `any` | +| `symbol` | `any` | +| `symbol_native` | `any` | + +#### Defined in + +[services/store.js:92](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L92) + +___ + +### removeCurrency + +▸ **removeCurrency**(`code`): `Promise`<`any`\> + +Removes a currency from the store + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `code` | `string` | 3 character ISO currency code | + +#### Returns + +`Promise`<`any`\> + +result after update + +#### Defined in + +[services/store.js:242](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L242) + +___ + +### retrieve + +▸ **retrieve**(`relations?`): `Promise`<`Store`\> + +Retrieve the store settings. There is always a maximum of one store. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `relations` | `string`[] | `[]` | relations to fetch with store | + +#### Returns + +`Promise`<`Store`\> + +the store + +#### Defined in + +[services/store.js:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L84) + +___ + +### update + +▸ **update**(`update`): `Promise`<`any`\> + +Updates a store + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `update` | `any` | an object with the update values. | + +#### Returns + +`Promise`<`any`\> + +resolves to the update result. + +#### Defined in + +[services/store.js:108](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L108) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`StoreService`](StoreService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`StoreService`](StoreService.md) + +#### Defined in + +[services/store.js:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/store.js#L31) diff --git a/docs/content/references/services/classes/SwapService.md b/docs/content/references/services/classes/SwapService.md new file mode 100644 index 0000000000..a7405ab7e6 --- /dev/null +++ b/docs/content/references/services/classes/SwapService.md @@ -0,0 +1,465 @@ +# Class: SwapService + +Handles swaps + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`SwapService`** + +## Constructors + +### constructor + +• **new SwapService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/swap.js:21](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L21) + +## Properties + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `CREATED` | `string` | +| `FULFILLMENT_CREATED` | `string` | +| `PAYMENT_CAPTURED` | `string` | +| `PAYMENT_CAPTURE_FAILED` | `string` | +| `PAYMENT_COMPLETED` | `string` | +| `PROCESS_REFUND_FAILED` | `string` | +| `RECEIVED` | `string` | +| `REFUND_PROCESSED` | `string` | +| `SHIPMENT_CREATED` | `string` | + +#### Defined in + +[services/swap.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L9) + +## Methods + +### cancel + +▸ **cancel**(`swapId`): `Promise`<`Swap`\> + +Cancels a given swap if possible. A swap can only be canceled if all +related returns, fulfillments, and payments have been canceled. If a swap +is associated with a refund, it cannot be canceled. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `swapId` | `string` | the id of the swap to cancel. | + +#### Returns + +`Promise`<`Swap`\> + +the canceled swap. + +#### Defined in + +[services/swap.js:790](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L790) + +___ + +### cancelFulfillment + +▸ **cancelFulfillment**(`fulfillmentId`): `Swap` + +Cancels a fulfillment (if related to a swap) + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fulfillmentId` | `string` | the ID of the fulfillment to cancel | + +#### Returns + +`Swap` + +updated swap + +#### Defined in + +[services/swap.js:983](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L983) + +___ + +### create + +▸ **create**(`order`, `returnItems`, `additionalItems`, `returnShipping`, `custom?`): `Promise`<`Swap`\> + +Creates a swap from an order, with given return items, additional items +and an optional return shipping method. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to base the swap off. | +| `returnItems` | `ReturnItem`[] | the items to return in the swap. | +| `additionalItems` | `undefined` \| `PreliminaryLineItem`[] | the items to send to the customer. | +| `returnShipping` | `any` | an optional shipping method for returning the returnItems. | +| `custom` | `any` | contains relevant custom information. This object may include no_notification which will disable sending notification when creating swap. If set, it overrules the attribute inherited from the order. | + +#### Returns + +`Promise`<`Swap`\> + +the newly created swap. + +#### Defined in + +[services/swap.js:313](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L313) + +___ + +### createCart + +▸ **createCart**(`swapId`, `customShippingOptions?`): `Promise`<`Swap`\> + +Creates a cart from the given swap and order. The cart can be used to pay +for differences associated with the swap. The swap represented by the +swapId must belong to the order. Fails if there is already a cart on the +swap. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `swapId` | `string` | `undefined` | the id of the swap to create the cart from | +| `customShippingOptions` | `any`[] | `[]` | the shipping options | + +#### Returns + +`Promise`<`Swap`\> + +the swap with its cart_id prop set to the id of + the new cart. + +#### Defined in + +[services/swap.js:544](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L544) + +___ + +### createFulfillment + +▸ **createFulfillment**(`swapId`, `config?`): `Promise`<`Swap`\> + +Fulfills the addtional items associated with the swap. Will call the +fulfillment providers associated with the shipping methods. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `swapId` | `string` | the id of the swap to fulfill, | +| `config` | `any` | optional configurations, includes optional metadata to attach to the shipment, and a no_notification flag. | + +#### Returns + +`Promise`<`Swap`\> + +the updated swap with new status and fulfillments. + +#### Defined in + +[services/swap.js:848](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L848) + +___ + +### createShipment + +▸ **createShipment**(`swapId`, `fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`Swap`\> + +Marks a fulfillment as shipped and attaches tracking numbers. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `swapId` | `string` | the id of the swap that has been shipped. | +| `fulfillmentId` | `string` | the id of the specific fulfillment that has been shipped | +| `trackingLinks` | `undefined` \| `TrackingLink`[] | the tracking numbers associated with the shipment | +| `config` | `any` | optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. | + +#### Returns + +`Promise`<`Swap`\> + +the updated swap with new fulfillments and status. + +#### Defined in + +[services/swap.js:1016](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L1016) + +___ + +### deleteMetadata + +▸ **deleteMetadata**(`swapId`, `key`): `Promise`<`any`\> + +Dedicated method to delete metadata for a swap. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `swapId` | `string` | the order to delete metadata from. | +| `key` | `string` | key for metadata field | + +#### Returns + +`Promise`<`any`\> + +resolves to the updated result. + +#### Defined in + +[services/swap.js:1089](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L1089) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `any` | the query object for find | +| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. | + +#### Returns + +`Promise`<`any`\> + +the result of the find operation + +#### Defined in + +[services/swap.js:238](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L238) + +___ + +### processDifference + +▸ **processDifference**(`swapId`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `swapId` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/swap.js:395](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L395) + +___ + +### registerCartCompletion + +▸ **registerCartCompletion**(`swapId`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `swapId` | `string` | The id of the swap | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/swap.js:659](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L659) + +___ + +### registerReceived + +▸ **registerReceived**(`id`): `Promise`<`Order`\> + +Registers the swap return items as received so that they cannot be used +as a part of other swaps/returns. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the order with the swap. | + +#### Returns + +`Promise`<`Order`\> + +the resulting order + +#### Defined in + +[services/swap.js:1114](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L1114) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`Swap`\> + +Retrieves a swap with the given id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | the id of the swap to retrieve | +| `config` | `any` | the configuration to retrieve the swap | + +#### Returns + +`Promise`<`Swap`\> + +the swap + +#### Defined in + +[services/swap.js:181](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L181) + +___ + +### retrieveByCartId + +▸ **retrieveByCartId**(`cartId`, `relations?`): `Promise`<`Swap`\> + +Retrieves a swap based on its associated cart id + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `cartId` | `string` | `undefined` | the cart id that the swap's cart has | +| `relations` | `string`[] | `[]` | the relations to retrieve swap | + +#### Returns + +`Promise`<`Swap`\> + +the swap + +#### Defined in + +[services/swap.js:216](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L216) + +___ + +### transformQueryForCart\_ + +▸ **transformQueryForCart_**(`config`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | `any` | + +#### Returns + +`any` + +#### Defined in + +[services/swap.js:114](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L114) + +___ + +### update + +▸ **update**(`swapId`, `update`): `Promise`<`any`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `swapId` | `any` | +| `update` | `any` | + +#### Returns + +`Promise`<`any`\> + +#### Defined in + +[services/swap.js:511](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L511) + +___ + +### validateReturnItems\_ + +▸ **validateReturnItems_**(`order`, `returnItems`): `ReturnItems`[] + +Goes through a list of return items to ensure that they exist on the +original order. If the item exists it is verified that the quantity to +return is not higher than the original quantity ordered. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `OrderLike` | the order to return from | +| `returnItems` | `ReturnItem`[] | the items to return | + +#### Returns + +`ReturnItems`[] + +the validated returnItems + +#### Defined in + +[services/swap.js:269](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L269) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`SwapService`](SwapService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `any` | + +#### Returns + +[`SwapService`](SwapService.md) + +#### Defined in + +[services/swap.js:86](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/swap.js#L86) diff --git a/docs/content/references/services/classes/SystemPaymentProviderService.md b/docs/content/references/services/classes/SystemPaymentProviderService.md new file mode 100644 index 0000000000..496aa5b25d --- /dev/null +++ b/docs/content/references/services/classes/SystemPaymentProviderService.md @@ -0,0 +1,237 @@ +# Class: SystemPaymentProviderService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`SystemPaymentProviderService`** + +## Constructors + +### constructor + +• **new SystemPaymentProviderService**(`_`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/system-payment-provider.js:6](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L6) + +## Properties + +### identifier + +▪ `Static` **identifier**: `string` = `"system"` + +#### Defined in + +[services/system-payment-provider.js:4](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L4) + +## Methods + +### authorizePayment + +▸ **authorizePayment**(`_`): `Promise`<{ `data`: {} = {}; `status`: `string` = "authorized" }\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{ `data`: {} = {}; `status`: `string` = "authorized" }\> + +#### Defined in + +[services/system-payment-provider.js:22](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L22) + +___ + +### cancelPayment + +▸ **cancelPayment**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:46](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L46) + +___ + +### capturePayment + +▸ **capturePayment**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L38) + +___ + +### createPayment + +▸ **createPayment**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:10](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L10) + +___ + +### deletePayment + +▸ **deletePayment**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L34) + +___ + +### getPaymentData + +▸ **getPaymentData**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:18](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L18) + +___ + +### getStatus + +▸ **getStatus**(`_`): `Promise`<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<`string`\> + +#### Defined in + +[services/system-payment-provider.js:14](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L14) + +___ + +### refundPayment + +▸ **refundPayment**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L42) + +___ + +### updatePayment + +▸ **updatePayment**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:30](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L30) + +___ + +### updatePaymentData + +▸ **updatePaymentData**(`_`): `Promise`<{}\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `_` | `any` | + +#### Returns + +`Promise`<{}\> + +#### Defined in + +[services/system-payment-provider.js:26](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/system-payment-provider.js#L26) diff --git a/docs/content/references/services/classes/TaxProviderService.md b/docs/content/references/services/classes/TaxProviderService.md new file mode 100644 index 0000000000..7c8bc5fc7f --- /dev/null +++ b/docs/content/references/services/classes/TaxProviderService.md @@ -0,0 +1,442 @@ +# Class: TaxProviderService + +Finds tax providers and assists in tax related operations. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`TaxProviderService`** + +## Constructors + +### constructor + +• **new TaxProviderService**(`container`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `container` | `AwilixContainer`<`any`\> | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/tax-provider.ts:44](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L44) + +## Properties + +### container\_ + +• `Private` **container\_**: `AwilixContainer`<`any`\> + +#### Defined in + +[services/tax-provider.ts:35](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L35) + +___ + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/tax-provider.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L36) + +___ + +### redis\_ + +• `Private` **redis\_**: `Redis` + +#### Defined in + +[services/tax-provider.ts:42](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L42) + +___ + +### smTaxLineRepo\_ + +• `Private` **smTaxLineRepo\_**: typeof `ShippingMethodTaxLineRepository` + +#### Defined in + +[services/tax-provider.ts:40](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L40) + +___ + +### taxLineRepo\_ + +• `Private` **taxLineRepo\_**: typeof `LineItemTaxLineRepository` + +#### Defined in + +[services/tax-provider.ts:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L39) + +___ + +### taxProviderRepo\_ + +• `Private` **taxProviderRepo\_**: typeof `TaxProviderRepository` + +#### Defined in + +[services/tax-provider.ts:41](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L41) + +___ + +### taxRateService\_ + +• `Private` **taxRateService\_**: [`TaxRateService`](TaxRateService.md) + +#### Defined in + +[services/tax-provider.ts:38](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L38) + +___ + +### transactionManager\_ + +• `Private` **transactionManager\_**: `EntityManager` + +#### Defined in + +[services/tax-provider.ts:37](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L37) + +## Methods + +### clearTaxLines + +▸ **clearTaxLines**(`cartId`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cartId` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/tax-provider.ts:98](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L98) + +___ + +### createShippingTaxLines + +▸ **createShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\> + +Persists the tax lines relevant for a shipping method to the database. Used +for return shipping methods. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `shippingMethod` | `ShippingMethod` | the shipping method to create tax lines for | +| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by | + +#### Returns + +`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\> + +the newly created tax lines + +#### Defined in + +[services/tax-provider.ts:166](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L166) + +___ + +### createTaxLines + +▸ **createTaxLines**(`cartOrLineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\> + +Persists the tax lines relevant for an order to the database. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrLineItems` | `Cart` \| `LineItem`[] | the cart or line items to create tax lines for | +| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by | + +#### Returns + +`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\> + +the newly created tax lines + +#### Defined in + +[services/tax-provider.ts:116](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L116) + +___ + +### getCacheEntry + +▸ `Private` **getCacheEntry**(`productId`, `regionId`): `Promise`<``null`` \| `TaxServiceRate`[]\> + +Gets the cache results for a set of ids + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product id to cache | +| `regionId` | `string` | the region id to cache | + +#### Returns + +`Promise`<``null`` \| `TaxServiceRate`[]\> + +the cached result or null + +#### Defined in + +[services/tax-provider.ts:450](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L450) + +___ + +### getCacheKey + +▸ `Private` **getCacheKey**(`productId`, `regionId`): `string` + +The cache key to get cache hits by. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product id to cache | +| `regionId` | `string` | the region id to cache | + +#### Returns + +`string` + +the cache key to use for the id set + +#### Defined in + +[services/tax-provider.ts:419](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L419) + +___ + +### getRegionRatesForProduct + +▸ **getRegionRatesForProduct**(`productId`, `region`): `Promise`<`TaxServiceRate`[]\> + +Gets the tax rates configured for a product. The rates are cached between +calls. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product id to get rates for | +| `region` | `Region` | the region to get configured rates for. | + +#### Returns + +`Promise`<`TaxServiceRate`[]\> + +the tax rates configured for the shipping option. + +#### Defined in + +[services/tax-provider.ts:374](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L374) + +___ + +### getRegionRatesForShipping + +▸ **getRegionRatesForShipping**(`optionId`, `region`): `Promise`<`TaxServiceRate`[]\> + +Gets the tax rates configured for a shipping option. The rates are cached +between calls. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optionId` | `string` | the option id of the shipping method. | +| `region` | `Region` | the region to get configured rates for. | + +#### Returns + +`Promise`<`TaxServiceRate`[]\> + +the tax rates configured for the shipping option. + +#### Defined in + +[services/tax-provider.ts:327](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L327) + +___ + +### getShippingTaxLines + +▸ **getShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<`ShippingMethodTaxLine`[]\> + +Gets the relevant tax lines for a shipping method. Note: this method +doesn't persist the tax lines. Use createShippingTaxLines if you wish to +persist the tax lines to the DB layer. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `shippingMethod` | `ShippingMethod` | the shipping method to get tax lines for | +| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by | + +#### Returns + +`Promise`<`ShippingMethodTaxLine`[]\> + +the computed tax lines + +#### Defined in + +[services/tax-provider.ts:185](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L185) + +___ + +### getTaxLines + +▸ **getTaxLines**(`lineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\> + +Gets the relevant tax lines for an order or cart. If an order is provided +the order's tax lines will be returned. If a cart is provided the tax lines +will be computed from the tax rules and potentially a 3rd party tax plugin. +Note: this method doesn't persist the tax lines. Use createTaxLines if you +wish to persist the tax lines to the DB layer. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `lineItems` | `LineItem`[] | the cart or order to get tax lines for | +| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by | + +#### Returns + +`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\> + +the computed tax lines + +#### Defined in + +[services/tax-provider.ts:237](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L237) + +___ + +### list + +▸ **list**(): `Promise`<`TaxProvider`[]\> + +#### Returns + +`Promise`<`TaxProvider`[]\> + +#### Defined in + +[services/tax-provider.ts:70](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L70) + +___ + +### registerInstalledProviders + +▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `providers` | `string`[] | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/tax-provider.ts:471](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L471) + +___ + +### retrieveProvider + +▸ **retrieveProvider**(`region`): `ITaxService` + +Retrieves the relevant tax provider for the given region. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `region` | `Region` | the region to get tax provider for. | + +#### Returns + +`ITaxService` + +the region specific tax provider + +#### Defined in + +[services/tax-provider.ts:80](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L80) + +___ + +### setCache + +▸ `Private` **setCache**(`productId`, `regionId`, `value`): `Promise`<`void`\> + +Sets the cache results for a set of ids + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `productId` | `string` | the product id to cache | +| `regionId` | `string` | the region id to cache | +| `value` | `TaxServiceRate`[] | tax rates to cache | + +#### Returns + +`Promise`<`void`\> + +promise that resolves after the cache has been set + +#### Defined in + +[services/tax-provider.ts:430](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L430) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`TaxProviderService`](TaxProviderService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`TaxProviderService`](TaxProviderService.md) + +#### Defined in + +[services/tax-provider.ts:57](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-provider.ts#L57) diff --git a/docs/content/references/services/classes/TaxRateService.md b/docs/content/references/services/classes/TaxRateService.md new file mode 100644 index 0000000000..ee995f4065 --- /dev/null +++ b/docs/content/references/services/classes/TaxRateService.md @@ -0,0 +1,392 @@ +# Class: TaxRateService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`TaxRateService`** + +## Constructors + +### constructor + +• **new TaxRateService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `Object` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/tax-rate.ts:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L27) + +## Properties + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/tax-rate.ts:21](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L21) + +___ + +### productService\_ + +• `Private` **productService\_**: [`ProductService`](ProductService.md) + +#### Defined in + +[services/tax-rate.ts:22](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L22) + +___ + +### productTypeService\_ + +• `Private` **productTypeService\_**: [`ProductTypeService`](ProductTypeService.md) + +#### Defined in + +[services/tax-rate.ts:23](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L23) + +___ + +### shippingOptionService\_ + +• `Private` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md) + +#### Defined in + +[services/tax-rate.ts:24](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L24) + +___ + +### taxRateRepository\_ + +• `Private` **taxRateRepository\_**: typeof `TaxRateRepository` + +#### Defined in + +[services/tax-rate.ts:25](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L25) + +## Methods + +### addToProduct + +▸ **addToProduct**(`id`, `productIds`, `replace?`): `Promise`<`ProductTaxRate` \| `ProductTaxRate`[]\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `id` | `string` | `undefined` | +| `productIds` | `string` \| `string`[] | `undefined` | +| `replace` | `boolean` | `false` | + +#### Returns + +`Promise`<`ProductTaxRate` \| `ProductTaxRate`[]\> + +#### Defined in + +[services/tax-rate.ts:197](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L197) + +___ + +### addToProductType + +▸ **addToProductType**(`id`, `productTypeIds`, `replace?`): `Promise`<`ProductTypeTaxRate`[]\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `id` | `string` | `undefined` | +| `productTypeIds` | `string` \| `string`[] | `undefined` | +| `replace` | `boolean` | `false` | + +#### Returns + +`Promise`<`ProductTypeTaxRate`[]\> + +#### Defined in + +[services/tax-rate.ts:233](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L233) + +___ + +### addToShippingOption + +▸ **addToShippingOption**(`id`, `optionIds`, `replace?`): `Promise`<`ShippingTaxRate`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `id` | `string` | `undefined` | +| `optionIds` | `string` \| `string`[] | `undefined` | +| `replace` | `boolean` | `false` | + +#### Returns + +`Promise`<`ShippingTaxRate`\> + +#### Defined in + +[services/tax-rate.ts:273](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L273) + +___ + +### create + +▸ **create**(`data`): `Promise`<`TaxRate`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `data` | `CreateTaxRateInput` | + +#### Returns + +`Promise`<`TaxRate`\> + +#### Defined in + +[services/tax-rate.ts:104](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L104) + +___ + +### delete + +▸ **delete**(`id`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` \| `string`[] | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/tax-rate.ts:135](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L135) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`TaxRate`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `selector` | `FilterableTaxRateProps` | +| `config` | `FindConfig`<`TaxRate`\> | + +#### Returns + +`Promise`<`TaxRate`[]\> + +#### Defined in + +[services/tax-rate.ts:62](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L62) + +___ + +### listAndCount + +▸ **listAndCount**(`selector`, `config?`): `Promise`<[`TaxRate`[], `number`]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `selector` | `FilterableTaxRateProps` | +| `config` | `FindConfig`<`TaxRate`\> | + +#### Returns + +`Promise`<[`TaxRate`[], `number`]\> + +#### Defined in + +[services/tax-rate.ts:73](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L73) + +___ + +### listByProduct + +▸ **listByProduct**(`productId`, `config`): `Promise`<`TaxRate`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `productId` | `string` | +| `config` | `TaxRateListByConfig` | + +#### Returns + +`Promise`<`TaxRate`[]\> + +#### Defined in + +[services/tax-rate.ts:321](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L321) + +___ + +### listByShippingOption + +▸ **listByShippingOption**(`shippingOptionId`, `config`): `Promise`<`TaxRate`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `shippingOptionId` | `string` | +| `config` | `TaxRateListByConfig` | + +#### Returns + +`Promise`<`TaxRate`[]\> + +#### Defined in + +[services/tax-rate.ts:332](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L332) + +___ + +### removeFromProduct + +▸ **removeFromProduct**(`id`, `productIds`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `productIds` | `string` \| `string`[] | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/tax-rate.ts:143](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L143) + +___ + +### removeFromProductType + +▸ **removeFromProductType**(`id`, `typeIds`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `typeIds` | `string` \| `string`[] | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/tax-rate.ts:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L161) + +___ + +### removeFromShippingOption + +▸ **removeFromShippingOption**(`id`, `optionIds`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `optionIds` | `string` \| `string`[] | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[services/tax-rate.ts:179](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L179) + +___ + +### retrieve + +▸ **retrieve**(`id`, `config?`): `Promise`<`TaxRate`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `config` | `FindConfig`<`TaxRate`\> | + +#### Returns + +`Promise`<`TaxRate`\> + +#### Defined in + +[services/tax-rate.ts:84](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L84) + +___ + +### update + +▸ **update**(`id`, `data`): `Promise`<`TaxRate`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `data` | `UpdateTaxRateInput` | + +#### Returns + +`Promise`<`TaxRate`\> + +#### Defined in + +[services/tax-rate.ts:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L120) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`TaxRateService`](TaxRateService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`TaxRateService`](TaxRateService.md) + +#### Defined in + +[services/tax-rate.ts:43](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/tax-rate.ts#L43) diff --git a/docs/content/references/services/classes/TotalsService.md b/docs/content/references/services/classes/TotalsService.md new file mode 100644 index 0000000000..98a4cdceab --- /dev/null +++ b/docs/content/references/services/classes/TotalsService.md @@ -0,0 +1,607 @@ +# Class: TotalsService + +A service that calculates total and subtotals for orders, carts etc.. + +**`implements`** {BaseService} + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`TotalsService`** + +## Constructors + +### constructor + +• **new TotalsService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `TotalsServiceProps` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/totals.ts:90](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L90) + +## Properties + +### taxCalculationStrategy\_ + +• `Private` **taxCalculationStrategy\_**: `ITaxCalculationStrategy` + +#### Defined in + +[services/totals.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L88) + +___ + +### taxProviderService\_ + +• `Private` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md) + +#### Defined in + +[services/totals.ts:87](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L87) + +## Methods + +### calculateDiscount\_ + +▸ **calculateDiscount_**(`lineItem`, `variant`, `variantPrice`, `value`, `discountType`): `LineDiscount` + +Calculates either fixed or percentage discount of a variant + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `lineItem` | `LineItem` | id of line item | +| `variant` | `string` | id of variant in line item | +| `variantPrice` | `number` | price of the variant based on region | +| `value` | `number` | discount value | +| `discountType` | `DiscountRuleType` | the type of discount (fixed or percentage) | + +#### Returns + +`LineDiscount` + +triples of lineitem, variant and applied discount + +#### Defined in + +[services/totals.ts:545](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L545) + +___ + +### getAllocationItemDiscounts + +▸ **getAllocationItemDiscounts**(`discount`, `cart`): `LineDiscount`[] + +If the rule of a discount has allocation="item", then we need +to calculate discount on each item in the cart. Furthermore, we need to +make sure to only apply the discount on valid variants. And finally we +return ether an array of percentages discounts or fixed discounts +alongside the variant on which the discount was applied. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `discount` | `Discount` | the discount to which we do the calculation | +| `cart` | `Cart` \| `Order` | the cart to calculate discounts for | + +#### Returns + +`LineDiscount`[] + +array of triples of lineitem, variant and applied discount + +#### Defined in + +[services/totals.ts:587](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L587) + +___ + +### getAllocationMap + +▸ **getAllocationMap**(`orderOrCart`, `options?`): `LineAllocationsMap` + +Gets a map of discounts and gift cards that apply to line items in an +order. The function calculates the amount of a discount or gift card that +applies to a specific line item. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `orderOrCart` | `Cart` \| `Order` | the order or cart to get an allocation map for | +| `options` | `AllocationMapOptions` | controls what should be included in allocation map | + +#### Returns + +`LineAllocationsMap` + +the allocation map for the line items in the cart or order. + +#### Defined in + +[services/totals.ts:368](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L368) + +___ + +### getCalculationContext + +▸ **getCalculationContext**(`cartOrOrder`, `options?`): `TaxCalculationContext` + +Prepares the calculation context for a tax total calculation. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get the calculation context for | +| `options` | `CalculationContextOptions` | options to gather context by | + +#### Returns + +`TaxCalculationContext` + +the tax calculation context + +#### Defined in + +[services/totals.ts:892](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L892) + +___ + +### getDiscountTotal + +▸ **getDiscountTotal**(`cartOrOrder`): `number` + +Calculates the total discount amount for each of the different supported +discount types. If discounts aren't present or invalid returns 0. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to calculate discounts for | + +#### Returns + +`number` + +the total discounts amount + +#### Defined in + +[services/totals.ts:858](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L858) + +___ + +### getGiftCardTotal + +▸ **getGiftCardTotal**(`cartOrOrder`): `number` + +Gets the gift card amount on a cart or order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get gift card amount for | + +#### Returns + +`number` + +the gift card amount applied to the cart or order + +#### Defined in + +[services/totals.ts:830](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L830) + +___ + +### getLineDiscounts + +▸ **getLineDiscounts**(`cartOrOrder`, `discount`): `LineDiscountAmount`[] + +Returns the discount amount allocated to the line items of an order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get line discount allocations for | +| `discount` | `Discount` | the discount to use as context for the calculation | + +#### Returns + +`LineDiscountAmount`[] + +the allocations that the discount has on the items in the cart or + order + +#### Defined in + +[services/totals.ts:638](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L638) + +___ + +### getLineItemAdjustmentsTotal + +▸ **getLineItemAdjustmentsTotal**(`cartOrOrder`): `number` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | + +#### Returns + +`number` + +#### Defined in + +[services/totals.ts:615](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L615) + +___ + +### getLineItemDiscountAdjustment + +▸ **getLineItemDiscountAdjustment**(`lineItem`, `discount`): `number` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `lineItem` | `LineItem` | +| `discount` | `Discount` | + +#### Returns + +`number` + +#### Defined in + +[services/totals.ts:600](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L600) + +___ + +### getLineItemRefund + +▸ **getLineItemRefund**(`order`, `lineItem`): `number` + +The amount that can be refunded for a given line item. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | order to use as context for the calculation | +| `lineItem` | `LineItem` | the line item to calculate the refund amount for. | + +#### Returns + +`number` + +the line item refund amount. + +#### Defined in + +[services/totals.ts:460](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L460) + +___ + +### getLineItemTotal + +▸ **getLineItemTotal**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`number`\> + +Gets a total for a line item. The total can take gift cards, discounts and +taxes into account. This can be controlled through the options. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `lineItem` | `LineItem` | the line item to calculate a total for | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the calculation | +| `options` | `GetLineItemTotalOptions` | the options to use for the calculation | + +#### Returns + +`Promise`<`number`\> + +the line item total + +#### Defined in + +[services/totals.ts:800](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L800) + +___ + +### getLineItemTotals + +▸ **getLineItemTotals**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`LineItemTotals`\> + +Breaks down the totals related to a line item; these are the subtotal, the +amount of discount applied to the line item, the amount of a gift card +applied to a line item and the amount of tax applied to a line item. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `lineItem` | `LineItem` | the line item to calculate totals for | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the calculation | +| `options` | `LineItemTotalsOptions` | the options to evaluate the line item totals for | + +#### Returns + +`Promise`<`LineItemTotals`\> + +the breakdown of the line item totals + +#### Defined in + +[services/totals.ts:684](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L684) + +___ + +### getPaidTotal + +▸ **getPaidTotal**(`order`): `number` + +Gets the total payments made on an order + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to calculate paid amount for | + +#### Returns + +`number` + +the total paid amount + +#### Defined in + +[services/totals.ts:125](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L125) + +___ + +### getRefundTotal + +▸ **getRefundTotal**(`order`, `lineItems`): `number` + +Calculates refund total of line items. +If any of the items to return have been discounted, we need to +apply the discount again before refunding them. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | cart or order to calculate subtotal for | +| `lineItems` | `LineItem`[] | the line items to calculate refund total for | + +#### Returns + +`number` + +the calculated subtotal + +#### Defined in + +[services/totals.ts:504](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L504) + +___ + +### getRefundedTotal + +▸ **getRefundedTotal**(`order`): `number` + +Gets the total refund amount for an order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to get total refund amount for. | + +#### Returns + +`number` + +the total refunded amount for an order. + +#### Defined in + +[services/totals.ts:445](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L445) + +___ + +### getShippingMethodTotals + +▸ **getShippingMethodTotals**(`shippingMethod`, `cartOrOrder`, `opts?`): `Promise`<`ShippingMethodTotals`\> + +Gets the totals breakdown for a shipping method. Fetches tax lines if not +already provided. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `shippingMethod` | `ShippingMethod` | the shipping method to get totals breakdown for. | +| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the breakdown | +| `opts` | `GetShippingMethodTotalsOptions` | options for what should be included | + +#### Returns + +`Promise`<`ShippingMethodTotals`\> + +An object that breaks down the totals for the shipping method + +#### Defined in + +[services/totals.ts:159](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L159) + +___ + +### getShippingTotal + +▸ **getShippingTotal**(`cartOrOrder`): `number` + +Calculates shipping total + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | cart or order to calculate subtotal for | + +#### Returns + +`number` + +shipping total + +#### Defined in + +[services/totals.ts:267](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L267) + +___ + +### getSubtotal + +▸ **getSubtotal**(`cartOrOrder`, `opts?`): `number` + +Calculates subtotal of a given cart or order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | cart or order to calculate subtotal for | +| `opts` | `SubtotalOptions` | options | + +#### Returns + +`number` + +the calculated subtotal + +#### Defined in + +[services/totals.ts:243](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L243) + +___ + +### getSwapTotal + +▸ **getSwapTotal**(`order`): `number` + +The total paid for swaps. May be negative in case of negative swap +difference. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `order` | `Order` | the order to calculate swap total for | + +#### Returns + +`number` + +the swap total + +#### Defined in + +[services/totals.ts:140](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L140) + +___ + +### getTaxTotal + +▸ **getTaxTotal**(`cartOrOrder`, `forceTaxes?`): `Promise`<``null`` \| `number`\> + +Calculates tax total +Currently based on the Danish tax system + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | `undefined` | cart or order to calculate tax total for | +| `forceTaxes` | `boolean` | `false` | whether taxes should be calculated regardless of region settings | + +#### Returns + +`Promise`<``null`` \| `number`\> + +tax total + +#### Defined in + +[services/totals.ts:282](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L282) + +___ + +### getTotal + +▸ **getTotal**(`cartOrOrder`, `options?`): `Promise`<`number`\> + +Calculates subtotal of a given cart or order. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `cartOrOrder` | `Cart` \| `Order` | object to calculate total for | +| `options` | `GetTotalsOptions` | options to calculate by | + +#### Returns + +`Promise`<`number`\> + +the calculated subtotal + +#### Defined in + +[services/totals.ts:106](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L106) + +___ + +### rounded + +▸ **rounded**(`value`): `number` + +Rounds a number using Math.round. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `value` | `number` | the value to round | + +#### Returns + +`number` + +the rounded value + +#### Defined in + +[services/totals.ts:922](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/totals.ts#L922) diff --git a/docs/content/references/services/classes/TransactionService.md b/docs/content/references/services/classes/TransactionService.md new file mode 100644 index 0000000000..d4388c1fb0 --- /dev/null +++ b/docs/content/references/services/classes/TransactionService.md @@ -0,0 +1,35 @@ +# Class: TransactionService + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`TransactionService`** + +## Constructors + +### constructor + +• **new TransactionService**() + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/transaction.js:5](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/transaction.js#L5) + +## Methods + +### createSession + +▸ **createSession**(): `Promise`<`ClientSession`\> + +#### Returns + +`Promise`<`ClientSession`\> + +#### Defined in + +[services/transaction.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/transaction.js#L9) diff --git a/docs/content/references/services/classes/UserService.md b/docs/content/references/services/classes/UserService.md new file mode 100644 index 0000000000..7d7898b24a --- /dev/null +++ b/docs/content/references/services/classes/UserService.md @@ -0,0 +1,384 @@ +# Class: UserService + +Provides layer to manipulate users. + +## Hierarchy + +- `"medusa-interfaces"` + + ↳ **`UserService`** + +## Constructors + +### constructor + +• **new UserService**(`__namedParameters`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `__namedParameters` | `UserServiceProps` | + +#### Overrides + +BaseService.constructor + +#### Defined in + +[services/user.ts:36](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L36) + +## Properties + +### eventBus\_ + +• `Private` **eventBus\_**: [`EventBusService`](EventBusService.md) + +#### Defined in + +[services/user.ts:32](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L32) + +___ + +### manager\_ + +• `Private` **manager\_**: `EntityManager` + +#### Defined in + +[services/user.ts:33](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L33) + +___ + +### transactionManager\_ + +• `Private` **transactionManager\_**: `EntityManager` + +#### Defined in + +[services/user.ts:34](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L34) + +___ + +### userRepository\_ + +• `Private` **userRepository\_**: typeof `UserRepository` + +#### Defined in + +[services/user.ts:31](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L31) + +___ + +### Events + +▪ `Static` **Events**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `PASSWORD_RESET` | `string` | + +#### Defined in + +[services/user.ts:27](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L27) + +## Methods + +### create + +▸ **create**(`user`, `password`): `Promise`<`User`\> + +Creates a user with username being validated. +Fails if email is not a valid format. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `user` | `CreateUserInput` | the user to create | +| `password` | `string` | user's password to hash | + +#### Returns + +`Promise`<`User`\> + +the result of create + +#### Defined in + +[services/user.ts:188](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L188) + +___ + +### delete + +▸ **delete**(`userId`): `Promise`<``null``\> + +Deletes a user from a given user id. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | the id of the user to delete. Must be castable as an ObjectId | + +#### Returns + +`Promise`<``null``\> + +the result of the delete operation. + +#### Defined in + +[services/user.ts:257](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L257) + +___ + +### generateResetPasswordToken + +▸ **generateResetPasswordToken**(`userId`): `Promise`<`string`\> + +Generate a JSON Web token, that will be sent to a user, that wishes to +reset password. +The token will be signed with the users current password hash as a secret +a long side a payload with userId and the expiry time for the token, which +is always 15 minutes. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | the id of the user to reset password for | + +#### Returns + +`Promise`<`string`\> + +the generated JSON web token + +#### Defined in + +[services/user.ts:311](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L311) + +___ + +### hashPassword\_ + +▸ **hashPassword_**(`password`): `Promise`<`string`\> + +Hashes a password + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `password` | `string` | the value to hash | + +#### Returns + +`Promise`<`string`\> + +hashed password + +#### Defined in + +[services/user.ts:176](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L176) + +___ + +### list + +▸ **list**(`selector`, `config?`): `Promise`<`User`[]\> + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `selector` | `FilterableUserProps` | the query object for find | +| `config` | `Object` | the configuration object for the query | + +#### Returns + +`Promise`<`User`[]\> + +the result of the find operation + +#### Defined in + +[services/user.ts:88](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L88) + +___ + +### retrieve + +▸ **retrieve**(`userId`, `config?`): `Promise`<`User`\> + +Gets a user by id. +Throws in case of DB Error and if user was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | the id of the user to get. | +| `config` | `FindConfig`<`User`\> | query configs | + +#### Returns + +`Promise`<`User`\> + +the user document. + +#### Defined in + +[services/user.ts:100](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L100) + +___ + +### retrieveByApiToken + +▸ **retrieveByApiToken**(`apiToken`, `relations?`): `Promise`<`User`\> + +Gets a user by api token. +Throws in case of DB Error and if user was not found. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `apiToken` | `string` | `undefined` | the token of the user to get. | +| `relations` | `string`[] | `[]` | relations to include with the user | + +#### Returns + +`Promise`<`User`\> + +the user document. + +#### Defined in + +[services/user.ts:124](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L124) + +___ + +### retrieveByEmail + +▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`User`\> + +Gets a user by email. +Throws in case of DB Error and if user was not found. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `email` | `string` | the email of the user to get. | +| `config` | `FindConfig`<`User`\> | query config | + +#### Returns + +`Promise`<`User`\> + +the user document. + +#### Defined in + +[services/user.ts:152](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L152) + +___ + +### setPassword\_ + +▸ **setPassword_**(`userId`, `password`): `Promise`<`User`\> + +Sets a password for a user +Fails if no user exists with userId and if the hashing of the new +password does not work. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | the userId to set password for | +| `password` | `string` | the old password to set | + +#### Returns + +`Promise`<`User`\> + +the result of the update operation + +#### Defined in + +[services/user.ts:282](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L282) + +___ + +### update + +▸ **update**(`userId`, `update`): `Promise`<`User`\> + +Updates a user. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `userId` | `string` | id of the user to update | +| `update` | `UpdateUserInput` | the values to be updated on the user | + +#### Returns + +`Promise`<`User`\> + +the result of create + +#### Defined in + +[services/user.ts:216](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L216) + +___ + +### validateEmail\_ + +▸ **validateEmail_**(`email`): `string` + +Used to validate user email. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `email` | `string` | email to validate | + +#### Returns + +`string` + +the validated email + +#### Defined in + +[services/user.ts:70](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L70) + +___ + +### withTransaction + +▸ **withTransaction**(`transactionManager`): [`UserService`](UserService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionManager` | `EntityManager` | + +#### Returns + +[`UserService`](UserService.md) + +#### Defined in + +[services/user.ts:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/user.ts#L49) diff --git a/docs/content/references/services/index.md b/docs/content/references/services/index.md new file mode 100644 index 0000000000..f3e237ab42 --- /dev/null +++ b/docs/content/references/services/index.md @@ -0,0 +1,45 @@ +# Services Reference + +## Classes + +- [AuthService](classes/AuthService.md) +- [CartService](classes/CartService.md) +- [ClaimItemService](classes/ClaimItemService.md) +- [ClaimService](classes/ClaimService.md) +- [CustomShippingOptionService](classes/CustomShippingOptionService.md) +- [CustomerGroupService](classes/CustomerGroupService.md) +- [CustomerService](classes/CustomerService.md) +- [DiscountService](classes/DiscountService.md) +- [DraftOrderService](classes/DraftOrderService.md) +- [EventBusService](classes/EventBusService.md) +- [FulfillmentProviderService](classes/FulfillmentProviderService.md) +- [FulfillmentService](classes/FulfillmentService.md) +- [GiftCardService](classes/GiftCardService.md) +- [IdempotencyKeyService](classes/IdempotencyKeyService.md) +- [InventoryService](classes/InventoryService.md) +- [LineItemService](classes/LineItemService.md) +- [MiddlewareService](classes/MiddlewareService.md) +- [NoteService](classes/NoteService.md) +- [NotificationService](classes/NotificationService.md) +- [OauthService](classes/OauthService.md) +- [OrderService](classes/OrderService.md) +- [PaymentProviderService](classes/PaymentProviderService.md) +- [ProductCollectionService](classes/ProductCollectionService.md) +- [ProductService](classes/ProductService.md) +- [ProductTypeService](classes/ProductTypeService.md) +- [ProductVariantService](classes/ProductVariantService.md) +- [QueryBuilderService](classes/QueryBuilderService.md) +- [RegionService](classes/RegionService.md) +- [ReturnReasonService](classes/ReturnReasonService.md) +- [ReturnService](classes/ReturnService.md) +- [SearchService](classes/SearchService.md) +- [ShippingOptionService](classes/ShippingOptionService.md) +- [ShippingProfileService](classes/ShippingProfileService.md) +- [StoreService](classes/StoreService.md) +- [SwapService](classes/SwapService.md) +- [SystemPaymentProviderService](classes/SystemPaymentProviderService.md) +- [TaxProviderService](classes/TaxProviderService.md) +- [TaxRateService](classes/TaxRateService.md) +- [TotalsService](classes/TotalsService.md) +- [TransactionService](classes/TransactionService.md) +- [UserService](classes/UserService.md) diff --git a/package.json b/package.json index 13953e8e09..1f6a520453 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "root", "private": true, "workspaces": { - "packages": [ + "packages": [ "packages/*" ], "nohoist": [ @@ -45,6 +45,8 @@ "prettier": "^2.1.1", "resolve-cwd": "^3.0.0", "ts-jest": "^26.5.6", + "typedoc": "^0.22.15", + "typedoc-plugin-markdown": "^3.12.1", "typeorm": "^0.2.31" }, "lint-staged": { @@ -64,7 +66,8 @@ "test:integration": "jest --config=integration-tests/jest.config.js", "test:integration:api": "jest --config=integration-tests/jest.config.js --projects=integration-tests/api", "test:integration:plugins": "jest --config=integration-tests/jest.config.js --projects=integration-tests/plugins", - "test:fixtures": "jest --config=docs-util/jest.config.js --runInBand" + "test:fixtures": "jest --config=docs-util/jest.config.js --runInBand", + "generate:services": "typedoc --options typedoc.services.js" }, "dependencies": { "global": "^4.4.0", diff --git a/typedoc.js b/typedoc.js new file mode 100644 index 0000000000..b0f340b2d9 --- /dev/null +++ b/typedoc.js @@ -0,0 +1,4 @@ +module.exports = { + plugin: ["typedoc-plugin-markdown"], + readme: "none", +} diff --git a/typedoc.services.js b/typedoc.services.js new file mode 100644 index 0000000000..4cf5f99381 --- /dev/null +++ b/typedoc.services.js @@ -0,0 +1,13 @@ +const globalTypedocOptions = require("./typedoc") + +module.exports = { + ...globalTypedocOptions, + entryPoints: ["packages/medusa/src/services/index.ts"], + out: ["docs/content/references/services"], + tsconfig: "packages/medusa/tsconfig.json", + name: "Services Reference", + indexTitle: "Services Reference", + entryDocument: "index.md", + hideInPageTOC: true, + hideBreadcrumbs: true, +} diff --git a/www/docs/docusaurus.config.js b/www/docs/docusaurus.config.js index 9f38d26f56..ce307ea1b1 100644 --- a/www/docs/docusaurus.config.js +++ b/www/docs/docusaurus.config.js @@ -53,8 +53,14 @@ module.exports = { }, items: [ { - href: "https://docs.medusajs.com", - label: "Introduction", + type: "docSidebar", + sidebarId: "tutorialSidebar", + label: "Docs" + }, + { + type: "docSidebar", + sidebarId: "servicesSidebar", + label: "Services Reference", }, { href: `https://docs.medusajs.com/api/store`, @@ -132,7 +138,7 @@ module.exports = { routeBasePath: "/", remarkPlugins: [ [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}], - ], + ] }, theme: { customCss: require.resolve("./src/css/custom.css"), diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index d6a25cf5ad..6901be9c7f 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -127,16 +127,9 @@ module.exports = { ] }, { - type: "category", - label: 'Services', - collapsed: false, - items: [ - { - type: "doc", - id: "advanced/backend/services/create-service", - label: "Create a Service" - }, - ] + type: "doc", + id: "advanced/backend/services/create-service", + label: "Create a Service" }, { type: "category", @@ -395,4 +388,10 @@ module.exports = { ], }, ], + servicesSidebar: [ + { + type: 'autogenerated', + dirName: 'references/services/classes', // generate sidebar from the docs folder (or versioned_docs/) + }, + ] } diff --git a/yarn.lock b/yarn.lock index e6e63d81eb..e523314be2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10176,6 +10176,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^2.3.1, braces@^2.3.2: version "2.3.2" resolved "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz" @@ -19020,6 +19027,11 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" +jsonc-parser@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.0.0.tgz#abdd785701c7e7eaca8a9ec8cf070ca51a745a22" + integrity sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA== + jsonfile@^2.1.0: version "2.4.0" resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz" @@ -19886,7 +19898,7 @@ lunr-mutable-indexes@2.3.2: dependencies: lunr ">= 2.3.0 < 2.4.0" -"lunr@>= 2.3.0 < 2.4.0": +"lunr@>= 2.3.0 < 2.4.0", lunr@^2.3.9: version "2.3.9" resolved "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz" integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== @@ -20058,6 +20070,11 @@ marked@^2.0.1: resolved "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz" integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA== +marked@^4.0.12: + version "4.0.16" + resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.16.tgz#9ec18fc1a723032eb28666100344d9428cf7a264" + integrity sha512-wahonIQ5Jnyatt2fn8KqF/nIqZM8mh3oRu2+l5EANGMhu6RFjiSG52QNE2eWzFMI94HqYSgN184NurgNG6CztA== + marksy@^8.0.0: version "8.0.0" resolved "https://registry.npmjs.org/marksy/-/marksy-8.0.0.tgz" @@ -20528,6 +20545,13 @@ minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" +minimatch@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7" + integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg== + dependencies: + brace-expansion "^2.0.1" + minimist-options@4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz" @@ -25491,6 +25515,15 @@ shellwords@^0.1.1: resolved "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== +shiki@^0.10.1: + version "0.10.1" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.10.1.tgz#6f9a16205a823b56c072d0f1a0bcd0f2646bef14" + integrity sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng== + dependencies: + jsonc-parser "^3.0.0" + vscode-oniguruma "^1.6.1" + vscode-textmate "5.2.0" + should-equal@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz" @@ -27502,6 +27535,24 @@ typedarray@^0.0.6: resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typedoc-plugin-markdown@^3.12.1: + version "3.12.1" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.12.1.tgz#2a33ca0018bdd7ed512e29960d3eb344ecb65f4a" + integrity sha512-gMntJq7+JlGJZ5sVjrkzO/rG2dsmNBbWk5ZkcKvYu6QOeBwGcK5tzEyS0aqnFTJj9GCHCB+brAnTuKtAyotNwA== + dependencies: + handlebars "^4.7.7" + +typedoc@^0.22.15: + version "0.22.15" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.22.15.tgz#c6ad7ed9d017dc2c3a06c9189cb392bd8e2d8c3f" + integrity sha512-CMd1lrqQbFvbx6S9G6fL4HKp3GoIuhujJReWqlIvSb2T26vGai+8Os3Mde7Pn832pXYemd9BMuuYWhFpL5st0Q== + dependencies: + glob "^7.2.0" + lunr "^2.3.9" + marked "^4.0.12" + minimatch "^5.0.1" + shiki "^0.10.1" + typeorm@^0.2.29, typeorm@^0.2.31: version "0.2.37" resolved "https://registry.npmjs.org/typeorm/-/typeorm-0.2.37.tgz" @@ -28237,6 +28288,16 @@ vm-browserify@^1.0.1: resolved "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== +vscode-oniguruma@^1.6.1: + version "1.6.2" + resolved "https://registry.yarnpkg.com/vscode-oniguruma/-/vscode-oniguruma-1.6.2.tgz#aeb9771a2f1dbfc9083c8a7fdd9cccaa3f386607" + integrity sha512-KH8+KKov5eS/9WhofZR8M8dMHWN2gTxjMsG4jd04YhpbPR91fUj7rYQ2/XjeHCJWbg7X++ApRIU9NUwM2vTvLA== + +vscode-textmate@5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.2.0.tgz#01f01760a391e8222fe4f33fbccbd1ad71aed74e" + integrity sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ== + w3c-hr-time@^1.0.1, w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz" From 150fc4978ff489f1ed076cacdc2765d47a24b259 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jun 2022 13:44:16 +0200 Subject: [PATCH 9/9] chore(deps): bump sqlite3 from 5.0.2 to 5.0.3 (#1453) Bumps [sqlite3](https://github.com/TryGhost/node-sqlite3) from 5.0.2 to 5.0.3. - [Release notes](https://github.com/TryGhost/node-sqlite3/releases) - [Changelog](https://github.com/TryGhost/node-sqlite3/blob/master/CHANGELOG.md) - [Commits](https://github.com/TryGhost/node-sqlite3/compare/v5.0.2...v5.0.3) --- yarn.lock | 365 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 225 insertions(+), 140 deletions(-) diff --git a/yarn.lock b/yarn.lock index e523314be2..6a06f8e6c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5450,6 +5450,21 @@ npmlog "^4.1.2" write-file-atomic "^2.3.0" +"@mapbox/node-pre-gyp@^1.0.0": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz#09a8781a3a036151cdebbe8719d6f8b25d4058bc" + integrity sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw== + dependencies: + detect-libc "^2.0.0" + https-proxy-agent "^5.0.0" + make-dir "^3.1.0" + node-fetch "^2.6.7" + nopt "^5.0.0" + npmlog "^5.0.1" + rimraf "^3.0.2" + semver "^7.3.5" + tar "^6.1.11" + "@mdx-js/loader@^1.6.22": version "1.6.22" resolved "https://registry.npmjs.org/@mdx-js/loader/-/loader-1.6.22.tgz" @@ -8738,7 +8753,7 @@ agent-base@4, agent-base@^4.3.0: dependencies: es6-promisify "^5.0.0" -agent-base@6: +agent-base@6, agent-base@^6.0.2: version "6.0.2" resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== @@ -8759,6 +8774,15 @@ agentkeepalive@^3.4.1: dependencies: humanize-ms "^1.2.1" +agentkeepalive@^4.1.3: + version "4.2.1" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.2.1.tgz#a7975cbb9f83b367f06c90cc51ff28fe7d499717" + integrity sha512-Zn4cw2NEqd+9fiSVWMscnjyQ1a8Yfoc5oBajLeo5w+YBHgDUcEBY2hS4YpTz6iN5f/2zQiktcuM6tS8x1p9dpA== + dependencies: + debug "^4.1.0" + depd "^1.1.2" + humanize-ms "^1.2.1" + aggregate-error@^3.0.0: version "3.1.0" resolved "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz" @@ -9072,6 +9096,14 @@ are-we-there-yet@^2.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +are-we-there-yet@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz#ba20bd6b553e31d62fc8c31bd23d22b95734390d" + integrity sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw== + dependencies: + delegates "^1.0.0" + readable-stream "^3.6.0" + are-we-there-yet@~1.1.2: version "1.1.5" resolved "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz" @@ -10076,13 +10108,6 @@ bl@^4.0.0, bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" -block-stream@*: - version "0.0.9" - resolved "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz" - integrity sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo= - dependencies: - inherits "~2.0.0" - bluebird@3.5.1: version "3.5.1" resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz" @@ -10556,7 +10581,7 @@ cacache@^12.0.0, cacache@^12.0.2, cacache@^12.0.3: unique-filename "^1.1.1" y18n "^4.0.0" -cacache@^15.0.5: +cacache@^15.0.5, cacache@^15.2.0: version "15.3.0" resolved "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz" integrity sha512-VVdYzXEn+cnbXpFgWs5hTT7OScegHVmLhJIR8Ufqk3iFD6A6j5iSX1KuBTfNEv4tdJWE2PzA6IVFtcLC7fN9wQ== @@ -11265,7 +11290,7 @@ color-string@^1.6.0: color-name "^1.0.0" simple-swizzle "^0.2.2" -color-support@^1.1.2: +color-support@^1.1.2, color-support@^1.1.3: version "1.1.3" resolved "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== @@ -12401,7 +12426,7 @@ debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2: dependencies: ms "2.1.2" -debug@^3.0.0, debug@^3.1.0, debug@^3.2.6, debug@^3.2.7: +debug@^3.0.0, debug@^3.1.0, debug@^3.2.7: version "3.2.7" resolved "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== @@ -12415,6 +12440,13 @@ debug@^4.0.1, debug@~4.3.1: dependencies: ms "2.1.2" +debug@^4.3.3: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + debuglog@^1.0.0, debuglog@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz" @@ -12618,7 +12650,7 @@ denque@^1.4.1: resolved "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz" integrity sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ== -depd@~1.1.2: +depd@^1.1.2, depd@~1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= @@ -12658,10 +12690,10 @@ detect-indent@^5.0.0: resolved "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz" integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50= -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= +detect-libc@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd" + integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w== detect-newline@^1.0.3: version "1.0.3" @@ -13091,7 +13123,7 @@ encoding-down@^6.3.0: level-codec "^9.0.0" level-errors "^2.0.0" -encoding@^0.1.11: +encoding@^0.1.11, encoding@^0.1.12: version "0.1.13" resolved "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz" integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== @@ -13204,6 +13236,11 @@ err-code@^1.0.0: resolved "https://registry.npmjs.org/err-code/-/err-code-1.1.2.tgz" integrity sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA= +err-code@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/err-code/-/err-code-2.0.3.tgz#23c2f3b756ffdfc608d30e27c9a941024807e7f9" + integrity sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA== + errno@^0.1.3, errno@~0.1.1, errno@~0.1.7: version "0.1.8" resolved "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz" @@ -14873,16 +14910,6 @@ fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2: resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -fstream@^1.0.0, fstream@^1.0.12: - version "1.0.12" - resolved "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz" - integrity sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg== - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" @@ -15358,6 +15385,20 @@ gauge@^3.0.0: strip-ansi "^6.0.1" wide-align "^1.1.2" +gauge@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-4.0.4.tgz#52ff0652f2bbf607a989793d53b751bef2328dce" + integrity sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg== + dependencies: + aproba "^1.0.3 || ^2.0.0" + color-support "^1.1.3" + console-control-strings "^1.1.0" + has-unicode "^2.0.1" + signal-exit "^3.0.7" + string-width "^4.2.3" + strip-ansi "^6.0.1" + wide-align "^1.1.5" + gauge@~2.7.3: version "2.7.4" resolved "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz" @@ -15597,7 +15638,7 @@ glob@^6.0.1: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.2.0: +glob@^7.0.0, glob@^7.2.0: version "7.2.0" resolved "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz" integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== @@ -16354,7 +16395,7 @@ http-cache-semantics@^3.8.1: resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz" integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== -http-cache-semantics@^4.0.0: +http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz" integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== @@ -16514,7 +16555,7 @@ hyperlinker@^1.0.0: resolved "https://registry.npmjs.org/hyperlinker/-/hyperlinker-1.0.0.tgz" integrity sha512-Ty8UblRWFEcfSuIaajM34LdPXIhbs1ajEX/BBPv24J+enSVaEVY63xQ6lTO9VRYS5LAoghIG0IDJ+p+IPzKUQQ== -iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4: +iconv-lite@0.4.24, iconv-lite@^0.4.24: version "0.4.24" resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -16688,7 +16729,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@^2.0.0, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.0, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -17162,6 +17203,11 @@ is-invalid-path@^0.1.0: dependencies: is-glob "^2.0.0" +is-lambda@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5" + integrity sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ== + is-map@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz" @@ -19979,6 +20025,28 @@ make-fetch-happen@^5.0.0: socks-proxy-agent "^4.0.0" ssri "^6.0.0" +make-fetch-happen@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-9.1.0.tgz#53085a09e7971433e6765f7971bf63f4e05cb968" + integrity sha512-+zopwDy7DNknmwPQplem5lAZX/eCOzSvSNNcSKm5eVwTkOBzoktEfXsa9L23J/GIRhxRsaxzkPEhrJEpE2F4Gg== + dependencies: + agentkeepalive "^4.1.3" + cacache "^15.2.0" + http-cache-semantics "^4.1.0" + http-proxy-agent "^4.0.1" + https-proxy-agent "^5.0.0" + is-lambda "^1.0.1" + lru-cache "^6.0.0" + minipass "^3.1.3" + minipass-collect "^1.0.2" + minipass-fetch "^1.3.2" + minipass-flush "^1.0.5" + minipass-pipeline "^1.2.4" + negotiator "^0.6.2" + promise-retry "^2.0.1" + socks-proxy-agent "^6.0.0" + ssri "^8.0.0" + makeerror@1.0.x: version "1.0.11" resolved "https://registry.npmjs.org/makeerror/-/makeerror-1.0.11.tgz" @@ -20586,6 +20654,17 @@ minipass-collect@^1.0.2: dependencies: minipass "^3.0.0" +minipass-fetch@^1.3.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/minipass-fetch/-/minipass-fetch-1.4.1.tgz#d75e0091daac1b0ffd7e9d41629faff7d0c1f1b6" + integrity sha512-CGH1eblLq26Y15+Azk7ey4xh0J/XfJfrCox5LDJiKqI2Q2iwOLOKrlmIaODiSQS8d18jalF6y2K2ePUm0CmShw== + dependencies: + minipass "^3.1.0" + minipass-sized "^1.0.3" + minizlib "^2.0.0" + optionalDependencies: + encoding "^0.1.12" + minipass-flush@^1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz" @@ -20593,13 +20672,20 @@ minipass-flush@^1.0.5: dependencies: minipass "^3.0.0" -minipass-pipeline@^1.2.2: +minipass-pipeline@^1.2.2, minipass-pipeline@^1.2.4: version "1.2.4" resolved "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz" integrity sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A== dependencies: minipass "^3.0.0" +minipass-sized@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/minipass-sized/-/minipass-sized-1.0.3.tgz#70ee5a7c5052070afacfbc22977ea79def353b70" + integrity sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g== + dependencies: + minipass "^3.0.0" + minipass@^2.3.5, minipass@^2.6.0, minipass@^2.9.0: version "2.9.0" resolved "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz" @@ -20608,7 +20694,7 @@ minipass@^2.3.5, minipass@^2.6.0, minipass@^2.9.0: safe-buffer "^5.1.2" yallist "^3.0.0" -minipass@^3.0.0, minipass@^3.1.1: +minipass@^3.0.0, minipass@^3.1.0, minipass@^3.1.1, minipass@^3.1.3: version "3.1.6" resolved "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz" integrity sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ== @@ -20622,7 +20708,7 @@ minizlib@^1.3.3: dependencies: minipass "^2.9.0" -minizlib@^2.1.1: +minizlib@^2.0.0, minizlib@^2.1.1: version "2.1.2" resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== @@ -20673,7 +20759,7 @@ mkdirp@*: dependencies: minimist "0.0.8" -mkdirp@0.5.5, mkdirp@0.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.4, mkdirp@^0.5.5, mkdirp@~0.5.1: +mkdirp@0.5.5, mkdirp@0.x, mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.4, mkdirp@^0.5.5, mkdirp@~0.5.1: version "0.5.5" resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -21025,20 +21111,16 @@ ncp@~2.0.0: resolved "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz" integrity sha1-GVoh1sRuNh0vsSgbo4uR6d9727M= -needle@^2.2.1: - version "2.9.1" - resolved "https://registry.npmjs.org/needle/-/needle-2.9.1.tgz" - integrity sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ== - dependencies: - debug "^3.2.6" - iconv-lite "^0.4.4" - sax "^1.2.4" - negotiator@0.6.2, negotiator@~0.6.2: version "0.6.2" resolved "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz" integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== +negotiator@^0.6.2: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + neo-async@^2.5.0, neo-async@^2.6.0, neo-async@^2.6.1, neo-async@^2.6.2: version "2.6.2" resolved "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz" @@ -21085,10 +21167,10 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -node-addon-api@^3.0.0: - version "3.2.1" - resolved "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz" - integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== +node-addon-api@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f" + integrity sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ== node-cleanup@^2.1.2: version "2.1.2" @@ -21151,6 +21233,13 @@ node-fetch@^2.6.6: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + node-gyp-build@^4.2.3: version "4.3.0" resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.3.0.tgz" @@ -21161,23 +21250,21 @@ node-gyp-build@~4.1.0: resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz" integrity sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ== -node-gyp@3.x: - version "3.8.0" - resolved "https://registry.npmjs.org/node-gyp/-/node-gyp-3.8.0.tgz" - integrity sha512-3g8lYefrRRzvGeSowdJKAKyks8oUpLEd/DyPV4eMhVlhJ0aNaZqIrNUIPuEWWTAoPqyFkfGrM67MC69baqn6vA== +node-gyp@8.x: + version "8.4.1" + resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-8.4.1.tgz#3d49308fc31f768180957d6b5746845fbd429937" + integrity sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w== dependencies: - fstream "^1.0.0" - glob "^7.0.3" - graceful-fs "^4.1.2" - mkdirp "^0.5.0" - nopt "2 || 3" - npmlog "0 || 1 || 2 || 3 || 4" - osenv "0" - request "^2.87.0" - rimraf "2" - semver "~5.3.0" - tar "^2.0.0" - which "1" + env-paths "^2.2.0" + glob "^7.1.4" + graceful-fs "^4.2.6" + make-fetch-happen "^9.1.0" + nopt "^5.0.0" + npmlog "^6.0.0" + rimraf "^3.0.2" + semver "^7.3.5" + tar "^6.1.2" + which "^2.0.2" node-gyp@^5.0.2: version "5.1.1" @@ -21268,22 +21355,6 @@ node-object-hash@^2.3.10: resolved "https://registry.npmjs.org/node-object-hash/-/node-object-hash-2.3.10.tgz" integrity sha512-jY5dPJzw6NHd/KPSfPKJ+IHoFS81/tJ43r34ZeNMXGzCOM8jwQDCD12HYayKIB6MuznrnqIYy2e891NA2g0ibA== -node-pre-gyp@^0.11.0: - version "0.11.0" - resolved "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz" - integrity sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4" - node-readfiles@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/node-readfiles/-/node-readfiles-0.2.0.tgz" @@ -21331,13 +21402,6 @@ nodemon@^2.0.1: undefsafe "^2.0.5" update-notifier "^5.1.0" -"nopt@2 || 3": - version "3.0.6" - resolved "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz" - integrity sha1-xkZdvwirzU2zWTF/eaxopkayj/k= - dependencies: - abbrev "1" - nopt@^4.0.1: version "4.0.3" resolved "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz" @@ -21346,6 +21410,13 @@ nopt@^4.0.1: abbrev "1" osenv "^0.1.4" +nopt@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88" + integrity sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ== + dependencies: + abbrev "1" + nopt@~1.0.10: version "1.0.10" resolved "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz" @@ -21436,7 +21507,7 @@ npm-normalize-package-bin@^1.0.0, npm-normalize-package-bin@^1.0.1: semver "^5.6.0" validate-npm-package-name "^3.0.0" -npm-packlist@^1.1.6, npm-packlist@^1.4.4: +npm-packlist@^1.4.4: version "1.4.8" resolved "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz" integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== @@ -21468,7 +21539,7 @@ npm-run-path@^4.0.0, npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" -"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.2, npmlog@^4.1.2: +npmlog@^4.1.2: version "4.1.2" resolved "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -21488,6 +21559,16 @@ npmlog@^5.0.1: gauge "^3.0.0" set-blocking "^2.0.0" +npmlog@^6.0.0: + version "6.0.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-6.0.2.tgz#c8166017a42f2dea92d6453168dd865186a70830" + integrity sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg== + dependencies: + are-we-there-yet "^3.0.0" + console-control-strings "^1.1.0" + gauge "^4.0.3" + set-blocking "^2.0.0" + nth-check@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz" @@ -21890,7 +21971,7 @@ os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: resolved "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -osenv@0, osenv@^0.1.4, osenv@^0.1.5: +osenv@^0.1.4, osenv@^0.1.5: version "0.1.5" resolved "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz" integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== @@ -23399,6 +23480,14 @@ promise-retry@^1.1.1: err-code "^1.0.0" retry "^0.10.0" +promise-retry@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/promise-retry/-/promise-retry-2.0.1.tgz#ff747a13620ab57ba688f5fc67855410c370da22" + integrity sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g== + dependencies: + err-code "^2.0.2" + retry "^0.12.0" + promise.allsettled@^1.0.0: version "1.0.5" resolved "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.5.tgz" @@ -23768,7 +23857,7 @@ raw-loader@^4.0.2: loader-utils "^2.0.0" schema-utils "^3.0.0" -rc@^1.2.7, rc@^1.2.8: +rc@^1.2.8: version "1.2.8" resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -24737,7 +24826,7 @@ request@2.88.0: tunnel-agent "^0.6.0" uuid "^3.3.2" -request@2.88.2, request@^2.87.0, request@^2.88.0: +request@2.88.2, request@^2.88.0: version "2.88.2" resolved "https://registry.npmjs.org/request/-/request-2.88.2.tgz" integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== @@ -24941,13 +25030,6 @@ reusify@^1.0.4: resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@2, rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3: - version "2.7.1" - resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - rimraf@2.6.3: version "2.6.3" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz" @@ -24962,6 +25044,13 @@ rimraf@3.0.2, rimraf@^3.0.0, rimraf@^3.0.2: dependencies: glob "^7.1.3" +rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + rimraf@~2.4.0: version "2.4.5" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz" @@ -25204,7 +25293,7 @@ sax@1.2.1: resolved "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz" integrity sha1-e45lYZCyKOgaZq6nSEgNgozS03o= -sax@>=0.6.0, sax@^1.2.4: +sax@>=0.6.0: version "1.2.4" resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -25312,7 +25401,7 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.0" -"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1: +"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1: version "5.7.1" resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -25341,11 +25430,6 @@ semver@7.3.5, semver@7.x, semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7 dependencies: lru-cache "^6.0.0" -semver@~5.3.0: - version "5.3.0" - resolved "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz" - integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= - send@0.17.1: version "0.17.1" resolved "https://registry.npmjs.org/send/-/send-0.17.1.tgz" @@ -25592,6 +25676,11 @@ signal-exit@^3.0.5, signal-exit@^3.0.6: resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz" integrity sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ== +signal-exit@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz" @@ -25696,7 +25785,7 @@ slugify@^1.6.1: resolved "https://registry.npmjs.org/slugify/-/slugify-1.6.5.tgz" integrity sha512-8mo9bslnBO3tr5PEVFzMPIWwWnipGS0xVbYf65zxDqfNwmzYn1LpiKNrR6DlClusuvo+hDHd1zKpmfAe83NQSQ== -smart-buffer@^4.1.0: +smart-buffer@^4.1.0, smart-buffer@^4.2.0: version "4.2.0" resolved "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz" integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== @@ -25781,6 +25870,23 @@ socks-proxy-agent@^4.0.0: agent-base "~4.2.1" socks "~2.3.2" +socks-proxy-agent@^6.0.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-6.2.0.tgz#f6b5229cc0cbd6f2f202d9695f09d871e951c85e" + integrity sha512-wWqJhjb32Q6GsrUqzuFkukxb/zzide5quXYcMVpIjxalDBBYy2nqKCFQ/9+Ie4dvOYSQdOk3hUlZSdzZOd3zMQ== + dependencies: + agent-base "^6.0.2" + debug "^4.3.3" + socks "^2.6.2" + +socks@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.6.2.tgz#ec042d7960073d40d94268ff3bb727dc685f111a" + integrity sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA== + dependencies: + ip "^1.1.5" + smart-buffer "^4.2.0" + socks@~2.3.2: version "2.3.3" resolved "https://registry.npmjs.org/socks/-/socks-2.3.3.tgz" @@ -25965,14 +26071,15 @@ sprintf-js@~1.0.2: integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= sqlite3@^5.0.2: - version "5.0.2" - resolved "https://registry.npmjs.org/sqlite3/-/sqlite3-5.0.2.tgz" - integrity sha512-1SdTNo+BVU211Xj1csWa8lV6KM0CtucDwRyA0VHl91wEH1Mgh7RxUpI4rVvG7OhHrzCSGaVyW5g8vKvlrk9DJA== + version "5.0.3" + resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-5.0.3.tgz#0c8303bcb8fbd6198a9f9645e7f363c191091483" + integrity sha512-/cDwes7XtTOtKH5zYeJSuiavuaJ6jXxPjebw9lDFxBAwR/DvP0tnJ5MPZQ3zpnNzJBa1G6mPTpB+5O1T+AoSdQ== dependencies: - node-addon-api "^3.0.0" - node-pre-gyp "^0.11.0" + "@mapbox/node-pre-gyp" "^1.0.0" + node-addon-api "^4.2.0" + tar "^6.1.11" optionalDependencies: - node-gyp "3.x" + node-gyp "8.x" sshpk@^1.7.0: version "1.16.1" @@ -25996,7 +26103,7 @@ ssri@^6.0.0, ssri@^6.0.1: dependencies: figgy-pudding "^3.5.1" -ssri@^8.0.1: +ssri@^8.0.0, ssri@^8.0.1: version "8.0.1" resolved "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz" integrity sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ== @@ -26689,16 +26796,7 @@ tapable@^2.1.1, tapable@^2.2.0: resolved "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz" integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== -tar@^2.0.0: - version "2.2.2" - resolved "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz" - integrity sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA== - dependencies: - block-stream "*" - fstream "^1.0.12" - inherits "2" - -tar@^4, tar@^4.0.2: +tar@^4.0.2, tar@^4.4.10, tar@^4.4.12, tar@^4.4.8: version "4.4.19" resolved "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz" integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== @@ -26711,20 +26809,7 @@ tar@^4, tar@^4.0.2: safe-buffer "^5.2.1" yallist "^3.1.1" -tar@^4.4.10, tar@^4.4.12, tar@^4.4.8: - version "4.4.17" - resolved "https://registry.npmjs.org/tar/-/tar-4.4.17.tgz" - integrity sha512-q7OwXq6NTdcYIa+k58nEMV3j1euhDhGCs/VRw9ymx/PbH0jtIM2+VTgDE/BW3rbLkrBUXs5fzEKgic5oUciu7g== - dependencies: - chownr "^1.1.4" - fs-minipass "^1.2.7" - minipass "^2.9.0" - minizlib "^1.3.3" - mkdirp "^0.5.5" - safe-buffer "^5.2.1" - yallist "^3.1.1" - -tar@^6.0.2: +tar@^6.0.2, tar@^6.1.11, tar@^6.1.2: version "6.1.11" resolved "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz" integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== @@ -28607,7 +28692,7 @@ which-module@^2.0.0: resolved "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which@1, which@^1.2.9, which@^1.3.1: +which@^1.2.9, which@^1.3.1: version "1.3.1" resolved "https://registry.npmjs.org/which/-/which-1.3.1.tgz" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== @@ -28628,7 +28713,7 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" -wide-align@^1.1.2: +wide-align@^1.1.2, wide-align@^1.1.5: version "1.1.5" resolved "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz" integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==