Merge branch 'master' into develop
This commit is contained in:
commit
77ef28d274
96 files changed
+39079
-28841
No files matched your search
@@ -24,6 +24,11 @@ jobs:
|
|||||||
node-version: "14"
|
node-version: "14"
|
||||||
cache: "yarn"
|
cache: "yarn"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
uses: ./.github/actions/cache-deps
|
||||||
|
with:
|
||||||
|
extension: docs
|
||||||
|
|
||||||
- name: Build Docusaurus website
|
- name: Build Docusaurus website
|
||||||
run: |
|
run: |
|
||||||
cd www/docs
|
cd www/docs
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ jobs:
|
|||||||
node-version: "14"
|
node-version: "14"
|
||||||
cache: "yarn"
|
cache: "yarn"
|
||||||
|
|
||||||
- name: Install packages
|
- name: Install dependencies
|
||||||
uses: ./.github/actions/cache-deps
|
uses: ./.github/actions/cache-deps
|
||||||
with:
|
with:
|
||||||
extension: unit-tests
|
extension: reference
|
||||||
|
|
||||||
- name: Build Packages
|
- name: Build Packages
|
||||||
run: yarn build
|
run: yarn build
|
||||||
@@ -44,3 +44,4 @@ jobs:
|
|||||||
commit_message: "docs: automatically Generated Services Reference"
|
commit_message: "docs: automatically Generated Services Reference"
|
||||||
file_pattern: docs/content/*
|
file_pattern: docs/content/*
|
||||||
skip_dirty_check: false
|
skip_dirty_check: false
|
||||||
|
branch: master
|
||||||
@@ -11,6 +11,7 @@ node_modules
|
|||||||
|
|
||||||
packages/**/.yarn/*
|
packages/**/.yarn/*
|
||||||
integration-tests/**/.yarn/*
|
integration-tests/**/.yarn/*
|
||||||
|
www/**/.yarn/*
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
lerna-debug.log
|
lerna-debug.log
|
||||||
|
|||||||
@@ -1,33 +1,98 @@
|
|||||||
# Algolia
|
# Algolia
|
||||||
|
|
||||||
We recently launched our sophisticated [Medusa](https://github.com/medusajs/medusa) Search API. It allows you to add a blazingly fast product search to your ecommerce setup, improving the overall customer experience and your conversion rates.
|
In this document, you’ll learn how to install the [Algolia plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-algolia) and use it on both your Medusa Server and your storefront.
|
||||||
|
|
||||||
From a developer perspective, the Search API unifies communication between Medusa and search engines thereby allowing you to switch between different engines in seconds with only a couple of lines of code. So far, Medusa has only supported product search using MeiliSearch, but we can now proudly present a plugin for Algolia - one of the giants.
|
## Overview
|
||||||
|
|
||||||
The purpose of this article is to show you how to install and configure Algolia for your Medusa store. Additionally, we'll showcase the powerful Search API by guiding you through changing from one search engine to another.
|
[Algolia](https://www.algolia.com/) is a search engine service that allows developers to integrate advanced search functionalities into their websites including typo tolerance, recommended results, and quick responses.
|
||||||
|
|
||||||
**Installation**
|
Algolia can be used for a wide range of use cases, including ecommerce websites. By integrating Algolia into your ecommerce website, you can provide your customers with a better user experience and help them find what they’re looking for swifltly.
|
||||||
|
|
||||||
Create an account on Algolia and grab your Application ID and Admin API Key from the settings panel.
|
Through Medusa's flexible plugin system, it is possible to add a search engine to your Medusa server and storefront using Algolia with just a few steps.
|
||||||
|
|
||||||

|
## Prerequisites
|
||||||
|
|
||||||
In your Medusa project, install the plugin using your favourite package manager:
|
### Medusa Components
|
||||||
|
|
||||||
|
It is required to have a Medusa server installed before starting with this documentation. If not, please follow along with our [quickstart guide](../quickstart/quick-start.md) to get started in minutes.
|
||||||
|
|
||||||
|
Furthermore, it’s highly recommended to ensure your Medusa server is configured to work with Redis. As Medusa uses Redis for the event queue internally, configuring Redis ensures that the search indices in Algolia are updated whenever products on the Medusa server are updated. You can follow [this documentation to install Redis](../tutorial/0-set-up-your-development-environment.mdx#redis) and then [configure it on your Medusa server](../usage/configurations.md#redis).
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
If you don’t install and configure Redis on your Medusa server, the Algolia integration will still work. However, products indexed in Algolia are only added and updated when you restart the Medusa server.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Algolia Account
|
||||||
|
|
||||||
|
You need to [create an Algolia account](https://www.algolia.com/users/sign_up) before you follow this documentation. Algolia offers a free plan to get started quickly.
|
||||||
|
|
||||||
|
## Create an Algolia App
|
||||||
|
|
||||||
|
The first step is to create an Algolia app for your Medusa server. To create one, open the [Applications page](https://www.algolia.com/account/applications) or, on your dashboard, go to Settings then choose Applications.
|
||||||
|
|
||||||
|
On the Applications page, click on the New application button at the top right.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the new page that opens, optionally enter a name for the application and choose a subscription plan. You can choose the Free plan for now, but it’s recommended to switch to the Pay-as-you-go plan as your business grows.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done, click on the Next Step button. If you picked Pay as you go service, you’ll need to enter billing details before you proceed.
|
||||||
|
|
||||||
|
Then, you’ll be asked to pick a region for your application. Once you’re done, click on Review Application Details.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the last step, you’ll see a summary of your order. If all looks good, check the checkboxes at the end of the form to indicate that you agree to the terms and conditions. Then, click on the Create Application button.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Retrieve API Keys
|
||||||
|
|
||||||
|
To retrieve the API keys that you’ll use in the next sections, go to Settings, then choose API Keys in the Team and Access section.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
On this page, you’ll find the Application ID, Search-Only API Key, and Admin API Key. You’ll need the Application ID and Admin API Key for the Medusa server. As for the storefront, you’ll need the Application ID and Search-Only API Key.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you have more than one application in your Algolia account, make sure you’re viewing the keys of the correct application by checking the Application dropdown at the top left.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Install the Algolia Plugin
|
||||||
|
|
||||||
|
In the directory of your Medusa server, run the following command to install the Algolia plugin:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install medusa-plugin-algolia@canary
|
npm install medusa-plugin-algolia
|
||||||
```
|
```
|
||||||
|
|
||||||
In your `medusa-config.js` add the integration to the array of plugins with the following settings:
|
Then, add the following environment variables to your Medusa server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ALGOLIA_APP_ID=<YOUR_APP_ID>
|
||||||
|
ALGOLIA_ADMIN_API_KEY=<YOUR_ADMIN_API_KEY>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_APP_ID>` and `<YOUR_ADMIN_API_KEY>` are respectively the Application ID and Admin API Key found on the [API Keys page](#retrieve-api-keys).
|
||||||
|
|
||||||
|
Finally, in `medusa-config.js` add the following item into the `plugins` array:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
const plugins = [
|
const plugins = [
|
||||||
// ...other plugins
|
//...
|
||||||
{
|
{
|
||||||
resolve: `medusa-plugin-algolia`,
|
resolve: `medusa-plugin-algolia`,
|
||||||
options: {
|
options: {
|
||||||
application_id: "your-application-id",
|
application_id: process.env.ALGOLIA_APP_ID,
|
||||||
admin_api_key: "your-admin-api-key",
|
admin_api_key: process.env.ALGOLIA_ADMIN_API_KEY,
|
||||||
settings: {
|
settings: {
|
||||||
products: {
|
products: {
|
||||||
searchableAttributes: ["title", "description"],
|
searchableAttributes: ["title", "description"],
|
||||||
@@ -48,23 +113,221 @@ const plugins = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above config, you've provided the id and key from Algolia alongside a couple of settings, that define the properties you can search for and the values you'll get in return.
|
The `searchableAttributes` are the attributes in a product that are searchable, and `attributesToRetrieve` are the attributes to retrieve for each product result. You’re free to make changes to these attributes as you see fit, but these are the recommended attributes.
|
||||||
|
|
||||||
And that's all! You've now enabled Algolia for your Medusa store engine. The plugin will make sure to synchronize products from Medusa to Algolia upon updating, deleting, or creating new ones. Now all you need to do is to restart your server.
|
## Test the Algolia Plugin
|
||||||
|
|
||||||
**Usage**
|
Run your Medusa server with the following command:
|
||||||
|
|
||||||
This article will not go too much into depth about how the search functionality works under the hood when querying the API. We refer to the [previous article on MeiliSearch](https://medusajs.com/blog/meilisearch-medusa) if this is of your interest. In there, you will find a quick showcase using Postman as well as a thorough walkthrough of how you can display the results in your storefront using ReactJS (GatsbyJS).
|
```bash npm2yarn
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
Instead, to illustrate the power of our Search API and search engine plugins, we'll switch out a MeiliSearch plugin with our new Algolia plugin in a store with existing products. Upon restarting the server with the new configuration, your products will automatically be fed into Algolia and the search functionality in your frontend will remain unchanged.
|
The quickest way to test that the integration is working is by sending a `POST` request to `/store/products/search`. This endpoint accepts a `q` body parameter of the query to search for and returns in the result the products that match this query.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**Next up**
|
You can also check that the products are properly indexed by opening your Algolia dashboard and choosing Search from the left sidebar. You’ll find your products that are on your Medusa server added there.
|
||||||
|
|
||||||
As mentioned in our post on MeiliSearch, we'll soon publish an article with a thorough walkthrough of our Search API. Until then, you should consider adding blazingly fast product search with one of our plugins to allow for your commerce business to grow to the next level.
|
:::note
|
||||||
|
|
||||||
Many thanks to community member Rolwin for building the plugin. If you want to be part of the Medusa community, feel free to join us on our [Discord channel](https://discord.gg/F87eGuwkTp).
|
If you have more than one application on your Algolia account, make sure you’re viewing the keys of the correct one by checking the Application dropdown at the top left.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Add or Update Products
|
||||||
|
|
||||||
|
If you add or update products on your Medusa server, the addition or update will be reflected in the Algolia indices.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
This feature is only available if you have Redis installed and configured with your Medusa server as mentioned in the [Prerequisites section](#prerequisites). Otherwise, you must re-run the Medusa server to see the change in the Algolia indices.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Add Search to your Storefront
|
||||||
|
|
||||||
|
In this section, you’ll learn how to add the UI on your storefront to allow searching with Algolia. This section has instructions for Medusa’s [Next.js](../starters/nextjs-medusa-starter.md) storefront as well as React-based frameworks such as the [Gatsby](../starters/gatsby-medusa-starter.md) storefront.
|
||||||
|
|
||||||
|
### Storefront Prerequisites
|
||||||
|
|
||||||
|
It is assumed you already have a storefront set up and working with the Medusa server, as this section only covers how to add the search UI.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
If you don’t have a storefront set up, you can use the [Gatsby](../starters/gatsby-medusa-starter.md) or [Next.js](../starters/nextjs-medusa-starter.md) storefronts Medusa provides.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Add to Next.js Storefront
|
||||||
|
|
||||||
|
The Next.js storefront has the Algolia integration available out of the box. To get it working, you just need to follow three steps.
|
||||||
|
|
||||||
|
First, ensure that the search feature is enabled in `store.config.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"features": {
|
||||||
|
"search": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, add the necessary environment variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NEXT_PUBLIC_SEARCH_APP_ID=<YOUR_APP_ID>
|
||||||
|
NEXT_PUBLIC_SEARCH_API_KEY=<YOUR_SEARCH_API_KEY>
|
||||||
|
NEXT_PUBLIC_SEARCH_INDEX_NAME=products
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_APP_ID>` and `<YOUR_SEARCH_API_KEY>` are respectively the Application ID and Search-Only API Key on the [API Keys page](#retrieve-api-keys).
|
||||||
|
|
||||||
|
Finally, change the code in `src/lib/search-client.ts` to the following:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import algoliasearch from "algoliasearch/lite"
|
||||||
|
|
||||||
|
const appId = process.env.NEXT_PUBLIC_SEARCH_APP_ID || "" // You should add this to your environment variables
|
||||||
|
|
||||||
|
const apiKey = process.env.NEXT_PUBLIC_SEARCH_API_KEY || "test_key"
|
||||||
|
|
||||||
|
export const searchClient = algoliasearch(appId, apiKey)
|
||||||
|
|
||||||
|
export const SEARCH_INDEX_NAME =
|
||||||
|
process.env.NEXT_PUBLIC_INDEX_NAME || "products"
|
||||||
|
```
|
||||||
|
|
||||||
|
If you run your Next.js storefront now while the Medusa server is running, the search functionality will be available in your storefront.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
To make sure the Next.js storefront properly displays the products in the search result, include in the `attributesToRetrieve` setting of the Algolia plugin on the Medusa server at least the fields `title`, `handle`, `description`, and `thumbnail`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Add to Gatsby and React-Based Storefronts
|
||||||
|
|
||||||
|
This section covers adding the search UI to React-based storefronts. It uses the Gatsby storefront as an example, but you can use the same steps on any React-based framework.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
For other frontend frameworks, please check out [Algolia’s Integrations guide](https://www.algolia.com/developers/?ui-libraries&client-libraries) for steps based on your framework.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
In the directory that contains your storefront, run the following command to install the necessary dependencies:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
npm install algoliasearch react-instantsearch-dom
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, add the following environment variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GATSBY_ALGOLIA_APP_ID=<YOUR_APP_ID>
|
||||||
|
GATSBY_ALGOLIA_SEARCH_API_KEY=<YOUR_SEARCH_API_KEY>
|
||||||
|
GATSBY_SEARCH_INDEX_NAME=products
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_APP_ID>` and `<YOUR_SEARCH_API_KEY>` are respectively the Application ID and Search-Only API Key on the [API Keys page](#retrieve-api-keys).
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
In Gatsby, environment variables that should be public and available in the browser are prefixed with `GATSBY_`. If you’re using another React-based framework, you might need to use a different prefix to ensure these variables can be used in your code. Please refer to your framework’s documentation for help on this.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
Then, create the file `src/components/header/search.jsx` with the following content:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import {
|
||||||
|
Highlight,
|
||||||
|
Hits,
|
||||||
|
InstantSearch,
|
||||||
|
SearchBox,
|
||||||
|
connectStateResults
|
||||||
|
} from "react-instantsearch-dom"
|
||||||
|
|
||||||
|
import React from "react"
|
||||||
|
import algoliasearch from 'algoliasearch/lite';
|
||||||
|
|
||||||
|
const searchClient = algoliasearch(
|
||||||
|
process.env.GATSBY_ALGOLIA_APP_ID,
|
||||||
|
process.env.GATSBY_ALGOLIA_SEARCH_API_KEY
|
||||||
|
)
|
||||||
|
|
||||||
|
const Search = () => {
|
||||||
|
const Results = connectStateResults(({ searchState, searchResults, children }) =>
|
||||||
|
searchState && searchState.query && searchResults && searchResults.nbHits !== 0 ? (
|
||||||
|
<div className="absolute top-full w-full p-2 bg-gray-200 shadow-md">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div></div>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<InstantSearch indexName={process.env.GATSBY_SEARCH_INDEX_NAME} searchClient={searchClient}>
|
||||||
|
<SearchBox submit={null} reset={null} />
|
||||||
|
<Results>
|
||||||
|
<Hits hitComponent={Hit} />
|
||||||
|
</Results>
|
||||||
|
</InstantSearch>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const Hit = ({ hit }) => {
|
||||||
|
return (
|
||||||
|
<div key={hit.id} className="relative">
|
||||||
|
<div className="hit-name">
|
||||||
|
<Highlight attribute="title" hit={hit} tagName="mark" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Search;
|
||||||
|
```
|
||||||
|
|
||||||
|
This file uses the dependencies you installed to show the search results. It also initializes Algolia using the environment variables you added.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you named your environment variables differently based on your framework, make sure to rename them here as well.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
Finally, import this file at the beginning of `src/components/header/index.jsx`:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import Search from "./search"
|
||||||
|
```
|
||||||
|
|
||||||
|
And add the `Search` component in the returned JSX before `RegionPopover`:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
//...
|
||||||
|
<Search />
|
||||||
|
<RegionPopover regions={mockData.regions} />
|
||||||
|
//...
|
||||||
|
```
|
||||||
|
|
||||||
|
If you run your Gatsby storefront while the Medusa server is running, you should find a search bar in the header of the page. Try entering a query to search through the products in your store.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Learn how to [deploy your Medusa server](../deployments/server/index.mdx).
|
||||||
|
- Learn how to [deploy your Gatsby storefront](../deployments/storefront/deploying-gatsby-on-netlify.md).
|
||||||
@@ -1,318 +0,0 @@
|
|||||||
# Contentful
|
|
||||||
|
|
||||||
## Introduction
|
|
||||||
|
|
||||||
In this guide we will go over how to set up a modern e-commerce store using [Gatsby](https://gatsby.com) as a front end, [Contentful](https://contentful.com) as a CMS system and Medusa as a store engine. The resulting e-commerce store will be blazingly fast, highly extendable and will provide the necessary foundation to grow and evolve your e-commerce stack as your business expands to new markets and develops new software requirements.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
After following the steps outlines in this series you will have:
|
|
||||||
|
|
||||||
- A Medusa store engine capable of managing products, processing orders, handling orders and integrating with all the tools in your e-commerce stack.
|
|
||||||
- A statically generated Gatsby storefront that is on brand and customizable from homepage to checkout flow.
|
|
||||||
- A headless CMS system that can be modified and extended to create the best customer experience.
|
|
||||||
|
|
||||||
You will make use of `medusa-plugin-contentful` which is a plugin to your Medusa store engine that syncronizes products and product variants between your Medusa engine and your Contentful space. This allows you to perform content enrichment in Contentful while keeping your core master data in Medusa, for a truly headless commerce setup.
|
|
||||||
|
|
||||||
Other concepts that will be covered in this series include:
|
|
||||||
|
|
||||||
- Gatsby plugins and [File System Route API](https://www.gatsbyjs.com/docs/reference/routing/file-system-route-api/)
|
|
||||||
- [Contentful Migrations](https://www.contentful.com/developers/docs/tutorials/cli/scripting-migrations/)
|
|
||||||
- Medusa payments, fulfillments and plugins
|
|
||||||
|
|
||||||
If you want to jump straight to the code for this series you can checkout:
|
|
||||||
|
|
||||||
- [`medusa-starter-contentful`](https://github.com/medusajs/medusa-starter-contentful)
|
|
||||||
- [`medusa-contentful-storefront`](https://github.com/medusajs/medusa-contentful-storefront)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
For a full guide to how to set up your development environment for Medusa please see [the tutorial](../tutorial/set-up-your-development-environment/)
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
In order to get you started with your Gatsby, Contentful, Medusa store you must complete a couple of installations:
|
|
||||||
|
|
||||||
- Install the Medusa CLI
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm install @medusajs/medusa-cli -g
|
|
||||||
```
|
|
||||||
|
|
||||||
- Install the Gatsby CLI
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm install gatsby-cli -g
|
|
||||||
```
|
|
||||||
|
|
||||||
- [Create a Contentful account](https://www.contentful.com/sign-up/)
|
|
||||||
- [Install Redis](https://redis.io/topics/quickstart)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
brew install redis
|
|
||||||
brew services start redis
|
|
||||||
```
|
|
||||||
|
|
||||||
Medusa has support for SQLite and PostgreSQL and uses Redis for caching and queueing of asynchronous tasks. Redis is required for `medusa-plugin-contentful` to work correctly.
|
|
||||||
|
|
||||||
## Setting up your Medusa server
|
|
||||||
|
|
||||||
We will make use of `medusa new` to setup your local Medusa server.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
medusa new medusa-contentful-store https://github.com/medusajs/medusa-starter-contentful
|
|
||||||
```
|
|
||||||
|
|
||||||
This command will setup a new directory at `medusa-contentful-store`, clone the `medusa-starter-contentful` into that directory and install the dependencies for the project.
|
|
||||||
|
|
||||||
### What's inside
|
|
||||||
|
|
||||||
You can now do `cd medusa-contentful-store` and open up your project in your text editor. Below is an overview of the directory structure and a walkthrough of what the different files do.
|
|
||||||
|
|
||||||
```
|
|
||||||
medusa-contentful-store
|
|
||||||
├── contentful-migrations
|
|
||||||
| ├── hero.js
|
|
||||||
| ├── index.js
|
|
||||||
| ├── link.js
|
|
||||||
| ├── navigation-item.js
|
|
||||||
| ├── navigation-menu.js
|
|
||||||
| ├── page.js
|
|
||||||
| ├── product-variant.js
|
|
||||||
| ├── product.js
|
|
||||||
| ├── region.js
|
|
||||||
| ├── tile-section.js
|
|
||||||
| └── tile.js
|
|
||||||
├── data
|
|
||||||
| ├── contentful-seed.json
|
|
||||||
| └── seed.json
|
|
||||||
├── src
|
|
||||||
| ├── api
|
|
||||||
| ├── loaders
|
|
||||||
| ├── services
|
|
||||||
| └── subscribers
|
|
||||||
├── .env
|
|
||||||
├── medusa-config.js
|
|
||||||
├── package.json
|
|
||||||
└── README.md
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `package.json`
|
|
||||||
|
|
||||||
If you are familiar with Node you will probably notice that your Medusa store is simply a Node project. Looking inside the `package.json` file you will find that one of the packages that is installed in the project is the `@medusajs/medusa` package. This is the core Medusa package that comes prepacked with all the functionality necessary to do digital commerce - it is also this package that makes sure to register and use the plugins and custom functionality that are configured for your store.
|
|
||||||
|
|
||||||
#### `medusa-config.js`
|
|
||||||
|
|
||||||
Your plugins and store configuration is managed in the `medusa-config.js`, if you open up the file you will see that `medusa-plugin-contentful` is configured with options as shown below. Later we will be setting up your Contentful space so that we can add the necessary environment variables to your `.env` file.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// medusa-config.js
|
|
||||||
|
|
||||||
// Contentful Variables
|
|
||||||
const CONTENTFUL_SPACE_ID = process.env.CONTENTFUL_SPACE_ID || "";
|
|
||||||
const CONTENTFUL_ACCESS_TOKEN = process.env.CONTENTFUL_ACCESS_TOKEN || "";
|
|
||||||
const CONTENTFUL_ENV = process.env.CONTENTFUL_ENV || "";
|
|
||||||
|
|
||||||
|
|
||||||
const plugins = [
|
|
||||||
...,
|
|
||||||
{
|
|
||||||
resolve: `medusa-plugin-contentful`,
|
|
||||||
options: {
|
|
||||||
space_id: CONTENTFUL_SPACE_ID,
|
|
||||||
access_token: CONTENTFUL_ACCESS_TOKEN,
|
|
||||||
environment: CONTENTFUL_ENV,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...
|
|
||||||
];
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
projectConfig: {
|
|
||||||
redis_url: REDIS_URL,
|
|
||||||
database_database: "./medusa-db.sql",
|
|
||||||
database_type: "sqlite",
|
|
||||||
store_cors: STORE_CORS,
|
|
||||||
admin_cors: ADMIN_CORS,
|
|
||||||
},
|
|
||||||
plugins,
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `/src`
|
|
||||||
|
|
||||||
In the `/src` directory there are 4 special subdirectories that are added for you already. These special directories can be used to add custom functionality to your store. Custom functionality can include custom endpoints (configured in `/api`), custom business logic (configured in `/services`), pub/sub-like subscriptions for asyncrhonous integration tasks (configured in `/subscribers`) and finally loader functions to be called when your Medusa server starts up (configured in `/loaders`). If you want to learn more about how to add custom functionality you can checkout [the tutorial](https://docs.medusajs.com/tutorials/adding-custom-functionality).
|
|
||||||
|
|
||||||
#### `/data`
|
|
||||||
|
|
||||||
We will be using two seed scripts to kickstart your development, namely:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run seed:contentful
|
|
||||||
npm run seed
|
|
||||||
```
|
|
||||||
|
|
||||||
Data for these seed scripts are contained in the `/data` directory.
|
|
||||||
|
|
||||||
When the seed scripts have been executed you will have a Contentful space that holds all the data for your website; this includes content for Pages, Navigtion Menu, etc.
|
|
||||||
|
|
||||||
#### `/contentful-migrations`
|
|
||||||
|
|
||||||
This directory contains scripts that create content types in your Contentful space. Contentful allows you to customize your content types with fields that can be used to hold all sorts of data, this makes it possible to create advanced data structures that will later be used to lay out your website. Writing migration scripts to evolve your content types is a really powerful tool as you can use it in CI/CD pipelines and makes your projects much more portable.
|
|
||||||
|
|
||||||
The migrations included in this project will create the following content types:
|
|
||||||
|
|
||||||
- **Page**: Represents a page on your website. Each page has a title and can take any number of "Content Modules". Content Modules can be either of the type Hero or Tile Section.
|
|
||||||
- **Hero**: a component that can take a Title, CTA and a background image.
|
|
||||||
- **Tile**: a component that can be added to a Tile Section and renders a Title, CTA and an Image.
|
|
||||||
- **Tile Section**: a component that can hold a number of Tiles or Products. When used with a Product, the Tile Section will display the product thumbnail and it's title and will link to the product page.
|
|
||||||
- **Link**: a component that can link to an external or internal path; or, alternatively, hold a reference to a Page or Product entry. If used with Page or Product, the link path will be infered from the referenced entry.
|
|
||||||
- **Navigation Item**: an item to include in a Navigation Menu. Each navigation item has a title that can be displayed in a menu and a link that defines where the user will be navigated to when the item is clicked.
|
|
||||||
- **Product**: represents a product as syncronized from Medusa. A product's variants will be copied over as well.
|
|
||||||
- **Product Variant**: The variants of a product.
|
|
||||||
- **Region**: Represents an available region in Medusa.
|
|
||||||
|
|
||||||
## Creating a Contentful space
|
|
||||||
|
|
||||||
To create a new Contentful space log in to your Contentful account. If you already have a Contentful account with a Space configured you can click your organization name in the top left corner to reveal an overview of your organization's spaces. At the bottom of the spaces list you should click "Add space".
|
|
||||||
|
|
||||||
**Select "Community space" and "Web app only"**
|
|
||||||
In this guide we will be using a free space which gives you an incredibly strong foundation for creating on-brand customer experiences and advances shopping flows.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Add a name and select "Empty space"**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Once your space is set up you can go to your space home. We will now get the credentials needed for `medusa-plugin-contentful` to work.
|
|
||||||
|
|
||||||
Open your `.env` file in your text editor you should see:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# .env
|
|
||||||
JWT_SECRET=something
|
|
||||||
COOKIE_SECRET=something
|
|
||||||
|
|
||||||
STRIPE_API_KEY=
|
|
||||||
STRIPE_WEBHOOK_SECRET=
|
|
||||||
|
|
||||||
CONTENTFUL_SPACE_ID=
|
|
||||||
CONTENTFUL_ACCESS_TOKEN=
|
|
||||||
CONTENTFUL_ENV=
|
|
||||||
```
|
|
||||||
|
|
||||||
Your `CONTENTFUL_SPACE_ID` can be found by going to your space home and checking your browser's URL bar. The space id is the alphanumeric string following `https://app.contentful.com/spaces/`. Copy this string and paste it into your `.env` file.
|
|
||||||
|
|
||||||
To get your `CONTENFUL_ACCESS_TOKEN` go to your space home and click **Settings** > **API keys**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Then click **Content management tokens** and click **Generate personal token**. After giving your token a name you can copy it to your `.env`
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
For `CONTENTFUL_ENVIRONMENT` add `master`.
|
|
||||||
|
|
||||||
You should now have a `.env` that looks like this:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# .env
|
|
||||||
JWT_SECRET=something
|
|
||||||
COOKIE_SECRET=something
|
|
||||||
|
|
||||||
STRIPE_API_KEY=
|
|
||||||
STRIPE_WEBHOOK_SECRET=
|
|
||||||
|
|
||||||
CONTENTFUL_SPACE_ID=****
|
|
||||||
CONTENTFUL_ACCESS_TOKEN=CFPAT-*******
|
|
||||||
CONTENTFUL_ENV=master
|
|
||||||
```
|
|
||||||
|
|
||||||
## Migrating and Seeding your Contentful space
|
|
||||||
|
|
||||||
Now that we have collected your credentials we are ready to migrate the Contentful space to add the content types we talked about earlier. To migrate the Contentful space open up your command line and `cd` into `medusa-contentful-store`.
|
|
||||||
|
|
||||||
You can now run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run migrate:contentful
|
|
||||||
```
|
|
||||||
|
|
||||||
This script will run each of the migrations in the `contentful-migrations` directory. After it has completed navigate to your Contentful space and click "Content model" in the top navigation bar. You will see that the content types will be imported into your space. Feel free to familiarize yourself with the different types by clicking them and inspecting the different fields that they hold.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
The next step is to seed the Contentful space with some data that can be used to display your ecommerce store's pages and navigation. To seed the database open up your command line and run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run seed:contentful
|
|
||||||
```
|
|
||||||
|
|
||||||
In your Contentful space navigate to "Content" and you will be able to see the different entries in your space. You can filter the entries by type to, for example, only view Pages:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
You will notice that there are not any Products in your store yet and this is because we haven't created any products in your Medusa store.
|
|
||||||
|
|
||||||
To do this open your command line and run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run seed
|
|
||||||
npm run start
|
|
||||||
```
|
|
||||||
|
|
||||||
This will seed your Medusa database, which will result in `medusa-plugin-contentful` synchronizing data to your Contentful space. Everytime you add or update a product the data will be copied into your Contentful space for further enrichment.
|
|
||||||
|
|
||||||
## Setting Featured Products
|
|
||||||
|
|
||||||
In Contentful navigate to "Content" and find the Page called "Home". We will now add some featured products to the home page.
|
|
||||||
|
|
||||||
- Click the "Home" entry and scroll down to the field called "Content modules"
|
|
||||||

|
|
||||||
|
|
||||||
- Click the Content module named "Featured Products" and click "Add content" in the "Tiles" field
|
|
||||||

|
|
||||||
|
|
||||||
- Click "Add existing content" as e will be adding the products that were copied over by Medusa
|
|
||||||

|
|
||||||
|
|
||||||
- Select Medusa Waterbottle and Medusa Shirt and click "Insert 2 entries"
|
|
||||||
|
|
||||||
Make sure that everything is published by hitting publish in the sidebar on the right-hand side.
|
|
||||||
|
|
||||||
## Setting up your Gatsby storefront
|
|
||||||
|
|
||||||
Now that we have your Medusa server running and your Contentful space seeded with some starter data it is time to add a presentational layer that can be used by customers to browse and purchase the items in your store.
|
|
||||||
|
|
||||||
We have already created the storefront and you can install and use it by simply running:
|
|
||||||
|
|
||||||
```
|
|
||||||
gatsby new medusa-contentful-storefront https://github.com/medusajs/medusa-contentful-storefront
|
|
||||||
```
|
|
||||||
|
|
||||||
Once `gatsby new` is complete you should rename the `.env.template` file to `.env` and add a Content Delivery token. Your content delivery token is different from the personal access token you generated earlier, so make sure that you are using the correct token when you paste it into your `.env`.
|
|
||||||
|
|
||||||
To get your token go to **Settings** > **API Keys** > **Add API key**. Now click save and copy the token specified in the field "Content Delivery API - access token".
|
|
||||||
|
|
||||||
After you have copied the token and your space ID to your `.env`, you can start your Gatsby development server on port 8000 by running:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run start
|
|
||||||
```
|
|
||||||
|
|
||||||
You can now go to https://localhost:8000 to check out your new Medusa store.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
Using three powerful tools we have now set up a modern headless ecommerce store on our local development machine. This setup can scale with your business's needs and evolve to fit create amazing commerce expereiences that are unique and on brand. The steps we took in this guide were really simple and fast: first we created a Medusa server using the Medusa CLI, we then configured a Contentful space by running migrations and seed scripts. We also installed a Gatsby front end for our Medusa store using the Gatsby CLI.
|
|
||||||
|
|
||||||
## What's next
|
|
||||||
|
|
||||||
In the next part we will dig deeper into how Contentful can be used to create pages, enrich your products and structure your content. We will also take a look at the files in your Gatsby storefront.
|
|
||||||
|
|
||||||
Stay tuned!
|
|
||||||
@@ -0,0 +1,314 @@
|
|||||||
|
# Customize your Medusa and Contentful Integration
|
||||||
|
|
||||||
|
In this document, you’ll learn how to customize the Contentful integration with Medusa and how to customize the Gatsby storefront that is connected to Contentful.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Part of what makes the integration between Medusa and Contentful powerful is that it’s completely customizable.
|
||||||
|
|
||||||
|
On the server, you can create Contentful migrations that allow you to add or edit Content Types in Contentful. Although this can be done through Contentful’s interface, this solution allows you to create a reusable codebase for your store that is independent of a specific Contentful Space.
|
||||||
|
|
||||||
|
On your storefront, you can add any necessary components that can render the Content Types you create.
|
||||||
|
|
||||||
|
As an example to explain this process, in this documentation, you’ll create a migration that creates a Rich Text content model in Contentful and edits the Page and Product content models to allow using Rich Text content as a tile in pages and products. Then, you’ll modify the Gatsby storefront to render the Rich Text content model.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
It’s assumed you already have set up a Medusa server integrated with Contentful and have a Gatsby storefront integrated with Contentful. If not, [please follow this documentation first](index.md).
|
||||||
|
|
||||||
|
## Create a Contentful Migration
|
||||||
|
|
||||||
|
The Contentful migrations are located in the `contentful-migrations` directory in the Medusa Contentful server starter. So, if you want to create your own Contentful migrations, you can create them under that directory.
|
||||||
|
|
||||||
|
Here’s an example of a migration created in a new file `contentful-migrations/rich-text.js`:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
|
const { runMigration } = require("contentful-migration");
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
spaceId: process.env.CONTENTFUL_SPACE_ID,
|
||||||
|
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
|
||||||
|
environment: process.env.CONTENTFUL_ENVIRONMENT,
|
||||||
|
yes: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const migration = async () => {
|
||||||
|
await runMigration({
|
||||||
|
...options,
|
||||||
|
migrationFunction: function (migration, context) {
|
||||||
|
|
||||||
|
//create Rich Text content model
|
||||||
|
const richText = migration
|
||||||
|
.createContentType("richText")
|
||||||
|
.name("Rich Text")
|
||||||
|
.displayField("title");
|
||||||
|
|
||||||
|
richText.createField("title").name("Title (Internal)").type("Symbol");
|
||||||
|
richText.createField("body").name("Body").type("RichText");
|
||||||
|
|
||||||
|
//edit Page content model
|
||||||
|
const page = migration.editContentType("page")
|
||||||
|
|
||||||
|
page.editField("contentModules").items({
|
||||||
|
type: "Link",
|
||||||
|
linkType: "Entry",
|
||||||
|
validations: [
|
||||||
|
{
|
||||||
|
linkContentType: ["hero", "tileSection", "richText"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
//edit Product content model
|
||||||
|
const product = migration.editContentType("product")
|
||||||
|
|
||||||
|
product
|
||||||
|
.createField("contentModules")
|
||||||
|
.name("Content Modules")
|
||||||
|
.type("Array")
|
||||||
|
.items({
|
||||||
|
type: "Link",
|
||||||
|
linkType: "Entry",
|
||||||
|
validations: [
|
||||||
|
{
|
||||||
|
linkContentType: ["richText"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
migration();
|
||||||
|
```
|
||||||
|
|
||||||
|
This example creates a new content model Rich Text that has two fields: title and body. It also edits the Page content model to allow using Rich Text content models on the page.
|
||||||
|
|
||||||
|
In addition, it edits the Product content model by adding a new field `contentModules`. This field accepts an array of sections that can be of type Rich Text. This allows you to display rich details on a product page.
|
||||||
|
|
||||||
|
You can also add other types of content models the `contentModules` should accept. For example, to accept `tileSection` add it to the `linkContentType` option:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
linkContentType: ["tileSection", "richText"],
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run a Contentful Migration
|
||||||
|
|
||||||
|
To run a Contentful Migration that you create you can use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node <file_path>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<file_path>` is the path of the file you created.
|
||||||
|
|
||||||
|
To run the Contentful migration in the previous example, you can use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node contentful-migrations/rich-text.js
|
||||||
|
```
|
||||||
|
|
||||||
|
This runs the Contentful migration in that file and makes the necessary changes in your Contentful Space.
|
||||||
|
|
||||||
|
### Test if Contentful Migration Worked
|
||||||
|
|
||||||
|
To check if the above migration worked, in your Contentful Space dashboard go to Content Models from the navigation bar. You should see the new content model Rich Text.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The above migration also allows you to add Rich Text content to pages. To test this out, go to Content from the navigation bar and choose Page in the select field next to the search bar. This shows the available pages in your Contentful Space.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Choose one of the pages. For example, the About page. Then, scroll down to the Add content button. If you click on it, you should be able to choose Rich Text under New Content.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click on Rich Text and a new form will open to create new Rich Text content. It has the same fields that you defined in the migration file.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
After adding the content you want, click on the Publish button on the right then go back to the About page editor.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Similarly, in the About page editor, click on the Publish Changes button on the right to view these changes later in the storefront.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Similarly, you can add Rich Text content to any product page.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Render New Content Models in the Storefront
|
||||||
|
|
||||||
|
After creating a new content model in your Contentful Space, you must add the necessary component to render it in your Gatsby storefront.
|
||||||
|
|
||||||
|
### Create Component
|
||||||
|
|
||||||
|
To render the Rich Text content you created in the previous example, create the file `src/components/rich-text/rich-text.js` with the following content:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import React from "react"
|
||||||
|
import { renderRichText } from "gatsby-source-contentful/rich-text"
|
||||||
|
|
||||||
|
const RichText = ({ data }) => {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
maxWidth: '870px',
|
||||||
|
margin: '0 auto',
|
||||||
|
paddingTop: '20px',
|
||||||
|
paddingBottom: '20px'
|
||||||
|
}}>
|
||||||
|
{data.body ? renderRichText(data.body) : ""}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RichText
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates the component `RichText` responsible for rendering the Rich Text content model. Notice that the fields of the content model are available under the `data` prop variable.
|
||||||
|
|
||||||
|
### Render Component in a Page
|
||||||
|
|
||||||
|
Since the Rich Text model can be added to any page, you must edit `src/pages/{ContentfulPage.slug}.js` to show it.
|
||||||
|
|
||||||
|
In `src/pages/{ContentfulPage.slug}.js`, import the `RichText` component at the top of the file:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import RichText from "../components/rich-text/rich-text"
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, in the returned JSX add a new case to the switch statement:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
switch (cm.internal.type) {
|
||||||
|
//...
|
||||||
|
case "ContentfulRichText":
|
||||||
|
return <RichText key={cm.id} data={cm} />
|
||||||
|
default:
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If the content model of a tile is Rich Text, you’ll display it with the `RichText` component.
|
||||||
|
|
||||||
|
Finally, to retrieve all necessary data of the Rich Text content, in the `query` GraphQL variable add the following after the `... on ContentfulTileSection` fragment:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
export const query = graphql`
|
||||||
|
# find the following line
|
||||||
|
... on ContentfulTileSection {
|
||||||
|
|
||||||
|
}
|
||||||
|
# add the following
|
||||||
|
... on ContentfulRichText {
|
||||||
|
id
|
||||||
|
body {
|
||||||
|
raw
|
||||||
|
}
|
||||||
|
internal {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test Rich Text in Page Content
|
||||||
|
|
||||||
|
To test this out, run your Medusa server by running this command in its directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run the Gatsby storefront by running this command in its directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
This runs the Gatsby storefront on `localhost:8000`. Go to the storefront in your browser and open the About page. You should see the Rich Text content you added.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Render Component in a Product Page
|
||||||
|
|
||||||
|
In the example migration, you also edited the product page to include a new Content Modules field that allows inserting Rich Text content.
|
||||||
|
|
||||||
|
To render them on the Product Page, add the following in the GraphQL query defined in the `query` variable inside `product`:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
export const query = graphql`
|
||||||
|
query ($id: String!) {
|
||||||
|
product: contentfulProduct(id: { eq: $id }) {
|
||||||
|
# Other fields
|
||||||
|
contentModules {
|
||||||
|
... on ContentfulRichText {
|
||||||
|
id
|
||||||
|
body {
|
||||||
|
raw
|
||||||
|
}
|
||||||
|
internal {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
```
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you added other accepted Content Models to the `contentModules` field of the Product content type, make sure to add them here.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
Then, in `src/views/product.js` import the `RichText` component:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import RichText from "../components/rich-text/rich-text"
|
||||||
|
```
|
||||||
|
|
||||||
|
And in the returned JSX add the following before the last `</div>`:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
<div className={styles.contentModules}>
|
||||||
|
{product.contentModules?.map((cm) => {
|
||||||
|
switch (cm.internal.type) {
|
||||||
|
case "ContentfulRichText":
|
||||||
|
return <RichText key={cm.id} data={cm} />
|
||||||
|
default:
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you added other accepted Content Models to the `contentModules` field of the Product content type, make sure to add cases for them here to display them.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
This loops over `contentModules` and if the type of the content is Rich Text, it is rendered with the `RichText` component.
|
||||||
|
|
||||||
|
### Test Rich Text on a Product Page
|
||||||
|
|
||||||
|
Restart the Gatsby storefront then open a product that you added Rich Text content to. You should see the Rich Text component at the end of the page.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Learn how to deploy your Medusa server to [Heroku](../../deployments/server/deploying-on-heroku.mdx), [Qovery](../../deployments/server/deploying-on-qovery.md), or [DigitalOcean](../../deployments/server/deploying-on-digital-ocean.md).
|
||||||
|
- Learn [how to deploy your Gatsby storefront to Netlify](../../deployments/storefront/deploying-gatsby-on-netlify.md).
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
# Contentful
|
||||||
|
|
||||||
|
In this document, you’ll learn how to integrate a Medusa server with Contentful to add rich CMS functionalities
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
[Contentful](https://www.contentful.com/) is a headless CMS service that allows developers to integrate rich CMS functionalities into any platform.
|
||||||
|
|
||||||
|
By integrating Contentful to Medusa, you can benefit from powerful features in your ecommerce store including detailed product CMS details, easy-to-use interface to use for static content and pages, localization, and much more.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
### Needed Accounts
|
||||||
|
|
||||||
|
- [Contentful](https://www.contentful.com/sign-up/) account with a space created. A space is created by default when you create a new account.
|
||||||
|
|
||||||
|
### Required Tools
|
||||||
|
|
||||||
|
- PostgreSQL with an empty database created. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#postgres).
|
||||||
|
- Redis. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#redis).
|
||||||
|
- Git’s CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
||||||
|
- Gatsby’s CLI tool. You can follow [this documentation to install it](https://www.gatsbyjs.com/docs/reference/gatsby-cli/#how-to-use-gatsby-cli).
|
||||||
|
- Medusa’s CLI tool. You can follow [this documentation to install it](../../cli/reference.md#how-to-install-cli-tool).
|
||||||
|
|
||||||
|
## Install Medusa Server Using Contentful Starter
|
||||||
|
|
||||||
|
Instead of using the default Medusa Server starter, you must use the [Contentful starter](https://github.com/medusajs/medusa-starter-contentful) to install a server that is ready to be used with Contentful. This server contains all the necessary files to make the integration work.
|
||||||
|
|
||||||
|
In your terminal, run the following command to install the server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
medusa new medusa-contentful https://github.com/medusajs/medusa-starter-contentful
|
||||||
|
```
|
||||||
|
|
||||||
|
This installs a new Medusa server in the directory `medusa-contentful`.
|
||||||
|
|
||||||
|
### Add Contentful Environment Variables
|
||||||
|
|
||||||
|
Change to the `medusa-contentful` directory. In `.env` you’ll find 3 variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CONTENTFUL_SPACE_ID=
|
||||||
|
CONTENTFUL_ACCESS_TOKEN=
|
||||||
|
CONTENTFUL_ENV=
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Value of CONTENTFUL_ENV
|
||||||
|
|
||||||
|
Set the value for `CONTENTFUL_ENV` to `master`.
|
||||||
|
|
||||||
|
#### Value of CONTENTFUL_SPACE_ID
|
||||||
|
|
||||||
|
To retrieve the value of `CONTENTFUL_SPACE_ID`, go to your [Contentful Space dashboard](https://app.contentful.com/). Then, choose Settings in the navigation bar and select API keys from the dropdown.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
On the APIs page, click Add API Key.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the form, enter a name for the API key and click Save.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, copy the value of Space ID and set it as the value of `CONTENTFUL_SPACE_ID`.
|
||||||
|
|
||||||
|
#### Value of CONTENTFUL_ACCESS_TOKEN
|
||||||
|
|
||||||
|
Go back to the API Keys page and click on the Content management tokens tab.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click on Generate personal token. A pop-up will open where you have to enter a name for the token.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you click Generate, a personal access token will be generated. Use it to set the value of `CONTENTFUL_ACCESS_TOKEN`.
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
|
||||||
|
Once you close the pop-up, you won’t be able to get the value of the personal access token again. Make sure to copy it first.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Configure Redis
|
||||||
|
|
||||||
|
In `.env` set the value of your Redis URL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
REDIS_URL=<YOUR_REDIS_URL>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_REDIS_URL>` is the URL of your Redis service.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
The default Redis URL is `redis://localhost:6379`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Configure PostgreSQL
|
||||||
|
|
||||||
|
In `.env` set the value of your PostgreSQL URL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DATABASE_URL=<YOUR_DB_URL>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_DB_URL>` is the URL of your PostgreSQL database.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
You can find the format of the PostgreSQL database URL in [PostgreSQL’s documentation](https://www.postgresql.org/docs/current/libpq-connect.html).
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
Then, in `medusa-config.js` in the exported object, comment out or remove the SQLite database configurations and add the PostgreSQL database configurations:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
module.exports = {
|
||||||
|
projectConfig: {
|
||||||
|
//...
|
||||||
|
database_url: DATABASE_URL,
|
||||||
|
database_type: "postgres",
|
||||||
|
//REMOVE OR COMMENT OUT THE BELOW:
|
||||||
|
// database_database: "./medusa-db.sql",
|
||||||
|
// database_type: "sqlite",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Migrate Content Types to Contentful
|
||||||
|
|
||||||
|
The Contentful starter provides the necessary scripts to create content types in your Contentful space.
|
||||||
|
|
||||||
|
Run the following commands to migrate the content types into Contentful:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run migrate:contentful
|
||||||
|
```
|
||||||
|
|
||||||
|
Once this command finishes executing, in your Contentful Space dashboard click on Content Model in the navigation bar. You should see a list of new content models added.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Seed Content to Contentful
|
||||||
|
|
||||||
|
The next step is to seed the Contentful Space with some content data.
|
||||||
|
|
||||||
|
Run the following command to seed some data into it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run seed:contentful
|
||||||
|
```
|
||||||
|
|
||||||
|
After this command finishes running, in your Contentful Space dashboard click on Content in the navigation bar. You should see a list of new content added.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### (Optional) Seed Medusa Database
|
||||||
|
|
||||||
|
This step seeds your Medusa database with demo data to easily add products as well as other data to your Medusa server.
|
||||||
|
|
||||||
|
Run the following command to seed the Medusa database:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run seed
|
||||||
|
```
|
||||||
|
|
||||||
|
### Start the Server
|
||||||
|
|
||||||
|
To start the server run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
If you seeded the database with demo data, you should see that events related to the products are triggered.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The Contentful integration ensures a two-way sync between the Medusa server and Contentful. So, when new products are added to Medusa, these products will be added to your Contentful Space as well.
|
||||||
|
|
||||||
|
## (Optional) Add Products with the Medusa Admin
|
||||||
|
|
||||||
|
Using the Medusa admin, you can add products to your Medusa server. This will trigger product events that subsequently add these products to Contentful.
|
||||||
|
|
||||||
|
## Manage Contentful Data
|
||||||
|
|
||||||
|
### Publish Products
|
||||||
|
|
||||||
|
Products added through the integration with the Medusa server are by default saved as drafts. To show them on the storefront, you must set them as published.
|
||||||
|
|
||||||
|
To do that, open your Contentful Space Dashboard and click on Content in the Navigation bar. Then, change Any to Product in the select field next to the search bar. This shows only the content of the type Product, rather than all content.
|
||||||
|
|
||||||
|
Click on the checkbox at the top of the table to select all products then click Publish to publish these products.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Added Featured Products
|
||||||
|
|
||||||
|
On the homepage of the storefront, there’s a featured products tile that shows a set of products. Before running the storefront, you must add at least one product to the list.
|
||||||
|
|
||||||
|
To do that, open your Contentful Space Dashboard and click on Content in the Navigation bar. Make sure the select field next to the search bar is set to Any and search for Featured Products. You should find one content of the type Tile Section.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click on it. You should find on the page an empty Tiles section where you can add tiles and products.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click on Add content then on Add existing content and pick some of the products you want to show on the homepage.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done adding products, click on Publish changes in the right sidebar.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Setup Gatsby Storefront
|
||||||
|
|
||||||
|
In this section, you’ll set up the Gatsby storefront of your Medusa server.
|
||||||
|
|
||||||
|
In your terminal in a different directory of the Medusa server, run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gatsby new medusa-contentful-storefront https://github.com/medusajs/medusa-contentful-storefront
|
||||||
|
```
|
||||||
|
|
||||||
|
This will install the storefront in the directory `medusa-contentful-storefront`.
|
||||||
|
|
||||||
|
### Set Contentful Environment Variables
|
||||||
|
|
||||||
|
Change to the newly created directory and rename `.env.template`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mv .env.template .env
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, open `.env`. You should find the following environment variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CONTENTFUL_SPACE_ID=
|
||||||
|
CONTENTFUL_ACCESS_TOKEN=
|
||||||
|
```
|
||||||
|
|
||||||
|
The value of `CONTENTFUL_SPACE_ID` is the same value you [retrieved while setting up the Medusa server](#value-of-contentful_space_id).
|
||||||
|
|
||||||
|
To retrieve the value of `CONTENTFUL_ACCESS_TOKEN`, on your Contentful Space dashboard click on Settings then API keys. Then, choose the API key you created in the previous section.
|
||||||
|
|
||||||
|
You should find the field "Content Delivery API - access token”. Copy its value and set it as the value of `CONTENTFUL_ACCESS_TOKEN`.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Start Storefront
|
||||||
|
|
||||||
|
Make sure the Medusa server is still running. Then, start the storefront:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
This starts the storefront at `localhost:8000`. Open it in your browser and you should see on the homepage the Featured Product section with the products you chose on Contentful.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Make Changes to Content
|
||||||
|
|
||||||
|
You can update the CMS content of your storefront in your Contentful Space. This includes the CMS pages or product details.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you make changes to the data while your Gatsby storefront is running, the changes are not reflected instantly. That’s because the data is fetched from Contentful during build time. Instead, you must restart your Gatsby storefront to see the changes you make.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
## What’s Next :rocket:
|
||||||
|
|
||||||
|
- Learn [how to customize your Contentful server and storefront](./customize-contentful.md).
|
||||||
|
- Learn how to deploy your Medusa server to [Heroku](../../deployments/server/deploying-on-heroku.mdx), [Qovery](../../deployments/server/deploying-on-qovery.md), or [DigitalOcean](../../deployments/server/deploying-on-digital-ocean.md).
|
||||||
|
- Learn [how to deploy your Gatsby storefront to Netlify](../../deployments/storefront/deploying-gatsby-on-netlify.md).
|
||||||
@@ -1,145 +1,292 @@
|
|||||||
# MeiliSearch
|
# MeiliSearch
|
||||||
|
|
||||||
### Introduction
|
In this document, you’ll learn how to install the [MeiliSearch plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-meilisearch) and use it on both your Medusa Server and your storefront.
|
||||||
|
|
||||||
Search functionality is one of the most useful and important features in e-commerce platforms. From increasing customer conversion rates to significantly improving the user experience, search engines can enable significant business growth. Medusa brings search functionality to your doorstep by leveraging some of the already existing search engines out there.
|
## Overview
|
||||||
|
|
||||||
We have developed a plugin that will allow you to use the performant, open-source, and feature-rich search engine MeiliSearch.
|
[MeiliSearch](https://www.meilisearch.com/) is a super-fast, open source search engine built in Rust. It comes with a wide range of features including typo-tolerance, filtering, and sorting.
|
||||||
|
|
||||||
MeiliSearch is a super-fast, open-source, search engine built in Rust. It comes with a wide range of features such as typo-tolerance, filtering, sorting, and [much more](https://docs.meilisearch.com/learn/what_is_meilisearch/features.html). MeiliSearch also provides a pleasant developer experience, as it is extremely intuitive and newcomer-friendly - so even if you're new to the search engine "ecosystem", you'll have a great time navigating through their documentation.
|
MeiliSearch also provides a pleasant developer experience, as it is extremely intuitive and newcomer-friendly. So, even if you're new to the search engine ecosystem, [their documentation](https://docs.meilisearch.com/) is resourceful enough for everyone to go through and understand.
|
||||||
|
|
||||||
Through Medusa flexible plugin system, it is possible to enable search functionality into your medusa applications with minimum hassle by including our new plugin `medusa-plugin-meilisearch` to your `medusa-config.js` file.
|
Through Medusa's flexible plugin system, it is possible to add a search engine to your Medusa server and storefront using MeiliSearch with just a few steps.
|
||||||
|
|
||||||
### Installation
|
## Prerequisites
|
||||||
|
|
||||||
In case you don't have MeiliSearch installed locally on your environment yet, you can run the following:
|
### Medusa Components
|
||||||
|
|
||||||
```bash
|
It is required to have a Medusa server installed before starting with this documentation. If not, please follow along with our [quickstart guide](../quickstart/quick-start.md) to get started in minutes.
|
||||||
# Install MeiliSearch
|
|
||||||
curl -L https://install.meilisearch.com | sh
|
|
||||||
|
|
||||||
# Launch MeiliSearch
|
Furthermore, it’s highly recommended to ensure your Medusa server is configured to work with Redis. As Medusa uses Redis for the event queue internally, configuring Redis ensures that the search indices in MeiliSearch are updated whenever products on the Medusa server are updated. You can follow [this documentation to install Redis](../tutorial/0-set-up-your-development-environment.mdx#redis) and then [configure it on your Medusa server](../usage/configurations.md#redis).
|
||||||
./meilisearch
|
|
||||||
```
|
|
||||||
|
|
||||||
For other installation alternatives, you can head over to Meilisearch's [installation guide](https://docs.meilisearch.com/learn/getting_started/installation.html).
|
:::caution
|
||||||
|
|
||||||
In order to add the plugin to your medusa project, you will need to first install the plugin using your favorite package manager:
|
If you don’t install and configure Redis on your Medusa server, the MeiliSearch integration will still work. However, products indexed in MeiliSearch are only added and updated when you restart the Medusa server.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### MeiliSearch Instance
|
||||||
|
|
||||||
|
You must install MeiliSearch to use it with Medusa. You can follow [this documentation to install MeiliSearch](https://docs.meilisearch.com/learn/getting_started/quick_start.html#setup-and-installation) either locally or on a cloud.
|
||||||
|
|
||||||
|
Furthermore, you should create a master key for your MeiliSearch instance. If you don’t have one created, follow [this guide](https://docs.meilisearch.com/learn/security/master_api_keys.html#protecting-a-meilisearch-instance) to create a master key.
|
||||||
|
|
||||||
|
## Install the MeiliSearch Plugin
|
||||||
|
|
||||||
|
In the directory of your Medusa server, run the following command to install the MeiliSearch plugin:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install medusa-plugin-meilisearch
|
npm install medusa-plugin-meilisearch
|
||||||
```
|
```
|
||||||
|
|
||||||
Then in your `medusa-config.js` file, add the plugin to your `plugins` array. For this example, assumption is that you're leveraging MeiliSearch to perform searches on an index called `products`
|
Then, add the following environment variables to your Medusa server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
MEILISEARCH_HOST=<YOUR_MEILISEARCH_HOST>
|
||||||
|
MEILISEARCH_API_KEY=<YOUR_MASTER_KEY>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_MEILISEARCH_HOST>` is the host of your MeiliSearch instance. By default, if MeiliSearch is installed locally, the host is `http://127.0.0.1:7700`.
|
||||||
|
|
||||||
|
`<YOUR_MASTER_KEY>` is the master key of your MeiliSearch instance.
|
||||||
|
|
||||||
|
Finally, in `medusa-config.js` add the following item into the `plugins` array:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
module.exports = {
|
const plugins = [
|
||||||
// ...other options
|
//...
|
||||||
plugins: [
|
|
||||||
// ...other plugins
|
|
||||||
{
|
{
|
||||||
resolve: `medusa-plugin-meilisearch`,
|
resolve: `medusa-plugin-meilisearch`,
|
||||||
options: {
|
options: {
|
||||||
// config object passed when creating an instance of the MeiliSearch client
|
// config object passed when creating an instance of the MeiliSearch client
|
||||||
config: {
|
config: {
|
||||||
host: "http://127.0.0.1:7700",
|
host: process.env.MEILISEARCH_HOST,
|
||||||
apiKey: "your_master_key",
|
apiKey: process.env.MEILISEARCH_API_KEY,
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
// index name
|
// index name
|
||||||
products: {
|
products: {
|
||||||
// MeiliSearch's setting options to be set on a particular index
|
// MeiliSearch's setting options to be set on a particular index
|
||||||
searchableAttributes: ["title", "description", "variant_sku"],
|
searchableAttributes: ["title", "description", "variant_sku"],
|
||||||
displayedAttributes: ["title", "description", "variant_sku"],
|
displayedAttributes: ["title", "description", "variant_sku", "thumbnail", "handle"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
You can change the `searchableAttributes` and `displayedAttributes` as you see fit. However, the attributes included are the recommended attributes.
|
||||||
|
|
||||||
|
## Test MeiliSearch Plugin
|
||||||
|
|
||||||
|
Make sure your MeiliSearch instance is running. If you’re unsure how to run it, you can check the [installation documentation](https://docs.meilisearch.com/learn/getting_started/quick_start.html#setup-and-installation) for the command to run the MeiliSearch instance.
|
||||||
|
|
||||||
|
Then, run the Medusa server:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
The quickest way to test that the integration is working is by sending a `POST` request to `/store/products/search`. This endpoint accepts a `q` body parameter of the query to search for and returns in the result the products that match this query.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You can also check that the products are properly indexed by opening the MeiliSearch host URL in your browser, which is `http://127.0.0.1:7700/` by default. You’ll find your products that are on your Medusa server added there.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Add or Update Products
|
||||||
|
|
||||||
|
If you add or update products on your Medusa server, the addition or update will be reflected in the MeiliSearch indices.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
This feature is only available if you have Redis installed and configured with your Medusa server as mentioned in the [Prerequisites section](#prerequisites). Otherwise, you must re-run the Medusa server to see the change in the MeiliSearch indices.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Add Search to your Storefront
|
||||||
|
|
||||||
|
In this section, you’ll learn how to add the UI on your storefront to allow searching with MeiliSearch. This section has instructions for Medusa’s [Next.js](../starters/nextjs-medusa-starter.md) storefront as well as React-based frameworks such as the [Gatsby storefront](../starters/gatsby-medusa-starter.md).
|
||||||
|
|
||||||
|
### Storefront Prerequisites
|
||||||
|
|
||||||
|
It is assumed you already have a storefront set up and working with the Medusa server, as this section only covers how to add the search UI.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
If you don’t have a storefront set up, you can use the [Gatsby](../starters/gatsby-medusa-starter.md) or [Next.js](../starters/nextjs-medusa-starter.md) storefronts Medusa provides.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
Furthermore, you must create an API key in your MeiliSearch instance that will be used to search on the storefront. To do that, run the following command in your terminal while the MeiliSearch instance is running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl \
|
||||||
|
-X POST '<MEILISEARCH_HOST>/keys' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-H 'Authorization: Bearer <MEILISEARCH_MASTER_KEY>' \
|
||||||
|
--data-binary '{
|
||||||
|
"description": "Search products",
|
||||||
|
"actions": ["search"],
|
||||||
|
"indexes": ["products"],
|
||||||
|
"expiresAt": "2024-01-01T00:00:00Z"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `<MEILISEARCH_HOST>` and `<MEILISEARCH_MASTER_KEY>` accordingly.
|
||||||
|
|
||||||
|
If this request is successful, the API key will be available under the `key` property returned in the JSON response.
|
||||||
|
|
||||||
|
### Add to Next.js Storefront
|
||||||
|
|
||||||
|
The Next.js storefront has the MeiliSearch integration available out of the box. To get it working, you just need to follow two steps.
|
||||||
|
|
||||||
|
First, ensure that the search feature is enabled in `store.config.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"features": {
|
||||||
|
"search": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Et voilà! That's all it takes to make medusa and MeiliSearch work in great harmony. Please note that you can use any other setting from this [list](https://docs.meilisearch.com/reference/features/settings.html#settings) such as `filterableAttributes`, `sortableAttributes`, and `synonyms`. We are working on another blog post that will demonstrate how you can make use of these settings to build a great storefront experience, so stay tuned to that!
|
Then, add the necessary environment variables:
|
||||||
|
|
||||||
### Simple Usage
|
```bash
|
||||||
|
NEXT_PUBLIC_SEARCH_ENDPOINT=<YOUR_MEILISEARCH_HOST>
|
||||||
|
NEXT_PUBLIC_SEARCH_API_KEY=<YOUR_API_KEY>
|
||||||
|
NEXT_PUBLIC_SEARCH_INDEX_NAME=products
|
||||||
|
```
|
||||||
|
|
||||||
Medusa exposes an API layer that can serve as an abstraction over various search providers. We will now be interacting with one of the search routes parts of that layer, namely, the `POST /store/products/search` route. The route will enable you to test out the integration between Medusa and MeiliSearch. The endpoint takes a mandatory `q` property and a set of optional parameters which will be passed to MeiliSearch's `search()` method as a second argument. The list of the parameters which can be provided can be found in MeiliSearch's [docs](https://docs.meilisearch.com/reference/api/search.html#search-in-an-index-with-post-route).
|
Make sure to replace `<YOUR_MEILISEARCH_HOST>` with your MeiliSearch host and `<YOUR_API_KEY>` with the API key you created as instructed in the [Storefront Prerequisites](#storefront-prerequisites) section.
|
||||||
|
|
||||||
Let's use Postman for this short demo to get some search results:
|
If you run your Next.js storefront now while the Medusa server and the MeiliSearch services are running, the search functionality will be available in your storefront.
|
||||||
|
|
||||||

|
:::note
|
||||||
|
|
||||||
We tried to perform a search query "creneck" to find all crewnecks in our store. Note how the explicit mistake of leaving a "w" out from "crewneck" still yields the correct results.
|
To make sure the Next.js storefront properly displays the products in the search result, include in the `displayedAttributes` setting of the MeiliSearch plugin on the Medusa server at least the fields `title`, `handle`, `description`, and `thumbnail`.
|
||||||
|
|
||||||
Postman is not the most exciting client to use to showcase this, so in the next section, there is a short guide on how you can use React and MeiliSearchh's ecosystem to build something that looks better than JSON.
|
:::
|
||||||
|
|
||||||
### Highlighting and Pagination in a React Storefront
|

|
||||||
|
|
||||||
The Medusa + MeiliSearch integration opens up a lot of capabilities for creating a rich UX for your storefront. The plugin indexes all your products and listens to any updates made on them, so you can then leverage any client-side SDKs developed by the MeiliSearch team to build cool search experiences for storefronts. For example, MeiliSearch exposes a React [adapter](https://github.com/meilisearch/meilisearch-react/) that can be used with React InstantSearch (made by Algolia) which provides features such as highlighting, filtering, and pagination out of the box.
|
### Add to Gatsby and React-Based Storefronts
|
||||||
|
|
||||||
In order to leverage this functionality, you'll need to install the corresponding packages by running:
|
This section covers adding the search UI to React-based storefronts. It uses the Gatsby storefront as an example, but you can use the same steps on any React-based framework.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
For other frontend frameworks, please check out [MeiliSearch’s Integrations guide](https://github.com/meilisearch/integration-guides) for steps based on your framework.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
In the directory that contains your storefront, run the following command to install the necessary dependencies:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install react-instantsearch-dom @meilisearch/instant-meilisearch
|
npm install react-instantsearch-dom @meilisearch/instant-meilisearch
|
||||||
```
|
```
|
||||||
|
|
||||||
You can then use the MeiliSearch client in your react app:
|
Then, add the following environment variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GATSBY_MEILISEARCH_HOST=<YOUR_MEILISEARCH_HOST>
|
||||||
|
GATSBY_MEILISEARCH_API_KEY=<YOUR_API_KEY>
|
||||||
|
GATSBY_SEARCH_INDEX_NAME=products
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `<YOUR_MEILISEARCH_HOST>` with your MeiliSearch host and `<YOUR_API_KEY>` with the API key you created as instructed in the [Storefront Prerequisites](#storefront-prerequisites) section.
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
In Gatsby, environment variables that should be public and available in the browser are prefixed with `GATSBY_`. If you’re using another React-based framework, you might need to use a different prefix to ensure these variables can be used in your code. Please refer to your framework’s documentation for help on this.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
Then, create the file `src/components/header/search.jsx` with the following content:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import React from "react"
|
|
||||||
import {
|
import {
|
||||||
InstantSearch,
|
|
||||||
Hits,
|
|
||||||
SearchBox,
|
|
||||||
Pagination,
|
|
||||||
Highlight,
|
Highlight,
|
||||||
|
Hits,
|
||||||
|
InstantSearch,
|
||||||
|
SearchBox,
|
||||||
|
connectStateResults
|
||||||
} from "react-instantsearch-dom"
|
} from "react-instantsearch-dom"
|
||||||
|
|
||||||
|
import React from "react"
|
||||||
import { instantMeiliSearch } from "@meilisearch/instant-meilisearch"
|
import { instantMeiliSearch } from "@meilisearch/instant-meilisearch"
|
||||||
|
|
||||||
const searchClient = instantMeiliSearch(
|
const searchClient = instantMeiliSearch(
|
||||||
"http://127.0.0.1:7700",
|
process.env.GATSBY_MEILISEARCH_HOST,
|
||||||
"your_master_key"
|
process.env.GATSBY_MEILISEARCH_API_KEY
|
||||||
)
|
)
|
||||||
|
|
||||||
const SearchPage = () => (
|
const Search = () => {
|
||||||
<InstantSearch indexName="products" searchClient={searchClient}>
|
const Results = connectStateResults(({ searchState, searchResults, children }) =>
|
||||||
<SearchBox />
|
searchState && searchState.query && searchResults && searchResults.nbHits !== 0 ? (
|
||||||
<Hits hitComponent={Hit} />
|
<div className="absolute top-full w-full p-2 bg-gray-200 shadow-md">
|
||||||
<Pagination />
|
{children}
|
||||||
</InstantSearch>
|
</div>
|
||||||
)
|
) : (
|
||||||
|
<div></div>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const Hit = ({ hit }) => {
|
|
||||||
return (
|
return (
|
||||||
<div key={hit.id}>
|
<div className="relative">
|
||||||
<div className="hit-name">
|
<InstantSearch indexName={process.env.GATSBY_SEARCH_INDEX_NAME} searchClient={searchClient}>
|
||||||
<Highlight attribute="name" hit={hit} />
|
<SearchBox submit={null} reset={null} />
|
||||||
</div>
|
<Results>
|
||||||
<img src={hit.image} align="left" alt={hit.name} />
|
<Hits hitComponent={Hit} />
|
||||||
<div className="hit-description">
|
</Results>
|
||||||
<Snippet attribute="description" hit={hit} />
|
</InstantSearch>
|
||||||
</div>
|
|
||||||
<div className="hit-info">price: {hit.price}</div>
|
|
||||||
<div className="hit-info">release date: {hit.releaseDate}</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Hit = ({ hit }) => {
|
||||||
|
return (
|
||||||
|
<div key={hit.id} className="relative">
|
||||||
|
<div className="hit-name">
|
||||||
|
<Highlight attribute="title" hit={hit} tagName="mark" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Search;
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to play around with the various features provided by React InstantSearch you can read more on algolia's [documentation](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/). You can also use MeiliSearch's react [demo](https://codesandbox.io/s/ms-react-is-sh9ud?fontsize=14&hidenavigation=1&theme=dark&file=/src/App.js) for a more interactive example.
|
This file uses the dependencies you installed to show the search results. It also initializes MeiliSearch using the environment variables you added.
|
||||||
|
|
||||||
### Demo: Palmes Storefront
|
:::caution
|
||||||
|
|
||||||
By using the above libraries (React, `react-instantsearch-dom`, and `instant-meilisearch`) in addition to the medusa plugin, we have successfully integrated the MeiliSearch plugin for one of our customers: Palmes. Following is a short GIF demoing the functionality.
|
If you named your environment variables differently based on your framework, make sure to rename them here as well.
|
||||||
|
|
||||||
[Palmes Tennis Society.mp4](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e0b596ab-e146-4151-a8b0-42c94401761f/Palmes_Tennis_Society.mp4)
|
:::
|
||||||
|
|
||||||
### Enhance your development experience with MeiliSearch's Web UI
|
Finally, import this file at the beginning of `src/components/header/index.jsx`:
|
||||||
|
|
||||||
For a quicker feedback loop on what's happening on your search engine, you can use MeiliSearch's helpful out-of-the-box web interface to run some searches and get live results. It comes with MeiliSearch when you first install it and requires 0 configuration. When integrating the MeiliSearch plugin to existing medusa projects, we also found it to be extremely helpful for debugging
|
```jsx
|
||||||
|
import Search from "./search"
|
||||||
|
```
|
||||||
|
|
||||||
<iframe src="https://player.vimeo.com/video/639184340?h=593662d9f6" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
And add the `Search` component in the returned JSX before `RegionPopover`:
|
||||||
|
|
||||||
### More to come
|
```jsx
|
||||||
|
//...
|
||||||
|
<Search />
|
||||||
|
<RegionPopover regions={mockData.regions} />
|
||||||
|
//...
|
||||||
|
```
|
||||||
|
|
||||||
As briefly mentioned before, we're preparing another blog post that dives a bit deeper into the Medusa Search API and provides a more in-depth walkthrough on how to build a feature-rich search experience that includes filtering, synonyms, stop-words, and more!
|
If you run your Gatsby storefront while the Medusa server and the MeiliSearch instance are running, you should find a search bar in the header of the page. Try entering a query to search through the products in your store.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Learn how to [deploy your Medusa server](../deployments/server/index.mdx).
|
||||||
|
- Learn how to [deploy your Gatsby storefront](./../deployments/storefront/deploying-gatsby-on-netlify.md).
|
||||||
@@ -105,6 +105,12 @@ Finally, configure your `medusa-config.js` to include the plugin with the requ
|
|||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
If you have multiple storage plugins configured, the last plugin declared in the `medusa-config.js` file will be used.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Test it Out
|
## Test it Out
|
||||||
|
|
||||||
Run your Medusa server alongside the [Medusa Admin](../admin/quickstart.md) to try out your new file service. Upon editing or creating products, you can now upload thumbnails and images, that are stored in a MinIO server.
|
Run your Medusa server alongside the [Medusa Admin](../admin/quickstart.md) to try out your new file service. Upon editing or creating products, you can now upload thumbnails and images, that are stored in a MinIO server.
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ Additionally, you need a Medusa server installed and set up. If not, you can fol
|
|||||||
|
|
||||||
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).
|
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
|
## Medusa Server
|
||||||
|
|
||||||
|
### Install the PayPal Plugin
|
||||||
|
|
||||||
In the root of your Medusa server, run the following command to install the PayPal plugin:
|
In the root of your Medusa server, run the following command to install the PayPal plugin:
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ In the root of your Medusa server, run the following command to install the PayP
|
|||||||
npm install medusa-payment-paypal
|
npm install medusa-payment-paypal
|
||||||
```
|
```
|
||||||
|
|
||||||
### Plugin Configuration
|
### Configure the PayPal Plugin
|
||||||
|
|
||||||
Next, you need to add configurations for your PayPal plugin.
|
Next, you need to add configurations for your PayPal plugin.
|
||||||
|
|
||||||
@@ -68,7 +70,15 @@ That’s all you need to install PayPal on your Medusa server!
|
|||||||
|
|
||||||
## Admin Setup
|
## Admin Setup
|
||||||
|
|
||||||
The next step is to enable PayPal as a payment provider in at least one region from the Medusa Admin.
|
This section will guide you through adding PayPal as a payment provider in a region using your Medusa admin dashboard.
|
||||||
|
|
||||||
|
This step is required for you to be able to use PayPal as a payment provider in your storefront.
|
||||||
|
|
||||||
|
### Admin Prerequisites
|
||||||
|
|
||||||
|
If you don’t have a Medusa admin installed, make sure to follow along with [the guide on how to install it](../admin/quickstart.md) before continuing with this section.
|
||||||
|
|
||||||
|
### Add PayPal to Regions
|
||||||
|
|
||||||
Run your Medusa server and Medusa admin, then open the Medusa admin and login.
|
Run your Medusa server and Medusa admin, then open the Medusa admin and login.
|
||||||
|
|
||||||
@@ -86,171 +96,52 @@ Once you’re done, click Save. PayPal is now a payment provider in your store i
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
### Storefront Prerequisites
|
||||||
|
|
||||||
|
All storefronts require that you obtain your PayPal Client ID. You can retrieve it from your PayPal developer dashboard.
|
||||||
|
|
||||||
|
### Process Overview
|
||||||
|
|
||||||
|
Aside from the Next.js Storefront, you need to add the implementation with PayPal manually.
|
||||||
|
|
||||||
:::note
|
:::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.
|
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 next sections have different implementations to add PayPal into your storefront, they essentially follow the same process:
|
||||||
|
|
||||||
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.
|
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.
|
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.
|
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.
|
4. Complete the cart to create the order.
|
||||||
|
|
||||||
:::note
|
:::info
|
||||||
|
|
||||||
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).
|
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
|
### Add to 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).
|
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:
|
In your `.env.local` file (or the file you’re using for your environment variables), add the following variable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
NEXT_PUBLIC_PAYPAL_CLIENT_ID=<CLIENT_ID>
|
NEXT_PUBLIC_PAYPAL_CLIENT_ID=<YOUR_CLIENT_ID>
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, install [PayPal’s React components](https://www.npmjs.com/package/@paypal/react-paypal-js) library:
|
Make sure to replace `<YOUR_CLIENT_ID>` with your PayPal Client ID.
|
||||||
|
|
||||||
```bash npm2yarn
|
Now, if you run your Medusa server and your storefront, on checkout you’ll be able to use PayPal].
|
||||||
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 (
|
|
||||||
<>
|
|
||||||
<PayPalScriptProvider options={{
|
|
||||||
"client-id": paypalClientId,
|
|
||||||
"currency": cart.region.currency_code.toUpperCase(),
|
|
||||||
"intent": "authorize"
|
|
||||||
}}>
|
|
||||||
{error && (
|
|
||||||
<span className="text-rose-500 mt-4">{error}</span>
|
|
||||||
)}
|
|
||||||
<PayPalButtons
|
|
||||||
style={{ layout: "horizontal" }}
|
|
||||||
onApprove={handleSubmit}
|
|
||||||
disabled={processing}
|
|
||||||
/>
|
|
||||||
</PayPalScriptProvider>
|
|
||||||
<button
|
|
||||||
className={styles.stepBack}
|
|
||||||
onClick={() => updateCheckoutStep(2)}
|
|
||||||
>
|
|
||||||
<BiLeftArrowAlt /> Back to shipping method
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (
|
|
||||||
<div key="paypal">
|
|
||||||
<h2>PayPal Payment</h2>
|
|
||||||
<Paypal />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
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.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
You can test out the payment with PayPal using your sandbox account.
|
You can test out the payment with PayPal using your sandbox account.
|
||||||
|
|
||||||
### Gatsby Storefront
|
### Add to 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).
|
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).
|
||||||
|
|
||||||
@@ -399,7 +290,7 @@ Now, start the Medusa server and the Gatsby storefront server. Try adding an ite
|
|||||||
|
|
||||||
You can test out the payment with PayPal using your sandbox account.
|
You can test out the payment with PayPal using your sandbox account.
|
||||||
|
|
||||||
### Custom Storefront
|
### Add to 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.
|
This section guides you to add PayPal into a React-based framework. The instructions are general instructions that you can use in your storefront.
|
||||||
|
|
||||||
@@ -503,7 +394,7 @@ If you run the Medusa server and the storefront server, you should see the PayPa
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Capture Payment
|
## Capture Payments
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
+134
-46
@@ -1,89 +1,177 @@
|
|||||||
# S3
|
# S3
|
||||||
|
|
||||||
In order to work with images in Medusa, you need a file service plugin responsible for hosting. Following this guide will allow you to upload images to AWS S3.
|
In this document, you’ll learn how to install the [S3 plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-file-s3) on your Medusa server and use it for storage.
|
||||||
|
|
||||||
### Before you start
|
## Overview
|
||||||
|
|
||||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusajs.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
To manage images in Medusa, you need a file service plugin responsible for hosting the images. Without a file service plugin, you will face issues while working with Medusa, such as when uploading images for products.
|
||||||
|
|
||||||
### Set up AWS
|
Medusa provides three different options to handle your file storage. This document focuses on using [S3](https://aws.amazon.com/s3/) to store your Medusa server’s images.
|
||||||
|
|
||||||
#### Create an S3 bucket
|
## Prerequisites
|
||||||
|
|
||||||
In the AWS console navigate to S3 and create a bucket for your images. Make sure to uncheck "Block _all_ public access".
|
### Medusa Server
|
||||||
|
|
||||||
Additionally, you need to add a policy to your bucket, that will allow public access to objects that are uploaded. Navigate to the permissions tab of your bucket and add the following policy:
|
A Medusa server is required to be set up before following along with this document. You can follow the [quickstart guide](../quickstart/quick-start.md) to get started in minutes.
|
||||||
|
|
||||||
```shell=
|
### Required Accounts
|
||||||
|
|
||||||
|
You need to [create an AWS account](https://console.aws.amazon.com/console/home?nc2=h_ct&src=header-signin) to follow along with this documentation.
|
||||||
|
|
||||||
|
## Create S3 Bucket
|
||||||
|
|
||||||
|
On your AWS Console, search for S3 in the search box at the top. Then, choose the first result you see which should be S3 under the Services category.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, on the new page that opens, click on Create Bucket button at the top right of the Buckets table.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The Create Bucket form will open. In the General Configuration section enter a name for the bucket and choose a region for the bucket. Both of the values of these fields are important as you’ll use them throughout the documentation.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Next, in the Object Ownership section, choose ACLs enabled. Then, 2 radio buttons will show below it. Choose Bucket owner preferred.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, in the “Block Public Access settings for this bucket” section, uncheck the “Block all public access” checkbox. This shows a warning message at the bottom of the section with another checkbox. Check the checkbox to ensure you understand that objects in the bucket are publicly accessible.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You can leave the rest of the fields in the form as is and scroll down to the end of the page. Then, click on the Create Bucket button.
|
||||||
|
|
||||||
|
## Manage Bucket Policies
|
||||||
|
|
||||||
|
On the page of the bucket you just created, click on the Permissions tab. Then, scroll down until you find the Bucket policy section. Click on Edit in that section.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the Edit Bucket Policy page, enter the following in the field:
|
||||||
|
|
||||||
|
```json
|
||||||
{
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
"Id": "Policy1397632521960",
|
"Id": "Policy1397632521960",
|
||||||
"Statement": [
|
"Statement": [
|
||||||
{
|
{
|
||||||
"Sid": "Stmt1397633323327",
|
"Sid": "Stmt1397633323327",
|
||||||
"Action": [
|
|
||||||
"s3:GetObject"
|
|
||||||
],
|
|
||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*",
|
|
||||||
"Principal": {
|
"Principal": {
|
||||||
"AWS": [
|
"AWS": "*"
|
||||||
"*"
|
},
|
||||||
]
|
"Action": "s3:GetObject",
|
||||||
}
|
"Resource": "arn:aws:s3:::<YOUR_BUCKET_NAME>/*"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Be aware, that this will allow for anyone to acces your bucket. Avoid storing sensitive data.
|
Make sure to replace `<YOUR_BUCKET_NAME>` with the name of the bucket you created.
|
||||||
|
|
||||||
#### Generate access keys
|
Once you’re done, scroll down and click on the Save changes button.
|
||||||
|
|
||||||
Navigate to the IAM section of your AWS console and perform the following steps:
|
### User Permissions
|
||||||
|
|
||||||
- Add a new user with programmatic access
|
Your user must have the `AmazonS3FullAccess` policy attached to it. You can refer to [this guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-and-attach-iam-policy.html) to learn how to add a policy if necessary.
|
||||||
- Add the existing **AmazonS3FullAccess** policy to the user
|
|
||||||
- Submit the details
|
|
||||||
|
|
||||||
Upon successfull creation of the user, you are presented with an **Access key ID** and a **Secret access key**. Note both of them down for later use.
|
### Obtain Access Keys
|
||||||
|
|
||||||
### Installation
|
You must obtain access keys for your user as you’ll use them to integrate the S3 plugin in Medusa with your bucket. To obtain the Access Key ID and the Secret Access Key, check out [this guide](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys).
|
||||||
|
|
||||||
First, install the plugin using your preferred package manager:
|
## Install the S3 Plugin
|
||||||
|
|
||||||
|
In the directory of your Medusa server, run the following command to install the S3 Plugin:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install medusa-file-s3
|
npm install medusa-file-s3
|
||||||
```
|
```
|
||||||
|
|
||||||
Then configure your `medusa-config.js` to include the plugin alongside the required options:
|
Then, add the following environment variables:
|
||||||
|
|
||||||
```=javascript
|
```bash
|
||||||
{
|
S3_URL=<YOUR_BUCKET_URL>
|
||||||
|
S3_BUCKET=<YOUR_BUCKET_NAME>
|
||||||
|
S3_REGION=<YOUR_BUCKET_REGION>
|
||||||
|
S3_ACCESS_KEY_ID=<YOUR_ACCESS_KEY_ID>
|
||||||
|
S3_SECRET_ACCESS_KEY=<YOUR_SECRET_ACCESS_KEY>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where:
|
||||||
|
|
||||||
|
1. `<YOUR_BUCKET_URL>` is the URL to your bucket. It’s in the form `https://<BUCKET_NAME>.s3.<REGION>.amazonaws.com`, where `<BUCKET_NAME>` is the name of the bucket and the `<REGION>` is the region the bucket is created in. If you’re not sure which region, on your bucket’s page on S3 click on Properties. You can then find the region under AWS Region. Make sure to only copy the code (for example, `us-east-1`).
|
||||||
|
2. `<YOUR_BUCKET_NAME>` is the name of the bucket you created.
|
||||||
|
3. `<YOUR_BUCKET_REGION>` is the region code of your bucket. For example, `us-east-1`.
|
||||||
|
4. `<YOUR_ACCESS_KEY_ID>` is the Access Key ID that you created for your user.
|
||||||
|
5. `<YOUR_SECRET_ACCESS_KEY>` is the Secret Access Key that you created for your user.
|
||||||
|
|
||||||
|
Finally, in `medusa-config.js`, add to the `plugins` array the following new item:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
const plugins = [
|
||||||
|
//...
|
||||||
|
{
|
||||||
resolve: `medusa-file-s3`,
|
resolve: `medusa-file-s3`,
|
||||||
options: {
|
options: {
|
||||||
s3_url: "https://s3-guide-test.s3.eu-west-1.amazonaws.com",
|
s3_url: process.env.S3_URL,
|
||||||
bucket: "test",
|
bucket: process.env.S3_BUCKET,
|
||||||
region: "eu-west-1"
|
region: process.env.S3_REGION,
|
||||||
access_key_id: "YOUR-ACCESS-KEY",
|
access_key_id: process.env.S3_ACCESS_KEY_ID,
|
||||||
secret_access_key: "YOUR-SECRET-KEY",
|
secret_access_key: process.env.S3_SECRET_ACCESS_KEY,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above options, an `s3_url` is included. The url has the following format:
|
:::caution
|
||||||
|
|
||||||
```shell=
|
If you have multiple storage plugins configured, the last plugin declared in the `medusa-config.js` file will be used.
|
||||||
https://[bucket].s3.[region].amazonaws.com
|
|
||||||
```
|
|
||||||
|
|
||||||
The two access keys in the options are the ones created in the previous section.
|
|
||||||
|
|
||||||
:::tip
|
|
||||||
|
|
||||||
Make sure to use an environment variable for the secret key in a live environment.
|
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Try it out
|
## Test the S3 Plugin
|
||||||
|
|
||||||
Finally, run your Medusa server alongside our admin system to try out your new file service. Upon editing or creating products, you can now upload thumbnails and images, that are stored in an AWS S3 bucket.
|
Run your Medusa server with the following command:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, you can either test the plugin using the [REST APIs](https://docs.medusajs.com/api/store) or using the [Medusa Admin](../admin/quickstart.md).
|
||||||
|
|
||||||
|
On the Medusa Admin, create a new product and, in the Images section, upload an image then click Save. If the integration was successful, the product image will be uploaded successfully.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You can also check that the image was uploaded on the S3 bucket’s page.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Next.js Storefront Configuration
|
||||||
|
|
||||||
|
If you’re using a [Next.js](../starters/nextjs-medusa-starter.md storefront, you need to add an additional configuration that adds the S3 bucket domain name into the configured images’ domain names. This is because all URLs of product images will be from the S3 bucket.
|
||||||
|
|
||||||
|
If this configuration is not added, you’ll receive the error ["next/image Un-configured Host”](https://nextjs.org/docs/messages/next-image-unconfigured-host).
|
||||||
|
|
||||||
|
In `next.config.js` add the following option in the exported object:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
module.exports = withStoreConfig({
|
||||||
|
//...
|
||||||
|
images: {
|
||||||
|
domains: [
|
||||||
|
//...
|
||||||
|
"<BUCKET_NAME>.s3.amazonaws.com"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<BUCKET_NAME>` is the name of the S3 bucket you’re using.
|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Check out [more plugins](https://github.com/medusajs/medusa/tree/master/packages) you can add to your store.
|
||||||
|
- Learn how to [deploy the Medusa server](../deployments/server/index.mdx).
|
||||||
|
- Learn about the [Next.js](../starters/nextjs-medusa-starter.md) and [Gatsby](../starters/gatsby-medusa-starter.md) storefronts.
|
||||||
@@ -1,103 +1,192 @@
|
|||||||
# Segment
|
# Segment
|
||||||
|
|
||||||
Modern e-commerce businesses have to integrate with a wide spectrum of tools from marketing and personalization to analytics and business intelligence. Integrations to these tools quickly become hard to maintain and new integrations become overly complex to implement putting a stretch on an e-commerce organization's resources.
|
In this document, you’ll learn about the [Segment plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-segment), what it does, and how to install and use it.
|
||||||
|
|
||||||
The CDP (Customer Data Platform) [Segment](https://segment.com/) solves this problem by allowing users to instantly integrate with +100 tools through a single unified API.
|
## Overview
|
||||||
|
|
||||||
Medusa has an official plugin `medusa-plugin-segment` that instantly gives you access to all Segment integrations and comes preconfigured with powerful server-side tracking
|
[Segment](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-segment) is a powerful Customer Data Platform that allows users to collect, transform, send and archive their customer data.
|
||||||
|
|
||||||
## Why Segment?
|
Segment allows users to manage different tracking and marketing tools using one API and interface, making it very simple to try out and integrate with different services in your ecommerce stack.
|
||||||
|
|
||||||
Segment is a powerful Customer Data Platform that allows users to collect, transform, send and archive their customer data.
|
|
||||||
|
|
||||||
Segment allows users to manage different tracking and marketing tools using one API and interface, making it very simple to try out and integrate with different services in your e-commerce stack.
|
|
||||||
|
|
||||||
Common integration use cases that can be implemented with Segment include:
|
Common integration use cases that can be implemented with Segment include:
|
||||||
|
|
||||||
|
- Google Analytics
|
||||||
- Mailchimp
|
- Mailchimp
|
||||||
- Klaviyo
|
- Zendesk
|
||||||
- Google Analytics Enhanced E-commerce tracking
|
|
||||||
- Data warehousing for advanced data analytics and segmentation through services like Snowflake
|
- Data warehousing for advanced data analytics and segmentation through services like Snowflake
|
||||||
|
|
||||||
## Adding Segment to your Medusa store
|
The Segment plugin in Medusa allows you to track ecommerce events and record them in Segment. Then, you can push these events to other destinations using Segment.
|
||||||
|
|
||||||
:::note
|
### Events That the Segment Plugin Tracks
|
||||||
|
|
||||||
You should create a [Node.js source in Segment](https://segment.com/docs/connections/sources/catalog/libraries/server/node/quickstart/) in order to obtain the write key that will be provided in the plugin options.
|
By default, the Segment plugin tracks the following events:
|
||||||
|
|
||||||
|
1. `order.placed`: Triggered when an order is placed.
|
||||||
|
2. `order.shipment_created`: Triggered when a shipment is created for an order.
|
||||||
|
3. `claim.created`: Triggered when a new claim is created.
|
||||||
|
4. `order.items_returned`: Triggered when an item in an order is returned.
|
||||||
|
5. `order.canceled`: Triggered when an order is canceled.
|
||||||
|
6. `swap.created`: Triggered when a swap is created.
|
||||||
|
7. `swap.shipment_created`: Triggered when a shipment is created for a swap.
|
||||||
|
8. `swap.payment_completed`: Triggered when payment for a swap is completed.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
Check out the [Event Reference](../advanced/backend/subscribers/events-list.md) to learn about all available events in Medusa.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
Plugins in Medusa's ecosystem come as separate npm packages, that can be installed from the npm registry.
|
## Prerequisites
|
||||||
|
|
||||||
|
### Medusa Server
|
||||||
|
|
||||||
|
It is assumed you already have a Medusa server installed. If not, please follow the [Quickstart guide](../quickstart/quick-start.md) to get started in minutes.
|
||||||
|
|
||||||
|
In addition, make sure to have Redis installed and configured with your Medusa server. If not, follow [this documentation](../tutorial/0-set-up-your-development-environment.mdx#redis) to install Redis and then [configure it](../usage/configurations.md#redis).
|
||||||
|
|
||||||
|
### Segment Account
|
||||||
|
|
||||||
|
You need to [create a Segment account](https://app.segment.com/signup/) to follow along with the tutorial. Segment offers a free plan to get started quickly.
|
||||||
|
|
||||||
|
## Create a Segment Source
|
||||||
|
|
||||||
|
On your Segment dashboard, choose Catalog from the sidebar under Connections.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, in the catalog list find the Server category and choose Node.js from the list.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This opens a new side menu. In the side menu, click on Add Source.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This opens a new page to create a Node.js source. Enter the name of the source then click Add Source.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
On the new source dashboard, you should find a Write Key. You’ll use this key in the next section after you install the Segment plugin on your Medusa server.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Optional: Add Destination
|
||||||
|
|
||||||
|
After you create the Segment source, you can add destinations. This is where the data is sent when you send them to Segment. You can add more than one destination.
|
||||||
|
|
||||||
|
To add a destination, on the same Segment source page, click on Add Destination in the Destinations section.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You can then choose from a list of destinations such as Google Universal Analytics or Facebook Pixel.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The process of integrating each destination is different, so you must follow the steps detailed in Segment for each destination you choose.
|
||||||
|
|
||||||
|
## Install the Segment Plugin
|
||||||
|
|
||||||
|
In the directory of your Medusa server, run the following command to install the Segment plugin:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install medusa-plugin-segment
|
npm install medusa-plugin-segment
|
||||||
```
|
```
|
||||||
|
|
||||||
After installation open `medusa-config.js` to configure the Segment plugin, by adding it to your project's plugin array and providing the options required by the plugin, namely the write key obtained from the Segment dashboard.
|
Then, add the following environment variable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
SEGMENT_WRITE_KEY=<YOUR_SEGMENT_WRITE_KEY>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_SEGMENT_WRITE_KEY>` is the Write Key shown on the page of the Segment source you created in the previous section.
|
||||||
|
|
||||||
|
Finally, in `medusa-config.js`, add the following new item to the `plugins` array:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
{
|
const plugins = [
|
||||||
|
//...
|
||||||
|
{
|
||||||
resolve: `medusa-plugin-segment`,
|
resolve: `medusa-plugin-segment`,
|
||||||
options: {
|
options: {
|
||||||
write_key: SEGMENT_WRITE_KEY,
|
write_key: process.env.SEGMENT_WRITE_KEY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
After the plugin has been configured you will get instant access to +100 services through the Segment dashboard. This allows you to try out new services for your e-commerce stack without having to make heavy integration investments.
|
## Test the Plugin
|
||||||
|
|
||||||
## Default tracking
|
Run your server with the following command:
|
||||||
|
|
||||||
`medusa-plugin-segment` comes with prebuilt tracking for common flows for Orders, Returns, Swaps, and Claims. Where applicable the events follow the [Segment Ecommerce Spec](https://segment.com/docs/connections/spec/ecommerce/v2/).
|
```bash npm2yarn
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
Below is a list of some of the events that are tracked by default:
|
Then, try triggering one of the [mentioned events earlier in this document](#events-that-the-segment-plugin-tracks). For example, you can place an order either using the [REST APIs](https://docs.medusajs.com/api/store) or using the [Next.js](../starters/nextjs-medusa-starter.md) or [Gatsby](../starters/gatsby-medusa-starter.md) storefronts.
|
||||||
|
|
||||||
- Orders
|
After you place an order, on the Segment source that you created, click on the Debugger tab. You should see at least one event triggered for each order you place. If you click on the event, you can see the order details are passed to the event.
|
||||||
- Order Completed
|
|
||||||
- Order Shipped
|
|
||||||
- Order Refunded ← Without returned products
|
|
||||||
- Order Cancelled
|
|
||||||
- Returns
|
|
||||||
- Order Refunded ← With returned products
|
|
||||||
- Swaps
|
|
||||||
- Swap Created
|
|
||||||
- Swap Confirmed
|
|
||||||
- Swap Shipped
|
|
||||||
- Claims
|
|
||||||
- Item Claimed
|
|
||||||
|
|
||||||
The default events serve as a good foundation for e-commerce tracking, allowing you to answer questions regarding product performance, return ratios, claim statistics, and more.
|

|
||||||
|
|
||||||
In many cases you will want to track other events that are specific to your store - this is also possible through the Segment plugin, as the plugin registers the `segmentService` in your Medusa project.
|
If you added a destination, you can also check your destination to make sure the data is reflected there.
|
||||||
|
|
||||||
## Tracking custom events
|
:::note
|
||||||
|
|
||||||
Building from the custom functionality that can be guided by [the tutorial](https://docs.medusajs.com/tutorial/adding-custom-functionality) in Medusa docs, imagine that you want to track all welcome opt-ins.
|
If the data is not appearing on the destination, the issue is related to your configuration between the Segment source and destination and not related to the Segment plugin. Go over the steps that Segment showed you when you added the destination to figure out the issue.
|
||||||
|
|
||||||
The `segmentService` exposes a `track` method that wraps [Segment's Track Spec](https://segment.com/docs/connections/spec/track/), allowing you to send events to the Segment from anywhere in your Medusa project.
|
:::
|
||||||
|
|
||||||
For example, to add tracking of the opt-ins in the `POST /welcome/:cart_id` endpoint, you could add the following code:
|
## Add Custom Tracking
|
||||||
|
|
||||||
|
In some cases, you might want to track more events or custom events. You can do that using the `SegmentService` provided by the Segment Plugin.
|
||||||
|
|
||||||
|
For example, you can add the following subscriber to listen to the `customer.created` event and add tracking for every customer created:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
const segmentService = req.scope.resolve("segmentService")
|
class CustomerSubscriber {
|
||||||
segmentService.track({
|
constructor({ segmentService, eventBusService }) {
|
||||||
event: "Welcome Opt-In Registered",
|
this.segmentService = segmentService;
|
||||||
properties: {
|
|
||||||
cart_id,
|
eventBusService.subscribe("customer.created", this.handleCustomer);
|
||||||
optin,
|
}
|
||||||
},
|
|
||||||
})
|
handleCustomer = async (data) => {
|
||||||
|
const customerData = data;
|
||||||
|
delete customerData['password_hash'];
|
||||||
|
|
||||||
|
this.segmentService.track({
|
||||||
|
event: 'Customer Created',
|
||||||
|
userId: data.id,
|
||||||
|
properties: customerData
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CustomerSubscriber;
|
||||||
```
|
```
|
||||||
|
|
||||||
The above snippet would send an event to Segment for further processing. The event data could be used for:
|
You resolve the `SegmentService` using dependency injection. Then, when the `customer.created` event is triggered, you use the `track` method available in the `SegmentService` to send tracking data to Segment.
|
||||||
|
|
||||||
- Segmentation of a mailing list in MailChimp or Klaviyo based on whether the customer opted in for welcomes
|
:::info
|
||||||
- Storage in the data warehouse for later analysis to answer questions like "Are customers who opt-in for welcomes more likely to become recurring customers?"
|
|
||||||
- Integration to Google Analytics's events
|
|
||||||
- etc.
|
|
||||||
|
|
||||||
## What's next?
|
Services can be resolved and used in Subscribers, endpoints, and other Services. Learn [how to resolve services in the Services documentation](../advanced/backend/services/create-service.md#using-your-custom-service).
|
||||||
|
|
||||||
This article covers the introduction to one of many Medusa plugins and an explanation of how you can enhance your e-commerce stack, which will help you to build a successful e-commerce project.
|
:::
|
||||||
|
|
||||||
Not sure where to start? We are happy to help and talk to you at our [Discord](https://discord.gg/EA5pd3WG)!
|
`track` accepts an object of data, where the keys `event` and `userId` are required. Instead of `userId`, you can use `anonymousId` to pass an anonymous user ID.
|
||||||
|
|
||||||
|
If you want to pass additional data to Segment, pass them under the `properties` object key.
|
||||||
|
|
||||||
|
The `SegmentServer` also provides the method `identify` to tie a user to their actions or specific traits.
|
||||||
|
|
||||||
|
### Test Custom Tracking
|
||||||
|
|
||||||
|
After adding the above subscriber, run your server again if it isn’t running and create a customer using the REST APIs or one of the Medusa storefronts. If you check the Debugger in your Segment source, you should see a new event “Customer Created” tracked. If you click on it, you’ll see the data you passed to the `track` method.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Learn how [services](../advanced/backend/services/create-service.md) and [subscribers](../advanced/backend/subscribers/create-subscriber.md) work.
|
||||||
|
- Check out a [full list of events](../advanced/backend/subscribers/events-list.md) in Medusa.
|
||||||
|
- Learn how to [deploy the Medusa server](../deployments/server/index.mdx).
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Spaces
|
# Spaces
|
||||||
|
|
||||||
In order to work with images in Medusa, you need a file service plugin responsible for hosting. Following this guide will allow you to upload images to DigitalOcean Spaces.
|
In this document, you’ll learn how to install the [Spaces plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-file-spaces) on your Medusa server and use it for storage.
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<video width="100%" height="100%" playsinline autoplay muted controls>
|
<video width="100%" height="100%" playsinline autoplay muted controls>
|
||||||
@@ -8,51 +8,157 @@ In order to work with images in Medusa, you need a file service plugin responsib
|
|||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
### Before you start
|
## Overview
|
||||||
|
|
||||||
At this point, you should have an instance of our store engine running. If not, we have a [full guide](https://docs.medusajs.com/tutorial/set-up-your-development-environment) for setting up your local environment.
|
To manage images in Medusa, you need a file service plugin responsible for hosting the images. Without a file service plugin, you will face issues while working with Medusa, such as when uploading images for products.
|
||||||
|
|
||||||
### Set up DigitalOcean
|
Medusa provides three different options to handle your file storage. This document focuses on using [Spaces](https://www.digitalocean.com/products/spaces) to store your Medusa server’s images.
|
||||||
|
|
||||||
#### Create a Space
|
## Prerequisites
|
||||||
|
|
||||||
Create an account on DigitalOcean and navigate to Spaces. Create a new Space with the default settings.
|
### Medusa Server
|
||||||
|
|
||||||
#### Generate access keys
|
A Medusa server is required to be set up before following along with this document. You can follow the [quickstart guide](../quickstart/quick-start.md) to get started in minutes.
|
||||||
|
|
||||||
Navigate to API in the left sidebar. Generate a new Spaces access key. This should provide you with an access key id and a secret key. Note them both down.
|
### Required Accounts
|
||||||
|
|
||||||
### Installation
|
You need to [create a DigitalOcean account](https://cloud.digitalocean.com/registrations/new) to follow along with this documentation. A credit card is required during registration.
|
||||||
|
|
||||||
First, install the plugin using your preferred package manager:
|
## Create DigitalOcean Space
|
||||||
|
|
||||||
|
In your DigitalOcean account, click on the Create button at the top right, then choose Spaces from the dropdown.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the Create a Space form, you can choose any of the regions listed. You can alternatively leave all settings as they are and scroll down to the Finalize and Create section.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the Finalize and Create section, enter a name for the field “Choose a unique name”. You’ll use this name later in the integration with Medusa. Also, select the project you want to add the new Space to.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done, click on the Create a Space button. This creates the Space and redirects you to the Space’s page.
|
||||||
|
|
||||||
|
## Create Space Access Keys
|
||||||
|
|
||||||
|
Choose API from the bottom of the sidebar.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This opens the Application & API page. Scroll down to Spaces Access Keys and click the Generate New Key button.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This shows a table with the Name field editable. Enter a name for the Access Keys and click on the checkmark button to save and generate the Spaces access keys.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, two keys will be available under the Key column of the table. The first one is the Access Key ID and the second is the Secret Access Key. Copy both as you’ll use them later.
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
The secret access key will not be shown again after you leave the page. Make sure to copy it when you see it or you’ll need to re-generate a new one.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Install the Spaces Plugin
|
||||||
|
|
||||||
|
In the directory of your Medusa server, run the following command to install the Spaces plugin:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install medusa-file-spaces
|
npm install medusa-file-spaces
|
||||||
```
|
```
|
||||||
|
|
||||||
Then configure your `medusa-config.js` to include the plugin alongside the required options:
|
Then, add the following environment variables:
|
||||||
|
|
||||||
```=javascript
|
```bash
|
||||||
{
|
SPACE_URL=<YOUR_SPACE_URL>
|
||||||
resolve: `medusa-file-spaces`,
|
SPACE_BUCKET=<YOUR_SPACE_NAME>
|
||||||
options: {
|
SPACE_ENDPOINT=<YOUR_SPACE_ENDPOINT>
|
||||||
spaces_url: "https://test.fra1.digitaloceanspaces.com",
|
SPACE_ACCESS_KEY_ID=<YOUR_ACCESS_KEY_ID>
|
||||||
bucket: "test",
|
SPACE_SECRET_ACCESS_KEY=<YOUR_SECRET_ACCESS_KEY>
|
||||||
endpoint: "fra1.digitaloceanspaces.com",
|
|
||||||
access_key_id: "YOUR-ACCESS-KEY",
|
|
||||||
secret_access_key: "YOUR-SECRET-KEY",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above options, a `spaces_url` is included. This can be found in your Space overview. The `bucket` should point to the name you gave your Space. The `endpoint` identifies the region in which you created the Space. And finally the two keys are the ones created in the previous section.
|
Where:
|
||||||
|
|
||||||
:::tip
|
1. `<YOUR_SPACE_URL>` is the URL of your Space which you can find on the Space’s page below the Space’s name.
|
||||||
|
|
||||||
Make sure to use an environment variable for the secret key in a live environment.
|

|
||||||
|
|
||||||
|
2. `<YOUR_SPACE_NAME>` is the name of your Space.
|
||||||
|
3. `<YOUR_SPACE_ENDPOINT>` is your Space’s endpoint which can be found by going to your Space’s page, clicking on the Settings tab, and scrolling to the Endpoint section.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
4. `<YOUR_ACCESS_KEY_ID>` and `<YOUR_SECRET_ACCESS_KEY>` are the keys you created in the previous section.
|
||||||
|
|
||||||
|
Finally, in `medusa-config.js` add a new item to the `plugins` array:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
const plugins = [
|
||||||
|
//...
|
||||||
|
{
|
||||||
|
resolve: `medusa-file-spaces`,
|
||||||
|
options: {
|
||||||
|
spaces_url: process.env.SPACE_URL,
|
||||||
|
bucket: process.env.SPACE_BUCKET,
|
||||||
|
endpoint: process.env.SPACE_ENDPOINT,
|
||||||
|
access_key_id: process.env.SPACE_ACCESS_KEY_ID,
|
||||||
|
secret_access_key: process.env.SPACE_SECRET_ACCESS_KEY,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
If you have multiple storage plugins configured, the last plugin declared in the `medusa-config.js` file will be used.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Try it out!
|
## Test the Space Plugin
|
||||||
|
|
||||||
Finally, run your Medusa server alongside our admin system to try out your new file service. Upon editing or creating products, you can now upload thumbnails and images, that are stored in DigitalOcean Spaces.
|
Run your Medusa server with the following command:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, you can either test the plugin using the [REST APIs](https://docs.medusajs.com/api/store) or using the [Medusa Admin](../admin/quickstart.md).
|
||||||
|
|
||||||
|
On the Medusa Admin, create a new product and, in the Images section, upload an image then click Save. If the integration was successful, the product image will be uploaded successfully.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You can also check that the image was uploaded on the Space’s page.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Next.js Storefront Configuration
|
||||||
|
|
||||||
|
If you’re using a [Next.js](../starters/nextjs-medusa-starter.md) storefront, you need to add an additional configuration that adds the Space’s domain name into the configured images’ domain names. This is because all URLs of product images will be from the Space.
|
||||||
|
|
||||||
|
If this configuration is not added, you’ll receive the error ["next/image Un-configured Host”](https://nextjs.org/docs/messages/next-image-unconfigured-host).
|
||||||
|
|
||||||
|
In `next.config.js` add the following option in the exported object:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
module.exports = withStoreConfig({
|
||||||
|
//...
|
||||||
|
images: {
|
||||||
|
domains: [
|
||||||
|
//...
|
||||||
|
"<YOUR_SPACE_DOMAIN>"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_SPACE_DOMAIN>` is the domain name for your Space which can be retrieved from the Space URL. For example, `medusa-server.fra1.digitaloceanspaces.com`.
|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Check out [more plugins](https://github.com/medusajs/medusa/tree/master/packages) you can add to your store.
|
||||||
|
- Learn how to [deploy the Medusa server on DigitalOcean](../deployments/server/deploying-on-digital-ocean.md).
|
||||||
|
- Learn about the [Next.js](../starters/nextjs-medusa-starter.md) and [Gatsby](../starters/gatsby-medusa-starter.md) storefronts.
|
||||||
@@ -28,7 +28,7 @@ This section guides you over the steps necessary to add Stripe as a payment prov
|
|||||||
|
|
||||||
If you don’t have a Medusa server installed yet, you must follow our [quickstart guide](../quickstart/quick-start) first.
|
If you don’t have a Medusa server installed yet, you must follow our [quickstart guide](../quickstart/quick-start) first.
|
||||||
|
|
||||||
### Plugin Installation
|
### Install the Stripe Plugin
|
||||||
|
|
||||||
In the root of your Medusa server, run the following command to install the stripe plugin:
|
In the root of your Medusa server, run the following command to install the stripe plugin:
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ In the root of your Medusa server, run the following command to install the stri
|
|||||||
npm install medusa-payment-stripe
|
npm install medusa-payment-stripe
|
||||||
```
|
```
|
||||||
|
|
||||||
### Plugin Configuration
|
### Configure the Stripe Plugin
|
||||||
|
|
||||||
Next, you need to add configurations for your stripe plugin.
|
Next, you need to add configurations for your stripe plugin.
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ You might find that this code is already available but commented out. You can pr
|
|||||||
|
|
||||||
The Stripe plugin uses 2 configuration options. The `api_key` is essential to both your development and production environments. As for the `webhook_secret`, it’s essential for your production environment. So, if you’re only using Stripe for development you can skip adding the value for this option at the moment.
|
The Stripe plugin uses 2 configuration options. The `api_key` is essential to both your development and production environments. As for the `webhook_secret`, it’s essential for your production environment. So, if you’re only using Stripe for development you can skip adding the value for this option at the moment.
|
||||||
|
|
||||||
### Retrieving The Keys
|
### Retrieve Stripe's Keys
|
||||||
|
|
||||||
On the [dashboard](https://dashboard.stripe.com) of your Stripe account click on the Developers link at the top right. This will take you to the developer dashboard.
|
On the [dashboard](https://dashboard.stripe.com) of your Stripe account click on the Developers link at the top right. This will take you to the developer dashboard.
|
||||||
|
|
||||||
@@ -89,10 +89,10 @@ The endpoint for Stripe’s webhook on your Medusa server is `{SERVER_URL}/strip
|
|||||||
|
|
||||||
Then, you can add a description. You must select at least one event to listen to. Once you’re done, click “Add endpoint”.
|
Then, you can add a description. You must select at least one event to listen to. Once you’re done, click “Add endpoint”.
|
||||||
|
|
||||||
After the Webhook is created, you’ll see a key at the top right that starts with `we_...`. Copy that key and in your Medusa server add the Webhook secret environment variable:
|
After the Webhook is created, you’ll see "Signing secret" in the Webhook details. Click on "Reveal" to reveal the secret key. Copy that key and in your Medusa server add the Webhook secret environment variable:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
STRIPE_WEBHOOK_SECRET=we_...
|
STRIPE_WEBHOOK_SECRET=whsec_...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Admin Setup
|
## Admin Setup
|
||||||
@@ -101,11 +101,11 @@ This section will guide you through adding Stripe as a payment provider in a reg
|
|||||||
|
|
||||||
This step is required for you to be able to use Stripe as a payment provider in your storefront.
|
This step is required for you to be able to use Stripe as a payment provider in your storefront.
|
||||||
|
|
||||||
### Prerequisites
|
### Admin Prerequisites
|
||||||
|
|
||||||
If you don’t have a Medusa admin installed, make sure to follow along with [the guide on how to install it](https://github.com/medusajs/admin#-quickstart) before continuing with this section.
|
If you don’t have a Medusa admin installed, make sure to follow along with [the guide on how to install it](https://github.com/medusajs/admin#-quickstart) before continuing with this section.
|
||||||
|
|
||||||
### Adding Stripe
|
### Add Stripe to Regions
|
||||||
|
|
||||||
First, make sure that both your Medusa server and Medusa Admin are running.
|
First, make sure that both your Medusa server and Medusa Admin are running.
|
||||||
|
|
||||||
@@ -123,31 +123,27 @@ Once you’re done, click Save. Stripe is now a payment provider in your store i
|
|||||||
|
|
||||||
This guide will take you through how to set up Stripe payments in your Medusa storefront. It includes the steps necessary when using one of Medusa’s official storefronts as well as your own custom React-based storefront.
|
This guide will take you through how to set up Stripe payments in your Medusa storefront. It includes the steps necessary when using one of Medusa’s official storefronts as well as your own custom React-based storefront.
|
||||||
|
|
||||||
### Prerequisites
|
### Storefront Prerequisites
|
||||||
|
|
||||||
All storefronts require that you obtain your Stripe’s Publishable Key. You can retrieve it from your Stripe’s developer dashboard by choosing API Keys and then copying the Publishable Key.
|
All storefronts require that you obtain your Stripe’s Publishable Key. You can retrieve it from your Stripe’s developer dashboard by choosing API Keys and then copying the Publishable Key.
|
||||||
|
|
||||||
### Next.js Storefront
|
### Add to 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).
|
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).
|
||||||
|
|
||||||
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 Publishable Key:
|
In your `.env.local` file (or the file you’re using for your environment variables), add the following variable:
|
||||||
|
|
||||||
```jsx
|
```bash
|
||||||
NEXT_PUBLIC_STRIPE_KEY=pk_...
|
NEXT_PUBLIC_STRIPE_KEY=<YOUR_PUBLISHABLE_KEY>
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
Make sure to replace `<YOUR_PUBLISHABLE_KEY>` with your Stripe Publishable Key.
|
||||||
|
|
||||||
This variable might be available in your `.env` file but commented out. You can instead remove the comment and change its value.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
Now, if you run your Medusa server and your storefront, on checkout you’ll be able to use Stripe.
|
Now, if you run your Medusa server and your storefront, on checkout you’ll be able to use Stripe.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Gatsby Storefront
|
### Add to Gatsby Storefront
|
||||||
|
|
||||||
Medusa also has a Gatsby storefront that you can use as your ecommerce store. If you don’t have the storefront installed, you can follow [this quickstart guide](../starters/gatsby-medusa-starter).
|
Medusa also has a Gatsby storefront that you can use as your ecommerce store. If you don’t have the storefront installed, you can follow [this quickstart guide](../starters/gatsby-medusa-starter).
|
||||||
|
|
||||||
@@ -167,7 +163,7 @@ Now, if you run your Medusa server and your storefront, on checkout you’ll be
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Custom Storefront
|
### Add to Custom Storefront
|
||||||
|
|
||||||
This section will go over how to add Stripe into a React-based framework. The instructions are general instructions that you can use in your storefront.
|
This section will go over how to add Stripe into a React-based framework. The instructions are general instructions that you can use in your storefront.
|
||||||
|
|
||||||
@@ -180,7 +176,7 @@ The integration with stripe must have the following workflow:
|
|||||||
3. After the user enters their card details and submits the form, confirm the payment with Stripe.
|
3. After the user enters their card details and submits the form, confirm the payment with Stripe.
|
||||||
4. If the payment is confirmed successfully, [complete the order](https://docs.medusajs.com/api/store/cart/complete-a-cart) in Medusa. Otherwise show an error.
|
4. If the payment is confirmed successfully, [complete the order](https://docs.medusajs.com/api/store/cart/complete-a-cart) in Medusa. Otherwise show an error.
|
||||||
|
|
||||||
#### Installing Dependencies
|
#### Install Dependencies
|
||||||
|
|
||||||
Before you start the implementations you need to install the necessary dependencies. You’ll be using Stripe’s React libraries to show the UI and handle the payment confirmation:
|
Before you start the implementations you need to install the necessary dependencies. You’ll be using Stripe’s React libraries to show the UI and handle the payment confirmation:
|
||||||
|
|
||||||
@@ -360,7 +356,7 @@ If you run your server and storefront now, you’ll see the Stripe UI element an
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Capturing Payment
|
## Capture Payments
|
||||||
|
|
||||||
After the customer places an order, you’ll be able to see the order on the admin panel. In the payment information under the “Payment” section, you should see a “Capture” button.
|
After the customer places an order, you’ll be able to see the order on the admin panel. In the payment information under the “Payment” section, you should see a “Capture” button.
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ If you’re not very familiar with Medusa’s architecture, you can learn more a
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
<!-- ## Instant Deployment to Netlify
|
## Instant Deployment to Netlify
|
||||||
|
|
||||||
Instead of manually following this guide to install then later deploy the Medusa Admin, you can deploy the Medusa Admin to Netlify with this button:
|
Instead of manually following this guide to install then later deploy the Medusa Admin, you can deploy the Medusa Admin to Netlify with this button:
|
||||||
|
|
||||||
[](https://app.netlify.com/start/deploy?repository=https://github.com/medusajs/admin) -->
|
[](https://app.netlify.com/start/deploy?repository=https://github.com/medusajs/admin)
|
||||||
|
|
||||||
## Install the Admin
|
## Install the Admin
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ An example of a flow that can be implemented using Medusa's Notification API is
|
|||||||
|
|
||||||
## What’s Next 🚀
|
## What’s Next 🚀
|
||||||
|
|
||||||
- Learn how to create your own Notification Provider.
|
- Learn how to [create your own Notification Provider](how-to-create-notification-provider.md).
|
||||||
- Check out the [list of events](../subscribers/events-list.md) in Medusa.
|
- Check out the [list of events](../subscribers/events-list.md) in Medusa.
|
||||||
- Check the [`NotificationService`](../../../references/services/classes/NotificationService.md) API reference for more details on how it works.
|
- Check the [`NotificationService`](../../../references/services/classes/NotificationService.md) API reference for more details on how it works.
|
||||||
- Check out the [SendGrid](../../../add-plugins/sendgrid.mdx) Notification plugin.
|
- Check out the [SendGrid](../../../add-plugins/sendgrid.mdx) Notification plugin.
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ Where `medusa-plugin-custom` is the name of the plugin you’re creating. In Med
|
|||||||
|
|
||||||
By convention, all plugin names start with `medusa` followed by a descriptive name of what the plugin does. For example, the Stripe plugin is named `medusa-payment-stripe`.
|
By convention, all plugin names start with `medusa` followed by a descriptive name of what the plugin does. For example, the Stripe plugin is named `medusa-payment-stripe`.
|
||||||
|
|
||||||
|
### Rename Project Name
|
||||||
|
|
||||||
|
Update the `name` field in the `package.json` file to the name of your plugin. This should be the same name that you chose when running the `medusa new` command.
|
||||||
|
|
||||||
### Project Structure
|
### Project Structure
|
||||||
|
|
||||||
The command above creates a new directory `medusa-plugin-custom` that holds essentially the same codebase you would have for a Medusa server. This is because a plugin has the same directory structure as a Medusa server.
|
The command above creates a new directory `medusa-plugin-custom` that holds essentially the same codebase you would have for a Medusa server. This is because a plugin has the same directory structure as a Medusa server.
|
||||||
@@ -266,6 +270,50 @@ Finally, start your server and test your plugin’s functionalities:
|
|||||||
npm run start
|
npm run start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Troubleshoot Errors
|
||||||
|
|
||||||
|
#### Error: The class must be a valid service implementation
|
||||||
|
|
||||||
|
Please make sure that your plugin is following the correct structure. If the error persists then please try the following fix:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
cd <SERVER_PATH>/node_modules/medusa-interfaces
|
||||||
|
npm link
|
||||||
|
cd <PLUGIN_PATH>
|
||||||
|
rm -rf node_modules/medusa-interfaces
|
||||||
|
npm link medusa-interfaces
|
||||||
|
npm link
|
||||||
|
cd <SERVER_PATH>
|
||||||
|
npm link your-plugin
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<SERVER_PATH>` is the path to your Medusa server and `<PLUGIN_PATH>` is the path to your plugin.
|
||||||
|
|
||||||
|
This links the `medusa-interfaces` package from your `medusa-backend` to your plugin directory and then links your plugin to your `medusa-backend`.
|
||||||
|
|
||||||
|
#### APIs not loading
|
||||||
|
|
||||||
|
If the APIs you added to your Medussa server are not loading then please try the following steps:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
cd <PLUGIN_PATH>
|
||||||
|
rm -rf node_modules
|
||||||
|
cd <SERVER_PATH>/node_modules/<PLUGIN_NAME>
|
||||||
|
npm install
|
||||||
|
cd <PLUGIN_PATH>
|
||||||
|
npm build
|
||||||
|
cd <SERVER_PATH>
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<SERVER_PATH>` is the path to your Medusa server, `<PLUGIN_PATH>` is the path to your plugin and `<PLUGIN_NAME>` is the name of your plugin as it is in your plugin `package.json` file.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
It is safe to ignore any `cross-env: command not found` error you may receive.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## NPM Ignore File
|
## NPM Ignore File
|
||||||
|
|
||||||
Not all files that you use while developing your plugin are necessary to be published.
|
Not all files that you use while developing your plugin are necessary to be published.
|
||||||
|
|||||||
@@ -67,6 +67,16 @@ async getProductCount() {
|
|||||||
|
|
||||||
You can use your custom service throughout your Medusa server just like you would use any of the core services.
|
You can use your custom service throughout your Medusa server just like you would use any of the core services.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
Before using your service, make sure you run the `build` command:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
### In a Service
|
### In a Service
|
||||||
|
|
||||||
To use your custom service in another custom service, you can have easy access to it in the dependencies injected to the constructor of your service:
|
To use your custom service in another custom service, you can have easy access to it in the dependencies injected to the constructor of your service:
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
In this document, you’ll learn how to deploy the Medusa Admin on [Netlify](https://www.netlify.com/).
|
In this document, you’ll learn how to deploy the Medusa Admin on [Netlify](https://www.netlify.com/).
|
||||||
|
|
||||||
<!-- Alternatively, you can use this button to deploy the Medusa Admin to Netlify directly:
|
Alternatively, you can use this button to deploy the Medusa Admin to Netlify directly:
|
||||||
|
|
||||||
[](https://app.netlify.com/start/deploy?repository=https://github.com/medusajs/admin) -->
|
[](https://app.netlify.com/start/deploy?repository=https://github.com/medusajs/admin)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -16,9 +16,8 @@ Additionally, this documentation does not cover how to deploy the Medusa server.
|
|||||||
|
|
||||||
### Needed Accounts
|
### Needed Accounts
|
||||||
|
|
||||||
You need a Netlify account to deploy the Medusa Admin. If you don’t have one, you can create one on [Netlify’s website](https://app.netlify.com/signup?_ga=2.249228995.556918419.1656505909-2004101041.1655191129).
|
- A [Netlify](https://app.netlify.com/signup) account to deploy the Medusa Admin.
|
||||||
|
- A [GitHub](https://github.com/signup) account where you will host the repository for the Medusa admin.
|
||||||
Additionally, you need a GitHub account where you will host the repository for the Medusa admin. You can create it on [GitHub’s website](https://github.com/signup).
|
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ If you want to use another Git Provider, it’s possible to follow along with th
|
|||||||
|
|
||||||
### Required Tools
|
### Required Tools
|
||||||
|
|
||||||
Git’s CLI tool is required while following along with this tutorial. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
- Git’s CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
||||||
|
|
||||||
## Create GitHub Repository
|
## Create GitHub Repository
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,49 @@
|
|||||||
# Deploying on DigitalOcean App Platform
|
# Deploy Your Medusa Server to DigitalOcean Apps
|
||||||
|
|
||||||
This is a guide for deploying a Medusa project on DigitalOcean App Platform.
|
In this document, you'll learn how to deploy your Medusa server to a DigitalOcean App.
|
||||||
|
|
||||||
:::note
|
DigitalOcean is a reliable hosting provider that provides different ways to host websites and servers. One way to host a server is using their DigitalOcean App Platform.
|
||||||
|
|
||||||
It is assumed, that you are currently running a local instance of Medusa. If not, check out our [Quickstart](https://docs.medusajs.com/quickstart/quick-start) or use `npx create-medusa-app` to set up your application in a matter of minutes. For the latter, see [this guide](../../usage/create-medusa-app.mdx) for a small walkthrough.
|
## Prerequisites
|
||||||
|
|
||||||
|
### Medusa Server
|
||||||
|
|
||||||
|
It is assumed that you already have a Medusa server installed locally. If you don’t, please follow our [quickstart guide](../../quickstart/quick-start.md).
|
||||||
|
|
||||||
|
Furthermore, your Medusa server should be configured to work with PostgreSQL and Redis. You can follow the [Configure your Server documentation](../../usage/configurations.md) to learn how to do that.
|
||||||
|
|
||||||
|
### Needed Accounts
|
||||||
|
|
||||||
|
- A [DigitalOcean](https://cloud.digitalocean.com/registrations/new) account. You need to provide a payment method on sign up.
|
||||||
|
- A [GitHub](https://github.com/) account to create a repository to host your server’s codebase.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
If you want to use another Git Provider supported by DigitalOcean, it’s possible to follow along with this guide but you’ll have to perform the equivalent steps in your Git Provider.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### 1. Configure Medusa
|
### Required Tools
|
||||||
|
|
||||||
Before jumping into DigitalOcean, your Medusa application needs to be configured.
|
- Git’s CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
||||||
|
|
||||||
#### Update `medusa-config.js`
|
## Changes to package.json
|
||||||
|
|
||||||
Instead of using a single environment variable for the database, `DATABASE_URL`, set `DB_*` variables and declare `DATABASE_URL` like so:
|
Change the `start` script in `package.json` to the following:
|
||||||
|
|
||||||
```javascript=
|
```json
|
||||||
|
"start": "medusa migrations run && medusa start"
|
||||||
|
```
|
||||||
|
|
||||||
|
This ensures that Migrations are run everytime the Medusa server is restarted.
|
||||||
|
|
||||||
|
## Changes to medusa-config.js
|
||||||
|
|
||||||
|
In `medusa-config.js`, the `DATABASE_URL` variable is set to the environment variable `DATABASE_URL`. This needs to be changed as DigitalOcean provides the different details of the database connection separately.
|
||||||
|
|
||||||
|
Replace the previous declaration of `DATABASE_URL` in `medusa-config.js` with the following:
|
||||||
|
|
||||||
|
```js
|
||||||
const DB_USERNAME = process.env.DB_USERNAME;
|
const DB_USERNAME = process.env.DB_USERNAME;
|
||||||
const DB_PASSWORD = process.env.DB_PASSWORD;
|
const DB_PASSWORD = process.env.DB_PASSWORD;
|
||||||
const DB_HOST = process.env.DB_HOST;
|
const DB_HOST = process.env.DB_HOST;
|
||||||
@@ -24,156 +51,231 @@ const DB_PORT = process.env.DB_PORT;
|
|||||||
const DB_DATABASE = process.env.DB_DATABASE;
|
const DB_DATABASE = process.env.DB_DATABASE;
|
||||||
|
|
||||||
const DATABASE_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}`;
|
const DATABASE_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}`;
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Update `module.exports` to include the following:
|
In addition, you must add to `projectConfig` in the exported object a new property `database_extra`:
|
||||||
|
|
||||||
```javascript=
|
```js
|
||||||
module.exports = {
|
module.exports = {
|
||||||
projectConfig: {
|
projectConfig: {
|
||||||
redis_url: REDIS_URL,
|
//...
|
||||||
database_url: DATABASE_URL,
|
|
||||||
database_type: "postgres",
|
|
||||||
store_cors: STORE_CORS,
|
|
||||||
admin_cors: ADMIN_CORS,
|
|
||||||
database_extra: { ssl: { rejectUnauthorized: false } }
|
database_extra: { ssl: { rejectUnauthorized: false } }
|
||||||
},
|
},
|
||||||
plugins,
|
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Update `package.json`
|
## Create GitHub Repository
|
||||||
|
|
||||||
Update `scripts` to have the following:
|
Before you can deploy your Medusa server you need to create a GitHub repository and push the code base to it.
|
||||||
|
|
||||||
```json=
|
On GitHub, click the plus icon at the top right, then click New Repository.
|
||||||
...
|
|
||||||
"scripts": {
|

|
||||||
"serve": "medusa start",
|
|
||||||
"start": "medusa migrations run && medusa develop",
|
You’ll then be redirected to a new page with a form. In the form, enter the Repository Name then scroll down and click Create repository.
|
||||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
|
||||||
}
|

|
||||||
...
|
|
||||||
|
### Push Code to GitHub Repository
|
||||||
|
|
||||||
|
The next step is to push the code to the GitHub repository you just created.
|
||||||
|
|
||||||
|
After creating the repository, you’ll be redirected to the repository’s page. On that page, you should see a URL that you can copy to connect your repository to a local directory.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Copy the link. Then, open your terminal in the directory that holds your Medusa server codebase and run the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git init
|
||||||
|
git remote add origin <GITHUB_URL>
|
||||||
```
|
```
|
||||||
|
|
||||||
Add a newer version of node to `engines`:
|
Where `<GITHUB_URL>` is the URL you just copied.
|
||||||
|
|
||||||
```json=
|
Then, add, commit, and push the changes into the repository:
|
||||||
...
|
|
||||||
"engines": {
|
|
||||||
"node": "14.x"
|
|
||||||
}
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Push changes to your repository
|
```bash
|
||||||
|
|
||||||
```shell=
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "chore: DigitalOcean setup"
|
git commit -m "initial commit"
|
||||||
git push origin master
|
git push origin master
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. [DigitalOcean](https://cloud.digitalocean.com/login)
|
After pushing the changes, you can find the files in your GitHub repository.
|
||||||
|
|
||||||
[Sign in](https://cloud.digitalocean.com/login) to your DigitalOcean Account or [create a new one](https://cloud.digitalocean.com/registrations/new).
|
## Deploy to DigitalOcean App
|
||||||
|
|
||||||
### 3. Create an App
|
After logging into your account, click on the Create button at the top right, then choose App.
|
||||||
|
|
||||||
Navigate to the top-right dropdown **Create** and select **Apps**.
|

|
||||||
|
|
||||||
### 4. Connect you Git repository
|
### Choose Repository
|
||||||
|
|
||||||
Choose **GitHub** or **GitLab** and select the repository that holds your Medusa project. Check **Autodeploy code changes**, if you want DigitalOcean to deploy on every push to your repository.
|
In the Create App page, choose GitHub from the Service Provider list.
|
||||||
|
|
||||||
:::tip
|

|
||||||
|
|
||||||
It's important, that DigitalOcean is pointing to the directory holding the Medusa store engine as it is only this which that will be deployed (If you followed the quickstart guide this will simply be the created project, and if you used the npx command this will be the backend folder inside of the newly created project).
|
If you haven’t given DigitalOcean access before, click on Manage Access under Source Code. You’ll then be redirected to GitHub to give DigitalOcean access.
|
||||||
|
|
||||||
:::
|
Once DigitalOcean have access to your GitHub account, you should see a Repository input. Click on it and search for the repository you created earlier.
|
||||||
|
|
||||||
### 5. Configure environment variables
|
Additional inputs will show up to choose the Branch, Source Directory, and Autodeploy options.
|
||||||
|
|
||||||
The default settings for your app should be sufficient. We only need to change environment variables to hold the following:
|

|
||||||
|
|
||||||
```shell=
|
If you host your Medusa server in a monorepo, you should change the Source Directory to the directory the server is available in the repository. Otherwise, it can be left as is.
|
||||||
|
|
||||||
|
Once you’re done, click Next to move on to the next step.
|
||||||
|
|
||||||
|
### Specify Web Service Resources
|
||||||
|
|
||||||
|
In the next step, you’ll see the resources to create.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If you have a Dockerfile available in the server’s codebase (which is available by default), you’ll have two resources showing. You can remove it by clicking on the trash icon at the right of the resource.
|
||||||
|
|
||||||
|
By default, DigitalOcean hosts the web service in a sub-path of the domain name of the created App. To change it to the root of the domain, click on the edit icon at the right of the Web Service resource.
|
||||||
|
|
||||||
|
Then, scroll to HTTP Request Routes and expand it by clicking on Edit at its right. Change the value of the Routes input to `/`.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done click Save. You’ll be taken back to the Resources page.
|
||||||
|
|
||||||
|
### Specify Database Resources
|
||||||
|
|
||||||
|
On the same page, expand the Add Resources section, choose Database, then click Add.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the new page, you’ll be shown a PostgreSQL database to be created. Notice that it’s important to choose a name that you’ll remember as you’ll need the name in next steps. You can leave the name as is if it’s not necessary to change it.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done, click Create and Attach. You’ll be redirected back to the previous page with the database added to the resources.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done, click Next to move on to the next step.
|
||||||
|
|
||||||
|
### Set Environment Variables
|
||||||
|
|
||||||
|
In this section, you’ll add environment variables that are essential to your Medusa server.
|
||||||
|
|
||||||
|
You should see 2 ways to add environment variables: Global or specific to the Web Service.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click Edit on the second row to add environment variables specific to the Web Service. Add the following environment variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
DB_USERNAME=${db.USERNAME}
|
DB_USERNAME=${db.USERNAME}
|
||||||
DB_PASSWORD=${db.PASSWORD}
|
DB_PASSWORD=${db.PASSWORD}
|
||||||
DB_HOST=${db.HOSTNAME}
|
DB_HOST=${db.HOSTNAME}
|
||||||
DB_PORT=${db.PORT}
|
DB_PORT=${db.PORT}
|
||||||
DB_DATABASE=${db.DATABASE}
|
DB_DATABASE=${db.DATABASE}
|
||||||
REDIS_URL=${redis.DATABASE_URL}
|
REDIS_URL=${redis.DATABASE_URL}
|
||||||
JWT_SECRET=your-jwt-secret
|
JWT_SECRET=secret
|
||||||
COOKIE_SECRET=your-cookie-secret
|
COOKIE_SECRET=secret
|
||||||
|
NPM_CONFIG_PRODUCTION=false
|
||||||
|
NODE_ENV=production
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
Notice how for database environment variables you access the values from the database you created earlier `db`. If you changed the name of the database, you must change `db` here to the name you supplied to the PostgreSQL database.
|
||||||
|
|
||||||
Make sure to use actual secrets in a production environment
|
Another thing to note here is that you added a `REDIS_URL` environment variable that uses a `redis` resource to retrieve the URL. You’ll be creating this resource in a later section.
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
It’s highly recommended to use strong, randomly generated secrets for `JWT_SECRET` and `COOKIE_SECRET`.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### 6. Set up a Database
|
Once you’re done click Save.
|
||||||
|
|
||||||
Click **Add a Database**. If you named your database instance something different than `db`, make sure your environment variable reflect this. See our use of `db` below.
|
### Finalize App
|
||||||
|
|
||||||
```shell=
|
In the next section, you’ll be shown the app info and the region it will be deployed to. You can leave it all as is or make changes if you find it necessary.
|
||||||
DB_USERNAME=${db.USERNAME}
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done, click Next to go to the next step.
|
||||||
|
|
||||||
|
In the final step, you can see a review of everything you created. If everything looks good, scroll down and click Create Resource.
|
||||||
|
|
||||||
|
### Create Redis Resource
|
||||||
|
|
||||||
|
While the server is being deployed, you can create the Redis resource.
|
||||||
|
|
||||||
|
Click the Create button at the top right and choose Database from the dropdown.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the new page under Choose a database engine, choose Redis.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, scroll down to the “Choose a name” input. Since you used the name `redis` in the `REDIS_URL` environment variables, change the value to `redis` here.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done, click on Create Database Cluster.
|
||||||
|
|
||||||
|
### Attach Redis Database
|
||||||
|
|
||||||
|
Once the Redis database is created go back to the App you created earlier by choose Apps in the sidebar then clicking on the App name.
|
||||||
|
|
||||||
|
Click at the white Create button at the top right and choose Create/Attach Database.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
In the new page, click on the Previously Created DigitalOcean Database radio button. Then, under Database Cluster select the Redis database you just created.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you’re done click Attach Database. This will add the Redis database to the list of resources of your App and will trigger a redeploy of the App.
|
||||||
|
|
||||||
|
## Test your Server
|
||||||
|
|
||||||
|
Once the redeployment is complete, copy the URL of the App which can be found under the App’s name.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Then, go to `<YOUR_APP_URL>/store/products`. If the deployment was successful, you should receive a JSON response.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Run Commands on Your Server
|
||||||
|
|
||||||
|
To run commands on your server, you can access the console on the App’s page by choosing the Console tab. This opens a console in your browser where you can run commands on your server.
|
||||||
|
|
||||||
|
For example, you can run the following commands to create a new admin user:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @medusajs/medusa-cli -g
|
||||||
|
medusa user --email <EMAIL> --password <PASSWORD>
|
||||||
```
|
```
|
||||||
|
|
||||||
### 7. Give your app a name
|
Make sure to replace `<EMAIL>` and `<PASSWORD>` with the credentials you want to give the user.
|
||||||
|
|
||||||
Enter a name for your app and select the most suitable region for your setup.
|

|
||||||
|
|
||||||
### 8. Finalize the setup
|
## Add Environment Variables
|
||||||
|
|
||||||
Choose a plan for your App. For just getting started, the Basic plan should be sufficient. For a production environment, the **Pro plan** is recommended.
|
You’ll likely need to add environment variables later such as Admin CORS and Store CORS variables.
|
||||||
|
|
||||||
Finally, launch the app.
|
To add environment variables, on the App’s page click on Settings and choose the Web Service component.
|
||||||
|
|
||||||
### 9. Add a Redis Database
|

|
||||||
|
|
||||||
The following steps will add a Redis database to your Medusa setup.
|
Then, scroll down and find Environment Variables. You can expand the environment variables by clicking Edit on the right. Here, you can edit, add, and remove environment variables.
|
||||||
|
|
||||||
1. Navigate to the top-right dropdown **Create** and select **Databases**
|

|
||||||
2. Select **Redis**
|
|
||||||
3. Select the same region you chose for your App
|
|
||||||
4. Leave VPC Network as it is
|
|
||||||
5. Choose a name for your Redis Database
|
|
||||||
|
|
||||||
Similarly to our other database, if you choose to name Redis something different than `redis`, you should udpdate the environment variable as well. See our use of `redis` below.
|
Once you click Save, the environment variables will be saved and a redeployment will be triggered.
|
||||||
|
|
||||||
```shell=
|
## What’s Next 🚀
|
||||||
REDIS_URL=${redis.DATABASE_URL}
|
|
||||||
```
|
|
||||||
|
|
||||||
6. Create the Redis database for your project
|
- Learn [how to deploy the Medusa Admin to Netlify](../admin/deploying-on-netlify.md).
|
||||||
|
- Learn [how to deploy the Gatsby Storefront to Netlify](../storefront/deploying-gatsby-on-netlify.md).
|
||||||
### 10. Configure Redis for your App
|
|
||||||
|
|
||||||
1. In the navbar on the left, click **Apps** and select your Medusa App
|
|
||||||
2. Select **Settings** ➜ **Add component** ➜ **Database**
|
|
||||||
3. Select **Previously Created DigitalOcean Database**
|
|
||||||
4. Select the Redis Cluster created in the previous step
|
|
||||||
|
|
||||||
### 11. Deploy Medusa
|
|
||||||
|
|
||||||
If you haven't already, make sure to rebuild and deploy your Medusa App.
|
|
||||||
|
|
||||||
### 12. Try it out!
|
|
||||||
|
|
||||||
In DigitalOcean, navigate to your App overview and access your endpoint to try out your new setup.
|
|
||||||
|
|
||||||
```
|
|
||||||
https://your-endpoint.ondigitalocean.app/health
|
|
||||||
```
|
|
||||||
|
|
||||||
### What's next?
|
|
||||||
|
|
||||||
You now have an application running on DigitalOcean. This can be scaled and configured to fit your business needs.
|
|
||||||
|
|
||||||
Furthermore, you can deploy a Medusa Admin for your application, such that you can start managing your store from an interface.
|
|
||||||
|
|
||||||
- [Deploy Admin on Netlify](../admin/deploying-on-netlify.md)
|
|
||||||
- Deploy Admin on Gatsby Cloud (Coming soon)
|
|
||||||
@@ -18,51 +18,24 @@ Alternatively, you can use this button to deploy the Medusa server to Heroku dir
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
Before you start with this guide, you must have a Medusa server installed locally.
|
### Medusa Server
|
||||||
|
|
||||||
To install a Medusa server, follow our [Quickstart guide](../../quickstart/quick-start.md).
|
It is assumed that you already have a Medusa server installed locally. If you don’t, please follow our [quickstart guide](../../quickstart/quick-start.md).
|
||||||
|
|
||||||
## How to Deploy Your Medusa Server on Heroku
|
Furthermore, your Medusa server should be configured to work with PostgreSQL and Redis. You can follow the [Configure your Server documentation](../../usage/configurations.md) to learn how to do that.
|
||||||
|
|
||||||
### 1. Install the Heroku CLI
|
### Needed Accounts
|
||||||
|
|
||||||
Install the Heroku CLI tool using the instructions that belong to your operating system.
|
- A [Heroku](https://heroku.com/) account.
|
||||||
|
|
||||||
<Tabs groupId="operating-systems" wrapperClassName={styles.osTabs}>
|
### Required Tools
|
||||||
<TabItem value="windows" label="Windows" default>
|
|
||||||
|
|
||||||
Download the appropriate installer for your Windows installation:
|
- Git’s CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
||||||
|
- Heroku's CLI tool. You can follow [Heroku's documentation to learn how to install it for your operating system](https://devcenter.heroku.com/articles/heroku-cli).
|
||||||
|
|
||||||
[64-bit installer](https://cli-assets.heroku.com/heroku-x64.exe)
|
## Deploy to Heroku
|
||||||
|
|
||||||
[32-bit installer](https://cli-assets.heroku.com/heroku-x86.exe)
|
### 1. Login to Heroku from your CLI
|
||||||
|
|
||||||
</TabItem>
|
|
||||||
<TabItem value="linux" label="Linux">
|
|
||||||
|
|
||||||
For Ubuntu, you can use the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo snap install --classic heroku
|
|
||||||
```
|
|
||||||
|
|
||||||
As for other Linux distributions, please check [Heroku's guide](https://devcenter.heroku.com/articles/heroku-cli#standalone-installation-with-a-tarball).
|
|
||||||
|
|
||||||
</TabItem>
|
|
||||||
<TabItem value="macos" label="macOS">
|
|
||||||
|
|
||||||
For macOS you can install Heroku's CLI tool using Homebrew:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
brew tap heroku/brew && brew install heroku
|
|
||||||
```
|
|
||||||
|
|
||||||
For other installation options, please check [Heroku's guide](https://devcenter.heroku.com/articles/heroku-cli#standalone-installation-with-a-tarball)
|
|
||||||
|
|
||||||
</TabItem>
|
|
||||||
</Tabs>
|
|
||||||
|
|
||||||
### 2. Login to Heroku from your CLI
|
|
||||||
|
|
||||||
Before you can create an app with Heroku, you must login with the CLI tool:
|
Before you can create an app with Heroku, you must login with the CLI tool:
|
||||||
|
|
||||||
@@ -72,7 +45,7 @@ heroku login
|
|||||||
|
|
||||||
Depending on your operating system, you must follow either the instructions in your terminal or a page in your browser will open.
|
Depending on your operating system, you must follow either the instructions in your terminal or a page in your browser will open.
|
||||||
|
|
||||||
### 3. Create an App with Heroku
|
### 2. Create an App with Heroku
|
||||||
|
|
||||||
In the root directory of your Medusa server, run the following commands to create an app on Heroku and add it as a remote origin:
|
In the root directory of your Medusa server, run the following commands to create an app on Heroku and add it as a remote origin:
|
||||||
|
|
||||||
@@ -83,7 +56,7 @@ heroku git:remote -a <APP_NAME>
|
|||||||
|
|
||||||
Where `<APP_NAME>` is the name of the app you'll create. You can use any name you want.
|
Where `<APP_NAME>` is the name of the app you'll create. You can use any name you want.
|
||||||
|
|
||||||
### 4. Install Postgresql and Redis on Heroku
|
### 3. Install Postgresql and Redis on Heroku
|
||||||
|
|
||||||
Medusa requires a Postgres database and a Redis instance to work. You can add those to your Heroku app using Add-ons.
|
Medusa requires a Postgres database and a Redis instance to work. You can add those to your Heroku app using Add-ons.
|
||||||
|
|
||||||
@@ -131,7 +104,7 @@ heroku addons:create upstash-redis
|
|||||||
|
|
||||||
This uses the free plan of Upstash. Make sure to check out [more information regarding the plans and pricing of Upstash](https://elements.heroku.com/addons/upstash-redis#pricing).
|
This uses the free plan of Upstash. Make sure to check out [more information regarding the plans and pricing of Upstash](https://elements.heroku.com/addons/upstash-redis#pricing).
|
||||||
|
|
||||||
### 5. Configure Environment Variables on Heroku
|
### 4. Configure Environment Variables on Heroku
|
||||||
|
|
||||||
Medusa requires a set of environment variables to be configured. You can learn more about Medusa's configurations in the [Configure your Medusa Server](../../usage/configurations.md) document.
|
Medusa requires a set of environment variables to be configured. You can learn more about Medusa's configurations in the [Configure your Medusa Server](../../usage/configurations.md) document.
|
||||||
|
|
||||||
@@ -202,7 +175,7 @@ heroku config:set STORE_CORS=<YOUR_STOREFRONT_URL>
|
|||||||
|
|
||||||
Where `<YOUR_STOREFRONT_URL>` is the URL of your storefront.
|
Where `<YOUR_STOREFRONT_URL>` is the URL of your storefront.
|
||||||
|
|
||||||
### 6. Configure Medusa Server
|
### 5. Configure Medusa Server
|
||||||
|
|
||||||
Before jumping into the deployment, you need to configure your Medusa server to ensure it uses the previous environment variables and the recommended production configurations.
|
Before jumping into the deployment, you need to configure your Medusa server to ensure it uses the previous environment variables and the recommended production configurations.
|
||||||
|
|
||||||
@@ -241,7 +214,7 @@ Update `scripts` to include the following scripts:
|
|||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
### 7. Launch your Medusa Server
|
### 6. Launch your Medusa Server
|
||||||
|
|
||||||
Finally, commit and push all changes to Heroku:
|
Finally, commit and push all changes to Heroku:
|
||||||
|
|
||||||
@@ -253,17 +226,41 @@ git push heroku HEAD:master
|
|||||||
|
|
||||||
This triggers a redeploy of the Medusa server with all the new configurations.
|
This triggers a redeploy of the Medusa server with all the new configurations.
|
||||||
|
|
||||||
## Troubleshooting: Inspect Build Logs
|
## Test your Server
|
||||||
|
|
||||||
|
To test your server, run the following command to retrieve the server's URL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
heroku apps:info -a <APP_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<APP_NAME>` is the name of the app. You should see as the output a bunch of info of the app.
|
||||||
|
|
||||||
|
The server's URL is available under "Web URL". You can copy it and perform requests to it to test it out.
|
||||||
|
|
||||||
|
For example, you can send a request to `<YOUR_SERVER_URL>/store/products` and you should receive a JSON response with the products in your store.
|
||||||
|
|
||||||
|
### Troubleshooting: Inspect Build Logs
|
||||||
|
|
||||||
If an error occurs during the deployment, you can explore your Heroku app build logs using the following command in the root directory of your Medusa server:
|
If an error occurs during the deployment, you can explore your Heroku app build logs using the following command in the root directory of your Medusa server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
heroku logs -n 500000 --remote heroku --tail
|
heroku logs -n 500000 --remote heroku --tail -a <APP_NAME>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create a User
|
Where `<APP_NAME>` is the name of the app.
|
||||||
|
|
||||||
As an optional extra step, you can create a user to use when your admin dashboard is up and running:
|
## Run Commands on Your Server
|
||||||
|
|
||||||
|
To run commands on your server, you can use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
heroku run -a <APP_NAME> -- <COMMAND>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<APP_NAME>` is the name of the app and `<COMMAND>` is the command you want to run.
|
||||||
|
|
||||||
|
For example, to create an admin user you can run the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
heroku run -a <APP_NAME> -- medusa user -e "<EMAIL>" -p "<PASSWORD>"
|
heroku run -a <APP_NAME> -- medusa user -e "<EMAIL>" -p "<PASSWORD>"
|
||||||
@@ -271,6 +268,18 @@ heroku run -a <APP_NAME> -- medusa user -e "<EMAIL>" -p "<PASSWORD>"
|
|||||||
|
|
||||||
Where `<APP_NAME>` is the name of your Heroku app, and `<EMAIL>` and `<PASSWORD>` are the credentials you want to use to log in to the Medusa admin dashboard.
|
Where `<APP_NAME>` is the name of your Heroku app, and `<EMAIL>` and `<PASSWORD>` are the credentials you want to use to log in to the Medusa admin dashboard.
|
||||||
|
|
||||||
|
## Add Environment Variables
|
||||||
|
|
||||||
|
You’ll likely need to add environment variables later such as Admin CORS and Store CORS variables.
|
||||||
|
|
||||||
|
To set or change an environment variable's value, you can use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
heroku config:set <ENV_NAME>=<ENV_VALUE> -a <APP_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<APP_NAME>` is the name of your Heroku app, `<ENV_NAME>` is the name of the environment variable, and `<ENV_VALUE>` is the value.
|
||||||
|
|
||||||
## What's Next :rocket:
|
## What's Next :rocket:
|
||||||
|
|
||||||
- Learn how to [deploy your Medusa admin](../admin/index.mdx).
|
- Learn how to [deploy your Medusa admin](../admin/index.mdx).
|
||||||
|
|||||||
@@ -1,138 +1,508 @@
|
|||||||
# Deploying on Qovery
|
# Deploy Your Medusa Server on Qovery
|
||||||
|
|
||||||
This is a guide for deploying a Medusa project to Qovery. Qovery is a Continuous Deployment Platform, that provides you with the developer experience of Heroku on top of your cloud provider (e.g. AWS, DigitalOcean).
|
In this document, you'll learn how to deploy your Medusa server on Qovery with the help of Terraform.
|
||||||
|
|
||||||
|
[Qovery](https://www.qovery.com/) is a Continuous Deployment Platform that provides you with the developer experience of Heroku on top of your cloud provider (e.g. AWS, DigitalOcean).
|
||||||
|
|
||||||
|
[Terraform](https://www.terraform.io/) is an open source infrastructure as code software (IaC) tool that allows you to easily deploy apps like Medusa and the resources it needs to Qovery using a single script.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
||||||
We assume, that you are currently running a local instance of Medusa. If not, check out our [Quickstart](https://docs.medusajs.com/quickstart/quick-start) or use `npx create-medusa-app` to set up your application in a matter of minutes. For the latter, see [this guide](../../usage/create-medusa-app.mdx) for a small walkthrough.
|
This tutorial explains how to deploy Medusa to a Qovery organization with an AWS cluster. If you want to use a cloud provider other than AWS, you need to make changes to some of the keys and variables used in the tutorial.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### 1. Qovery Console
|
## Prerequisites
|
||||||
|
|
||||||
Create an account on [Qovery](https://www.qovery.com/) on their free community plan and jump into the console.
|
### Medusa Server
|
||||||
|
|
||||||
### 2. Setup
|
It is assumed that you already have a Medusa server installed locally. If you don’t, please follow our [quickstart guide](../../quickstart/quick-start.md).
|
||||||
|
|
||||||
Create a project and an environment.
|
Furthermore, your Medusa server should be configured to work with PostgreSQL and Redis. You can follow the [Configure your Server documentation](../../usage/configurations.md) to learn how to do that.
|
||||||
|
|
||||||
### 3. Add your Medusa app
|
### Needed Accounts
|
||||||
|
|
||||||
Add a new app to your Qovery environment and connect the Git repository that holds your Medusa project. In your application settings, set the port to 9000 unless something else is specified in your setup.
|
- A [Qovery](https://start.qovery.com/) account with a created organization. Qovery provides a free plan that you can use.
|
||||||
|
- An [AWS](https://aws.amazon.com/) account that you’ll connect to a Qovery cluster.
|
||||||
:::note
|
- A [GitHub](https://github.com/) account to create a repository to host your server’s codebase.
|
||||||
|
|
||||||
If you used our `npx` starter, your repository will most likely hold all components; storefront, admin and backend. Ensure that **Root application path** in Qovery is pointing to your Medusa project (`/backend`).
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
### 4. Add a database
|
|
||||||
|
|
||||||
Navigate to your environment overview and add the databases required by Medusa.
|
|
||||||
|
|
||||||
- Add Postgres database version 10, 11 or 12
|
|
||||||
- Add Redis database version 5 or 6
|
|
||||||
|
|
||||||
### 5. Configure Medusa
|
|
||||||
|
|
||||||
Our Medusa project needs a bit of configuration to fit the needs of Qovery.
|
|
||||||
|
|
||||||
#### Update `medusa-config.js`
|
|
||||||
|
|
||||||
First, add the Postgres and Redis database url to your `medusa-config.js`. In Qovery, click on your Medusa app in the environment overview. Navigate to environment variables in the sidebar on the left. Among the secret variables you should find your database urls. They should look something like this:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
QOVERY_REDIS_123456789_DATABASE_URL
|
|
||||||
QOVERY_POSTGRESQL_123456789_DATABASE_URL
|
|
||||||
```
|
|
||||||
|
|
||||||
Add these to your `medusa-config.js`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const DATABASE_URL = process.env.QOVERY_POSTGRESQL_123456789_DATABASE_URL
|
|
||||||
const REDIS_URL= process.env.QOVERY_REDIS_123456789_DATABASE_URL
|
|
||||||
```
|
|
||||||
|
|
||||||
Furthermore, update `module.exports` to include the following:
|
|
||||||
|
|
||||||
```js
|
|
||||||
module.exports = {
|
|
||||||
projectConfig: {
|
|
||||||
redis_url: REDIS_URL,
|
|
||||||
database_url: DATABASE_URL,
|
|
||||||
database_type: "postgres",
|
|
||||||
store_cors: STORE_CORS,
|
|
||||||
admin_cors: ADMIN_CORS,
|
|
||||||
database_extra: { }
|
|
||||||
},
|
|
||||||
plugins,
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
:::caution IMPORTANT
|
|
||||||
|
|
||||||
We are using the Qovery community plan, that does not allow SSL connections for the database, so this is disabled.
|
|
||||||
|
|
||||||
In a production environment, you would need the following in the config:
|
|
||||||
`database_extra: { ssl: { rejectUnauthorized: false } }`
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
#### Add some extra variables
|
|
||||||
|
|
||||||
We need to add a couple of more environment variables in Qovery. Add the following variables in your Console with an application scope:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
JTW_SECRET=something_secret_jwt
|
|
||||||
COOKIE_SECRET=something_secret_cookie
|
|
||||||
```
|
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
Make sure to use actual secrets in a production environment.
|
If you want to use another [Git Provider supported by Qovery](https://hub.qovery.com/docs/useful-resources/faq/#what-git-providers-do-you-support), it’s possible to follow along with this guide but you’ll have to perform the equivalent steps in your Git Provider.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
#### Update `package.json`
|
### Required Tools
|
||||||
|
|
||||||
Update `scripts` to the following:
|
- Git’s CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
||||||
|
- Terraform’s CLI tool. You can follow [this guide to install it based on your operating system](https://www.terraform.io/downloads).
|
||||||
|
- Qovery’s CLI tool. You can follow [this guide to install it based on your operating system](https://hub.qovery.com/docs/using-qovery/interface/cli/#install).
|
||||||
|
|
||||||
```json
|
## Create GitHub Repository
|
||||||
"scripts": {
|
|
||||||
"serve": "medusa start",
|
Before you can deploy your Medusa server you need to create a GitHub repository and push the code base to it.
|
||||||
"start": "medusa migrations run && medusa start",
|
|
||||||
"prepare": "npm run build",
|
On GitHub, click the plus icon at the top right, then click New Repository.
|
||||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
|
||||||
},
|

|
||||||
|
|
||||||
|
You’ll then be redirected to a new page with a form. In the form, enter the Repository Name then scroll down and click Create repository.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Push Code to GitHub Repository
|
||||||
|
|
||||||
|
The next step is to push the code to the GitHub repository you just created.
|
||||||
|
|
||||||
|
After creating the repository, you’ll be redirected to the repository’s page. On that page, you should see a URL that you can copy to connect your repository to a local directory.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Copy the link. Then, open your terminal in the directory that holds your Medusa server codebase and run the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git init
|
||||||
|
git remote add origin <GITHUB_URL>
|
||||||
```
|
```
|
||||||
|
|
||||||
### 6. Deploy Medusa
|
Where `<GITHUB_URL>` is the URL you just copied.
|
||||||
|
|
||||||
Finally, deploy your Redis and Postgres followed by your Medusa application.
|
Then, add, commit, and push the changes into the repository:
|
||||||
|
|
||||||
#### Deploy databases
|
|
||||||
|
|
||||||
In your environment overview in Qovery, deploy your databases one after the other. Only when these are deployed, proceed to next step.
|
|
||||||
|
|
||||||
#### Push changes to your repository
|
|
||||||
|
|
||||||
To initialise your first build Qovery, simply commit and push your changes.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git add .
|
git add .
|
||||||
git commit -m "chore: Qovery setup"
|
git commit -m "initial commit"
|
||||||
git push origin main
|
git push origin master
|
||||||
```
|
```
|
||||||
|
|
||||||
### 6. Try it out!
|
After pushing the changes, you can find the files in your GitHub repository.
|
||||||
|
|
||||||
In Qovery, click on your Medusa app in the environment overview. In the top right you are able to open up your application. Navigate to `/health` to ensure, that the app is running.
|
## Deploy to Qovery
|
||||||
|
|
||||||
### What's next?
|
In this section, you’ll learn how to deploy your Medusa server to Qovery with the help of Terraform.
|
||||||
|
|
||||||
You now have an application running on Qovery. This can be scaled and configured to fit your business needs. As mentioned, we used the community plan, so this should be upgraded when moving to production.
|
### Sign in Using Qovery CLI
|
||||||
|
|
||||||
Furthermore, you can deploy Medusa Admin for your application, such that you can start managing your store from an interface.
|
If you haven’t logged in to your Qovery account using the Qovery CLI tool yet, run the following command:
|
||||||
|
|
||||||
- [Deploy Admin on Netlify](../admin/deploying-on-netlify.md)
|
```bash
|
||||||
- Deploy Admin on Gatsby Cloud (Coming soon)
|
qovery auth
|
||||||
|
```
|
||||||
|
|
||||||
|
This opens a new page in your browser to log in to Qovery.
|
||||||
|
|
||||||
|
### Retrieve Qovery Access Token
|
||||||
|
|
||||||
|
Terraform needs an access token from Qovery so that it can deploy to your Qovery organization.
|
||||||
|
|
||||||
|
Run the following command to retrieve a Qovery access token:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qovery token
|
||||||
|
```
|
||||||
|
|
||||||
|
You’ll be prompted to choose an organization and add a name and description for the token. Once the command finishes executing, you’ll be given an access token. Save it to use in the next steps.
|
||||||
|
|
||||||
|
### Add Terraform Variables
|
||||||
|
|
||||||
|
You need to add some variables to use for your Medusa deployment to Qovery.
|
||||||
|
|
||||||
|
In the root directory of your Medusa server, create the file `variables.tf` with the following content:
|
||||||
|
|
||||||
|
```
|
||||||
|
variable "qovery_organization_id" {
|
||||||
|
type = string
|
||||||
|
nullable = false
|
||||||
|
description = "ID of Qovery organization"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "qovery_create_cluster" {
|
||||||
|
type = bool
|
||||||
|
nullable = false
|
||||||
|
default = true
|
||||||
|
description = "Whether to create a new cluster or not"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "qovery_cluster_id" {
|
||||||
|
type = string
|
||||||
|
nullable = true
|
||||||
|
default = ""
|
||||||
|
description = "The ID of the cluster you want to use if you don't want to create a new one. You can get the Cluster ID using this endpoint: https://api-doc.qovery.com/#tag/Clusters/operation/listOrganizationCluster"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "qovery_access_token" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
nullable = false
|
||||||
|
description = "Qovery's access token generated with the command 'qovery token'"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "aws_access_key_id" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
nullable = true
|
||||||
|
description = "Necessary only if creating a new cluster"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "aws_secret_access_key" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
nullable = true
|
||||||
|
description = "Necessary only if creating a new cluster"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "aws_region" {
|
||||||
|
type = string
|
||||||
|
nullable = false
|
||||||
|
default = "us-east-2"
|
||||||
|
description = "Necessary only if creating a new cluster"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "medusa_jwt_secret" {
|
||||||
|
type = string
|
||||||
|
default = "your-super-secret" # TO CHANGE FOR PRODUCTION
|
||||||
|
sensitive = true
|
||||||
|
nullable = false
|
||||||
|
description = "The JWT Secret to use in Medusa"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "medusa_cookie_secret" {
|
||||||
|
type = string
|
||||||
|
default = "your-super-secret-pt2" # TO CHANGE FOR PRODUCTION
|
||||||
|
sensitive = true
|
||||||
|
nullable = false
|
||||||
|
description = "The Cookie Secret to use in Medusa"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "git_url" {
|
||||||
|
type = string
|
||||||
|
nullable = false
|
||||||
|
description = "The Git repo associated with the qovery app. Make sure it ends with '.git'."
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "git_branch" {
|
||||||
|
type = string
|
||||||
|
nullable = false
|
||||||
|
default = "master"
|
||||||
|
description = "The branch of the Git repo. Default is master"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "git_root_path" {
|
||||||
|
type = string
|
||||||
|
nullable = false
|
||||||
|
default = "/"
|
||||||
|
description = "The base directory to run the app from. Default is /"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This defines the required variables and sets some of them as `secret` to ensure their values aren’t printed in the console during deployment.
|
||||||
|
|
||||||
|
Next, to set the values of these variables, create the file `terraform.tfvars` with the following content:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qovery_organization_id = ""
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
qovery_create_cluster = true
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
qovery_cluster_id = null
|
||||||
|
|
||||||
|
qovery_access_token = ""
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
aws_access_key_id = null
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
aws_secret_access_key = null
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
aws_region = null
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
medusa_jwt_secret = "secret"
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
medusa_cookie_secret = "secret"
|
||||||
|
|
||||||
|
git_url = ""
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
git_branch = "master"
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
git_root_path = "/"
|
||||||
|
```
|
||||||
|
|
||||||
|
Here’s an explanation of each of the variables and how to retrieve their variables:
|
||||||
|
|
||||||
|
- `qovery_organization_id`: The ID of the Qovery organization to deploy the server to. It can be found by logging into your [Qovery Console](https://console.qovery.com/). You’ll be redirected to the organization’s main page with a URL of the format `https://console.qovery.com/platform/organization/<ORGANIZATION_ID>/projects`. Copy the `<ORGANIZATION_ID>` in the URL to use as the value of this field.
|
||||||
|
- `qovery_create_cluster`: A boolean value indicating whether a new cluster should be created or not. If you already have a cluster that you want to use, you can set the value to `false` and set the value of `qovery_cluster_id`. Otherwise, set the value to `true` and set the values of `aws_access_key_id`, `aws_secret_access_key`, and `aws_region`.
|
||||||
|
- `qovery_cluster_id`: The ID of the existing cluster to use (if `qovery_create_cluster` is set to `false`). You can use [Qovery’s REST API](https://api-doc.qovery.com/#tag/Clusters/operation/listOrganizationCluster) to retrieve the cluster ID. You can use the token you generated earlier for the Bearer authorization token as explained [here](https://hub.qovery.com/docs/using-qovery/interface/cli/#generate-api-token).
|
||||||
|
- `aws_access_key_id`, `aws_secret_access_key`, and `aws_region`: The credentials used to create the cluster (if `qovery_create_cluster` is set to `true`). You can refer to [this guide](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) to learn how to retrieve the `aws_access_key_id` and `aws_secret_access_key`.
|
||||||
|
- `medusa_jwt_secret`: The value of the JWT Secret on your Medusa server. It’s recommended to use a strong randomly generated string.
|
||||||
|
- `medusa_cookie_secret`: The value of the Cookie Secret on your Medusa server. It’s recommended to use a strong randomly generated string.
|
||||||
|
- `git_url`: The URL of the Git repository you created earlier. Make sure it ends with `.git`.
|
||||||
|
- `git_branch`: The branch to use in the GitHub repo. By default it’s `master`.
|
||||||
|
- `git_root_path`: The root path of the Medusa server. By default, it’s `/`. If you are hosting your Medusa server in a monorepo in a nested directory, you need to change the value of this variable.
|
||||||
|
|
||||||
|
### Add Terraform Configuration File
|
||||||
|
|
||||||
|
In the root directory of your Medusa server, create the file `main.tf` with the following content:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install the Qovery Terraform provider
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
qovery = {
|
||||||
|
source = "qovery/qovery"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set the access token
|
||||||
|
provider "qovery" {
|
||||||
|
token = var.qovery_access_token
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create the AWS credentials if qovery_create_cluster is true
|
||||||
|
resource "qovery_aws_credentials" "my_aws_creds" {
|
||||||
|
organization_id = var.qovery_organization_id
|
||||||
|
name = "My AWS Creds"
|
||||||
|
access_key_id = var.aws_access_key_id
|
||||||
|
secret_access_key = var.aws_secret_access_key
|
||||||
|
count = var.qovery_create_cluster ? 1 : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a new cluster if qovery_create_cluster is true
|
||||||
|
resource "qovery_cluster" "my_cluster" {
|
||||||
|
organization_id = var.qovery_organization_id
|
||||||
|
credentials_id = qovery_aws_credentials.my_aws_creds[0].id
|
||||||
|
name = "Demo Medusa cluster"
|
||||||
|
description = "Terraform medusa cluster"
|
||||||
|
cloud_provider = "AWS"
|
||||||
|
region = var.aws_region
|
||||||
|
instance_type = "T3A_MEDIUM"
|
||||||
|
min_running_nodes = 3
|
||||||
|
max_running_nodes = 4
|
||||||
|
state = "RUNNING"
|
||||||
|
count = var.qovery_create_cluster ? 1 : 0
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
qovery_aws_credentials.my_aws_creds
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a new project
|
||||||
|
resource "qovery_project" "my_project" {
|
||||||
|
organization_id = var.qovery_organization_id
|
||||||
|
name = "Medusa"
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
qovery_cluster.my_cluster
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a new environment in the project
|
||||||
|
resource "qovery_environment" "production" {
|
||||||
|
project_id = qovery_project.my_project.id
|
||||||
|
name = "production"
|
||||||
|
mode = "PRODUCTION"
|
||||||
|
cluster_id = !var.qovery_create_cluster && var.qovery_cluster_id != "" ? var.qovery_cluster_id : qovery_cluster.my_cluster[0].id
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
qovery_project.my_project
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a PostgreSQL database in the environment
|
||||||
|
resource "qovery_database" "my_psql_database" {
|
||||||
|
environment_id = qovery_environment.production.id
|
||||||
|
name = "medusa psql db"
|
||||||
|
type = "POSTGRESQL"
|
||||||
|
version = "13"
|
||||||
|
mode = "MANAGED" # Use AWS RDS for PostgreSQL (backup and PITR automatically configured by Qovery)
|
||||||
|
storage = 10 # 10GB of storage
|
||||||
|
accessibility = "PRIVATE" # do not make it publicly accessible
|
||||||
|
state = "RUNNING"
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
qovery_environment.production,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a Redis database in the environment
|
||||||
|
resource "qovery_database" "my_redis_database" {
|
||||||
|
environment_id = qovery_environment.production.id
|
||||||
|
name = "medusa redis db"
|
||||||
|
type = "REDIS"
|
||||||
|
version = "6"
|
||||||
|
mode = "CONTAINER"
|
||||||
|
storage = 10 # 10GB of storage
|
||||||
|
accessibility = "PRIVATE"
|
||||||
|
state = "RUNNING"
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
qovery_environment.production,
|
||||||
|
qovery_database.my_psql_database,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create the Medusa application with all the configuration needed
|
||||||
|
resource "qovery_application" "medusa_app" {
|
||||||
|
environment_id = qovery_environment.production.id
|
||||||
|
name = "medusa app"
|
||||||
|
cpu = 1000
|
||||||
|
memory = 512
|
||||||
|
state = "RUNNING"
|
||||||
|
git_repository = {
|
||||||
|
url = var.git_url
|
||||||
|
branch = var.git_branch
|
||||||
|
root_path = var.git_root_path
|
||||||
|
}
|
||||||
|
build_mode = "DOCKER"
|
||||||
|
dockerfile_path = "Dockerfile"
|
||||||
|
min_running_instances = 1
|
||||||
|
max_running_instances = 1
|
||||||
|
ports = [
|
||||||
|
{
|
||||||
|
internal_port = 9000
|
||||||
|
external_port = 443
|
||||||
|
protocol = "HTTP"
|
||||||
|
publicly_accessible = true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
environment_variables = [
|
||||||
|
{
|
||||||
|
key = "PORT"
|
||||||
|
value = "9000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key = "NODE_ENV"
|
||||||
|
value = "production"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key = "NPM_CONFIG_PRODUCTION"
|
||||||
|
value = "false"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
secrets = [
|
||||||
|
{
|
||||||
|
key = "JWT_SECRET"
|
||||||
|
value = var.medusa_jwt_secret
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key = "COOKIE_SECRET"
|
||||||
|
value = var.medusa_cookie_secret
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key = "DATABASE_URL"
|
||||||
|
value = "postgresql://${qovery_database.my_psql_database.login}:${qovery_database.my_psql_database.password}@${qovery_database.my_psql_database.internal_host}:${qovery_database.my_psql_database.port}/postgres"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key = "REDIS_URL"
|
||||||
|
value = "redis://${qovery_database.my_redis_database.login}:${qovery_database.my_redis_database.password}@${qovery_database.my_redis_database.internal_host}:${qovery_database.my_redis_database.port}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
qovery_environment.production,
|
||||||
|
qovery_database.my_psql_database,
|
||||||
|
qovery_database.my_redis_database,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This is a Terraform configuration file that creates all the resources necessary to deploy Medusa to Qovery. If you set `qovery_create_cluster` to `true`, it will create new credentials and a cluster in your Qovery organization using the AWS credentials you set in the variables.
|
||||||
|
|
||||||
|
Next, it creates a new project, environment, PostgreSQL database, and a Redis database in your Qovery organization.
|
||||||
|
|
||||||
|
Finally, it creates the Medusa app and sets all the necessary environment variables needed to run it.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
This deployment uses Docker. By default, you should have the files [`Dockerfile`](https://github.com/medusajs/medusa-starter-default/blob/master/Dockerfile) and [`docker-compose.yml`](https://github.com/medusajs/medusa-starter-default/blob/master/docker-compose.yml)` in the root of your Medusa server.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Change develop.sh
|
||||||
|
|
||||||
|
The `Dockerfile` runs the file `develop.sh` to start the server. Change the content of `develop.sh` to the following:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Run migrations to ensure the database is updated
|
||||||
|
medusa migrations run
|
||||||
|
|
||||||
|
#Start production server
|
||||||
|
medusa start
|
||||||
|
```
|
||||||
|
|
||||||
|
This makes sure the production server is started and not a development server.
|
||||||
|
|
||||||
|
### Initialize Terraform
|
||||||
|
|
||||||
|
In your terminal, run the following command to initialize Terraform:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
terraform init
|
||||||
|
```
|
||||||
|
|
||||||
|
This will install the Qovery Terraform provider and have everything ready before the deployment.
|
||||||
|
|
||||||
|
### Deploy the Medusa App
|
||||||
|
|
||||||
|
Finally, run the following command to deploy your Medusa app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
terraform apply
|
||||||
|
```
|
||||||
|
|
||||||
|
You’ll be asked to confirm creating all the necessary resources in Qovery. Enter `yes` and the deployment will start.
|
||||||
|
|
||||||
|
The deployment can take up to 30 minutes to finish. You’ll be able to track its status both in your terminal and in the [Qovery Console](https://console.qovery.com/).
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
If you run into any errors while running this command, you can just re-run it after fixing the errors and it will pick up from where it left off. For example, if an error occurred after the creation of the PostgreSQL database, terraform continues from the next task and does not recreate the PostgreSQL database.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Test your Server
|
||||||
|
|
||||||
|
Once the command finishes and the deployment is successful, you can access your server in the [Qovery Console](https://console.qovery.com/). Go to the project, environment, then the app that you created using Terraform and Qovery. In the app, click the Open button at the top right to open your website in a new tab.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You can access any of the endpoints on your server using the server URL. For example, you can get the list of products using the endpoint `/store/products`.
|
||||||
|
|
||||||
|
## Run Commands on Your Server
|
||||||
|
|
||||||
|
To run commands on your server, run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qovery shell
|
||||||
|
```
|
||||||
|
|
||||||
|
You’ll be asked to either confirm the existing context or choose a new context.
|
||||||
|
|
||||||
|
After choosing your Medusa app in the context, you should be able to execute any command in the directory of your Medusa server. For example, you can run the [`user` command using Medusa’s CLI tool to create a new user](../../cli/reference.md#user):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @medusajs/medusa-cli -g
|
||||||
|
medusa user --email <EMAIL> --password <PASSWORD>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add Environment Variables
|
||||||
|
|
||||||
|
You’ll likely need to add environment variables later such as Admin CORS and Store CORS variables.
|
||||||
|
|
||||||
|
To add environment variables, in your [Qovery Console](https://console.qovery.com/) go to the Medusa app and choose Environment Variables from the sidebar. You can add environment variables here at any point later on.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## What’s Next 🚀
|
||||||
|
|
||||||
|
- Learn how to [deploy the Medusa Admin to Netlify](../admin/deploying-on-netlify.md).
|
||||||
|
- Learn how to [deploy the Gatsby Storefront to Netlify](../storefront/deploying-gatsby-on-netlify.md).
|
||||||
@@ -16,9 +16,8 @@ Additionally, this documentation does not cover how to deploy the Medusa server.
|
|||||||
|
|
||||||
### Needed Accounts
|
### Needed Accounts
|
||||||
|
|
||||||
You need a Netlify account to deploy the Gatsby storefront. If you don’t have one, you can create one on [Netlify’s website](https://app.netlify.com/signup).
|
- A [Netlify](https://app.netlify.com/signup) account to deploy the Gatsby storefront.
|
||||||
|
- A [GitHub](https://github.com/signup) account where you will host the repository for the Gatsby storefront.
|
||||||
Additionally, you need a GitHub account where you will host the repository for the Gatsby storefront. You can create it on [GitHub’s website](https://github.com/signup).
|
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ If you want to use another Git Provider, it’s possible to follow along with th
|
|||||||
|
|
||||||
### Required Tools
|
### Required Tools
|
||||||
|
|
||||||
Git’s CLI tool is required while following along with this tutorial. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
- Git’s CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../tutorial/0-set-up-your-development-environment.mdx#git).
|
||||||
|
|
||||||
## Create GitHub Repository
|
## Create GitHub Repository
|
||||||
|
|
||||||
@@ -111,6 +110,12 @@ If you haven’t deployed your Medusa server yet, you can leave the value blank
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you use more environment variables in your storefront be sure to add them here.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
Once you’re done, scroll down and click on Deploy site.
|
Once you’re done, scroll down and click on Deploy site.
|
||||||
|
|
||||||
You’ll be then redirected to the dashboard of the new website. Netlify will build your website in the background. You should see “Site deploy in progress” on the top card.
|
You’ll be then redirected to the dashboard of the new website. Netlify will build your website in the background. You should see “Site deploy in progress” on the top card.
|
||||||
@@ -238,6 +243,12 @@ netlify env:set GATSBY_MEDUSA_BACKEND_URL "<YOUR_SERVER_URL>"
|
|||||||
|
|
||||||
Where `<YOUR_SERVER_URL>` is the URL of your Medusa server.
|
Where `<YOUR_SERVER_URL>` is the URL of your Medusa server.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
If you use more environment variables in your storefront be sure to add them here.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
#### Check deployment status
|
#### Check deployment status
|
||||||
|
|
||||||
You can check the deployment status of your website by running the following command:
|
You can check the deployment status of your website by running the following command:
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ Medusa comes with a set of building blocks that allow you to create unique digit
|
|||||||
|
|
||||||
You can follow our [quickstart guide](quickstart/quick-start.md) to install and run a Medusa server.
|
You can follow our [quickstart guide](quickstart/quick-start.md) to install and run a Medusa server.
|
||||||
|
|
||||||
It's also recommended to learn how to [set up your development environment](tutorial/set-up-your-development-environment) with the requirements tools and services to run a Medusa server, then [configure your Medusa server](usage/configurations.md).
|
It's also recommended to learn how to [set up your development environment](tutorial/set-up-your-development-environment) with the required tools and services to run a Medusa server, then [configure your Medusa server](usage/configurations.md).
|
||||||
|
|
||||||
### The Medusa Admin
|
### The Medusa Admin
|
||||||
|
|
||||||
|
|||||||
@@ -1,328 +0,0 @@
|
|||||||
---
|
|
||||||
title: Create a headless ecommerce store with Gatsby, Contentful & Medusa
|
|
||||||
---
|
|
||||||
|
|
||||||
# Creating a headless ecommerce store with Gatsby, Contentful and Medusa
|
|
||||||
|
|
||||||
:::info About Medusa
|
|
||||||
|
|
||||||
Medusa is an open source headless commerce engine that allow you to create amazing digital commerce experiences. Medusa is highly customizable, allowing you to extend the core to fit your needs.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Introduction
|
|
||||||
|
|
||||||
In this guide we will go over how to set up a modern e-commerce store using [Gatsby](https://gatsby.com) as a front end, [Contentful](https://contentful.com) as a CMS system and Medusa as a store engine. The resulting e-commerce store will be blazingly fast, highly extendable and will provide the necessary foundation to grow and evolve your e-commerce stack as your business expands to new markets and develops new software requirements.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
After following the steps outlines in this series you will have:
|
|
||||||
|
|
||||||
- A Medusa store engine capable of managing products, processing orders, handling orders and integrating with all the tools in your e-commerce stack.
|
|
||||||
- A statically generated Gatsby storefront that is on brand and customizable from homepage to checkout flow.
|
|
||||||
- A headless CMS system that can be modified and extended to create the best customer experience.
|
|
||||||
|
|
||||||
You will make use of `medusa-plugin-contentful` which is a plugin to your Medusa store engine that syncronizes products and product variants between your Medusa engine and your Contentful space. This allows you to perform content enrichment in Contentful while keeping your core master data in Medusa, for a truly headless commerce setup.
|
|
||||||
|
|
||||||
Other concepts that will be covered in this series include:
|
|
||||||
|
|
||||||
- Gatsby plugins and [File System Route API](https://www.gatsbyjs.com/docs/reference/routing/file-system-route-api/)
|
|
||||||
- [Contentful Migrations](https://www.contentful.com/developers/docs/tutorials/cli/scripting-migrations/)
|
|
||||||
- Medusa payments, fulfillments and plugins
|
|
||||||
|
|
||||||
If you want to jump straight to the code for this series you can checkout:
|
|
||||||
|
|
||||||
- [`medusa-starter-contentful`](https://github.com/medusajs/medusa-starter-contentful)
|
|
||||||
- [`medusa-contentful-storefront`](https://github.com/medusajs/medusa-contentful-storefront)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
For a full guide to how to set up your development environment for Medusa please see [the tutorial](https://docs.medusajs.com/tutorials/set-up-your-development-environment)
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
In order to get you started with your Gatsby, Contentful, Medusa store you must complete a couple of installations:
|
|
||||||
|
|
||||||
- Install the Medusa CLI
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm install @medusajs/medusa-cli -g
|
|
||||||
```
|
|
||||||
|
|
||||||
- Install the Gatsby CLI
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm install gatsby-cli -g
|
|
||||||
```
|
|
||||||
|
|
||||||
- [Create a Contentful account](https://www.contentful.com/sign-up/)
|
|
||||||
- [Install Redis](https://redis.io/topics/quickstart)
|
|
||||||
|
|
||||||
```
|
|
||||||
brew install redis
|
|
||||||
brew services start redis
|
|
||||||
```
|
|
||||||
|
|
||||||
Medusa has support for SQLite and PostgreSQL and uses Redis for caching and queueing of asynchronous tasks. Redis is required for `medusa-plugin-contentful` to work correctly.
|
|
||||||
|
|
||||||
## Setting up your Medusa server
|
|
||||||
|
|
||||||
We will make use of `medusa new` to setup your local Medusa server.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
medusa new medusa-contentful-store https://github.com/medusajs/medusa-starter-contentful
|
|
||||||
```
|
|
||||||
|
|
||||||
This command will setup a new directory at `medusa-contentful-store`, clone the `medusa-starter-contentful` into that directory and install the dependencies for the project.
|
|
||||||
|
|
||||||
### What's inside
|
|
||||||
|
|
||||||
You can now do `cd medusa-contentful-store` and open up your project in your text editor. Below is an overview of the directory structure and a walkthrough of what the different files do.
|
|
||||||
|
|
||||||
```
|
|
||||||
medusa-contentful-store
|
|
||||||
├── contentful-migrations
|
|
||||||
| ├── hero.js
|
|
||||||
| ├── index.js
|
|
||||||
| ├── link.js
|
|
||||||
| ├── navigation-item.js
|
|
||||||
| ├── navigation-menu.js
|
|
||||||
| ├── page.js
|
|
||||||
| ├── product-variant.js
|
|
||||||
| ├── product.js
|
|
||||||
| ├── region.js
|
|
||||||
| ├── tile-section.js
|
|
||||||
| └── tile.js
|
|
||||||
├── data
|
|
||||||
| ├── contentful-seed.json
|
|
||||||
| └── seed.json
|
|
||||||
├── src
|
|
||||||
| ├── api
|
|
||||||
| ├── loaders
|
|
||||||
| ├── services
|
|
||||||
| └── subscribers
|
|
||||||
├── .env
|
|
||||||
├── medusa-config.js
|
|
||||||
├── package.json
|
|
||||||
└── README.md
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `package.json`
|
|
||||||
|
|
||||||
If you are familiar with Node you will probably notice that your Medusa store is simply a Node project. Looking inside the `package.json` file you will find that one of the packages that is installed in the project is the `@medusajs/medusa` package. This is the core Medusa package that comes prepacked with all the functionality necessary to do digital commerce - it is also this package that makes sure to register and use the plugins and custom functionality that are configured for your store.
|
|
||||||
|
|
||||||
#### `medusa-config.js`
|
|
||||||
|
|
||||||
Your plugins and store configuration is managed in the `medusa-config.js`, if you open up the file you will see that `medusa-plugin-contentful` is configured with options as shown below. Later we will be setting up your Contentful space so that we can add the necessary environment variables to your `.env` file.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// medusa-config.js
|
|
||||||
|
|
||||||
// Contentful Variables
|
|
||||||
const CONTENTFUL_SPACE_ID = process.env.CONTENTFUL_SPACE_ID || "";
|
|
||||||
const CONTENTFUL_ACCESS_TOKEN = process.env.CONTENTFUL_ACCESS_TOKEN || "";
|
|
||||||
const CONTENTFUL_ENV = process.env.CONTENTFUL_ENV || "";
|
|
||||||
|
|
||||||
|
|
||||||
const plugins = [
|
|
||||||
...,
|
|
||||||
{
|
|
||||||
resolve: `medusa-plugin-contentful`,
|
|
||||||
options: {
|
|
||||||
space_id: CONTENTFUL_SPACE_ID,
|
|
||||||
access_token: CONTENTFUL_ACCESS_TOKEN,
|
|
||||||
environment: CONTENTFUL_ENV,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...
|
|
||||||
];
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
projectConfig: {
|
|
||||||
redis_url: REDIS_URL,
|
|
||||||
database_database: "./medusa-db.sql",
|
|
||||||
database_type: "sqlite",
|
|
||||||
store_cors: STORE_CORS,
|
|
||||||
admin_cors: ADMIN_CORS,
|
|
||||||
},
|
|
||||||
plugins,
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `/src`
|
|
||||||
|
|
||||||
In the `/src` directory there are 4 special subdirectories that are added for you already. These special directories can be used to add custom functionality to your store. Custom functionality can include custom endpoints (configured in `/api`), custom business logic (configured in `/services`), pub/sub-like subscriptions for asyncrhonous integration tasks (configured in `/subscribers`) and finally loader functions to be called when your Medusa server starts up (configured in `/loaders`). If you want to learn more about how to add custom functionality you can checkout [the tutorial](https://docs.medusajs.com/tutorials/adding-custom-functionality).
|
|
||||||
|
|
||||||
#### `/data`
|
|
||||||
|
|
||||||
We will be using two seed scripts to kickstart your development, namely:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run seed:contentful
|
|
||||||
npm run seed
|
|
||||||
```
|
|
||||||
|
|
||||||
Data for these seed scripts are contained in the `/data` directory.
|
|
||||||
|
|
||||||
When the seed scripts have been executed you will have a Contentful space that holds all the data for your website; this includes content for Pages, Navigtion Menu, etc.
|
|
||||||
|
|
||||||
#### `/contentful-migrations`
|
|
||||||
|
|
||||||
This directory contains scripts that create content types in your Contentful space. Contentful allows you to customize your content types with fields that can be used to hold all sorts of data, this makes it possible to create advanced data structures that will later be used to lay out your website. Writing migration scripts to evolve your content types is a really powerful tool as you can use it in CI/CD pipelines and makes your projects much more portable.
|
|
||||||
|
|
||||||
The migrations included in this project will create the following content types:
|
|
||||||
|
|
||||||
- **Page**: Represents a page on your website. Each page has a title and can take any number of "Content Modules". Content Modules can be either of the type Hero or Tile Section.
|
|
||||||
- **Hero**: a component that can take a Title, CTA and a background image.
|
|
||||||
- **Tile**: a component that can be added to a Tile Section and renders a Title, CTA and an Image.
|
|
||||||
- **Tile Section**: a component that can hold a number of Tiles or Products. When used with a Product, the Tile Section will display the product thumbnail and it's title and will link to the product page.
|
|
||||||
- **Link**: a component that can link to an external or internal path; or, alternatively, hold a reference to a Page or Product entry. If used with Page or Product, the link path will be inferred from the referenced entry.
|
|
||||||
- **Navigation Item**: an item to include in a Navigation Menu. Each navigation item has a title that can be displayed in a menu and a link that defines where the user will be navigated to when the item is clicked.
|
|
||||||
- **Product**: represents a product as syncronized from Medusa. A product's variants will be copied over as well.
|
|
||||||
- **Product Variant**: The variants of a product.
|
|
||||||
- **Region**: Represents an available region in Medusa.
|
|
||||||
|
|
||||||
## Creating a Contentful space
|
|
||||||
|
|
||||||
To create a new Contentful space log in to your Contentful account. If you already have a Contentful account with a Space configured you can click your organization name in the top left corner to reveal an overview of your organization's spaces. At the bottom of the spaces list you should click "Add space".
|
|
||||||
|
|
||||||
**Select "Community space" and "Web app only"**
|
|
||||||
In this guide we will be using a free space which gives you an incredibly strong foundation for creating on-brand customer experiences and advances shopping flows.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Add a name and select "Empty space"**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Once your space is set up you can go to your space home. We will now get the credentials needed for `medusa-plugin-contentful` to work.
|
|
||||||
|
|
||||||
Open your `.env` file in your text editor you should see:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# .env
|
|
||||||
JWT_SECRET=something
|
|
||||||
COOKIE_SECRET=something
|
|
||||||
|
|
||||||
STRIPE_API_KEY=
|
|
||||||
STRIPE_WEBHOOK_SECRET=
|
|
||||||
|
|
||||||
CONTENTFUL_SPACE_ID=
|
|
||||||
CONTENTFUL_ACCESS_TOKEN=
|
|
||||||
CONTENTFUL_ENV=
|
|
||||||
```
|
|
||||||
|
|
||||||
Your `CONTENTFUL_SPACE_ID` can be found by going to your space home and checking your browser's URL bar. The space id is the alphanumeric string following `https://app.contentful.com/spaces/`. Copy this string and paste it into your `.env` file.
|
|
||||||
|
|
||||||
To get your `CONTENFUL_ACCESS_TOKEN` go to your space home and click **Settings** > **API keys**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Then click **Content management tokens** and click **Generate personal token**. After giving your token a name you can copy it to your `.env`
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
For `CONTENTFUL_ENVIRONMENT` add `master`.
|
|
||||||
|
|
||||||
You should now have a `.env` that looks like this:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# .env
|
|
||||||
JWT_SECRET=something
|
|
||||||
COOKIE_SECRET=something
|
|
||||||
|
|
||||||
STRIPE_API_KEY=
|
|
||||||
STRIPE_WEBHOOK_SECRET=
|
|
||||||
|
|
||||||
CONTENTFUL_SPACE_ID=****
|
|
||||||
CONTENTFUL_ACCESS_TOKEN=CFPAT-*******
|
|
||||||
CONTENTFUL_ENV=master
|
|
||||||
```
|
|
||||||
|
|
||||||
## Migrating and Seeding your Contentful space
|
|
||||||
|
|
||||||
Now that we have collected your credentials we are ready to migrate the Contentful space to add the content types we talked about earlier. To migrate the Contentful space open up your command line and `cd` into `medusa-contentful-store`.
|
|
||||||
|
|
||||||
You can now run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run migrate:contentful
|
|
||||||
```
|
|
||||||
|
|
||||||
This script will run each of the migrations in the `contentful-migrations` directory. After it has completed navigate to your Contentful space and click "Content model" in the top navigation bar. You will see that the content types will be imported into your space. Feel free to familiarize yourself with the different types by clicking them and inspecting the different fields that they hold.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
The next step is to seed the Contentful space with some data that can be used to display your ecommerce store's pages and navigation. To seed the database open up your command line and run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run seed:contentful
|
|
||||||
```
|
|
||||||
|
|
||||||
In your Contentful space navigate to "Content" and you will be able to see the different entries in your space. You can filter the entries by type to, for example, only view Pages:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
You will notice that there are not any Products in your store yet and this is because we haven't created any products in your Medusa store.
|
|
||||||
|
|
||||||
To do this open your command line and run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run seed
|
|
||||||
npm run start
|
|
||||||
```
|
|
||||||
|
|
||||||
This will seed your Medusa database, which will result in `medusa-plugin-contentful` synchronizing data to your Contentful space. Everytime you add or update a product the data will be copied into your Contentful space for further enrichment.
|
|
||||||
|
|
||||||
## Setting Featured Products
|
|
||||||
|
|
||||||
In Contentful navigate to "Content" and find the Page called "Home". We will now add some featured products to the home page.
|
|
||||||
|
|
||||||
- Click the "Home" entry and scroll down to the field called "Content modules"
|
|
||||||

|
|
||||||
|
|
||||||
- Click the Content module named "Featured Products" and click "Add content" in the "Tiles" field
|
|
||||||

|
|
||||||
|
|
||||||
- Click "Add existing content" as e will be adding the products that were copied over by Medusa
|
|
||||||

|
|
||||||
|
|
||||||
- Select Medusa Waterbottle and Medusa Shirt and click "Insert 2 entries"
|
|
||||||
|
|
||||||
Make sure that everything is published by hitting publish in the sidebar on the right-hand side.
|
|
||||||
|
|
||||||
## Setting up your Gatsby storefront
|
|
||||||
|
|
||||||
Now that we have your Medusa server running and your Contentful space seeded with some starter data it is time to add a presentational layer that can be used by customers to browse and purchase the items in your store.
|
|
||||||
|
|
||||||
We have already created the storefront and you can install and use it by simply running:
|
|
||||||
|
|
||||||
```
|
|
||||||
gatsby new medusa-contentful-storefront https://github.com/medusajs/medusa-contentful-storefront
|
|
||||||
```
|
|
||||||
|
|
||||||
Once `gatsby new` is complete you should rename the `.env.template` file to `.env` and add a Content Delivery token. Your content delivery token is different from the personal access token you generated earlier, so make sure that you are using the correct token when you paste it into your `.env`.
|
|
||||||
|
|
||||||
To get your token go to **Settings** > **API Keys** > **Add API key**. Now click save and copy the token specified in the field "Content Delivery API - access token".
|
|
||||||
|
|
||||||
After you have copied the token and your space ID to your `.env`, you can start your Gatsby development server on port 8000 by running:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run start
|
|
||||||
```
|
|
||||||
|
|
||||||
You can now go to https://localhost:8000 to check out your new Medusa store.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
Using three powerful tools we have now set up a modern headless ecommerce store on our local development machine. This setup can scale with your business's needs and evolve to fit create amazing commerce expereiences that are unique and on brand. The steps we took in this guide were really simple and fast: first we created a Medusa server using the Medusa CLI, we then configured a Contentful space by running migrations and seed scripts. We also installed a Gatsby front end for our Medusa store using the Gatsby CLI.
|
|
||||||
|
|
||||||
## What's next
|
|
||||||
|
|
||||||
In the next part we will dig deeper into how Contentful can be used to create pages, enrich your products and structure your content. We will also take a look at the files in your Gatsby storefront.
|
|
||||||
|
|
||||||
Stay tuned!
|
|
||||||
@@ -1,316 +0,0 @@
|
|||||||
---
|
|
||||||
title: Making your store more powerful with Contentful
|
|
||||||
---
|
|
||||||
|
|
||||||
# Making your store more powerful with Contentful
|
|
||||||
|
|
||||||
In [part 1](https://docs.medusajs.com/how-to/headless-ecommerce-store-with-gatsby-contentful-medusa/) of this series you have set up [Medusa](https://medusajs.com) with Contentful as your CMS system and added a Gatsby storefront. In this part you will get a further introduction to Contentful and learn how [`medusa-plugin-contentful`](https://github.com/medusajs/medusa/tree/master/packages/medusa-plugin-contentful) can be leveraged to make your store more powerful. Apart from a front page, product pages and a checkout flow, most ecommerce stores also need miscalleneous pages like About and Contact pages. In this guide you will add a Rich Text content module to your Contentful space so that you can make this pages cool. You will also see how the content modules can be used to give your product pages more life.
|
|
||||||
|
|
||||||
What you will do in this guide:
|
|
||||||
|
|
||||||
- Add a rich text content module
|
|
||||||
- Add rich text to your `/about` page
|
|
||||||
- Add a "Related Products" section to your product page
|
|
||||||
|
|
||||||
Topics covered:
|
|
||||||
|
|
||||||
- Contentful Migrations
|
|
||||||
- Product enrichment
|
|
||||||
|
|
||||||
## Creating a rich text content module
|
|
||||||
|
|
||||||
In this guide you will make use of [Contentful Migrations](https://github.com/contentful/contentful-migration) to keep a versioned controlled record of how your Content evolves over time. The Contentful app allows you to create content models straight from their dashboard, however, when using the migrations tool you will be able to 1) quickly replicate your Contentful space and 2) incorporate migrations as part of a CI/CD pipeline. [You can read more about how to use CMS as Code here](https://www.contentful.com/help/cms-as-code/).
|
|
||||||
|
|
||||||
To prepare your migration create a new file at `contentful-migrations/rich-text.js` and add the following code:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// contentful-migrations/rich-text.js
|
|
||||||
|
|
||||||
module.exports = function (migration, context) {
|
|
||||||
const richText = migration
|
|
||||||
.createContentType("richText")
|
|
||||||
.name("Rich Text")
|
|
||||||
.displayField("title")
|
|
||||||
|
|
||||||
richText.createField("title").name("Title (Internal)").type("Symbol")
|
|
||||||
richText.createField("body").name("Body").type("RichText")
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This small snippet will create a content model in your Contentful space with two fields: a title which will be used to name entries in a meaningful manner (i.e. it won't be displayed to customers) and a body which contains the rich text to display. To apply your migration run:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run migrate:contentful --file contentful-migrations/rich-text.js
|
|
||||||
```
|
|
||||||
|
|
||||||
If you go to your Contentful space and click Content Model you will see that the Rich Text model has been added to your space:
|
|
||||||

|
|
||||||
|
|
||||||
The validation rules in the Page model only allow Hero and Tile Sections to be added to the Content Modules fields so you will need another migration to make it possible for pages to make use of the new Rich Text modules. Create a new migration at `contentful-migrations/update-page-module-validation.js` and add the following:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// contentful-migrations/update-page-module-validation.js
|
|
||||||
|
|
||||||
module.exports = function (migration, context) {
|
|
||||||
const page = migration.editContentType("page")
|
|
||||||
|
|
||||||
page.editField("contentModules").items({
|
|
||||||
type: "Link",
|
|
||||||
linkType: "Entry",
|
|
||||||
validations: [
|
|
||||||
{
|
|
||||||
linkContentType: ["hero", "tileSection", "richText"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
After migrating your space you are ready create your new contact page:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run migrate:contentful --file contentful-migrations/update-page-module-validation.js
|
|
||||||
```
|
|
||||||
|
|
||||||
## Adding Rich Text to About
|
|
||||||
|
|
||||||
To use your new Rich Text module **Content > Page > About**, and click **Add Content > Page**. You will now make use of the new Rich Text module to add some more details about your store. You can write your own text or use the text provided below if you just want to copy/paste.
|
|
||||||
|
|
||||||
:::info About Medusa
|
|
||||||
|
|
||||||
Medusa is an open-source headless commerce engine for fast-growing businesses. Getting started with Medusa is very easy and you will be able to start selling online with a basic setup in no time, however, the real power of Medusa starts showing up when you add custom functionality and extend your core to fit your needs.
|
|
||||||
|
|
||||||
The core Medusa package and all the official Medusa plugins ship as individual NPM packages that you install into a Node project. You store and plugins are configured in your medusa-config.js file making it very easy to manage your store as your business grows. Custom functionality doesn't have to come from plugins, you can also add project-level functionality by simply adding files in your `src/` folder. Medusa will automatically register your custom functionalities in the bootstrap phase.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
When you have added your text you can click **Publish changes** (make sure the About page is published too).
|
|
||||||
|
|
||||||
## Updating the storefront to support the Rich Text module
|
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
If you want to jump straight to the final frontend code visit [medusajs/medusa-contentful-storefront@part-2](https://github.com/medusajs/medusa-contentful-storefront/tree/part-2).
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
To display your newly created Rich Text module open up the storefront code and create a new file at `src/components/rich-text/rich-text.jsx`.
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
// src/components/rich-text/rich-text.jsx
|
|
||||||
|
|
||||||
import React from "react"
|
|
||||||
import { renderRichText } from "gatsby-source-contentful/rich-text"
|
|
||||||
|
|
||||||
import * as styles from "../../styles/rich-text.module.css"
|
|
||||||
|
|
||||||
const RichText = ({ data }) => {
|
|
||||||
return (
|
|
||||||
<div className={styles.container}>
|
|
||||||
<div className={styles.content}>
|
|
||||||
{data.body ? renderRichText(data.body) : ""}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RichText
|
|
||||||
```
|
|
||||||
|
|
||||||
The `renderRichText` function is imported from the `gatsby-source-contentful` plugin to easily transform the text you entered in the Rich Text module to html. To make the Rich Text component render nicely add a style file as well at `src/styles/rich-text.module.css`.
|
|
||||||
|
|
||||||
```css
|
|
||||||
/* src/styles/rich-text.module.css */
|
|
||||||
|
|
||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
padding-top: 100px;
|
|
||||||
padding-bottom: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
margin: auto;
|
|
||||||
max-width: 870px;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you restart your storefront server now you will not be able to see your new Rich Text module just yet. The last step to making that happen will be to let the Page component know to render the new Rich Text component when it encounters Rich Text in the Page's Content Modules. In your editor open up the file `src/pages/{ContentfulPage.slug}.js` and add the following:
|
|
||||||
|
|
||||||
At the top of the file import your `RichText` component:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
...
|
|
||||||
import RichText from "../components/rich-text/rich-text"
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
Now in the `contentModules.map` function return the `RichText` component whenever a `ContentfulRichText` module is encountered. Add a case to the switch statement:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
case "ContentfulRichText":
|
|
||||||
return <RichText key={cm.id} data={cm} />
|
|
||||||
```
|
|
||||||
|
|
||||||
Finally you will need to fetch the Rich Text data from Gatsby's data layer by modifying the GraphQL code at the bottom of the file after the line with `contentModules {` add:
|
|
||||||
|
|
||||||
```graphql
|
|
||||||
... on ContentfulRichText {
|
|
||||||
id
|
|
||||||
body {
|
|
||||||
raw
|
|
||||||
}
|
|
||||||
internal {
|
|
||||||
type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart your local Gatsby server and visit `http://localhost:8000/about`, you will now see the your newly added Rich Text module.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Enriching your Product pages
|
|
||||||
|
|
||||||
You have now seen how the Page model in Contentful can be extended to include a new content module in a reusable and modular manner. The same idea can be extended to your Product pages allowing you to create completely bespoke universes around your products. You will use the same techniques as above to create a Related Products section below the "Medusa Shirt" product.
|
|
||||||
|
|
||||||
### Migrating Products
|
|
||||||
|
|
||||||
First, add a new field to the Product content model. Using migrations you can create a file `contentful-migrations/product-add-modules.js`:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// contentful-migrations/product-add-modules.js
|
|
||||||
|
|
||||||
module.exports = function (migration, context) {
|
|
||||||
const product = migration.editContentType("product")
|
|
||||||
|
|
||||||
product
|
|
||||||
.createField("contentModules")
|
|
||||||
.name("Content Modules")
|
|
||||||
.type("Array")
|
|
||||||
.items({
|
|
||||||
type: "Link",
|
|
||||||
linkType: "Entry",
|
|
||||||
validations: [
|
|
||||||
{
|
|
||||||
linkContentType: ["hero", "tileSection", "richText"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Run the migration:
|
|
||||||
|
|
||||||
```bash npm2yarn
|
|
||||||
npm run migrate:contentful --file contentful-migrations/product-add-modules.js
|
|
||||||
```
|
|
||||||
|
|
||||||
### Adding "Related Products" Tile Section
|
|
||||||
|
|
||||||
After the migration you can now add Content Modules to Products, to enrich the Product pages with relevant content. In this guide you will add a Tile Section that holds "Related Products", but the functionality could be further extended to showcase look book images, inspirational content or more detailed product descriptions.
|
|
||||||
|
|
||||||
In Contentful go to **Content > Product > Medusa Shirt** scroll all the way to the bottom, where you should be able to find the new _Content Modules_ field:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Click **Add content > Tile Section** which will open a new Tile Section. For the Title write "Related Products", and for Tiles click **Add content > Add existing content > Medusa Waterbottle > Insert 1 entry**.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Click **Publish** and make sure that the Medusa Shirt product is published too.
|
|
||||||
|
|
||||||
Your data is now ready to be used in the storefront, but you still need to make a couple of changes to the storefront code to be able to view the new content.
|
|
||||||
|
|
||||||
## Adding Content Modules to Product pages
|
|
||||||
|
|
||||||
Just like you did for the Page component, you will have to fetch the Content Modules from Gatsby's GraphQL data layer.
|
|
||||||
|
|
||||||
In the file `src/pages/products/{ContentfulProduct.handle}.js` add the following in the GraphQL query at the bottom of the file (e.g. after the variants query):
|
|
||||||
|
|
||||||
```graphql
|
|
||||||
# src/pages/products/{ContentfulProduct.handle}.js
|
|
||||||
|
|
||||||
contentModules {
|
|
||||||
... on ContentfulTileSection {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
tiles {
|
|
||||||
... on ContentfulProduct {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
handle
|
|
||||||
thumbnail {
|
|
||||||
gatsbyImageData
|
|
||||||
}
|
|
||||||
internal {
|
|
||||||
type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on ContentfulTile {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
cta
|
|
||||||
image {
|
|
||||||
gatsbyImageData
|
|
||||||
}
|
|
||||||
link {
|
|
||||||
linkTo
|
|
||||||
reference {
|
|
||||||
slug
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal {
|
|
||||||
type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal {
|
|
||||||
type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This snippet will query the Content Modules defined for the product and will allow you to use the data in your components.
|
|
||||||
|
|
||||||
Next open up the `src/views/products.jsx` file and add the following snippets.
|
|
||||||
|
|
||||||
Import the `TileSection` component:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import TileSection from "../components/tile-section/tile-section"
|
|
||||||
```
|
|
||||||
|
|
||||||
Add the Content Modules in the JSX just before the final closing `div`:
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
// src/views/products.jsx
|
|
||||||
|
|
||||||
<div className={styles.contentModules}>
|
|
||||||
{product.contentModules?.map((cm) => {
|
|
||||||
switch (cm.internal.type) {
|
|
||||||
case "ContentfulTileSection":
|
|
||||||
return <TileSection key={cm.id} data={cm} />
|
|
||||||
default:
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart the Gatsby server and visit http://localhost:8000/product/medusa-shirt you should now see the new "Related Products" Tile Section below the Product page controls.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
In this guide you created a new content model for Rich Text input in Contentful using [contentful-migration](https://github.com/contentful/contentful-migration). You further extended the storefront to render the new Rich Text plugin. The concepts in this guide are meant to demonstrate how Contentful can be used to make your store more powerful in a modular and scalable way. The content modules covered in this guide could be further extended to add other custom modules, for example, you could add a Newsletter Signup, module that when encountered in the code renders a newsletter form.
|
|
||||||
|
|
||||||
## What's next
|
|
||||||
|
|
||||||
In the next part of this guide you will learn how to implement further commerce functionalities to your site such as adding support for discount codes, region based shopping and more. (Coming soon)
|
|
||||||
|
|
||||||
- [Deploying Medusa Server](../deployments/server/index.mdx)
|
|
||||||
- [Deploying Medusa Admin](../deployments/admin/index.mdx)
|
|
||||||
@@ -27,7 +27,7 @@ You can install Node from the [official website](https://nodejs.org/en/).
|
|||||||
### 1. Install Medusa CLI
|
### 1. Install Medusa CLI
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash npm2yarn
|
||||||
npm install -g @medusajs/medusa-cli
|
npm install @medusajs/medusa-cli -g
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create a new Medusa project
|
### 2. Create a new Medusa project
|
||||||
@@ -81,5 +81,5 @@ You can learn more about configuring your server and loading environment variabl
|
|||||||
|
|
||||||
- Install our [Next.js](../starters/nextjs-medusa-starter) or [Gatsby](../starters/gatsby-medusa-starter) storefronts to set up your ecommerce storefront quickly.
|
- Install our [Next.js](../starters/nextjs-medusa-starter) or [Gatsby](../starters/gatsby-medusa-starter) storefronts to set up your ecommerce storefront quickly.
|
||||||
- Install the [Medusa Admin](../admin/quickstart.md) to supercharge your ecommerce experience with easy access to configurations and features.
|
- Install the [Medusa Admin](../admin/quickstart.md) to supercharge your ecommerce experience with easy access to configurations and features.
|
||||||
- Check our the [API reference](https://docs.medusajs.com/api) to learn more about available endpoints available on your Medusa server.
|
- Check out the [API reference](https://docs.medusajs.com/api) to learn more about available endpoints available on your Medusa server.
|
||||||
- Install [plugins](https://github.com/medusajs/medusa/tree/master/packages) for features like Payment, CMS, Notifications, among other features.
|
- Install [plugins](https://github.com/medusajs/medusa/tree/master/packages) for features like Payment, CMS, Notifications, among other features.
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: AuthService
|
# Class: AuthService
|
||||||
|
|
||||||
Can authenticate a user based on email password combination
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`AuthService`](AuthService.md)\>
|
- `TransactionBaseService`<[`AuthService`](AuthService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<AuthService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L25)
|
[services/auth.ts:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L25)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L23)
|
[services/auth.ts:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L23)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:20](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L20)
|
[services/auth.ts:20](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L20)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -84,7 +82,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:21](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L21)
|
[services/auth.ts:21](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L21)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -94,7 +92,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:22](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L22)
|
[services/auth.ts:22](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L22)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -102,10 +100,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -117,23 +111,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -141,27 +133,20 @@ ___
|
|||||||
|
|
||||||
▸ **authenticate**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
▸ **authenticate**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
||||||
|
|
||||||
Authenticates a given user based on an email, password combination. Uses
|
|
||||||
scrypt to match password with hashed value.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `email` | `string` | the email of the user |
|
| `email` | `string` | |
|
||||||
| `password` | `string` | the password of the user |
|
| `password` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`AuthenticateResult`\>
|
`Promise`<`AuthenticateResult`\>
|
||||||
|
|
||||||
success: whether authentication succeeded
|
|
||||||
user: the user document if authentication succeded
|
|
||||||
error: a string with the error message
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:98](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L98)
|
[services/auth.ts:98](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L98)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -169,25 +154,19 @@ ___
|
|||||||
|
|
||||||
▸ **authenticateAPIToken**(`token`): `Promise`<`AuthenticateResult`\>
|
▸ **authenticateAPIToken**(`token`): `Promise`<`AuthenticateResult`\>
|
||||||
|
|
||||||
Authenticates a given user with an API token
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `token` | `string` | the api_token of the user to authenticate |
|
| `token` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`AuthenticateResult`\>
|
`Promise`<`AuthenticateResult`\>
|
||||||
|
|
||||||
success: whether authentication succeeded
|
|
||||||
user: the user document if authentication succeded
|
|
||||||
error: a string with the error message
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:55](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L55)
|
[services/auth.ts:55](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L55)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -195,27 +174,20 @@ ___
|
|||||||
|
|
||||||
▸ **authenticateCustomer**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
▸ **authenticateCustomer**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
||||||
|
|
||||||
Authenticates a customer based on an email, password combination. Uses
|
|
||||||
scrypt to match password with hashed value.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `email` | `string` | the email of the user |
|
| `email` | `string` | |
|
||||||
| `password` | `string` | the password of the user |
|
| `password` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`AuthenticateResult`\>
|
`Promise`<`AuthenticateResult`\>
|
||||||
|
|
||||||
success: whether authentication succeeded
|
|
||||||
user: the user document if authentication succeded
|
|
||||||
error: a string with the error message
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:147](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L147)
|
[services/auth.ts:147](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L147)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -223,24 +195,20 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **comparePassword_**(`password`, `hash`): `Promise`<`boolean`\>
|
▸ `Protected` **comparePassword_**(`password`, `hash`): `Promise`<`boolean`\>
|
||||||
|
|
||||||
Verifies if a password is valid given the provided password hash
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `password` | `string` | the raw password to check |
|
| `password` | `string` | |
|
||||||
| `hash` | `string` | the hash to compare against |
|
| `hash` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`boolean`\>
|
`Promise`<`boolean`\>
|
||||||
|
|
||||||
the result of the comparison
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/auth.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/auth.ts#L39)
|
[services/auth.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/auth.ts#L39)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -264,7 +232,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -288,4 +256,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -24,7 +24,7 @@ TransactionBaseService<BatchJobService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:93](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L93)
|
[services/batch-job.ts:93](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L93)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ TransactionBaseService<BatchJobService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:41](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L41)
|
[services/batch-job.ts:41](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L41)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L45)
|
[services/batch-job.ts:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L42)
|
[services/batch-job.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:38](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L38)
|
[services/batch-job.ts:38](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L38)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L43)
|
[services/batch-job.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L43)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L39)
|
[services/batch-job.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L39)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L27)
|
[services/batch-job.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L27)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -143,10 +143,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -158,23 +154,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -194,7 +188,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:284](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L284)
|
[services/batch-job.ts:284](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L284)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -214,7 +208,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:266](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L266)
|
[services/batch-job.ts:266](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L266)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -234,7 +228,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:248](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L248)
|
[services/batch-job.ts:248](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L248)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -254,7 +248,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:153](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L153)
|
[services/batch-job.ts:153](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L153)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -275,7 +269,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:137](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L137)
|
[services/batch-job.ts:137](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L137)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -296,7 +290,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:380](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L380)
|
[services/batch-job.ts:380](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L380)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -317,7 +311,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:112](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L112)
|
[services/batch-job.ts:112](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L112)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -338,7 +332,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:354](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L354)
|
[services/batch-job.ts:354](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L354)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -358,7 +352,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:302](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L302)
|
[services/batch-job.ts:302](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L302)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -378,7 +372,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:334](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L334)
|
[services/batch-job.ts:334](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L334)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -402,7 +396,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -423,7 +417,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:172](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L172)
|
[services/batch-job.ts:172](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L172)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -444,7 +438,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/batch-job.ts:213](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/batch-job.ts#L213)
|
[services/batch-job.ts:213](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/batch-job.ts#L213)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -468,4 +462,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -24,7 +24,7 @@ BaseService<ClaimItemService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L30)
|
[services/claim-item.ts:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L30)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ BaseService<ClaimItemService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L25)
|
[services/claim-item.ts:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L25)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L23)
|
[services/claim-item.ts:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L23)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:24](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L24)
|
[services/claim-item.ts:24](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L24)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:22](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L22)
|
[services/claim-item.ts:22](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L22)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:21](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L21)
|
[services/claim-item.ts:21](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L21)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ BaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L27)
|
[services/claim-item.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L27)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ BaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:28](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L28)
|
[services/claim-item.ts:28](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L28)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L15)
|
[services/claim-item.ts:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L15)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -148,10 +148,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -163,23 +159,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
BaseService.atomicPhase\_
|
BaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -199,7 +193,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L49)
|
[services/claim-item.ts:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L49)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -211,18 +205,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`ClaimItem`\> | the query object for find |
|
| `selector` | `Selector`<`ClaimItem`\> | |
|
||||||
| `config` | `FindConfig`<`ClaimItem`\> | the config object for find |
|
| `config` | `FindConfig`<`ClaimItem`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ClaimItem`[]\>
|
`Promise`<`ClaimItem`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:214](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L214)
|
[services/claim-item.ts:214](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L214)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -230,24 +222,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`ClaimItem`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`ClaimItem`\>
|
||||||
|
|
||||||
Gets a claim item by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of ClaimItem to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `FindConfig`<`ClaimItem`\> | configuration for the find operation |
|
| `config` | `FindConfig`<`ClaimItem`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ClaimItem`\>
|
`Promise`<`ClaimItem`\>
|
||||||
|
|
||||||
the ClaimItem
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:233](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L233)
|
[services/claim-item.ts:233](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L233)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -271,7 +259,7 @@ BaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -292,7 +280,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim-item.ts:132](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim-item.ts#L132)
|
[services/claim-item.ts:132](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim-item.ts#L132)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -316,4 +304,4 @@ BaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -27,7 +27,7 @@ TransactionBaseService<
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:85](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L85)
|
[services/claim.ts:85](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L85)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ TransactionBaseService<
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:68](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L68)
|
[services/claim.ts:68](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L68)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:72](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L72)
|
[services/claim.ts:72](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L72)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:69](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L69)
|
[services/claim.ts:69](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L69)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:73](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L73)
|
[services/claim.ts:73](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L73)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:74](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L74)
|
[services/claim.ts:74](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L74)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:75](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L75)
|
[services/claim.ts:75](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L75)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:76](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L76)
|
[services/claim.ts:76](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L76)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:71](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L71)
|
[services/claim.ts:71](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L71)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:77](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L77)
|
[services/claim.ts:77](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L77)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:65](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L65)
|
[services/claim.ts:65](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L65)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:78](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L78)
|
[services/claim.ts:78](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L78)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:79](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L79)
|
[services/claim.ts:79](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L79)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:80](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L80)
|
[services/claim.ts:80](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L80)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:70](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L70)
|
[services/claim.ts:70](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L70)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:81](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L81)
|
[services/claim.ts:81](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L81)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:82](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L82)
|
[services/claim.ts:82](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L82)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:83](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L83)
|
[services/claim.ts:83](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L83)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:66](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L66)
|
[services/claim.ts:66](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L66)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:56](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L56)
|
[services/claim.ts:56](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L56)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -264,10 +264,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -279,23 +275,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -315,7 +309,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:753](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L753)
|
[services/claim.ts:753](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L753)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -335,7 +329,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:602](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L602)
|
[services/claim.ts:602](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L602)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -343,25 +337,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`ClaimOrder`\>
|
▸ **create**(`data`): `Promise`<`ClaimOrder`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `CreateClaimInput` | the object containing all data required to create a claim |
|
| `data` | `CreateClaimInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ClaimOrder`\>
|
`Promise`<`ClaimOrder`\>
|
||||||
|
|
||||||
created claim
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:217](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L217)
|
[services/claim.ts:217](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L217)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -373,20 +361,18 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the object containing all data required to create a claim |
|
| `id` | `string` | |
|
||||||
| `config` | `Object` | config object |
|
| `config` | `Object` | |
|
||||||
| `config.metadata?` | `Record`<`string`, `unknown`\> | config metadata |
|
| `config.metadata?` | `Record`<`string`, `unknown`\> | |
|
||||||
| `config.no_notification?` | `boolean` | config no notification |
|
| `config.no_notification?` | `boolean` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ClaimOrder`\>
|
`Promise`<`ClaimOrder`\>
|
||||||
|
|
||||||
created claim
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:456](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L456)
|
[services/claim.ts:456](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L456)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -411,7 +397,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:674](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L674)
|
[services/claim.ts:674](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L674)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -423,18 +409,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `FindConfig`<`ClaimOrder`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`ClaimOrder`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ClaimOrder`[]\>
|
`Promise`<`ClaimOrder`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:809](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L809)
|
[services/claim.ts:809](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L809)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -454,7 +438,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:628](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L628)
|
[services/claim.ts:628](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L628)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -462,24 +446,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`ClaimOrder`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`ClaimOrder`\>
|
||||||
|
|
||||||
Gets an order by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of the claim order to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `FindConfig`<`ClaimOrder`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`ClaimOrder`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ClaimOrder`\>
|
`Promise`<`ClaimOrder`\>
|
||||||
|
|
||||||
the order document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:834](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L834)
|
[services/claim.ts:834](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L834)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -503,7 +483,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -524,7 +504,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/claim.ts:127](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/claim.ts#L127)
|
[services/claim.ts:127](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/claim.ts#L127)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -548,4 +528,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -24,7 +24,7 @@ TransactionBaseService<CustomShippingOptionService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:19](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L19)
|
[services/custom-shipping-option.ts:19](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L19)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:17](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L17)
|
[services/custom-shipping-option.ts:17](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L17)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L15)
|
[services/custom-shipping-option.ts:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L15)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L16)
|
[services/custom-shipping-option.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L16)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -90,10 +90,6 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -105,23 +101,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -129,23 +123,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`CustomShippingOption`\>
|
▸ **create**(`data`): `Promise`<`CustomShippingOption`\>
|
||||||
|
|
||||||
Creates a custom shipping option
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `CreateCustomShippingOptionInput` | the custom shipping option to create |
|
| `data` | `CreateCustomShippingOptionInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomShippingOption`\>
|
`Promise`<`CustomShippingOption`\>
|
||||||
|
|
||||||
resolves to the creation result
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:90](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L90)
|
[services/custom-shipping-option.ts:90](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L90)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -153,24 +143,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector`, `config?`): `Promise`<`CustomShippingOption`[]\>
|
▸ **list**(`selector`, `config?`): `Promise`<`CustomShippingOption`[]\>
|
||||||
|
|
||||||
Fetches all custom shipping options based on the given selector
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`CustomShippingOption`\> | the query object for find |
|
| `selector` | `Selector`<`CustomShippingOption`\> | |
|
||||||
| `config` | `FindConfig`<`CustomShippingOption`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
| `config` | `FindConfig`<`CustomShippingOption`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomShippingOption`[]\>
|
`Promise`<`CustomShippingOption`[]\>
|
||||||
|
|
||||||
custom shipping options matching the query
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:65](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L65)
|
[services/custom-shipping-option.ts:65](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L65)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -178,24 +164,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`CustomShippingOption`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`CustomShippingOption`\>
|
||||||
|
|
||||||
Retrieves a specific shipping option.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the custom shipping option to retrieve. |
|
| `id` | `string` | |
|
||||||
| `config` | `FindConfig`<`CustomShippingOption`\> | any options needed to query for the result. |
|
| `config` | `FindConfig`<`CustomShippingOption`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomShippingOption`\>
|
`Promise`<`CustomShippingOption`\>
|
||||||
|
|
||||||
the requested custom shipping option.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/custom-shipping-option.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/custom-shipping-option.ts#L36)
|
[services/custom-shipping-option.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/custom-shipping-option.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -219,7 +201,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -243,4 +225,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
# Class: CustomerGroupService
|
# Class: CustomerGroupService
|
||||||
|
|
||||||
Provides layer to manipulate discounts.
|
|
||||||
|
|
||||||
**`implements`** {BaseService}
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -28,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:31](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L31)
|
[services/customer-group.ts:31](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L31)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -38,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L27)
|
[services/customer-group.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L27)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -48,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:29](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L29)
|
[services/customer-group.ts:29](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L29)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -58,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L25)
|
[services/customer-group.ts:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L25)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -66,24 +62,20 @@ ___
|
|||||||
|
|
||||||
▸ **addCustomers**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
▸ **addCustomers**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
||||||
|
|
||||||
Add a batch of customers to a customer group at once
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of the customer group to add customers to |
|
| `id` | `string` | |
|
||||||
| `customerIds` | `string` \| `string`[] | customer id's to add to the group |
|
| `customerIds` | `string` \| `string`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomerGroup`\>
|
`Promise`<`CustomerGroup`\>
|
||||||
|
|
||||||
the customer group after insertion
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:113](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L113)
|
[services/customer-group.ts:113](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L113)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -91,23 +83,27 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`group`): `Promise`<`CustomerGroup`\>
|
▸ **create**(`group`): `Promise`<`CustomerGroup`\>
|
||||||
|
|
||||||
Creates a customer group with the provided data.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `group` | `DeepPartial`<`CustomerGroup`\> | the customer group to create |
|
| `group` | `Object` | |
|
||||||
|
| `group.created_at?` | { toString?: {} \| undefined; toDateString?: {} \| undefined; toTimeString?: {} \| undefined; toLocaleString?: {} \| undefined; toLocaleDateString?: {} \| undefined; toLocaleTimeString?: {} \| undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} \| undefined; } | - |
|
||||||
|
| `group.customers?` | (`undefined` \| { email?: string \| undefined; first\_name?: string \| undefined; last\_name?: string \| undefined; billing\_address\_id?: string \| null \| undefined; billing\_address?: { customer\_id?: string \| null \| undefined; ... 16 more ...; updated\_at?: { ...; } \| undefined; } \| undefined; ... 10 more ...; updated\_at?: { ...; } \| undef...)[] | - |
|
||||||
|
| `group.deleted_at?` | ``null`` \| { toString?: {} \| undefined; toDateString?: {} \| undefined; toTimeString?: {} \| undefined; toLocaleString?: {} \| undefined; toLocaleDateString?: {} \| undefined; toLocaleTimeString?: {} \| undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} \| undefined; } | - |
|
||||||
|
| `group.id?` | `string` | - |
|
||||||
|
| `group.metadata?` | { [x: string]: unknown; } | - |
|
||||||
|
| `group.name?` | `string` | - |
|
||||||
|
| `group.price_lists?` | (`undefined` \| { name?: string \| undefined; description?: string \| undefined; type?: PriceListType \| undefined; status?: PriceListStatus \| undefined; starts\_at?: { ...; } \| ... 1 more ... \| undefined; ... 6 more ...; updated\_at?: { ...; } \| undefined; })[] | - |
|
||||||
|
| `group.updated_at?` | { toString?: {} \| undefined; toDateString?: {} \| undefined; toTimeString?: {} \| undefined; toLocaleString?: {} \| undefined; toLocaleDateString?: {} \| undefined; toLocaleTimeString?: {} \| undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} \| undefined; } | - |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomerGroup`\>
|
`Promise`<`CustomerGroup`\>
|
||||||
|
|
||||||
the result of the create operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:86](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L86)
|
[services/customer-group.ts:86](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L86)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -115,23 +111,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`groupId`): `Promise`<`void`\>
|
▸ **delete**(`groupId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Remove customer group
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `groupId` | `string` | id of the customer group to delete |
|
| `groupId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
a promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:194](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L194)
|
[services/customer-group.ts:194](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L194)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -139,24 +131,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector?`, `config`): `Promise`<`CustomerGroup`[]\>
|
▸ **list**(`selector?`, `config`): `Promise`<`CustomerGroup`[]\>
|
||||||
|
|
||||||
List customer groups.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableCustomerGroupProps` | the query object for find |
|
| `selector` | `FilterableCustomerGroupProps` | |
|
||||||
| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find |
|
| `config` | `FindConfig`<`CustomerGroup`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomerGroup`[]\>
|
`Promise`<`CustomerGroup`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:217](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L217)
|
[services/customer-group.ts:217](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L217)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -164,24 +152,20 @@ ___
|
|||||||
|
|
||||||
▸ **listAndCount**(`selector?`, `config`): `Promise`<[`CustomerGroup`[], `number`]\>
|
▸ **listAndCount**(`selector?`, `config`): `Promise`<[`CustomerGroup`[], `number`]\>
|
||||||
|
|
||||||
Retrieve a list of customer groups and total count of records that match the query.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableCustomerGroupProps` | the query object for find |
|
| `selector` | `FilterableCustomerGroupProps` | |
|
||||||
| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find |
|
| `config` | `FindConfig`<`CustomerGroup`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`CustomerGroup`[], `number`]\>
|
`Promise`<[`CustomerGroup`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:236](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L236)
|
[services/customer-group.ts:236](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L236)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -189,24 +173,20 @@ ___
|
|||||||
|
|
||||||
▸ **removeCustomer**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
▸ **removeCustomer**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
||||||
|
|
||||||
Remove list of customers from a customergroup
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of the customer group from which the customers are removed |
|
| `id` | `string` | |
|
||||||
| `customerIds` | `string` \| `string`[] | id's of the customer to remove from group |
|
| `customerIds` | `string` \| `string`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomerGroup`\>
|
`Promise`<`CustomerGroup`\>
|
||||||
|
|
||||||
the customergroup with the provided id
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:271](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L271)
|
[services/customer-group.ts:271](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L271)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -227,7 +207,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:62](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L62)
|
[services/customer-group.ts:62](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L62)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -235,24 +215,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`customerGroupId`, `update`): `Promise`<`CustomerGroup`[]\>
|
▸ **update**(`customerGroupId`, `update`): `Promise`<`CustomerGroup`[]\>
|
||||||
|
|
||||||
Update a customer group.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customerGroupId` | `string` | id of the customer group |
|
| `customerGroupId` | `string` | |
|
||||||
| `update` | `CustomerGroupUpdate` | customer group partial data |
|
| `update` | `CustomerGroupUpdate` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`CustomerGroup`[]\>
|
`Promise`<`CustomerGroup`[]\>
|
||||||
|
|
||||||
resulting customer group
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:162](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L162)
|
[services/customer-group.ts:162](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L162)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -272,4 +248,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer-group.ts:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer-group.ts#L46)
|
[services/customer-group.ts:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer-group.ts#L46)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: CustomerService
|
# Class: CustomerService
|
||||||
|
|
||||||
Provides layer to manipulate customers.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`CustomerService`](CustomerService.md)\>
|
- `TransactionBaseService`<[`CustomerService`](CustomerService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<CustomerService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L40)
|
[services/customer.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L40)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ TransactionBaseService<CustomerService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:28](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L28)
|
[services/customer.ts:28](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L28)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L27)
|
[services/customer.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L27)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:29](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L29)
|
[services/customer.ts:29](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L29)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:31](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L31)
|
[services/customer.ts:31](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L31)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -104,7 +102,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:32](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L32)
|
[services/customer.ts:32](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L32)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -122,13 +120,13 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L34)
|
[services/customer.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L34)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
### addAddress
|
### addAddress
|
||||||
|
|
||||||
▸ **addAddress**(`customerId`, `address`): `Promise`<`Customer` \| `Address`\>
|
▸ **addAddress**(`customerId`, `address`): `Promise`<`Address` \| `Customer`\>
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
@@ -139,11 +137,11 @@ ___
|
|||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer` \| `Address`\>
|
`Promise`<`Address` \| `Customer`\>
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:471](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L471)
|
[services/customer.ts:471](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L471)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -151,10 +149,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -166,23 +160,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -190,17 +182,13 @@ ___
|
|||||||
|
|
||||||
▸ **count**(): `Promise`<`number`\>
|
▸ **count**(): `Promise`<`number`\>
|
||||||
|
|
||||||
Return the total number of documents in database
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`number`\>
|
`Promise`<`number`\>
|
||||||
|
|
||||||
the result of the count operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:161](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L161)
|
[services/customer.ts:161](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L161)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -208,26 +196,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`customer`): `Promise`<`Customer`\>
|
▸ **create**(`customer`): `Promise`<`Customer`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customer` | `CreateCustomerInput` | the customer to create |
|
| `customer` | `CreateCustomerInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer`\>
|
`Promise`<`Customer`\>
|
||||||
|
|
||||||
the result of create
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:255](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L255)
|
[services/customer.ts:255](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L255)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -235,23 +216,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`customerId`): `Promise`<`void` \| `Customer`\>
|
▸ **delete**(`customerId`): `Promise`<`void` \| `Customer`\>
|
||||||
|
|
||||||
Deletes a customer from a given customer id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customerId` | `string` | the id of the customer to delete. Must be castable as an ObjectId |
|
| `customerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void` \| `Customer`\>
|
`Promise`<`void` \| `Customer`\>
|
||||||
|
|
||||||
the result of the delete operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:519](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L519)
|
[services/customer.ts:519](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L519)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -259,27 +236,19 @@ ___
|
|||||||
|
|
||||||
▸ **generateResetPasswordToken**(`customerId`): `Promise`<`string`\>
|
▸ **generateResetPasswordToken**(`customerId`): `Promise`<`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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customerId` | `string` | the customer to reset the password for |
|
| `customerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`string`\>
|
`Promise`<`string`\>
|
||||||
|
|
||||||
the generated JSON web token
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:65](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L65)
|
[services/customer.ts:65](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L65)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -287,23 +256,19 @@ ___
|
|||||||
|
|
||||||
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
||||||
|
|
||||||
Hashes a password
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `password` | `string` | the value to hash |
|
| `password` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`string`\>
|
`Promise`<`string`\>
|
||||||
|
|
||||||
hashed password
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:242](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L242)
|
[services/customer.ts:242](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L242)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -315,18 +280,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`Customer`\> & { `q?`: `string` } | the query object for find |
|
| `selector` | `Selector`<`Customer`\> & { `q?`: `string` } | |
|
||||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Customer`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer`[]\>
|
`Promise`<`Customer`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:108](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L108)
|
[services/customer.ts:108](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L108)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -338,18 +301,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`Customer`\> & { `q?`: `string` } | the query object for find |
|
| `selector` | `Selector`<`Customer`\> & { `q?`: `string` } | |
|
||||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Customer`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`Customer`[], `number`]\>
|
`Promise`<[`Customer`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:133](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L133)
|
[services/customer.ts:133](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L133)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -370,7 +331,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:454](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L454)
|
[services/customer.ts:454](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L454)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -378,24 +339,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`customerId`, `config?`): `Promise`<`Customer`\>
|
▸ **retrieve**(`customerId`, `config?`): `Promise`<`Customer`\>
|
||||||
|
|
||||||
Gets a customer by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customerId` | `string` | the id of the customer to get. |
|
| `customerId` | `string` | |
|
||||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Customer`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer`\>
|
`Promise`<`Customer`\>
|
||||||
|
|
||||||
the customer document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:228](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L228)
|
[services/customer.ts:228](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L228)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -403,24 +360,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`Customer`\>
|
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`Customer`\>
|
||||||
|
|
||||||
Gets a customer by email.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `email` | `string` | the email of the customer to get. |
|
| `email` | `string` | |
|
||||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Customer`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer`\>
|
`Promise`<`Customer`\>
|
||||||
|
|
||||||
the customer document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:198](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L198)
|
[services/customer.ts:198](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L198)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -428,24 +381,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByPhone**(`phone`, `config?`): `Promise`<`Customer`\>
|
▸ **retrieveByPhone**(`phone`, `config?`): `Promise`<`Customer`\>
|
||||||
|
|
||||||
Gets a customer by phone.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `phone` | `string` | the phone of the customer to get. |
|
| `phone` | `string` | |
|
||||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Customer`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer`\>
|
`Promise`<`Customer`\>
|
||||||
|
|
||||||
the customer document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:213](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L213)
|
[services/customer.ts:213](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L213)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -466,7 +415,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:168](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L168)
|
[services/customer.ts:168](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L168)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -490,7 +439,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -498,24 +447,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`customerId`, `update`): `Promise`<`Customer`\>
|
▸ **update**(`customerId`, `update`): `Promise`<`Customer`\>
|
||||||
|
|
||||||
Updates a customer.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customerId` | `string` | the id of the variant. Must be a string that can be casted to an ObjectId |
|
| `customerId` | `string` | |
|
||||||
| `update` | `UpdateCustomerInput` | an object with the update values. |
|
| `update` | `UpdateCustomerInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Customer`\>
|
`Promise`<`Customer`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:310](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L310)
|
[services/customer.ts:310](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L310)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -537,7 +482,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:426](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L426)
|
[services/customer.ts:426](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L426)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -545,24 +490,20 @@ ___
|
|||||||
|
|
||||||
▸ **updateBillingAddress_**(`customer`, `addressOrId`): `Promise`<`void`\>
|
▸ **updateBillingAddress_**(`customer`, `addressOrId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Updates the customers' billing address.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `customer` | `Customer` | the Customer to update |
|
| `customer` | `Customer` | |
|
||||||
| `addressOrId` | `undefined` \| `string` \| `DeepPartial`<`Address`\> | the value to set the billing address to |
|
| `addressOrId` | `undefined` \| `string` \| { `address_1?`: ``null`` \| `string` ; `address_2?`: ``null`` \| `string` ; `city?`: ``null`` \| `string` ; `company?`: ``null`` \| `string` ; `country?`: ``null`` \| { id?: number \| undefined; iso\_2?: string \| undefined; iso\_3?: string \| undefined; num\_code?: number \| undefined; name?: string \| undefined; display\_name?: string \| undefined; region\_id?: string \| ... 1 more ... \| undefined; region?: { ...; } \| undefined; } ; `country_code?`: ``null`` \| `string` ; `created_at?`: { toString?: {} \| undefined; toDateString?: {} \| undefined; toTimeString?: {} \| undefined; toLocaleString?: {} \| undefined; toLocaleDateString?: {} \| undefined; toLocaleTimeString?: {} \| undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} \| undefined; } ; `customer?`: ``null`` \| { email?: string \| undefined; first\_name?: string \| undefined; last\_name?: string \| undefined; billing\_address\_id?: string \| null \| undefined; billing\_address?: { customer\_id?: string \| null \| undefined; ... 16 more ...; updated\_at?: { ...; } \| undefined; } \| undefined; ... 10 more ...; updated\_at?: { ...; } \| undef... ; `customer_id?`: ``null`` \| `string` ; `deleted_at?`: ``null`` \| { toString?: {} \| undefined; toDateString?: {} \| undefined; toTimeString?: {} \| undefined; toLocaleString?: {} \| undefined; toLocaleDateString?: {} \| undefined; toLocaleTimeString?: {} \| undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} \| undefined; } ; `first_name?`: ``null`` \| `string` ; `id?`: `string` ; `last_name?`: ``null`` \| `string` ; `metadata?`: { [x: string]: unknown; } ; `phone?`: ``null`` \| `string` ; `postal_code?`: ``null`` \| `string` ; `province?`: ``null`` \| `string` ; `updated_at?`: { toString?: {} \| undefined; toDateString?: {} \| undefined; toTimeString?: {} \| undefined; toLocaleString?: {} \| undefined; toLocaleDateString?: {} \| undefined; toLocaleTimeString?: {} \| undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} \| undefined; } } | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/customer.ts:374](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/customer.ts#L374)
|
[services/customer.ts:374](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/customer.ts#L374)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -586,4 +527,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
# Class: DiscountService
|
# Class: DiscountService
|
||||||
|
|
||||||
Provides layer to manipulate discounts.
|
|
||||||
|
|
||||||
**`implements`** {BaseService}
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`DiscountService`](DiscountService.md)\>
|
- `TransactionBaseService`<[`DiscountService`](DiscountService.md)\>
|
||||||
@@ -28,7 +24,7 @@ TransactionBaseService<DiscountService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:62](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L62)
|
[services/discount.ts:62](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L62)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -58,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:52](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L52)
|
[services/discount.ts:52](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L52)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -68,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:55](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L55)
|
[services/discount.ts:55](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L55)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -78,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:56](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L56)
|
[services/discount.ts:56](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L56)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -88,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:51](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L51)
|
[services/discount.ts:51](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L51)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -98,7 +94,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L53)
|
[services/discount.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -108,7 +104,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:60](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L60)
|
[services/discount.ts:60](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L60)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -118,7 +114,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:54](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L54)
|
[services/discount.ts:54](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L54)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -132,7 +128,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:48](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L48)
|
[services/discount.ts:48](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L48)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -142,7 +138,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:58](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L58)
|
[services/discount.ts:58](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L58)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -152,7 +148,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:59](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L59)
|
[services/discount.ts:59](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L59)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -162,7 +158,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:57](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L57)
|
[services/discount.ts:57](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L57)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -176,7 +172,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L49)
|
[services/discount.ts:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L49)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -184,24 +180,20 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ **addRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
▸ **addRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Adds a region to the discount regions array.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | id of discount |
|
| `discountId` | `string` | |
|
||||||
| `regionId` | `string` | id of region to add |
|
| `regionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:477](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L477)
|
[services/discount.ts:477](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L477)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -209,10 +201,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -224,23 +212,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -262,7 +248,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:576](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L576)
|
[services/discount.ts:576](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L576)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -283,7 +269,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:720](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L720)
|
[services/discount.ts:720](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L720)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -291,24 +277,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`discount`): `Promise`<`Discount`\>
|
▸ **create**(`discount`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Creates a discount with provided data given that the data is validated.
|
|
||||||
Normalizes discount code to uppercase.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discount` | `CreateDiscountInput` | the discount data to create |
|
| `discount` | `CreateDiscountInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the result of the create operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:182](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L182)
|
[services/discount.ts:182](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L182)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -316,24 +297,20 @@ ___
|
|||||||
|
|
||||||
▸ **createDynamicCode**(`discountId`, `data`): `Promise`<`Discount`\>
|
▸ **createDynamicCode**(`discountId`, `data`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Creates a dynamic code for a discount id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | the id of the discount to create a code for |
|
| `discountId` | `string` | |
|
||||||
| `data` | `CreateDynamicDiscountInput` | the object containing a code to identify the discount by |
|
| `data` | `CreateDynamicDiscountInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the newly created dynamic code
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:405](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L405)
|
[services/discount.ts:405](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L405)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -341,23 +318,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`discountId`): `Promise`<`void`\>
|
▸ **delete**(`discountId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Deletes a discount idempotently
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | id of discount to delete |
|
| `discountId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
the result of the delete operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:537](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L537)
|
[services/discount.ts:537](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L537)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -365,24 +338,20 @@ ___
|
|||||||
|
|
||||||
▸ **deleteDynamicCode**(`discountId`, `code`): `Promise`<`void`\>
|
▸ **deleteDynamicCode**(`discountId`, `code`): `Promise`<`void`\>
|
||||||
|
|
||||||
Deletes a dynamic code for a discount id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | the id of the discount to create a code for |
|
| `discountId` | `string` | |
|
||||||
| `code` | `string` | the code to identify the discount by |
|
| `code` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
the newly created dynamic code
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:456](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L456)
|
[services/discount.ts:456](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L456)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -402,7 +371,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:689](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L689)
|
[services/discount.ts:689](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L689)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -422,7 +391,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:685](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L685)
|
[services/discount.ts:685](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L685)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -442,7 +411,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:679](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L679)
|
[services/discount.ts:679](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L679)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -462,7 +431,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:697](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L697)
|
[services/discount.ts:697](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L697)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -483,7 +452,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:701](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L701)
|
[services/discount.ts:701](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L701)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -495,18 +464,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableDiscountProps` | the query object for find |
|
| `selector` | `FilterableDiscountProps` | |
|
||||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Discount`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`[]\>
|
`Promise`<`Discount`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:114](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L114)
|
[services/discount.ts:114](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L114)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -518,18 +485,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableDiscountProps` | the query object for find |
|
| `selector` | `FilterableDiscountProps` | |
|
||||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Discount`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`Discount`[], `number`]\>
|
`Promise`<[`Discount`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:133](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L133)
|
[services/discount.ts:133](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L133)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -537,24 +502,20 @@ ___
|
|||||||
|
|
||||||
▸ **removeRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
▸ **removeRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Removes a region from the discount regions array.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | id of discount |
|
| `discountId` | `string` | |
|
||||||
| `regionId` | `string` | id of region to remove |
|
| `regionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:512](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L512)
|
[services/discount.ts:512](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L512)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -562,24 +523,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`discountId`, `config?`): `Promise`<`Discount`\>
|
▸ **retrieve**(`discountId`, `config?`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Gets a discount by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | id of discount to retrieve |
|
| `discountId` | `string` | |
|
||||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Discount`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the discount
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:247](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L247)
|
[services/discount.ts:247](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L247)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -587,24 +544,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByCode**(`discountCode`, `config?`): `Promise`<`Discount`\>
|
▸ **retrieveByCode**(`discountCode`, `config?`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Gets a discount by discount code.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountCode` | `string` | discount code of discount to retrieve |
|
| `discountCode` | `string` | |
|
||||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
| `config` | `FindConfig`<`Discount`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the discount document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:276](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L276)
|
[services/discount.ts:276](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L276)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -628,7 +581,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -636,24 +589,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`discountId`, `update`): `Promise`<`Discount`\>
|
▸ **update**(`discountId`, `update`): `Promise`<`Discount`\>
|
||||||
|
|
||||||
Updates a discount.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountId` | `string` | discount id of discount to update |
|
| `discountId` | `string` | |
|
||||||
| `update` | `UpdateDiscountInput` | the data to update the discount with |
|
| `update` | `UpdateDiscountInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Discount`\>
|
`Promise`<`Discount`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:310](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L310)
|
[services/discount.ts:310](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L310)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -674,7 +623,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:619](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L619)
|
[services/discount.ts:619](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L619)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -695,7 +644,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:551](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L551)
|
[services/discount.ts:551](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L551)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -703,8 +652,6 @@ ___
|
|||||||
|
|
||||||
▸ **validateDiscountRule_**<`T`\>(`discountRule`): `T`
|
▸ **validateDiscountRule_**<`T`\>(`discountRule`): `T`
|
||||||
|
|
||||||
Creates a discount rule with provided data given that the data is validated.
|
|
||||||
|
|
||||||
#### Type parameters
|
#### Type parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
@@ -715,17 +662,15 @@ Creates a discount rule with provided data given that the data is validated.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discountRule` | `T` | the discount rule to create |
|
| `discountRule` | `T` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`T`
|
`T`
|
||||||
|
|
||||||
the result of the create operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/discount.ts:96](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/discount.ts#L96)
|
[services/discount.ts:96](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/discount.ts#L96)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -749,4 +694,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
# Class: DraftOrderService
|
# Class: DraftOrderService
|
||||||
|
|
||||||
Handles draft orders
|
|
||||||
|
|
||||||
**`implements`** {BaseService}
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`DraftOrderService`](DraftOrderService.md)\>
|
- `TransactionBaseService`<[`DraftOrderService`](DraftOrderService.md)\>
|
||||||
@@ -28,7 +24,7 @@ TransactionBaseService<DraftOrderService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:51](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L51)
|
[services/draft-order.ts:51](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L51)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -38,7 +34,7 @@ TransactionBaseService<DraftOrderService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L46)
|
[services/draft-order.ts:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -68,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L42)
|
[services/draft-order.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -78,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L45)
|
[services/draft-order.ts:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -88,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L47)
|
[services/draft-order.ts:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -102,7 +98,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L39)
|
[services/draft-order.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L39)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -112,7 +108,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:44](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L44)
|
[services/draft-order.ts:44](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L44)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -122,7 +118,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L43)
|
[services/draft-order.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L43)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -132,7 +128,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:48](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L48)
|
[services/draft-order.ts:48](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L48)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -142,7 +138,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L49)
|
[services/draft-order.ts:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L49)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -156,7 +152,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L40)
|
[services/draft-order.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L40)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -173,7 +169,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L34)
|
[services/draft-order.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L34)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -181,10 +177,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -196,23 +188,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -220,23 +210,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`DraftOrder`\>
|
▸ **create**(`data`): `Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
Creates a draft order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `AdminPostDraftOrdersReq` | data to create draft order from |
|
| `data` | `AdminPostDraftOrdersReq` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`DraftOrder`\>
|
`Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
the created draft order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:257](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L257)
|
[services/draft-order.ts:257](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L257)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -244,23 +230,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`draftOrderId`): `Promise`<`undefined` \| `DraftOrder`\>
|
▸ **delete**(`draftOrderId`): `Promise`<`undefined` \| `DraftOrder`\>
|
||||||
|
|
||||||
Deletes draft order idempotently.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `draftOrderId` | `string` | id of draft order to delete |
|
| `draftOrderId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`undefined` \| `DraftOrder`\>
|
`Promise`<`undefined` \| `DraftOrder`\>
|
||||||
|
|
||||||
empty promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:150](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L150)
|
[services/draft-order.ts:150](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L150)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -268,24 +250,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector`, `config?`): `Promise`<`DraftOrder`[]\>
|
▸ **list**(`selector`, `config?`): `Promise`<`DraftOrder`[]\>
|
||||||
|
|
||||||
Lists draft orders
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `FindConfig`<`DraftOrder`\> | configurable attributes for find |
|
| `config` | `FindConfig`<`DraftOrder`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`DraftOrder`[]\>
|
`Promise`<`DraftOrder`[]\>
|
||||||
|
|
||||||
list of draft orders
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:231](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L231)
|
[services/draft-order.ts:231](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L231)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -293,24 +271,20 @@ ___
|
|||||||
|
|
||||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`DraftOrder`[], `number`]\>
|
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`DraftOrder`[], `number`]\>
|
||||||
|
|
||||||
Lists draft orders alongside the count
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | query selector to filter draft orders |
|
| `selector` | `any` | |
|
||||||
| `config` | `FindConfig`<`DraftOrder`\> | query config |
|
| `config` | `FindConfig`<`DraftOrder`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`DraftOrder`[], `number`]\>
|
`Promise`<[`DraftOrder`[], `number`]\>
|
||||||
|
|
||||||
draft orders
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:174](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L174)
|
[services/draft-order.ts:174](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L174)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -318,24 +292,20 @@ ___
|
|||||||
|
|
||||||
▸ **registerCartCompletion**(`draftOrderId`, `orderId`): `Promise`<`UpdateResult`\>
|
▸ **registerCartCompletion**(`draftOrderId`, `orderId`): `Promise`<`UpdateResult`\>
|
||||||
|
|
||||||
Registers a draft order as completed, when an order has been completed.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `draftOrderId` | `string` | id of draft order to complete |
|
| `draftOrderId` | `string` | |
|
||||||
| `orderId` | `string` | id of order completed from draft order cart |
|
| `orderId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`UpdateResult`\>
|
`Promise`<`UpdateResult`\>
|
||||||
|
|
||||||
the created order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:363](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L363)
|
[services/draft-order.ts:363](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L363)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -343,24 +313,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`DraftOrder`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
Retrieves a draft order with the given id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of the draft order to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `FindConfig`<`DraftOrder`\> | query object for findOne |
|
| `config` | `FindConfig`<`DraftOrder`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`DraftOrder`\>
|
`Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
the draft order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:91](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L91)
|
[services/draft-order.ts:91](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L91)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -368,24 +334,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`DraftOrder`\>
|
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
Retrieves a draft order based on its associated cart id
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartId` | `string` | cart id that the draft orders's cart has |
|
| `cartId` | `string` | |
|
||||||
| `config` | `FindConfig`<`DraftOrder`\> | query object for findOne |
|
| `config` | `FindConfig`<`DraftOrder`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`DraftOrder`\>
|
`Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
the draft order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:121](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L121)
|
[services/draft-order.ts:121](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L121)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -409,7 +371,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -417,25 +379,21 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`id`, `data`): `Promise`<`DraftOrder`\>
|
▸ **update**(`id`, `data`): `Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
Updates a draft order with the given data
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of the draft order |
|
| `id` | `string` | |
|
||||||
| `data` | `Object` | values to update the order with |
|
| `data` | `Object` | |
|
||||||
| `data.no_notification_order` | `boolean` | - |
|
| `data.no_notification_order` | `boolean` | - |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`DraftOrder`\>
|
`Promise`<`DraftOrder`\>
|
||||||
|
|
||||||
the updated draft order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/draft-order.ts:392](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/draft-order.ts#L392)
|
[services/draft-order.ts:392](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/draft-order.ts#L392)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -459,4 +417,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
# Class: EventBusService
|
# Class: EventBusService
|
||||||
|
|
||||||
Can keep track of multiple subscribers to different events and run the
|
|
||||||
subscribers when events happen. Events will run asynchronously.
|
|
||||||
|
|
||||||
## Constructors
|
## Constructors
|
||||||
|
|
||||||
### constructor
|
### constructor
|
||||||
@@ -19,7 +16,7 @@ subscribers when events happen. Events will run asynchronously.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:38](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L38)
|
[services/event-bus.ts:38](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L38)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -29,7 +26,7 @@ subscribers when events happen. Events will run asynchronously.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:24](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L24)
|
[services/event-bus.ts:24](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L24)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -39,7 +36,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:29](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L29)
|
[services/event-bus.ts:29](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L29)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -49,7 +46,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:32](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L32)
|
[services/event-bus.ts:32](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L32)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -59,7 +56,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L36)
|
[services/event-bus.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -69,7 +66,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:26](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L26)
|
[services/event-bus.ts:26](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L26)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -79,7 +76,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L25)
|
[services/event-bus.ts:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L25)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -89,7 +86,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:28](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L28)
|
[services/event-bus.ts:28](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L28)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -99,7 +96,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:33](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L33)
|
[services/event-bus.ts:33](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L33)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -109,7 +106,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L30)
|
[services/event-bus.ts:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -119,7 +116,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:31](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L31)
|
[services/event-bus.ts:31](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L31)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -129,7 +126,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L34)
|
[services/event-bus.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -139,7 +136,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L27)
|
[services/event-bus.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L27)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -149,7 +146,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:35](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L35)
|
[services/event-bus.ts:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L35)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -157,8 +154,6 @@ ___
|
|||||||
|
|
||||||
▸ **createCronJob**<`T`\>(`eventName`, `data`, `cron`, `handler`): `void`
|
▸ **createCronJob**<`T`\>(`eventName`, `data`, `cron`, `handler`): `void`
|
||||||
|
|
||||||
Registers a cron job.
|
|
||||||
|
|
||||||
#### Type parameters
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -169,20 +164,18 @@ Registers a cron job.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `eventName` | `string` | the name of the event |
|
| `eventName` | `string` | |
|
||||||
| `data` | `T` | the data to be sent with the event |
|
| `data` | `T` | |
|
||||||
| `cron` | `string` | the cron pattern |
|
| `cron` | `string` | |
|
||||||
| `handler` | `Subscriber`<`unknown`\> | the handler to call on each cron job |
|
| `handler` | `Subscriber`<`unknown`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`void`
|
`void`
|
||||||
|
|
||||||
void
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:308](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L308)
|
[services/event-bus.ts:308](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L308)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -190,8 +183,6 @@ ___
|
|||||||
|
|
||||||
▸ **cronWorker_**<`T`\>(`job`): `Promise`<`unknown`[]\>
|
▸ **cronWorker_**<`T`\>(`job`): `Promise`<`unknown`[]\>
|
||||||
|
|
||||||
Handles incoming jobs.
|
|
||||||
|
|
||||||
#### Type parameters
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -202,7 +193,7 @@ Handles incoming jobs.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `job` | `Object` | The job object |
|
| `job` | `Object` | |
|
||||||
| `job.data` | `Object` | - |
|
| `job.data` | `Object` | - |
|
||||||
| `job.data.data` | `T` | - |
|
| `job.data.data` | `T` | - |
|
||||||
| `job.data.eventName` | `string` | - |
|
| `job.data.eventName` | `string` | - |
|
||||||
@@ -211,11 +202,9 @@ Handles incoming jobs.
|
|||||||
|
|
||||||
`Promise`<`unknown`[]\>
|
`Promise`<`unknown`[]\>
|
||||||
|
|
||||||
resolves to the results of the subscriber calls.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:281](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L281)
|
[services/event-bus.ts:281](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L281)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -223,8 +212,6 @@ ___
|
|||||||
|
|
||||||
▸ **emit**<`T`\>(`eventName`, `data`, `options?`): `Promise`<`void` \| `StagedJob`\>
|
▸ **emit**<`T`\>(`eventName`, `data`, `options?`): `Promise`<`void` \| `StagedJob`\>
|
||||||
|
|
||||||
Calls all subscribers when an event occurs.
|
|
||||||
|
|
||||||
#### Type parameters
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -235,20 +222,18 @@ Calls all subscribers when an event occurs.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `eventName` | `string` | the name of the event to be process. |
|
| `eventName` | `string` | |
|
||||||
| `data` | `T` | the data to send to the subscriber. |
|
| `data` | `T` | |
|
||||||
| `options` | `Object` | options to add the job with |
|
| `options` | `Object` | |
|
||||||
| `options.delay?` | `number` | - |
|
| `options.delay?` | `number` | - |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void` \| `StagedJob`\>
|
`Promise`<`void` \| `StagedJob`\>
|
||||||
|
|
||||||
the job from our queue
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:179](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L179)
|
[services/event-bus.ts:179](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L179)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -262,7 +247,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:215](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L215)
|
[services/event-bus.ts:215](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L215)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -270,24 +255,20 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **registerCronHandler_**(`event`, `subscriber`): [`EventBusService`](EventBusService.md)
|
▸ `Protected` **registerCronHandler_**(`event`, `subscriber`): [`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
Adds a function to a list of event subscribers.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `event` | `string` \| `symbol` | the event that the subscriber will listen for. |
|
| `event` | `string` \| `symbol` | |
|
||||||
| `subscriber` | `Subscriber`<`unknown`\> | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
| `subscriber` | `Subscriber`<`unknown`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
[`EventBusService`](EventBusService.md)
|
[`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:158](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L158)
|
[services/event-bus.ts:158](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L158)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -301,7 +282,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:205](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L205)
|
[services/event-bus.ts:205](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L205)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -315,7 +296,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:210](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L210)
|
[services/event-bus.ts:210](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L210)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -323,24 +304,20 @@ ___
|
|||||||
|
|
||||||
▸ **subscribe**(`event`, `subscriber`): [`EventBusService`](EventBusService.md)
|
▸ **subscribe**(`event`, `subscriber`): [`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
Adds a function to a list of event subscribers.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `event` | `string` \| `symbol` | the event that the subscriber will listen for. |
|
| `event` | `string` \| `symbol` | |
|
||||||
| `subscriber` | `Subscriber`<`unknown`\> | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
| `subscriber` | `Subscriber`<`unknown`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
[`EventBusService`](EventBusService.md)
|
[`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:118](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L118)
|
[services/event-bus.ts:118](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L118)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -348,24 +325,20 @@ ___
|
|||||||
|
|
||||||
▸ **unsubscribe**(`event`, `subscriber`): [`EventBusService`](EventBusService.md)
|
▸ **unsubscribe**(`event`, `subscriber`): [`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
Adds a function to a list of event subscribers.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `event` | `string` \| `symbol` | the event that the subscriber will listen for. |
|
| `event` | `string` \| `symbol` | |
|
||||||
| `subscriber` | `Subscriber`<`unknown`\> | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
| `subscriber` | `Subscriber`<`unknown`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
[`EventBusService`](EventBusService.md)
|
[`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:136](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L136)
|
[services/event-bus.ts:136](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L136)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -385,7 +358,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:88](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L88)
|
[services/event-bus.ts:88](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L88)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -393,8 +366,6 @@ ___
|
|||||||
|
|
||||||
▸ **worker_**<`T`\>(`job`): `Promise`<`unknown`[]\>
|
▸ **worker_**<`T`\>(`job`): `Promise`<`unknown`[]\>
|
||||||
|
|
||||||
Handles incoming jobs.
|
|
||||||
|
|
||||||
#### Type parameters
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -405,7 +376,7 @@ Handles incoming jobs.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `job` | `Object` | The job object |
|
| `job` | `Object` | |
|
||||||
| `job.data` | `Object` | - |
|
| `job.data` | `Object` | - |
|
||||||
| `job.data.data` | `T` | - |
|
| `job.data.data` | `T` | - |
|
||||||
| `job.data.eventName` | `string` | - |
|
| `job.data.eventName` | `string` | - |
|
||||||
@@ -414,8 +385,6 @@ Handles incoming jobs.
|
|||||||
|
|
||||||
`Promise`<`unknown`[]\>
|
`Promise`<`unknown`[]\>
|
||||||
|
|
||||||
resolves to the results of the subscriber calls.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/event-bus.ts:250](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/event-bus.ts#L250)
|
[services/event-bus.ts:250](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/event-bus.ts#L250)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: FulfillmentProviderService
|
# Class: FulfillmentProviderService
|
||||||
|
|
||||||
Helps retrive fulfillment providers
|
|
||||||
|
|
||||||
## Constructors
|
## Constructors
|
||||||
|
|
||||||
### constructor
|
### constructor
|
||||||
@@ -16,7 +14,7 @@ Helps retrive fulfillment providers
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:7](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L7)
|
[services/fulfillment-provider.js:7](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L7)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ Helps retrive fulfillment providers
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:79](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L79)
|
[services/fulfillment-provider.js:79](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L79)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -58,7 +56,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:64](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L64)
|
[services/fulfillment-provider.js:64](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L64)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -78,7 +76,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:74](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L74)
|
[services/fulfillment-provider.js:74](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L74)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -101,7 +99,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:59](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L59)
|
[services/fulfillment-provider.js:59](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L59)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -121,7 +119,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:89](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L89)
|
[services/fulfillment-provider.js:89](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L89)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -135,7 +133,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L23)
|
[services/fulfillment-provider.js:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L23)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -155,7 +153,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L30)
|
[services/fulfillment-provider.js:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -175,7 +173,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:12](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L12)
|
[services/fulfillment-provider.js:12](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L12)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -183,15 +181,13 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveDocuments**(`providerId`, `fulfillmentData`, `documentType`): `Promise`<`any`\>
|
▸ **retrieveDocuments**(`providerId`, `fulfillmentData`, `documentType`): `Promise`<`any`\>
|
||||||
|
|
||||||
Fetches documents from the fulfillment provider
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `providerId` | `string` | the id of the provider |
|
| `providerId` | `string` | |
|
||||||
| `fulfillmentData` | `any` | the data relating to the fulfillment |
|
| `fulfillmentData` | `any` | |
|
||||||
| `documentType` | ``"invoice"`` \| ``"label"`` | the typ of document to fetch |
|
| `documentType` | ``"label"`` \| ``"invoice"`` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -199,7 +195,7 @@ Fetches documents from the fulfillment provider
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:102](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L102)
|
[services/fulfillment-provider.js:102](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L102)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -211,17 +207,15 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `provider_id` | `string` | the provider id |
|
| `provider_id` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`FulfillmentService`
|
`FulfillmentService`
|
||||||
|
|
||||||
the payment fulfillment provider
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:48](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L48)
|
[services/fulfillment-provider.js:48](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L48)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -243,7 +237,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:69](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L69)
|
[services/fulfillment-provider.js:69](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L69)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -263,4 +257,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment-provider.js:84](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment-provider.js#L84)
|
[services/fulfillment-provider.js:84](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment-provider.js#L84)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: FulfillmentService
|
# Class: FulfillmentService
|
||||||
|
|
||||||
Handles Fulfillments
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`FulfillmentService`](FulfillmentService.md)\>
|
- `TransactionBaseService`<[`FulfillmentService`](FulfillmentService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<FulfillmentService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L47)
|
[services/fulfillment.ts:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L47)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L42)
|
[services/fulfillment.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L43)
|
[services/fulfillment.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L43)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L45)
|
[services/fulfillment.ts:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L40)
|
[services/fulfillment.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L40)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -100,7 +98,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L36)
|
[services/fulfillment.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -110,7 +108,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:41](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L41)
|
[services/fulfillment.ts:41](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L41)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -120,7 +118,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L39)
|
[services/fulfillment.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L39)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -130,7 +128,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:44](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L44)
|
[services/fulfillment.ts:44](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L44)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -144,7 +142,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:37](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L37)
|
[services/fulfillment.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L37)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -152,10 +150,6 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -167,23 +161,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -191,25 +183,19 @@ ___
|
|||||||
|
|
||||||
▸ **cancelFulfillment**(`fulfillmentOrId`): `Promise`<`Fulfillment`\>
|
▸ **cancelFulfillment**(`fulfillmentOrId`): `Promise`<`Fulfillment`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `fulfillmentOrId` | `string` \| `Fulfillment` | the fulfillment object or id. |
|
| `fulfillmentOrId` | `string` \| `Fulfillment` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Fulfillment`\>
|
`Promise`<`Fulfillment`\>
|
||||||
|
|
||||||
the result of the save operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:254](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L254)
|
[services/fulfillment.ts:254](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L254)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -217,28 +203,21 @@ ___
|
|||||||
|
|
||||||
▸ **createFulfillment**(`order`, `itemsToFulfill`, `custom?`): `Promise`<`Fulfillment`[]\>
|
▸ **createFulfillment**(`order`, `itemsToFulfill`, `custom?`): `Promise`<`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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `CreateFulfillmentOrder` | order to create fulfillment for |
|
| `order` | `CreateFulfillmentOrder` | |
|
||||||
| `itemsToFulfill` | `FulFillmentItemType`[] | the items in the order to fulfill |
|
| `itemsToFulfill` | `FulFillmentItemType`[] | |
|
||||||
| `custom` | `Partial`<`Fulfillment`\> | potential custom values to add |
|
| `custom` | `Partial`<`Fulfillment`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Fulfillment`[]\>
|
`Promise`<`Fulfillment`[]\>
|
||||||
|
|
||||||
the created fulfillments
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:199](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L199)
|
[services/fulfillment.ts:199](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L199)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -246,26 +225,21 @@ ___
|
|||||||
|
|
||||||
▸ **createShipment**(`fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`Fulfillment`\>
|
▸ **createShipment**(`fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`Fulfillment`\>
|
||||||
|
|
||||||
Creates a shipment by marking a fulfillment as shipped. Adds
|
|
||||||
tracking links and potentially more metadata.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `fulfillmentId` | `string` | the fulfillment to ship |
|
| `fulfillmentId` | `string` | |
|
||||||
| `trackingLinks` | { `tracking_number`: `string` }[] | tracking links for the shipment |
|
| `trackingLinks` | { `tracking_number`: `string` }[] | |
|
||||||
| `config` | `CreateShipmentConfig` | potential configuration settings, such as no_notification and metadata |
|
| `config` | `CreateShipmentConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Fulfillment`\>
|
`Promise`<`Fulfillment`\>
|
||||||
|
|
||||||
the shipped fulfillment
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:304](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L304)
|
[services/fulfillment.ts:304](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L304)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -273,24 +247,20 @@ ___
|
|||||||
|
|
||||||
▸ **getFulfillmentItems_**(`order`, `items`): `Promise`<(``null`` \| `LineItem`)[]\>
|
▸ **getFulfillmentItems_**(`order`, `items`): `Promise`<(``null`` \| `LineItem`)[]\>
|
||||||
|
|
||||||
Retrieves the order line items, given an array of items.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `CreateFulfillmentOrder` | the order to get line items from |
|
| `order` | `CreateFulfillmentOrder` | |
|
||||||
| `items` | `FulFillmentItemType`[] | the items to get |
|
| `items` | `FulFillmentItemType`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<(``null`` \| `LineItem`)[]\>
|
`Promise`<(``null`` \| `LineItem`)[]\>
|
||||||
|
|
||||||
the line items generated by the transformer.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:109](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L109)
|
[services/fulfillment.ts:109](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L109)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -311,7 +281,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:71](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L71)
|
[services/fulfillment.ts:71](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L71)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -319,24 +289,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Fulfillment`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`Fulfillment`\>
|
||||||
|
|
||||||
Retrieves a fulfillment by its id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the fulfillment to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `FindConfig`<`Fulfillment`\> | optional values to include with fulfillmentRepository query |
|
| `config` | `FindConfig`<`Fulfillment`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Fulfillment`\>
|
`Promise`<`Fulfillment`\>
|
||||||
|
|
||||||
the fulfillment
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:166](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L166)
|
[services/fulfillment.ts:166](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L166)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -360,7 +326,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -368,28 +334,20 @@ ___
|
|||||||
|
|
||||||
▸ **validateFulfillmentLineItem_**(`item`, `quantity`): ``null`` \| `LineItem`
|
▸ **validateFulfillmentLineItem_**(`item`, `quantity`): ``null`` \| `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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `item` | `undefined` \| `LineItem` | the line item to check has sufficient fulfillable quantity. |
|
| `item` | `undefined` \| `LineItem` | |
|
||||||
| `quantity` | `number` | the quantity that is requested to be fulfilled. |
|
| `quantity` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
``null`` \| `LineItem`
|
``null`` \| `LineItem`
|
||||||
|
|
||||||
a line item that has the requested fulfillment quantity
|
|
||||||
set.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/fulfillment.ts:134](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/fulfillment.ts#L134)
|
[services/fulfillment.ts:134](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/fulfillment.ts#L134)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -413,4 +371,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: GiftCardService
|
# Class: GiftCardService
|
||||||
|
|
||||||
Provides layer to manipulate gift cards.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`GiftCardService`](GiftCardService.md)\>
|
- `TransactionBaseService`<[`GiftCardService`](GiftCardService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<GiftCardService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L46)
|
[services/gift-card.ts:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L46)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:37](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L37)
|
[services/gift-card.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L37)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L34)
|
[services/gift-card.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:35](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L35)
|
[services/gift-card.ts:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L35)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L39)
|
[services/gift-card.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L39)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -100,7 +98,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L36)
|
[services/gift-card.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -114,7 +112,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L40)
|
[services/gift-card.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L40)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -130,7 +128,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L42)
|
[services/gift-card.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L42)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -138,10 +136,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -153,23 +147,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -177,23 +169,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`giftCard`): `Promise`<`GiftCard`\>
|
▸ **create**(`giftCard`): `Promise`<`GiftCard`\>
|
||||||
|
|
||||||
Creates a gift card with provided data given that the data is validated.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `giftCard` | `CreateGiftCardInput` | the gift card data to create |
|
| `giftCard` | `CreateGiftCardInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`GiftCard`\>
|
`Promise`<`GiftCard`\>
|
||||||
|
|
||||||
the result of the create operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:155](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L155)
|
[services/gift-card.ts:155](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L155)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -213,7 +201,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:139](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L139)
|
[services/gift-card.ts:139](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L139)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -221,23 +209,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`giftCardId`): `Promise`<`void` \| `GiftCard`\>
|
▸ **delete**(`giftCardId`): `Promise`<`void` \| `GiftCard`\>
|
||||||
|
|
||||||
Deletes a gift card idempotently
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `giftCardId` | `string` | id of gift card to delete |
|
| `giftCardId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void` \| `GiftCard`\>
|
`Promise`<`void` \| `GiftCard`\>
|
||||||
|
|
||||||
the result of the delete operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:288](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L288)
|
[services/gift-card.ts:288](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L288)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -249,18 +233,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `QuerySelector`<`GiftCard`\> | the query object for find |
|
| `selector` | `QuerySelector`<`GiftCard`\> | |
|
||||||
| `config` | `FindConfig`<`GiftCard`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
| `config` | `FindConfig`<`GiftCard`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`GiftCard`[]\>
|
`Promise`<`GiftCard`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:114](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L114)
|
[services/gift-card.ts:114](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L114)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -272,18 +254,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `QuerySelector`<`GiftCard`\> | the query object for find |
|
| `selector` | `QuerySelector`<`GiftCard`\> | |
|
||||||
| `config` | `FindConfig`<`GiftCard`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
| `config` | `FindConfig`<`GiftCard`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`GiftCard`[], `number`]\>
|
`Promise`<[`GiftCard`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:84](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L84)
|
[services/gift-card.ts:84](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L84)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -291,24 +271,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`giftCardId`, `config?`): `Promise`<`GiftCard`\>
|
▸ **retrieve**(`giftCardId`, `config?`): `Promise`<`GiftCard`\>
|
||||||
|
|
||||||
Gets a gift card by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `giftCardId` | `string` | id of gift card to retrieve |
|
| `giftCardId` | `string` | |
|
||||||
| `config` | `FindConfig`<`GiftCard`\> | optional values to include with gift card query |
|
| `config` | `FindConfig`<`GiftCard`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`GiftCard`\>
|
`Promise`<`GiftCard`\>
|
||||||
|
|
||||||
the gift card
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:220](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L220)
|
[services/gift-card.ts:220](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L220)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -329,7 +305,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:229](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L229)
|
[services/gift-card.ts:229](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L229)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -350,7 +326,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:185](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L185)
|
[services/gift-card.ts:185](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L185)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -374,7 +350,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -382,24 +358,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`giftCardId`, `update`): `Promise`<`GiftCard`\>
|
▸ **update**(`giftCardId`, `update`): `Promise`<`GiftCard`\>
|
||||||
|
|
||||||
Updates a giftCard.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `giftCardId` | `string` | giftCard id of giftCard to update |
|
| `giftCardId` | `string` | |
|
||||||
| `update` | `UpdateGiftCardInput` | the data to update the giftCard with |
|
| `update` | `UpdateGiftCardInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`GiftCard`\>
|
`Promise`<`GiftCard`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:244](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L244)
|
[services/gift-card.ts:244](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L244)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -423,7 +395,7 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -431,14 +403,10 @@ ___
|
|||||||
|
|
||||||
▸ `Static` **generateCode**(): `string`
|
▸ `Static` **generateCode**(): `string`
|
||||||
|
|
||||||
Generates a 16 character gift card code
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
the generated gift card code
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/gift-card.ts:68](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/gift-card.ts#L68)
|
[services/gift-card.ts:68](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/gift-card.ts#L68)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:8](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L8)
|
[services/idempotency-key.js:8](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L8)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -32,25 +32,19 @@ BaseService.constructor
|
|||||||
|
|
||||||
▸ **create**(`payload`): `Promise`<`IdempotencyKeyModel`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `payload` | `any` | payload of request to create idempotency key for |
|
| `payload` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`IdempotencyKeyModel`\>
|
`Promise`<`IdempotencyKeyModel`\>
|
||||||
|
|
||||||
the created idempotency key
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:52](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L52)
|
[services/idempotency-key.js:52](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L52)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -58,26 +52,22 @@ ___
|
|||||||
|
|
||||||
▸ **initializeRequest**(`headerKey`, `reqMethod`, `reqParams`, `reqPath`): `Promise`<`IdempotencyKeyModel`\>
|
▸ **initializeRequest**(`headerKey`, `reqMethod`, `reqParams`, `reqPath`): `Promise`<`IdempotencyKeyModel`\>
|
||||||
|
|
||||||
Execute the initial steps in a idempotent request.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `headerKey` | `string` | potential idempotency key from header |
|
| `headerKey` | `string` | |
|
||||||
| `reqMethod` | `string` | method of request |
|
| `reqMethod` | `string` | |
|
||||||
| `reqParams` | `string` | params of request |
|
| `reqParams` | `string` | |
|
||||||
| `reqPath` | `string` | path of request |
|
| `reqPath` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`IdempotencyKeyModel`\>
|
`Promise`<`IdempotencyKeyModel`\>
|
||||||
|
|
||||||
the existing or created idempotency key
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:26](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L26)
|
[services/idempotency-key.js:26](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L26)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -85,23 +75,19 @@ ___
|
|||||||
|
|
||||||
▸ **lock**(`idempotencyKey`): `Promise`<`any`\>
|
▸ **lock**(`idempotencyKey`): `Promise`<`any`\>
|
||||||
|
|
||||||
Locks an idempotency.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `idempotencyKey` | `string` | key to lock |
|
| `idempotencyKey` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:90](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L90)
|
[services/idempotency-key.js:90](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L90)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -109,23 +95,19 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`idempotencyKey`): `Promise`<`IdempotencyKeyModel`\>
|
▸ **retrieve**(`idempotencyKey`): `Promise`<`IdempotencyKeyModel`\>
|
||||||
|
|
||||||
Retrieves an idempotency key
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `idempotencyKey` | `string` | key to retrieve |
|
| `idempotencyKey` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`IdempotencyKeyModel`\>
|
`Promise`<`IdempotencyKeyModel`\>
|
||||||
|
|
||||||
idempotency key
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:73](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L73)
|
[services/idempotency-key.js:73](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L73)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -133,24 +115,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`idempotencyKey`, `update`): `Promise`<`any`\>
|
▸ **update**(`idempotencyKey`, `update`): `Promise`<`any`\>
|
||||||
|
|
||||||
Locks an idempotency.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `idempotencyKey` | `string` | key to update |
|
| `idempotencyKey` | `string` | |
|
||||||
| `update` | `any` | update object |
|
| `update` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:117](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L117)
|
[services/idempotency-key.js:117](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L117)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -158,25 +136,17 @@ ___
|
|||||||
|
|
||||||
▸ **workStage**(`idempotencyKey`, `func`): `IdempotencyKeyModel`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `idempotencyKey` | `string` | current idempotency key |
|
| `idempotencyKey` | `string` | |
|
||||||
| `func` | `Function` | functionality to execute within the phase |
|
| `func` | `Function` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`IdempotencyKeyModel`
|
`IdempotencyKeyModel`
|
||||||
|
|
||||||
new updated idempotency key
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/idempotency-key.js:144](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/idempotency-key.js#L144)
|
[services/idempotency-key.js:144](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/idempotency-key.js#L144)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/inventory.js:5](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/inventory.js#L5)
|
[services/inventory.js:5](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/inventory.js#L5)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -32,24 +32,20 @@ BaseService.constructor
|
|||||||
|
|
||||||
▸ **adjustInventory**(`variantId`, `adjustment`): `Promise`<`any`\>
|
▸ **adjustInventory**(`variantId`, `adjustment`): `Promise`<`any`\>
|
||||||
|
|
||||||
Updates the inventory of a variant based on a given adjustment.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to update |
|
| `variantId` | `string` | |
|
||||||
| `adjustment` | `number` | the number to adjust the inventory quantity by |
|
| `adjustment` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/inventory.js:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/inventory.js#L36)
|
[services/inventory.js:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/inventory.js#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -57,26 +53,20 @@ ___
|
|||||||
|
|
||||||
▸ **confirmInventory**(`variantId`, `quantity`): `Promise`<`boolean`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to check |
|
| `variantId` | `string` | |
|
||||||
| `quantity` | `number` | the number of units to check availability for |
|
| `quantity` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`boolean`\>
|
`Promise`<`boolean`\>
|
||||||
|
|
||||||
true if the inventory covers the quantity
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/inventory.js:62](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/inventory.js#L62)
|
[services/inventory.js:62](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/inventory.js#L62)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -96,4 +86,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/inventory.js:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/inventory.js#L15)
|
[services/inventory.js:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/inventory.js#L15)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: LineItemService
|
# Class: LineItemService
|
||||||
|
|
||||||
Provides layer to manipulate line items.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:44](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L44)
|
[services/line-item.ts:44](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L44)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:38](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L38)
|
[services/line-item.ts:38](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L38)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:37](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L37)
|
[services/line-item.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L37)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L42)
|
[services/line-item.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L36)
|
[services/line-item.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:35](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L35)
|
[services/line-item.ts:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L35)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L40)
|
[services/line-item.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L40)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -96,7 +94,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L39)
|
[services/line-item.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L39)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -106,7 +104,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:41](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L41)
|
[services/line-item.ts:41](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L41)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -114,23 +112,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`LineItem`\>
|
▸ **create**(`data`): `Promise`<`LineItem`\>
|
||||||
|
|
||||||
Create a line item
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `Partial`<`LineItem`\> | the line item object to create |
|
| `data` | `Partial`<`LineItem`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItem`\>
|
`Promise`<`LineItem`\>
|
||||||
|
|
||||||
the created line item
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:270](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L270)
|
[services/line-item.ts:270](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L270)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -138,25 +132,20 @@ ___
|
|||||||
|
|
||||||
▸ **createReturnLines**(`returnId`, `cartId`): `Promise`<`LineItem`[]\>
|
▸ **createReturnLines**(`returnId`, `cartId`): `Promise`<`LineItem`[]\>
|
||||||
|
|
||||||
Creates return line items for a given cart based on the return items in a
|
|
||||||
return.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `returnId` | `string` | the id to generate return items from. |
|
| `returnId` | `string` | |
|
||||||
| `cartId` | `string` | the cart to assign the return line items to. |
|
| `cartId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItem`[]\>
|
`Promise`<`LineItem`[]\>
|
||||||
|
|
||||||
the created line items
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:142](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L142)
|
[services/line-item.ts:142](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L142)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -164,23 +153,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`id`): `Promise`<`undefined` \| `LineItem`\>
|
▸ **delete**(`id`): `Promise`<`undefined` \| `LineItem`\>
|
||||||
|
|
||||||
Deletes a line item.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the line item to delete |
|
| `id` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`undefined` \| `LineItem`\>
|
`Promise`<`undefined` \| `LineItem`\>
|
||||||
|
|
||||||
the result of the delete operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:318](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L318)
|
[services/line-item.ts:318](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L318)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -207,7 +192,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:195](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L195)
|
[services/line-item.ts:195](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L195)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -232,7 +217,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:90](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L90)
|
[services/line-item.ts:90](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L90)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -240,24 +225,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`LineItem`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`LineItem`\>
|
||||||
|
|
||||||
Retrieves a line item by its id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the line item to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `Object` | the config to be used at query building |
|
| `config` | `Object` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItem`\>
|
`Promise`<`LineItem`\>
|
||||||
|
|
||||||
the line item
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:111](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L111)
|
[services/line-item.ts:111](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L111)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -265,24 +246,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`id`, `data`): `Promise`<`LineItem`\>
|
▸ **update**(`id`, `data`): `Promise`<`LineItem`\>
|
||||||
|
|
||||||
Updates a line item
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the line item to update |
|
| `id` | `string` | |
|
||||||
| `data` | `Partial`<`LineItem`\> | the properties to update on line item |
|
| `data` | `Partial`<`LineItem`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItem`\>
|
`Promise`<`LineItem`\>
|
||||||
|
|
||||||
the update line item
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:289](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L289)
|
[services/line-item.ts:289](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L289)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -302,4 +279,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/line-item.ts:68](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/line-item.ts#L68)
|
[services/line-item.ts:68](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/line-item.ts#L68)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: MiddlewareService
|
# Class: MiddlewareService
|
||||||
|
|
||||||
Orchestrates dynamic middleware registered through the Medusa Middleware API
|
|
||||||
|
|
||||||
## Constructors
|
## Constructors
|
||||||
|
|
||||||
### constructor
|
### constructor
|
||||||
@@ -16,7 +14,7 @@ Orchestrates dynamic middleware registered through the Medusa Middleware API
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:7](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L7)
|
[services/middleware.js:7](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L7)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -26,7 +24,7 @@ Orchestrates dynamic middleware registered through the Medusa Middleware API
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:8](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L8)
|
[services/middleware.js:8](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L8)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:9](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L9)
|
[services/middleware.js:9](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L9)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:10](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L10)
|
[services/middleware.js:10](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L10)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:11](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L11)
|
[services/middleware.js:11](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L11)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -64,14 +62,12 @@ ___
|
|||||||
|
|
||||||
▸ **addPostAuthentication**(`middleware`, `options`): `void`
|
▸ **addPostAuthentication**(`middleware`, `options`): `void`
|
||||||
|
|
||||||
Adds a middleware function to be called after authentication is completed.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `middleware` | `Function` | the middleware function. Should return a middleware function. |
|
| `middleware` | `Function` | |
|
||||||
| `options` | `any` | the arguments that will be passed to the middleware |
|
| `options` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -79,7 +75,7 @@ Adds a middleware function to be called after authentication is completed.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L45)
|
[services/middleware.js:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -87,14 +83,12 @@ ___
|
|||||||
|
|
||||||
▸ **addPreAuthentication**(`middleware`, `options`): `void`
|
▸ **addPreAuthentication**(`middleware`, `options`): `void`
|
||||||
|
|
||||||
Adds a middleware function to be called before authentication is completed.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `middleware` | `Function` | the middleware function. Should return a middleware function. |
|
| `middleware` | `Function` | |
|
||||||
| `options` | `any` | the arguments that will be passed to the middleware |
|
| `options` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -102,7 +96,7 @@ Adds a middleware function to be called before authentication is completed.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:61](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L61)
|
[services/middleware.js:61](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L61)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -110,13 +104,11 @@ ___
|
|||||||
|
|
||||||
▸ **addPreCartCreation**(`middleware`): `void`
|
▸ **addPreCartCreation**(`middleware`): `void`
|
||||||
|
|
||||||
Adds a middleware function to be called before cart creation
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `middleware` | `Function` | the middleware function. Should return a middleware function. |
|
| `middleware` | `Function` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -124,7 +116,7 @@ Adds a middleware function to be called before cart creation
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:75](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L75)
|
[services/middleware.js:75](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L75)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -145,7 +137,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:14](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L14)
|
[services/middleware.js:14](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -165,7 +157,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:19](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L19)
|
[services/middleware.js:19](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L19)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -173,13 +165,11 @@ ___
|
|||||||
|
|
||||||
▸ **usePostAuthentication**(`app`): `void`
|
▸ **usePostAuthentication**(`app`): `void`
|
||||||
|
|
||||||
Adds post authentication middleware to an express app.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `app` | `ExpressApp` | the express app to add the middleware to |
|
| `app` | `ExpressApp` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -187,7 +177,7 @@ Adds post authentication middleware to an express app.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:85](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L85)
|
[services/middleware.js:85](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L85)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -195,13 +185,11 @@ ___
|
|||||||
|
|
||||||
▸ **usePreAuthentication**(`app`): `void`
|
▸ **usePreAuthentication**(`app`): `void`
|
||||||
|
|
||||||
Adds pre authentication middleware to an express app.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `app` | `ExpressApp` | the express app to add the middleware to |
|
| `app` | `ExpressApp` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -209,7 +197,7 @@ Adds pre authentication middleware to an express app.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:96](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L96)
|
[services/middleware.js:96](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L96)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -223,7 +211,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:102](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L102)
|
[services/middleware.js:102](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L102)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -231,13 +219,11 @@ ___
|
|||||||
|
|
||||||
▸ **validateMiddleware_**(`fn`): `void`
|
▸ **validateMiddleware_**(`fn`): `void`
|
||||||
|
|
||||||
Validates a middleware function, throws if fn is not of type function.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `fn` | `Function` | the middleware function to validate. |
|
| `fn` | `Function` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -245,4 +231,4 @@ Validates a middleware function, throws if fn is not of type function.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/middleware.js:28](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/middleware.js#L28)
|
[services/middleware.js:28](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/middleware.js#L28)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:12](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L12)
|
[services/note.js:12](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L12)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:6](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L6)
|
[services/note.js:6](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L6)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -50,24 +50,20 @@ BaseService.constructor
|
|||||||
|
|
||||||
▸ **create**(`data`, `config?`): `Promise`<`any`\>
|
▸ **create**(`data`, `config?`): `Promise`<`any`\>
|
||||||
|
|
||||||
Creates a note associated with a given author
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `CreateNoteInput` | the note to create |
|
| `data` | `CreateNoteInput` | |
|
||||||
| `config` | `any` | any configurations if needed, including meta data |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the creation result
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:98](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L98)
|
[services/note.js:98](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L98)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -75,13 +71,11 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`noteId`): `Promise`<`any`\>
|
▸ **delete**(`noteId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Deletes a given note
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `noteId` | `any` | id of the note to delete |
|
| `noteId` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -89,7 +83,7 @@ Deletes a given note
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:154](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L154)
|
[services/note.js:154](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L154)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -97,27 +91,23 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector`, `config?`): `Promise`<`Note`[]\>
|
▸ **list**(`selector`, `config?`): `Promise`<`Note`[]\>
|
||||||
|
|
||||||
Fetches all notes related to the given selector
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `Object` | the configuration used to find the objects. contains relations, skip, and take. |
|
| `config` | `Object` | |
|
||||||
| `config.relations` | `string`[] | Which relations to include in the resulting list of Notes. |
|
| `config.relations` | `string`[] | |
|
||||||
| `config.skip` | `number` | How many Notes to skip in the resulting list of Notes. |
|
| `config.skip` | `number` | |
|
||||||
| `config.take` | `number` | How many Notes to take in the resulting list of Notes. |
|
| `config.take` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Note`[]\>
|
`Promise`<`Note`[]\>
|
||||||
|
|
||||||
notes related to the given search.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:77](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L77)
|
[services/note.js:77](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L77)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -125,24 +115,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Note`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`Note`\>
|
||||||
|
|
||||||
Retrieves a specific note.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the note to retrieve. |
|
| `id` | `string` | |
|
||||||
| `config` | `any` | any options needed to query for the result. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Note`\>
|
`Promise`<`Note`\>
|
||||||
|
|
||||||
which resolves to the requested note.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:51](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L51)
|
[services/note.js:51](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L51)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -150,24 +136,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`noteId`, `value`): `Promise`<`any`\>
|
▸ **update**(`noteId`, `value`): `Promise`<`any`\>
|
||||||
|
|
||||||
Updates a given note with a new value
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `noteId` | `any` | the id of the note to update |
|
| `noteId` | `any` | |
|
||||||
| `value` | `any` | the new value |
|
| `value` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the updated element
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:131](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L131)
|
[services/note.js:131](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L131)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -175,20 +157,16 @@ ___
|
|||||||
|
|
||||||
▸ **withTransaction**(`transactionManager`): [`NoteService`](NoteService.md)
|
▸ **withTransaction**(`transactionManager`): [`NoteService`](NoteService.md)
|
||||||
|
|
||||||
Sets the service's manager to a given transaction manager
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `transactionManager` | `EntityManager` | the manager to use |
|
| `transactionManager` | `EntityManager` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
[`NoteService`](NoteService.md)
|
[`NoteService`](NoteService.md)
|
||||||
|
|
||||||
a cloned note service
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/note.js:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/note.js#L30)
|
[services/note.js:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/note.js#L30)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: NotificationService
|
# Class: NotificationService
|
||||||
|
|
||||||
Provides layer to manipulate orchestrate notifications.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:9](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L9)
|
[services/notification.js:9](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L9)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L30)
|
[services/notification.js:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:19](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L19)
|
[services/notification.js:19](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L19)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L23)
|
[services/notification.js:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L23)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L27)
|
[services/notification.js:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L27)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:29](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L29)
|
[services/notification.js:29](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L29)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -84,26 +82,20 @@ ___
|
|||||||
|
|
||||||
▸ **handleEvent**(`eventName`, `data`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `eventName` | `string` | the event to handle |
|
| `eventName` | `string` | |
|
||||||
| `data` | `any` | the data the event was sent with |
|
| `data` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
- the result of notification subscribed
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:166](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L166)
|
[services/notification.js:166](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L166)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -111,24 +103,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector`, `config?`): `Notification`[]
|
▸ **list**(`selector`, `config?`): `Notification`[]
|
||||||
|
|
||||||
Retrieves a list of notifications.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the params to select the notifications by. |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the configuration to apply to the query |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Notification`[]
|
`Notification`[]
|
||||||
|
|
||||||
the notifications that satisfy the query.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:84](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L84)
|
[services/notification.js:84](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L84)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -136,14 +124,11 @@ ___
|
|||||||
|
|
||||||
▸ **registerAttachmentGenerator**(`service`): `void`
|
▸ **registerAttachmentGenerator**(`service`): `void`
|
||||||
|
|
||||||
Registers an attachment generator to the service. The generator can be
|
|
||||||
used to generate on demand invoices or other documents.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type | Description |
|
||||||
| :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `service` | `any` |
|
| `service` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -151,7 +136,7 @@ used to generate on demand invoices or other documents.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:38](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L38)
|
[services/notification.js:38](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L38)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -159,13 +144,11 @@ ___
|
|||||||
|
|
||||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||||
|
|
||||||
Takes a list of notification provider ids and persists them in the database.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `providers` | `string`[] | a list of provider ids |
|
| `providers` | `string`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -173,7 +156,7 @@ Takes a list of notification provider ids and persists them in the database.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:68](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L68)
|
[services/notification.js:68](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L68)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -181,25 +164,20 @@ ___
|
|||||||
|
|
||||||
▸ **resend**(`id`, `config?`): `Notification`
|
▸ **resend**(`id`, `config?`): `Notification`
|
||||||
|
|
||||||
Resends a notification by retrieving a prior notification and calling the
|
|
||||||
underlying provider's resendNotification method.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the notification |
|
| `id` | `string` | |
|
||||||
| `config` | `any` | any configuration that might override the previous send |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Notification`
|
`Notification`
|
||||||
|
|
||||||
the newly created notification
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:237](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L237)
|
[services/notification.js:237](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L237)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -207,24 +185,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Notification`
|
▸ **retrieve**(`id`, `config?`): `Notification`
|
||||||
|
|
||||||
Retrieves a notification with a given id
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the notification |
|
| `id` | `string` | |
|
||||||
| `config` | `any` | the configuration to apply to the query |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Notification`
|
`Notification`
|
||||||
|
|
||||||
the notification
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:101](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L101)
|
[services/notification.js:101](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L101)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -232,24 +206,19 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveProvider_**(`id`): `NotificationProvider`
|
▸ **retrieveProvider_**(`id`): `NotificationProvider`
|
||||||
|
|
||||||
Finds a provider with a given id. Will throw a NOT_FOUND error if the
|
|
||||||
resolution fails.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the provider |
|
| `id` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`NotificationProvider`
|
`NotificationProvider`
|
||||||
|
|
||||||
the notification provider
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:147](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L147)
|
[services/notification.js:147](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L147)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -257,26 +226,21 @@ ___
|
|||||||
|
|
||||||
▸ **send**(`event`, `eventData`, `providerId`): `Notification`
|
▸ **send**(`event`, `eventData`, `providerId`): `Notification`
|
||||||
|
|
||||||
Sends a notification, by calling the given provider's sendNotification
|
|
||||||
method. Persists the Notification in the database.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `event` | `string` | the name of the event |
|
| `event` | `string` | |
|
||||||
| `eventData` | `any` | the data the event was sent with |
|
| `eventData` | `any` | |
|
||||||
| `providerId` | `string` | the provider that should hande the event. |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Notification`
|
`Notification`
|
||||||
|
|
||||||
the created notification
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:195](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L195)
|
[services/notification.js:195](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L195)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -284,14 +248,12 @@ ___
|
|||||||
|
|
||||||
▸ **subscribe**(`eventName`, `providerId`): `void`
|
▸ **subscribe**(`eventName`, `providerId`): `void`
|
||||||
|
|
||||||
Subscribes a given provider to an event.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `eventName` | `string` | the event to subscribe to |
|
| `eventName` | `string` | |
|
||||||
| `providerId` | `string` | the provider that the event will be sent to |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -299,7 +261,7 @@ Subscribes a given provider to an event.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:126](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L126)
|
[services/notification.js:126](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L126)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -307,20 +269,16 @@ ___
|
|||||||
|
|
||||||
▸ **withTransaction**(`transactionManager`): [`NotificationService`](NotificationService.md)
|
▸ **withTransaction**(`transactionManager`): [`NotificationService`](NotificationService.md)
|
||||||
|
|
||||||
Sets the service's manager to a given transaction manager.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `transactionManager` | `EntityManager` | the manager to use |
|
| `transactionManager` | `EntityManager` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
[`NotificationService`](NotificationService.md)
|
[`NotificationService`](NotificationService.md)
|
||||||
|
|
||||||
a cloned notification service
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/notification.js:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/notification.js#L47)
|
[services/notification.js:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/notification.js#L47)
|
||||||
@@ -24,7 +24,7 @@ OauthService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:10](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L10)
|
[services/oauth.js:10](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L10)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ OauthService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L15)
|
[services/oauth.js:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L15)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:17](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L17)
|
[services/oauth.js:17](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L17)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:14](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L14)
|
[services/oauth.js:14](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L16)
|
[services/oauth.js:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L16)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:5](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L5)
|
[services/oauth.js:5](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L5)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:32](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L32)
|
[services/oauth.js:32](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L32)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:66](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L66)
|
[services/oauth.js:66](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L66)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L27)
|
[services/oauth.js:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L27)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:96](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L96)
|
[services/oauth.js:96](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L96)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:56](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L56)
|
[services/oauth.js:56](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L56)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:20](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L20)
|
[services/oauth.js:20](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L20)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -224,4 +224,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/oauth.js:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/oauth.js#L45)
|
[services/oauth.js:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/oauth.js#L45)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L25)
|
[services/order.js:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L25)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:6](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L6)
|
[services/order.js:6](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L6)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:806](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L806)
|
[services/order.js:806](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L806)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -86,24 +86,19 @@ ___
|
|||||||
|
|
||||||
▸ **archive**(`orderId`): `Promise`<`any`\>
|
▸ **archive**(`orderId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Archives an order. It only alloved, if the order has been fulfilled
|
|
||||||
and payment has been captured.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | the order to archive |
|
| `orderId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1301](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1301)
|
[services/order.js:1302](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1302)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -111,25 +106,19 @@ ___
|
|||||||
|
|
||||||
▸ **cancel**(`orderId`): `Promise`<`any`\>
|
▸ **cancel**(`orderId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Cancels an order.
|
|
||||||
Throws if fulfillment process has been initiated.
|
|
||||||
Throws if payment process has been initiated.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | id of order to cancel. |
|
| `orderId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result of the update operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:952](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L952)
|
[services/order.js:952](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L952)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -137,23 +126,19 @@ ___
|
|||||||
|
|
||||||
▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`any`\>
|
▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Cancels a fulfillment (if related to an order)
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `fulfillmentId` | `string` | the ID of the fulfillment to cancel |
|
| `fulfillmentId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
updated order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1242](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1242)
|
[services/order.js:1243](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1243)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -161,23 +146,19 @@ ___
|
|||||||
|
|
||||||
▸ **capturePayment**(`orderId`): `Promise`<`any`\>
|
▸ **capturePayment**(`orderId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Captures payment for an order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | id of order to capture payment for. |
|
| `orderId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result of the update operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1021](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1021)
|
[services/order.js:1021](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1021)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -189,17 +170,15 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | id of the order to complete |
|
| `orderId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:429](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L429)
|
[services/order.js:429](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L429)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -207,23 +186,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`any`\>
|
▸ **create**(`data`): `Promise`<`any`\>
|
||||||
|
|
||||||
Creates an order
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `any` | the data to create an order |
|
| `data` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the creation result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:723](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L723)
|
[services/order.js:723](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L723)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -231,23 +206,19 @@ ___
|
|||||||
|
|
||||||
▸ **createFromCart**(`cartId`): `Promise`<`any`\>
|
▸ **createFromCart**(`cartId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Creates an order from a cart
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartId` | `string` | id of the cart to create an order from |
|
| `cartId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the creation result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:465](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L465)
|
[services/order.js:465](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L465)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -255,28 +226,21 @@ ___
|
|||||||
|
|
||||||
▸ **createFulfillment**(`orderId`, `itemsToFulfill`, `config?`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | id of order to cancel. |
|
| `orderId` | `string` | |
|
||||||
| `itemsToFulfill` | `any` | items to fulfil. |
|
| `itemsToFulfill` | `any` | |
|
||||||
| `config` | `any` | the config to cancel. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result of the update operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1121](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1121)
|
[services/order.js:1121](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1121)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -284,27 +248,23 @@ ___
|
|||||||
|
|
||||||
▸ **createRefund**(`orderId`, `refundAmount`, `reason`, `note`, `config?`): `Promise`<`any`\>
|
▸ **createRefund**(`orderId`, `refundAmount`, `reason`, `note`, `config?`): `Promise`<`any`\>
|
||||||
|
|
||||||
Refunds a given amount back to the customer.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | id of the order to refund. |
|
| `orderId` | `string` | |
|
||||||
| `refundAmount` | `float` | the amount to refund. |
|
| `refundAmount` | `float` | |
|
||||||
| `reason` | `string` | the reason to refund. |
|
| `reason` | `string` | |
|
||||||
| `note` | `undefined` \| `string` | note for refund. |
|
| `note` | `undefined` \| `string` | |
|
||||||
| `config` | `any` | the config for refund. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the refund operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1328](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1328)
|
[services/order.js:1329](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1329)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -312,28 +272,22 @@ ___
|
|||||||
|
|
||||||
▸ **createShipment**(`orderId`, `fulfillmentId`, `trackingLinks`, `config?`): `order`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | the id of the order that has been shipped |
|
| `orderId` | `string` | |
|
||||||
| `fulfillmentId` | `string` | the fulfillment that has now been shipped |
|
| `fulfillmentId` | `string` | |
|
||||||
| `trackingLinks` | `undefined` \| `TrackingLink`[] | array of tracking numebers associated with the shipment |
|
| `trackingLinks` | `undefined` \| `TrackingLink`[] | |
|
||||||
| `config` | `any` | the config of the order that has been shipped |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`order`
|
`order`
|
||||||
|
|
||||||
the resulting order following the update.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:643](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L643)
|
[services/order.js:643](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L643)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -354,7 +308,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1377](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1377)
|
[services/order.js:1378](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1378)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -362,24 +316,20 @@ ___
|
|||||||
|
|
||||||
▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\>
|
▸ **deleteMetadata**(`orderId`, `key`): `Promise`<`any`\>
|
||||||
|
|
||||||
Dedicated method to delete metadata for an order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | the order to delete metadata from. |
|
| `orderId` | `string` | |
|
||||||
| `key` | `string` | key for metadata field |
|
| `key` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the updated result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1550](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1550)
|
[services/order.js:1553](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1553)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -387,23 +337,19 @@ ___
|
|||||||
|
|
||||||
▸ **existsByCartId**(`cartId`): `Promise`<`Order`\>
|
▸ **existsByCartId**(`cartId`): `Promise`<`Order`\>
|
||||||
|
|
||||||
Checks the existence of an order by cart id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartId` | `string` | cart id to find order |
|
| `cartId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Order`\>
|
`Promise`<`Order`\>
|
||||||
|
|
||||||
the order document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:417](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L417)
|
[services/order.js:417](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L417)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -411,27 +357,23 @@ ___
|
|||||||
|
|
||||||
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
||||||
|
|
||||||
Retrieves the order line items, given an array of items.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to get line items from |
|
| `order` | `Order` | |
|
||||||
| `items` | `Object` | the items to get |
|
| `items` | `Object` | |
|
||||||
| `items.item_id` | `string` | - |
|
| `items.item_id` | `string` | - |
|
||||||
| `items.quantity` | `number` | - |
|
| `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. |
|
| `transformer` | `Function` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItem`[]\>
|
`Promise`<`LineItem`[]\>
|
||||||
|
|
||||||
the line items generated by the transformer.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1284](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1284)
|
[services/order.js:1285](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1285)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -443,18 +385,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the config to be used for find |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:148](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L148)
|
[services/order.js:148](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L148)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -479,7 +419,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:173](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L173)
|
[services/order.js:173](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L173)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -487,31 +427,21 @@ ___
|
|||||||
|
|
||||||
▸ **registerReturnReceived**(`orderId`, `receivedReturn`, `customRefundAmount`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | the order to return. |
|
| `orderId` | `string` | |
|
||||||
| `receivedReturn` | `any` | the received return |
|
| `receivedReturn` | `any` | |
|
||||||
| `customRefundAmount` | `float` | the custom refund amount return |
|
| `customRefundAmount` | `float` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1473](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1473)
|
[services/order.js:1476](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1476)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -519,24 +449,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`orderId`, `config?`): `Promise`<`Order`\>
|
▸ **retrieve**(`orderId`, `config?`): `Promise`<`Order`\>
|
||||||
|
|
||||||
Gets an order by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | id of order to retrieve |
|
| `orderId` | `string` | |
|
||||||
| `config` | `any` | config of order to retrieve |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Order`\>
|
`Promise`<`Order`\>
|
||||||
|
|
||||||
the order document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:305](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L305)
|
[services/order.js:305](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L305)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -544,24 +470,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`Order`\>
|
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`Order`\>
|
||||||
|
|
||||||
Gets an order by cart id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartId` | `string` | cart id to find order |
|
| `cartId` | `string` | |
|
||||||
| `config` | `any` | the config to be used to find order |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Order`\>
|
`Promise`<`Order`\>
|
||||||
|
|
||||||
the order document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:343](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L343)
|
[services/order.js:343](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L343)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -569,24 +491,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Order`\>
|
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Order`\>
|
||||||
|
|
||||||
Gets an order by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `externalId` | `string` | id of order to retrieve |
|
| `externalId` | `string` | |
|
||||||
| `config` | `any` | query config to get order by |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Order`\>
|
`Promise`<`Order`\>
|
||||||
|
|
||||||
the order document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:380](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L380)
|
[services/order.js:380](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L380)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -606,7 +524,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:234](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L234)
|
[services/order.js:234](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L234)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -614,26 +532,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`orderId`, `update`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderId` | `string` | the id of the order. Must be a string that can be casted to an ObjectId |
|
| `orderId` | `string` | |
|
||||||
| `update` | `any` | an object with the update values. |
|
| `update` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:864](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L864)
|
[services/order.js:864](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L864)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -641,24 +553,20 @@ ___
|
|||||||
|
|
||||||
▸ **updateBillingAddress_**(`order`, `address`): `Promise`<`any`\>
|
▸ **updateBillingAddress_**(`order`, `address`): `Promise`<`any`\>
|
||||||
|
|
||||||
Updates the order's billing address.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `any` | the order to update |
|
| `order` | `any` | |
|
||||||
| `address` | `any` | the value to set the billing address to |
|
| `address` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:744](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L744)
|
[services/order.js:744](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L744)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -666,24 +574,20 @@ ___
|
|||||||
|
|
||||||
▸ **updateShippingAddress_**(`order`, `address`): `Promise`<`any`\>
|
▸ **updateShippingAddress_**(`order`, `address`): `Promise`<`any`\>
|
||||||
|
|
||||||
Updates the order's shipping address.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `any` | the order to update |
|
| `order` | `any` | |
|
||||||
| `address` | `any` | the value to set the shipping address to |
|
| `address` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:779](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L779)
|
[services/order.js:779](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L779)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -691,28 +595,20 @@ ___
|
|||||||
|
|
||||||
▸ **validateFulfillmentLineItem_**(`item`, `quantity`): `LineItem`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `item` | `LineItem` | the line item to check has sufficient fulfillable quantity. |
|
| `item` | `LineItem` | |
|
||||||
| `quantity` | `number` | the quantity that is requested to be fulfilled. |
|
| `quantity` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`LineItem`
|
`LineItem`
|
||||||
|
|
||||||
a line item that has the requested fulfillment quantity
|
|
||||||
set.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:1091](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L1091)
|
[services/order.js:1091](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L1091)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -720,23 +616,19 @@ ___
|
|||||||
|
|
||||||
▸ **validateId_**(`rawId`): `string`
|
▸ **validateId_**(`rawId`): `string`
|
||||||
|
|
||||||
Used to validate order ids. Throws an error if the cast fails
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `rawId` | `string` | the raw order id to validate. |
|
| `rawId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
the validated id
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:139](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L139)
|
[services/order.js:139](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L139)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -756,4 +648,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/order.js:102](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/order.js#L102)
|
[services/order.js:102](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/order.js#L102)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: PaymentProviderService
|
# Class: PaymentProviderService
|
||||||
|
|
||||||
Helps retrive payment providers
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:8](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L8)
|
[services/payment-provider.js:8](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L8)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:14](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L14)
|
[services/payment-provider.js:14](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:18](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L18)
|
[services/payment-provider.js:18](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L18)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L16)
|
[services/payment-provider.js:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L16)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:20](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L20)
|
[services/payment-provider.js:20](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L20)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -87,7 +85,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:283](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L283)
|
[services/payment-provider.js:283](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L283)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -107,7 +105,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:324](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L324)
|
[services/payment-provider.js:324](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L324)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -127,7 +125,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:343](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L343)
|
[services/payment-provider.js:343](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L343)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -147,7 +145,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:246](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L246)
|
[services/payment-provider.js:246](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L246)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -155,24 +153,20 @@ ___
|
|||||||
|
|
||||||
▸ **createSession**(`providerId`, `cart`): `Promise`<`any`\>
|
▸ **createSession**(`providerId`, `cart`): `Promise`<`any`\>
|
||||||
|
|
||||||
Creates a payment session with the given provider.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `providerId` | `string` | the id of the provider to create payment with |
|
| `providerId` | `string` | |
|
||||||
| `cart` | `Cart` | a cart object used to calculate the amount, etc. from |
|
| `cart` | `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the payment session
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:121](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L121)
|
[services/payment-provider.js:121](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L121)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -192,7 +186,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:202](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L202)
|
[services/payment-provider.js:202](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L202)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -212,7 +206,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:338](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L338)
|
[services/payment-provider.js:338](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L338)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -226,7 +220,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L47)
|
[services/payment-provider.js:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -251,7 +245,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:80](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L80)
|
[services/payment-provider.js:80](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L80)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -259,25 +253,20 @@ ___
|
|||||||
|
|
||||||
▸ **refreshSession**(`paymentSession`, `cart`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `paymentSession` | `PaymentSession` | the payment session object to update |
|
| `paymentSession` | `PaymentSession` | |
|
||||||
| `cart` | `Cart` | a cart object used to calculate the amount, etc. from |
|
| `cart` | `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the payment session
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:152](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L152)
|
[services/payment-provider.js:152](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L152)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -300,7 +289,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:358](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L358)
|
[services/payment-provider.js:358](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L358)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -320,7 +309,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:35](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L35)
|
[services/payment-provider.js:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L35)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -341,7 +330,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:54](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L54)
|
[services/payment-provider.js:54](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L54)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -349,23 +338,19 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveProvider**(`providerId`): `PaymentService`
|
▸ **retrieveProvider**(`providerId`): `PaymentService`
|
||||||
|
|
||||||
Finds a provider given an id
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `providerId` | `string` | the id of the provider to get |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`PaymentService`
|
`PaymentService`
|
||||||
|
|
||||||
the payment provider
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:228](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L228)
|
[services/payment-provider.js:228](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L228)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -386,7 +371,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:422](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L422)
|
[services/payment-provider.js:422](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L422)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -407,7 +392,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:89](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L89)
|
[services/payment-provider.js:89](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L89)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -428,7 +413,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:266](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L266)
|
[services/payment-provider.js:266](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L266)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -436,24 +421,20 @@ ___
|
|||||||
|
|
||||||
▸ **updateSession**(`paymentSession`, `cart`): `Promise`<`any`\>
|
▸ **updateSession**(`paymentSession`, `cart`): `Promise`<`any`\>
|
||||||
|
|
||||||
Updates an existing payment session.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `paymentSession` | `PaymentSession` | the payment session object to update |
|
| `paymentSession` | `PaymentSession` | |
|
||||||
| `cart` | `Cart` | the cart object to update for |
|
| `cart` | `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the updated payment session
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:188](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L188)
|
[services/payment-provider.js:188](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L188)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -474,7 +455,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:308](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L308)
|
[services/payment-provider.js:308](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L308)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -494,4 +475,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/payment-provider.js:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/payment-provider.js#L23)
|
[services/payment-provider.js:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/payment-provider.js#L23)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: PricingService
|
# Class: PricingService
|
||||||
|
|
||||||
Allows retrieval of prices.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`PricingService`](PricingService.md)\>
|
- `TransactionBaseService`<[`PricingService`](PricingService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<PricingService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L40)
|
[services/pricing.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L40)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:33](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L33)
|
[services/pricing.ts:33](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L33)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:37](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L37)
|
[services/pricing.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L37)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:38](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L38)
|
[services/pricing.ts:38](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L38)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:35](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L35)
|
[services/pricing.ts:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L35)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -100,7 +98,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L36)
|
[services/pricing.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -114,7 +112,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L34)
|
[services/pricing.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L34)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -122,10 +120,6 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -137,23 +131,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -161,24 +153,20 @@ ___
|
|||||||
|
|
||||||
▸ **calculateTaxes**(`variantPricing`, `productRates`): `Promise`<`TaxedPricing`\>
|
▸ **calculateTaxes**(`variantPricing`, `productRates`): `Promise`<`TaxedPricing`\>
|
||||||
|
|
||||||
Gets the prices for a product variant
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantPricing` | `ProductVariantPricing` | the prices retrieved from a variant |
|
| `variantPricing` | `ProductVariantPricing` | |
|
||||||
| `productRates` | `TaxServiceRate`[] | the tax rates that the product has applied |
|
| `productRates` | `TaxServiceRate`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TaxedPricing`\>
|
`Promise`<`TaxedPricing`\>
|
||||||
|
|
||||||
The tax related variant prices.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:102](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L102)
|
[services/pricing.ts:102](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L102)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -186,24 +174,19 @@ ___
|
|||||||
|
|
||||||
▸ **collectPricingContext**(`context`): `Promise`<`PricingContext`\>
|
▸ **collectPricingContext**(`context`): `Promise`<`PricingContext`\>
|
||||||
|
|
||||||
Collects additional information neccessary for completing the price
|
|
||||||
selection.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`PricingContext`\>
|
`Promise`<`PricingContext`\>
|
||||||
|
|
||||||
The pricing context
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:63](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L63)
|
[services/pricing.ts:63](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L63)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -211,25 +194,20 @@ ___
|
|||||||
|
|
||||||
▸ **getProductPricing**(`product`, `context`): `Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
▸ **getProductPricing**(`product`, `context`): `Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||||
|
|
||||||
Gets all the variant prices for a product. All the product's variants will
|
|
||||||
be fetched.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `product` | `Pick`<`Product`, ``"id"`` \| ``"variants"``\> | the product to get pricing for. |
|
| `product` | `Pick`<`Product`, ``"id"`` \| ``"variants"``\> | |
|
||||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
`Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||||
|
|
||||||
A map of variant ids to their corresponding prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:292](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L292)
|
[services/pricing.ts:292](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L292)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -237,24 +215,20 @@ ___
|
|||||||
|
|
||||||
▸ **getProductPricingById**(`productId`, `context`): `Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
▸ **getProductPricingById**(`productId`, `context`): `Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||||
|
|
||||||
Gets all the variant prices for a product by the product id
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the id of the product to get prices for |
|
| `productId` | `string` | |
|
||||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
`Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||||
|
|
||||||
A map of variant ids to their corresponding prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:310](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L310)
|
[services/pricing.ts:310](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L310)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -276,7 +250,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:254](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L254)
|
[services/pricing.ts:254](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L254)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -284,24 +258,20 @@ ___
|
|||||||
|
|
||||||
▸ **getProductVariantPricing**(`variant`, `context`): `Promise`<`ProductVariantPricing`\>
|
▸ **getProductVariantPricing**(`variant`, `context`): `Promise`<`ProductVariantPricing`\>
|
||||||
|
|
||||||
Gets the prices for a product variant.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variant` | `Pick`<`ProductVariant`, ``"id"`` \| ``"product_id"``\> | the id of the variant to get prices for |
|
| `variant` | `Pick`<`ProductVariant`, ``"id"`` \| ``"product_id"``\> | |
|
||||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` \| `PricingContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariantPricing`\>
|
`Promise`<`ProductVariantPricing`\>
|
||||||
|
|
||||||
The product variant prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:180](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L180)
|
[services/pricing.ts:180](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L180)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -309,24 +279,20 @@ ___
|
|||||||
|
|
||||||
▸ **getProductVariantPricingById**(`variantId`, `context`): `Promise`<`ProductVariantPricing`\>
|
▸ **getProductVariantPricingById**(`variantId`, `context`): `Promise`<`ProductVariantPricing`\>
|
||||||
|
|
||||||
Gets the prices for a product variant by a variant id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to get prices for |
|
| `variantId` | `string` | |
|
||||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` \| `PricingContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariantPricing`\>
|
`Promise`<`ProductVariantPricing`\>
|
||||||
|
|
||||||
The product variant prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:218](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L218)
|
[services/pricing.ts:218](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L218)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -348,7 +314,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:138](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L138)
|
[services/pricing.ts:138](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L138)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -356,24 +322,20 @@ ___
|
|||||||
|
|
||||||
▸ **getShippingOptionPricing**(`shippingOption`, `context`): `Promise`<`PricedShippingOption`\>
|
▸ **getShippingOptionPricing**(`shippingOption`, `context`): `Promise`<`PricedShippingOption`\>
|
||||||
|
|
||||||
Gets the prices for a shipping option.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `shippingOption` | `ShippingOption` | the shipping option to get prices for |
|
| `shippingOption` | `ShippingOption` | |
|
||||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` \| `PricingContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`PricedShippingOption`\>
|
`Promise`<`PricedShippingOption`\>
|
||||||
|
|
||||||
The shipping option prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:396](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L396)
|
[services/pricing.ts:396](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L396)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -381,24 +343,20 @@ ___
|
|||||||
|
|
||||||
▸ **setProductPrices**(`products`, `context?`): `Promise`<(`Product` \| `PricedProduct`)[]\>
|
▸ **setProductPrices**(`products`, `context?`): `Promise`<(`Product` \| `PricedProduct`)[]\>
|
||||||
|
|
||||||
Set additional prices on a list of products.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `products` | `Product`[] | list of products on which to set additional prices |
|
| `products` | `Product`[] | |
|
||||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<(`Product` \| `PricedProduct`)[]\>
|
`Promise`<(`Product` \| `PricedProduct`)[]\>
|
||||||
|
|
||||||
A list of products with variants decorated with prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:353](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L353)
|
[services/pricing.ts:353](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L353)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -406,24 +364,20 @@ ___
|
|||||||
|
|
||||||
▸ **setShippingOptionPrices**(`shippingOptions`, `context?`): `Promise`<`PricedShippingOption`[]\>
|
▸ **setShippingOptionPrices**(`shippingOptions`, `context?`): `Promise`<`PricedShippingOption`[]\>
|
||||||
|
|
||||||
Set additional prices on a list of shipping options.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `shippingOptions` | `ShippingOption`[] | list of shipping options on which to set additional prices |
|
| `shippingOptions` | `ShippingOption`[] | |
|
||||||
| `context` | `Omit`<`PriceSelectionContext`, ``"region_id"``\> | the price selection context to use |
|
| `context` | `Omit`<`PriceSelectionContext`, ``"region_id"``\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`PricedShippingOption`[]\>
|
`Promise`<`PricedShippingOption`[]\>
|
||||||
|
|
||||||
A list of shipping options with prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:445](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L445)
|
[services/pricing.ts:445](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L445)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -431,24 +385,20 @@ ___
|
|||||||
|
|
||||||
▸ **setVariantPrices**(`variants`, `context`): `Promise`<`PricedVariant`[]\>
|
▸ **setVariantPrices**(`variants`, `context`): `Promise`<`PricedVariant`[]\>
|
||||||
|
|
||||||
Set additional prices on a list of product variants.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variants` | `ProductVariant`[] | list of variants on which to set additional prices |
|
| `variants` | `ProductVariant`[] | |
|
||||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
| `context` | `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`PricedVariant`[]\>
|
`Promise`<`PricedVariant`[]\>
|
||||||
|
|
||||||
A list of products with variants decorated with prices
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/pricing.ts:328](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/pricing.ts#L328)
|
[services/pricing.ts:328](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/pricing.ts#L328)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -472,7 +422,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -496,4 +446,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: ProductCollectionService
|
# Class: ProductCollectionService
|
||||||
|
|
||||||
Provides layer to manipulate product collections.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:11](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L11)
|
[services/product-collection.js:11](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L11)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -47,7 +45,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:170](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L170)
|
[services/product-collection.js:170](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L170)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -55,23 +53,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`collection`): `Promise`<`ProductCollection`\>
|
▸ **create**(`collection`): `Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
Creates a product collection
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `collection` | `any` | the collection to create |
|
| `collection` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductCollection`\>
|
`Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
created collection
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:104](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L104)
|
[services/product-collection.js:104](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L104)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -79,23 +73,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`collectionId`): `Promise`<`any`\>
|
▸ **delete**(`collectionId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Deletes a product collection idempotently
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `collectionId` | `string` | id of collection to delete |
|
| `collectionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
empty promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:152](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L152)
|
[services/product-collection.js:152](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L152)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -103,24 +93,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||||
|
|
||||||
Lists product collections
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the config to be used for find |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:206](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L206)
|
[services/product-collection.js:206](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L206)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -128,24 +114,20 @@ ___
|
|||||||
|
|
||||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<`any`\>
|
▸ **listAndCount**(`selector?`, `config?`): `Promise`<`any`\>
|
||||||
|
|
||||||
Lists product collections and add count.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the config to be used for find |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:221](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L221)
|
[services/product-collection.js:221](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L221)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -166,7 +148,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:188](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L188)
|
[services/product-collection.js:188](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L188)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -174,24 +156,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`collectionId`, `config?`): `Promise`<`ProductCollection`\>
|
▸ **retrieve**(`collectionId`, `config?`): `Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
Retrieves a product collection by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `collectionId` | `string` | the id of the collection to retrieve. |
|
| `collectionId` | `string` | |
|
||||||
| `config` | `any` | the config of the collection to retrieve. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductCollection`\>
|
`Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
the collection.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:55](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L55)
|
[services/product-collection.js:55](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L55)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -199,24 +177,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByHandle**(`collectionHandle`, `config?`): `Promise`<`ProductCollection`\>
|
▸ **retrieveByHandle**(`collectionHandle`, `config?`): `Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
Retrieves a product collection by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `collectionHandle` | `string` | the handle of the collection to retrieve. |
|
| `collectionHandle` | `string` | |
|
||||||
| `config` | `any` | query config for request |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductCollection`\>
|
`Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
the collection.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:81](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L81)
|
[services/product-collection.js:81](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L81)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -224,24 +198,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`collectionId`, `update`): `Promise`<`ProductCollection`\>
|
▸ **update**(`collectionId`, `update`): `Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
Updates a product collection
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `collectionId` | `string` | id of collection to update |
|
| `collectionId` | `string` | |
|
||||||
| `update` | `any` | update object |
|
| `update` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductCollection`\>
|
`Promise`<`ProductCollection`\>
|
||||||
|
|
||||||
update collection
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:125](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L125)
|
[services/product-collection.js:125](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L125)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -261,4 +231,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-collection.js:32](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-collection.js#L32)
|
[services/product-collection.js:32](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-collection.js#L32)
|
||||||
@@ -24,7 +24,7 @@ TransactionBaseService<ProductService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:62](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L62)
|
[services/product.ts:62](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L62)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L53)
|
[services/product.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:50](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L50)
|
[services/product.ts:50](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L50)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L42)
|
[services/product.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L45)
|
[services/product.ts:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L46)
|
[services/product.ts:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L49)
|
[services/product.ts:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L49)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:48](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L48)
|
[services/product.ts:48](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L48)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L47)
|
[services/product.ts:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:51](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L51)
|
[services/product.ts:51](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L51)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:52](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L52)
|
[services/product.ts:52](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L52)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L43)
|
[services/product.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L43)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:56](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L56)
|
[services/product.ts:56](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L56)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:55](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L55)
|
[services/product.ts:55](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L55)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -198,26 +198,20 @@ ___
|
|||||||
|
|
||||||
▸ **addOption**(`productId`, `optionTitle`): `Promise`<`Product`\>
|
▸ **addOption**(`productId`, `optionTitle`): `Promise`<`Product`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product to apply the new option to |
|
| `productId` | `string` | |
|
||||||
| `optionTitle` | `string` | the display title of the option, e.g. "Size" |
|
| `optionTitle` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the result of the model update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:552](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L552)
|
[services/product.ts:552](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L552)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -225,10 +219,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -240,23 +230,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -264,23 +252,19 @@ ___
|
|||||||
|
|
||||||
▸ **count**(`selector?`): `Promise`<`number`\>
|
▸ **count**(`selector?`): `Promise`<`number`\>
|
||||||
|
|
||||||
Return the total number of documents in database
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`Product`\> | the selector to choose products by |
|
| `selector` | `Selector`<`Product`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`number`\>
|
`Promise`<`number`\>
|
||||||
|
|
||||||
the result of the count operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:175](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L175)
|
[services/product.ts:175](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L175)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -288,23 +272,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`productObject`): `Promise`<`Product`\>
|
▸ **create**(`productObject`): `Promise`<`Product`\>
|
||||||
|
|
||||||
Creates a product.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productObject` | `CreateProductInput` | the product to create |
|
| `productObject` | `CreateProductInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
resolves to the creation result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:324](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L324)
|
[services/product.ts:324](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L324)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -312,24 +292,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`productId`): `Promise`<`void`\>
|
▸ **delete**(`productId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Deletes a product from a given product id. The product's associated
|
|
||||||
variants will also be deleted.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the id of the product to delete. Must be castable as an ObjectId |
|
| `productId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
empty promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:518](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L518)
|
[services/product.ts:518](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L518)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -337,24 +312,20 @@ ___
|
|||||||
|
|
||||||
▸ **deleteOption**(`productId`, `optionId`): `Promise`<`void` \| `Product`\>
|
▸ **deleteOption**(`productId`, `optionId`): `Promise`<`void` \| `Product`\>
|
||||||
|
|
||||||
Delete an option from a product.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product to delete an option from |
|
| `productId` | `string` | |
|
||||||
| `optionId` | `string` | the option to delete |
|
| `optionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void` \| `Product`\>
|
`Promise`<`void` \| `Product`\>
|
||||||
|
|
||||||
the updated product
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:693](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L693)
|
[services/product.ts:693](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L693)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -362,24 +333,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector?`, `config?`): `Promise`<`Product`[]\>
|
▸ **list**(`selector?`, `config?`): `Promise`<`Product`[]\>
|
||||||
|
|
||||||
Lists products based on the provided parameters.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductProps` \| `Selector`<`Product`\> | an object that defines rules to filter products by |
|
| `selector` | `Selector`<`Product`\> \| `FilterableProductProps` | |
|
||||||
| `config` | `FindProductConfig` | object that defines the scope for what should be returned |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`[]\>
|
`Promise`<`Product`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:107](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L107)
|
[services/product.ts:107](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L107)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -387,27 +354,20 @@ ___
|
|||||||
|
|
||||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Product`[], `number`]\>
|
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Product`[], `number`]\>
|
||||||
|
|
||||||
Lists products based on the provided parameters and includes the count of
|
|
||||||
products that match the query.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductProps` \| `Selector`<`Product`\> | an object that defines rules to filter products by |
|
| `selector` | `Selector`<`Product`\> \| `FilterableProductProps` | |
|
||||||
| `config` | `FindProductConfig` | object that defines the scope for what should be returned |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`Product`[], `number`]\>
|
`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
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:144](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L144)
|
[services/product.ts:144](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L144)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -427,7 +387,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:309](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L309)
|
[services/product.ts:309](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L309)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -441,7 +401,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:299](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L299)
|
[services/product.ts:299](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L299)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -449,22 +409,17 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **prepareListQuery_**(`selector`, `config`): `Object`
|
▸ `Protected` **prepareListQuery_**(`selector`, `config`): `Object`
|
||||||
|
|
||||||
Creates a query object to be used for list queries.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductProps` \| `Selector`<`Product`\> | the selector to create the query from |
|
| `selector` | `Selector`<`Product`\> \| `FilterableProductProps` | |
|
||||||
| `config` | `FindProductConfig` | the config to use for the query |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Object`
|
`Object`
|
||||||
|
|
||||||
an object containing the query, relations and free-text
|
|
||||||
search param.
|
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :------ | :------ |
|
| :------ | :------ |
|
||||||
| `q` | `string` |
|
| `q` | `string` |
|
||||||
@@ -473,7 +428,7 @@ an object containing the query, relations and free-text
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:759](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L759)
|
[services/product.ts:759](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L759)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -494,7 +449,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:591](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L591)
|
[services/product.ts:591](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L591)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -502,25 +457,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`productId`, `config?`): `Promise`<`Product`\>
|
▸ **retrieve**(`productId`, `config?`): `Promise`<`Product`\>
|
||||||
|
|
||||||
Gets a product by id.
|
|
||||||
Throws in case of DB Error and if product was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | id of the product to get. |
|
| `productId` | `string` | |
|
||||||
| `config` | `FindProductConfig` | object that defines what should be included in the query response |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the result of the find one operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:191](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L191)
|
[services/product.ts:191](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L191)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -528,25 +478,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Product`\>
|
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Product`\>
|
||||||
|
|
||||||
Gets a product by external id.
|
|
||||||
Throws in case of DB Error and if product was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `externalId` | `string` | handle of the product to get. |
|
| `externalId` | `string` | |
|
||||||
| `config` | `FindProductConfig` | details about what to get from the product |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the result of the find one operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:225](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L225)
|
[services/product.ts:225](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L225)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -554,25 +499,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByHandle**(`productHandle`, `config?`): `Promise`<`Product`\>
|
▸ **retrieveByHandle**(`productHandle`, `config?`): `Promise`<`Product`\>
|
||||||
|
|
||||||
Gets a product by handle.
|
|
||||||
Throws in case of DB Error and if product was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productHandle` | `string` | handle of the product to get. |
|
| `productHandle` | `string` | |
|
||||||
| `config` | `FindProductConfig` | details about what to get from the product |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the result of the find one operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:209](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L209)
|
[services/product.ts:209](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L209)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -580,24 +520,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveVariants**(`productId`, `config?`): `Promise`<`ProductVariant`[]\>
|
▸ **retrieveVariants**(`productId`, `config?`): `Promise`<`ProductVariant`[]\>
|
||||||
|
|
||||||
Gets all variants belonging to a product.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the id of the product to get variants from. |
|
| `productId` | `string` | |
|
||||||
| `config` | `FindProductConfig` | The config to select and configure relations etc... |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariant`[]\>
|
`Promise`<`ProductVariant`[]\>
|
||||||
|
|
||||||
an array of variants
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:279](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L279)
|
[services/product.ts:279](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L279)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -605,25 +541,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve_**(`selector`, `config?`): `Promise`<`Product`\>
|
▸ **retrieve_**(`selector`, `config?`): `Promise`<`Product`\>
|
||||||
|
|
||||||
Gets a product by selector.
|
|
||||||
Throws in case of DB Error and if product was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`Product`\> | selector object |
|
| `selector` | `Selector`<`Product`\> | |
|
||||||
| `config` | `FindProductConfig` | object that defines what should be included in the query response |
|
| `config` | `FindProductConfig` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the result of the find one operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:242](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L242)
|
[services/product.ts:242](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L242)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -647,7 +578,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -655,26 +586,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`productId`, `update`): `Promise`<`Product`\>
|
▸ **update**(`productId`, `update`): `Promise`<`Product`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the id of the product. Must be a string that can be casted to an ObjectId |
|
| `productId` | `string` | |
|
||||||
| `update` | `UpdateProductInput` | an object with the update values. |
|
| `update` | `UpdateProductInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:399](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L399)
|
[services/product.ts:399](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L399)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -682,26 +607,21 @@ ___
|
|||||||
|
|
||||||
▸ **updateOption**(`productId`, `optionId`, `data`): `Promise`<`Product`\>
|
▸ **updateOption**(`productId`, `optionId`, `data`): `Promise`<`Product`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product whose option we are updating |
|
| `productId` | `string` | |
|
||||||
| `optionId` | `string` | the id of the option we are updating |
|
| `optionId` | `string` | |
|
||||||
| `data` | `ProductOptionInput` | the data to update the option with |
|
| `data` | `ProductOptionInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the updated product
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product.ts:637](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product.ts#L637)
|
[services/product.ts:637](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product.ts#L637)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -725,4 +645,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: ProductTypeService
|
# Class: ProductTypeService
|
||||||
|
|
||||||
Provides layer to manipulate products.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L16)
|
[services/product-type.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L16)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:14](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L14)
|
[services/product-type.ts:14](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L15)
|
[services/product-type.ts:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L15)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -54,24 +52,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector?`, `config?`): `Promise`<`ProductType`[]\>
|
▸ **list**(`selector?`, `config?`): `Promise`<`ProductType`[]\>
|
||||||
|
|
||||||
Lists product types
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductTypeProps` | the query object for find |
|
| `selector` | `FilterableProductTypeProps` | |
|
||||||
| `config` | `FindConfig`<`ProductType`\> | the config to be used for find |
|
| `config` | `FindConfig`<`ProductType`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductType`[]\>
|
`Promise`<`ProductType`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:72](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L72)
|
[services/product-type.ts:72](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L72)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -79,24 +73,20 @@ ___
|
|||||||
|
|
||||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`ProductType`[], `number`]\>
|
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`ProductType`[], `number`]\>
|
||||||
|
|
||||||
Lists product tags and adds count.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductTypeProps` | the query object for find |
|
| `selector` | `FilterableProductTypeProps` | |
|
||||||
| `config` | `FindConfig`<`ProductType`\> | the config to be used for find |
|
| `config` | `FindConfig`<`ProductType`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`ProductType`[], `number`]\>
|
`Promise`<[`ProductType`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:88](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L88)
|
[services/product-type.ts:88](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L88)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -104,25 +94,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`ProductType`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`ProductType`\>
|
||||||
|
|
||||||
Gets a product by id.
|
|
||||||
Throws in case of DB Error and if product was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of the product to get. |
|
| `id` | `string` | |
|
||||||
| `config` | `FindConfig`<`ProductType`\> | object that defines what should be included in the query response |
|
| `config` | `FindConfig`<`ProductType`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductType`\>
|
`Promise`<`ProductType`\>
|
||||||
|
|
||||||
the result of the find one operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L47)
|
[services/product-type.ts:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -142,4 +127,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-type.ts:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-type.ts#L23)
|
[services/product-type.ts:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-type.ts#L23)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: ProductVariantService
|
# Class: ProductVariantService
|
||||||
|
|
||||||
Provides layer to manipulate product variants.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:52](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L52)
|
[services/product-variant.ts:52](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L52)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:50](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L50)
|
[services/product-variant.ts:50](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L50)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L45)
|
[services/product-variant.ts:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L42)
|
[services/product-variant.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:48](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L48)
|
[services/product-variant.ts:48](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L48)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L47)
|
[services/product-variant.ts:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L49)
|
[services/product-variant.ts:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L49)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -96,7 +94,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:44](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L44)
|
[services/product-variant.ts:44](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L44)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -106,7 +104,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L43)
|
[services/product-variant.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L43)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L46)
|
[services/product-variant.ts:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L36)
|
[services/product-variant.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L36)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -142,29 +140,21 @@ ___
|
|||||||
|
|
||||||
▸ **addOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the variant to decorate. |
|
| `variantId` | `string` | |
|
||||||
| `optionId` | `string` | the option from product. |
|
| `optionId` | `string` | |
|
||||||
| `optionValue` | `string` | option value to add. |
|
| `optionValue` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductOptionValue`\>
|
`Promise`<`ProductOptionValue`\>
|
||||||
|
|
||||||
the result of the update operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:529](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L529)
|
[services/product-variant.ts:529](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L529)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -172,25 +162,20 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`productOrProductId`, `variant`): `Promise`<`ProductVariant`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productOrProductId` | `string` \| `Product` | the product the variant will be added to |
|
| `productOrProductId` | `string` \| `Product` | |
|
||||||
| `variant` | `CreateProductVariantInput` | the variant to create |
|
| `variant` | `CreateProductVariantInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariant`\>
|
`Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
resolves to the creation result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:183](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L183)
|
[services/product-variant.ts:183](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L183)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -198,24 +183,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`variantId`): `Promise`<`void`\>
|
▸ **delete**(`variantId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Deletes variant.
|
|
||||||
Will never fail due to delete being idempotent.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to delete. Must be castable as an ObjectId |
|
| `variantId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
empty promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:682](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L682)
|
[services/product-variant.ts:682](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L682)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -223,25 +203,20 @@ ___
|
|||||||
|
|
||||||
▸ **deleteOptionValue**(`variantId`, `optionId`): `Promise`<`void`\>
|
▸ **deleteOptionValue**(`variantId`, `optionId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Deletes option value from given variant.
|
|
||||||
Will never fail due to delete being idempotent.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the variant to decorate. |
|
| `variantId` | `string` | |
|
||||||
| `optionId` | `string` | the option from product. |
|
| `optionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
empty promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:556](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L556)
|
[services/product-variant.ts:556](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L556)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -249,27 +224,21 @@ ___
|
|||||||
|
|
||||||
▸ **getFreeTextQueryBuilder_**(`variantRepo`, `query`, `q?`): `SelectQueryBuilder`<`ProductVariant`\>
|
▸ **getFreeTextQueryBuilder_**(`variantRepo`, `query`, `q?`): `SelectQueryBuilder`<`ProductVariant`\>
|
||||||
|
|
||||||
Lists variants based on the provided parameters and includes the count of
|
|
||||||
variants that match the query.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantRepo` | `ProductVariantRepository` | the variant repository |
|
| `variantRepo` | `ProductVariantRepository` | |
|
||||||
| `query` | `FindWithRelationsOptions` | object that defines the scope for what should be returned |
|
| `query` | `FindWithRelationsOptions` | |
|
||||||
| `q?` | `string` | free text query |
|
| `q?` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`SelectQueryBuilder`<`ProductVariant`\>
|
`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
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:788](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L788)
|
[services/product-variant.ts:788](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L788)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -277,26 +246,20 @@ ___
|
|||||||
|
|
||||||
▸ **getRegionPrice**(`variantId`, `context`): `Promise`<`number`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to get price from |
|
| `variantId` | `string` | |
|
||||||
| `context` | `GetRegionPriceContext` | context for getting region price |
|
| `context` | `GetRegionPriceContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`number`\>
|
`Promise`<`number`\>
|
||||||
|
|
||||||
the price specific to the region
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:404](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L404)
|
[services/product-variant.ts:404](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L404)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -308,18 +271,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductVariantProps` | the query object for find |
|
| `selector` | `FilterableProductVariantProps` | |
|
||||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval |
|
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariant`[]\>
|
`Promise`<`ProductVariant`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:624](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L624)
|
[services/product-variant.ts:624](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L624)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -331,18 +292,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductVariantProps` | the query object for find |
|
| `selector` | `FilterableProductVariantProps` | |
|
||||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval |
|
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`ProductVariant`[], `number`]\>
|
`Promise`<[`ProductVariant`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:583](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L583)
|
[services/product-variant.ts:583](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L583)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -350,22 +309,17 @@ ___
|
|||||||
|
|
||||||
▸ **prepareListQuery_**(`selector`, `config`): `Object`
|
▸ **prepareListQuery_**(`selector`, `config`): `Object`
|
||||||
|
|
||||||
Creates a query object to be used for list queries.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableProductVariantProps` | the selector to create the query from |
|
| `selector` | `FilterableProductVariantProps` | |
|
||||||
| `config` | `FindConfig`<`ProductVariant`\> | the config to use for the query |
|
| `config` | `FindConfig`<`ProductVariant`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Object`
|
`Object`
|
||||||
|
|
||||||
an object containing the query, relations and free-text
|
|
||||||
search param.
|
|
||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :------ | :------ |
|
| :------ | :------ |
|
||||||
| `q?` | `string` |
|
| `q?` | `string` |
|
||||||
@@ -374,7 +328,7 @@ an object containing the query, relations and free-text
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:749](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L749)
|
[services/product-variant.ts:749](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L749)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -382,24 +336,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`variantId`, `config?`): `Promise`<`ProductVariant`\>
|
▸ **retrieve**(`variantId`, `config?`): `Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
Gets a product variant by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the product to get. |
|
| `variantId` | `string` | |
|
||||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. |
|
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariant`\>
|
`Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
the product document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:117](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L117)
|
[services/product-variant.ts:117](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L117)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -407,24 +357,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveBySKU**(`sku`, `config?`): `Promise`<`ProductVariant`\>
|
▸ **retrieveBySKU**(`sku`, `config?`): `Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
Gets a product variant by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `sku` | `string` | The unique stock keeping unit used to identify the product variant. |
|
| `sku` | `string` | |
|
||||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. |
|
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariant`\>
|
`Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
the product document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:147](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L147)
|
[services/product-variant.ts:147](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L147)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -432,24 +378,20 @@ ___
|
|||||||
|
|
||||||
▸ **setCurrencyPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
▸ **setCurrencyPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
||||||
|
|
||||||
Sets the default price for the given currency.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to set prices for |
|
| `variantId` | `string` | |
|
||||||
| `price` | `ProductVariantPrice` | the price for the variant |
|
| `price` | `ProductVariantPrice` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`MoneyAmount`\>
|
`Promise`<`MoneyAmount`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:470](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L470)
|
[services/product-variant.ts:470](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L470)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -457,24 +399,20 @@ ___
|
|||||||
|
|
||||||
▸ **setMetadata_**(`variant`, `metadata`): `Record`<`string`, `unknown`\>
|
▸ **setMetadata_**(`variant`, `metadata`): `Record`<`string`, `unknown`\>
|
||||||
|
|
||||||
Dedicated method to set metadata for a variant.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variant` | `ProductVariant` | the variant to set metadata for. |
|
| `variant` | `ProductVariant` | |
|
||||||
| `metadata` | `object` | the metadata to set |
|
| `metadata` | `object` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Record`<`string`, `unknown`\>
|
`Record`<`string`, `unknown`\>
|
||||||
|
|
||||||
updated metadata object
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:717](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L717)
|
[services/product-variant.ts:717](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L717)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -482,24 +420,20 @@ ___
|
|||||||
|
|
||||||
▸ **setRegionPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
▸ **setRegionPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
||||||
|
|
||||||
Sets the default price of a specific region
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of the variant to update |
|
| `variantId` | `string` | |
|
||||||
| `price` | `ProductVariantPrice` | the price for the variant. |
|
| `price` | `ProductVariantPrice` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`MoneyAmount`\>
|
`Promise`<`MoneyAmount`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:433](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L433)
|
[services/product-variant.ts:433](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L433)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -507,26 +441,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`variantOrVariantId`, `update`): `Promise`<`ProductVariant`\>
|
▸ **update**(`variantOrVariantId`, `update`): `Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
Updates a variant.
|
|
||||||
Price updates should use dedicated methods.
|
|
||||||
The function will throw, if price updates are attempted.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantOrVariantId` | `string` \| `Partial`<`ProductVariant`\> | variant or id of a variant. |
|
| `variantOrVariantId` | `string` \| `Partial`<`ProductVariant`\> | |
|
||||||
| `update` | `UpdateProductVariantInput` | an object with the update values. |
|
| `update` | `UpdateProductVariantInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductVariant`\>
|
`Promise`<`ProductVariant`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:288](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L288)
|
[services/product-variant.ts:288](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L288)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -534,26 +462,21 @@ ___
|
|||||||
|
|
||||||
▸ **updateOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
▸ **updateOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
||||||
|
|
||||||
Updates variant's option value.
|
|
||||||
Option value must be of type string or number.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the variant to decorate. |
|
| `variantId` | `string` | |
|
||||||
| `optionId` | `string` | the option from product. |
|
| `optionId` | `string` | |
|
||||||
| `optionValue` | `string` | option value to add. |
|
| `optionValue` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ProductOptionValue`\>
|
`Promise`<`ProductOptionValue`\>
|
||||||
|
|
||||||
the result of the update operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:491](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L491)
|
[services/product-variant.ts:491](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L491)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -561,25 +484,20 @@ ___
|
|||||||
|
|
||||||
▸ **updateVariantPrices**(`variantId`, `prices`): `Promise`<`void`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `variantId` | `string` | the id of variant variant |
|
| `variantId` | `string` | |
|
||||||
| `prices` | `ProductVariantPrice`[] | the update prices |
|
| `prices` | `ProductVariantPrice`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
empty promise
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:366](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L366)
|
[services/product-variant.ts:366](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L366)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -599,4 +517,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/product-variant.ts:89](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/product-variant.ts#L89)
|
[services/product-variant.ts:89](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/product-variant.ts#L89)
|
||||||
@@ -34,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/query-builder.js:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/query-builder.js#L25)
|
[services/query-builder.js:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/query-builder.js#L25)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/query-builder.js:5](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/query-builder.js#L5)
|
[services/query-builder.js:5](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/query-builder.js#L5)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,4 +76,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/query-builder.js:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/query-builder.js#L39)
|
[services/query-builder.js:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/query-builder.js#L39)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: RegionService
|
# Class: RegionService
|
||||||
|
|
||||||
Provides layer to manipulate regions.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L16)
|
[services/region.js:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L16)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -44,7 +42,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:10](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L10)
|
[services/region.js:10](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L10)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -52,24 +50,20 @@ BaseService.constructor
|
|||||||
|
|
||||||
▸ **addCountry**(`regionId`, `code`): `Promise`<`any`\>
|
▸ **addCountry**(`regionId`, `code`): `Promise`<`any`\>
|
||||||
|
|
||||||
Adds a country to the region.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to add a country to |
|
| `regionId` | `string` | |
|
||||||
| `code` | `string` | a 2 digit alphanumeric ISO country code. |
|
| `code` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:462](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L462)
|
[services/region.js:462](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L462)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -77,25 +71,20 @@ ___
|
|||||||
|
|
||||||
▸ **addFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
▸ **addFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Adds a fulfillment provider that is available in the region. Fails if the
|
|
||||||
provider doesn't exist.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to add the provider to |
|
| `regionId` | `string` | |
|
||||||
| `providerId` | `string` | the provider to add to the region |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:582](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L582)
|
[services/region.js:582](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L582)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -103,25 +92,20 @@ ___
|
|||||||
|
|
||||||
▸ **addPaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
▸ **addPaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Adds a payment provider that is available in the region. Fails if the
|
|
||||||
provider doesn't exist.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to add the provider to |
|
| `regionId` | `string` | |
|
||||||
| `providerId` | `string` | the provider to add to the region |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:535](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L535)
|
[services/region.js:535](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L535)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -129,23 +113,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`regionObject`): `Region`
|
▸ **create**(`regionObject`): `Region`
|
||||||
|
|
||||||
Creates a region.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionObject` | `Region` | the unvalidated region |
|
| `regionObject` | `Region` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Region`
|
`Region`
|
||||||
|
|
||||||
the newly created region
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:95](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L95)
|
[services/region.js:95](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L95)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -153,23 +133,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`regionId`): `Promise`<`any`\>
|
▸ **delete**(`regionId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Deletes a region.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to delete |
|
| `regionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the delete operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:432](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L432)
|
[services/region.js:432](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L432)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -177,24 +153,20 @@ ___
|
|||||||
|
|
||||||
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
▸ **list**(`selector?`, `config?`): `Promise`<`any`\>
|
||||||
|
|
||||||
Lists all regions based on a query
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | configuration settings |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:420](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L420)
|
[services/region.js:420](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L420)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -202,24 +174,20 @@ ___
|
|||||||
|
|
||||||
▸ **removeCountry**(`regionId`, `code`): `Promise`<`any`\>
|
▸ **removeCountry**(`regionId`, `code`): `Promise`<`any`\>
|
||||||
|
|
||||||
Removes a country from a Region
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to remove from |
|
| `regionId` | `string` | |
|
||||||
| `code` | `string` | a 2 digit alphanumeric ISO country code to remove |
|
| `code` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:499](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L499)
|
[services/region.js:499](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L499)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -227,24 +195,20 @@ ___
|
|||||||
|
|
||||||
▸ **removeFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
▸ **removeFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Removes a fulfillment provider from a region. Is idempotent.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to remove the provider from |
|
| `regionId` | `string` | |
|
||||||
| `providerId` | `string` | the provider to remove from the region |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:660](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L660)
|
[services/region.js:660](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L660)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -252,24 +216,20 @@ ___
|
|||||||
|
|
||||||
▸ **removePaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
▸ **removePaymentProvider**(`regionId`, `providerId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Removes a payment provider from a region. Is idempotent.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to remove the provider from |
|
| `regionId` | `string` | |
|
||||||
| `providerId` | `string` | the provider to remove from the region |
|
| `providerId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:626](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L626)
|
[services/region.js:626](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L626)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -277,24 +237,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`regionId`, `config?`): `Region`
|
▸ **retrieve**(`regionId`, `config?`): `Region`
|
||||||
|
|
||||||
Retrieves a region by its id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the id of the region to retrieve |
|
| `regionId` | `string` | |
|
||||||
| `config` | `any` | configuration settings |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Region`
|
`Region`
|
||||||
|
|
||||||
the region
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:396](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L396)
|
[services/region.js:396](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L396)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -315,7 +271,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:362](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L362)
|
[services/region.js:362](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L362)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -323,24 +279,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`regionId`, `update`): `Promise`<`any`\>
|
▸ **update**(`regionId`, `update`): `Promise`<`any`\>
|
||||||
|
|
||||||
Updates a region
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `regionId` | `string` | the region to update |
|
| `regionId` | `string` | |
|
||||||
| `update` | `any` | the data to update the region with |
|
| `update` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:153](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L153)
|
[services/region.js:153](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L153)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -348,15 +300,12 @@ ___
|
|||||||
|
|
||||||
▸ **validateCountry_**(`code`, `regionId`): `Promise`<`any`\>
|
▸ **validateCountry_**(`code`, `regionId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Validates a country code. Will normalize the code before checking for
|
|
||||||
existence.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `code` | `string` | a 2 digit alphanumeric ISO country code |
|
| `code` | `string` | |
|
||||||
| `regionId` | `string` | the id of the current region to check against |
|
| `regionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -364,7 +313,7 @@ existence.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:323](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L323)
|
[services/region.js:323](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L323)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -372,13 +321,11 @@ ___
|
|||||||
|
|
||||||
▸ **validateCurrency_**(`currencyCode`): `Promise`<`void`\>
|
▸ **validateCurrency_**(`currencyCode`): `Promise`<`void`\>
|
||||||
|
|
||||||
Validates a currency code. Will throw if the currency code doesn't exist.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `currencyCode` | `string` | an ISO currency code |
|
| `currencyCode` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -386,7 +333,7 @@ Validates a currency code. Will throw if the currency code doesn't exist.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:302](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L302)
|
[services/region.js:302](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L302)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -394,25 +341,20 @@ ___
|
|||||||
|
|
||||||
▸ **validateFields_**(`region`, `id?`): `any`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `region` | `any` | `undefined` | the region data to validate |
|
| `region` | `any` | `undefined` | |
|
||||||
| `id` | ``null`` \| `string` | `undefined` | optional id of the region to check against |
|
| `id` | ``null`` \| `string` | `undefined` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`any`
|
`any`
|
||||||
|
|
||||||
the validated region data
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:213](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L213)
|
[services/region.js:213](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L213)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -420,13 +362,11 @@ ___
|
|||||||
|
|
||||||
▸ **validateTaxRate_**(`taxRate`): `void`
|
▸ **validateTaxRate_**(`taxRate`): `void`
|
||||||
|
|
||||||
Validates a tax rate. Will throw if the tax rate is not between 0 and 1.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `taxRate` | `number` | a number representing the tax rate of the region |
|
| `taxRate` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -434,7 +374,7 @@ Validates a tax rate. Will throw if the tax rate is not between 0 and 1.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:289](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L289)
|
[services/region.js:289](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L289)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -454,4 +394,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/region.js:65](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/region.js#L65)
|
[services/region.js:65](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/region.js#L65)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:5](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L5)
|
[services/return-reason.js:5](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L5)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L30)
|
[services/return-reason.js:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:114](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L114)
|
[services/return-reason.js:114](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L114)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,18 +76,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | config object |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:82](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L82)
|
[services/return-reason.js:82](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L82)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -95,24 +93,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Order`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`Order`\>
|
||||||
|
|
||||||
Gets an order by id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | id of order to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `any` | config object |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Order`\>
|
`Promise`<`Order`\>
|
||||||
|
|
||||||
the order document
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:97](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L97)
|
[services/return-reason.js:97](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L97)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -133,7 +127,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:52](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L52)
|
[services/return-reason.js:52](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L52)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -153,4 +147,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return-reason.js:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return-reason.js#L15)
|
[services/return-reason.js:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return-reason.js#L15)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: ReturnService
|
# Class: ReturnService
|
||||||
|
|
||||||
Handles Returns
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:9](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L9)
|
[services/return.js:9](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L9)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L49)
|
[services/return.js:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L49)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L47)
|
[services/return.js:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L39)
|
[services/return.js:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L39)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -64,23 +62,19 @@ ___
|
|||||||
|
|
||||||
▸ **cancel**(`returnId`): `Promise`<`Return`\>
|
▸ **cancel**(`returnId`): `Promise`<`Return`\>
|
||||||
|
|
||||||
Cancels a return if possible. Returns can be canceled if it has not been received.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `returnId` | `string` | the id of the return to cancel. |
|
| `returnId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Return`\>
|
`Promise`<`Return`\>
|
||||||
|
|
||||||
the updated Return
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:134](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L134)
|
[services/return.js:134](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L134)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -88,25 +82,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`Return`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `any` | data to use for the return e.g. shipping_method, items or refund_amount |
|
| `data` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Return`\>
|
`Promise`<`Return`\>
|
||||||
|
|
||||||
the created return
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:307](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L307)
|
[services/return.js:307](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L307)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -126,7 +114,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:450](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L450)
|
[services/return.js:450](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L450)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -134,27 +122,23 @@ ___
|
|||||||
|
|
||||||
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>
|
||||||
|
|
||||||
Retrieves the order line items, given an array of items
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to get line items from |
|
| `order` | `Order` | |
|
||||||
| `items` | `Object` | the items to get |
|
| `items` | `Object` | |
|
||||||
| `items.item_id` | `string` | - |
|
| `items.item_id` | `string` | - |
|
||||||
| `items.quantity` | `number` | - |
|
| `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. |
|
| `transformer` | `Function` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItem`[]\>
|
`Promise`<`LineItem`[]\>
|
||||||
|
|
||||||
the line items generated by the transformer.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:89](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L89)
|
[services/return.js:89](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L89)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -166,18 +150,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the config object for find |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:120](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L120)
|
[services/return.js:120](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L120)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -185,32 +167,22 @@ ___
|
|||||||
|
|
||||||
▸ **receive**(`return_id`, `received_items`, `refund_amount`, `allow_mismatch?`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `return_id` | `string` | `undefined` | the orderId to return to |
|
| `return_id` | `string` | `undefined` | |
|
||||||
| `received_items` | `Item`[] | `undefined` | the items received after return. |
|
| `received_items` | `Item`[] | `undefined` | |
|
||||||
| `refund_amount` | `undefined` \| `number` | `undefined` | the amount to return |
|
| `refund_amount` | `undefined` \| `number` | `undefined` | |
|
||||||
| `allow_mismatch` | `bool` | `false` | whether to ignore return/received product mismatch |
|
| `allow_mismatch` | `bool` | `false` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:524](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L524)
|
[services/return.js:524](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L524)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -218,24 +190,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Return`
|
▸ **retrieve**(`id`, `config?`): `Return`
|
||||||
|
|
||||||
Retrieves a return by its id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the return to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `any` | the config object |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Return`
|
`Return`
|
||||||
|
|
||||||
the return
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:229](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L229)
|
[services/return.js:229](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L229)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -256,7 +224,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:248](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L248)
|
[services/return.js:248](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L248)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -277,7 +245,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:271](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L271)
|
[services/return.js:271](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L271)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -285,28 +253,21 @@ ___
|
|||||||
|
|
||||||
▸ **validateReturnLineItem_**(`item`, `quantity`, `additional`): `LineItem`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `item` | `any` | the line item to check has sufficient returnable quantity. |
|
| `item` | `any` | |
|
||||||
| `quantity` | `number` | the quantity that is requested to be returned. |
|
| `quantity` | `number` | |
|
||||||
| `additional` | `any` | the quantity that is requested to be returned. |
|
| `additional` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`LineItem`
|
`LineItem`
|
||||||
|
|
||||||
a line item where the quantity is set to the requested
|
|
||||||
return quantity.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:191](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L191)
|
[services/return.js:191](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L191)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -314,17 +275,11 @@ ___
|
|||||||
|
|
||||||
▸ **validateReturnStatuses_**(`order`): `void`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to check statuses on |
|
| `order` | `Order` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -332,7 +287,7 @@ payment_status must be captured.
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:161](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L161)
|
[services/return.js:161](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L161)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -352,4 +307,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/return.js:55](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/return.js#L55)
|
[services/return.js:55](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/return.js#L55)
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
# Class: SalesChannelService
|
||||||
|
|
||||||
|
## Hierarchy
|
||||||
|
|
||||||
|
- `TransactionBaseService`<[`SalesChannelService`](SalesChannelService.md)\>
|
||||||
|
|
||||||
|
↳ **`SalesChannelService`**
|
||||||
|
|
||||||
|
## Constructors
|
||||||
|
|
||||||
|
### constructor
|
||||||
|
|
||||||
|
• **new SalesChannelService**(`__namedParameters`)
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `__namedParameters` | `InjectedDependencies` |
|
||||||
|
|
||||||
|
#### Overrides
|
||||||
|
|
||||||
|
TransactionBaseService<SalesChannelService\>.constructor
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L37)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### configModule
|
||||||
|
|
||||||
|
• `Protected` `Optional` `Readonly` **configModule**: `Record`<`string`, `unknown`\>
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
TransactionBaseService.configModule
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### container
|
||||||
|
|
||||||
|
• `Protected` `Readonly` **container**: `unknown`
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
TransactionBaseService.container
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### eventBusService\_
|
||||||
|
|
||||||
|
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L34)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### manager\_
|
||||||
|
|
||||||
|
• `Protected` **manager\_**: `EntityManager`
|
||||||
|
|
||||||
|
#### Overrides
|
||||||
|
|
||||||
|
TransactionBaseService.manager\_
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L30)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### salesChannelRepository\_
|
||||||
|
|
||||||
|
• `Protected` `Readonly` **salesChannelRepository\_**: typeof `SalesChannelRepository`
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:33](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L33)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### storeService\_
|
||||||
|
|
||||||
|
• `Protected` `Readonly` **storeService\_**: [`StoreService`](StoreService.md)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L35)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### transactionManager\_
|
||||||
|
|
||||||
|
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||||
|
|
||||||
|
#### Overrides
|
||||||
|
|
||||||
|
TransactionBaseService.transactionManager\_
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:31](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L31)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### Events
|
||||||
|
|
||||||
|
▪ `Static` **Events**: `Object`
|
||||||
|
|
||||||
|
#### Type declaration
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `CREATED` | `string` |
|
||||||
|
| `DELETED` | `string` |
|
||||||
|
| `UPDATED` | `string` |
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:24](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L24)
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### atomicPhase\_
|
||||||
|
|
||||||
|
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||||
|
|
||||||
|
#### Type parameters
|
||||||
|
|
||||||
|
| Name |
|
||||||
|
| :------ |
|
||||||
|
| `TResult` |
|
||||||
|
| `TError` |
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### create
|
||||||
|
|
||||||
|
▸ **create**(`data`): `Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `data` | `CreateSalesChannelInput` |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:102](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L102)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### createDefault
|
||||||
|
|
||||||
|
▸ **createDefault**(): `Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:182](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L182)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### delete
|
||||||
|
|
||||||
|
▸ **delete**(`salesChannelId`): `Promise`<`void`\>
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `salesChannelId` | `string` | |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`void`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:154](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L154)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### listAndCount
|
||||||
|
|
||||||
|
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`SalesChannel`[], `number`]\>
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `selector` | `QuerySelector`<`any`\> |
|
||||||
|
| `config` | `FindConfig`<`any`\> |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<[`SalesChannel`[], `number`]\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:88](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L88)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### retrieve
|
||||||
|
|
||||||
|
▸ **retrieve**(`salesChannelId`, `config?`): `Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `salesChannelId` | `string` |
|
||||||
|
| `config` | `FindConfig`<`SalesChannel`\> |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:59](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L59)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### 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/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### update
|
||||||
|
|
||||||
|
▸ **update**(`salesChannelId`, `data`): `Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `salesChannelId` | `string` |
|
||||||
|
| `data` | `Partial`<`CreateSalesChannelInput`\> |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`SalesChannel`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/sales-channel.ts:119](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/sales-channel.ts#L119)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### withTransaction
|
||||||
|
|
||||||
|
▸ **withTransaction**(`transactionManager?`): [`SalesChannelService`](SalesChannelService.md)
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `transactionManager?` | `EntityManager` |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
[`SalesChannelService`](SalesChannelService.md)
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
TransactionBaseService.withTransaction
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: SearchService
|
# Class: SearchService
|
||||||
|
|
||||||
Default class that implements SearchService but provides stuv implementation for all methods
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ SearchService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:8](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L8)
|
[services/search.js:8](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L8)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ SearchService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:11](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L11)
|
[services/search.js:11](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L11)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:13](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L13)
|
[services/search.js:13](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L13)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -68,7 +66,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:28](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L28)
|
[services/search.js:28](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L28)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -89,7 +87,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L16)
|
[services/search.js:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L16)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -109,7 +107,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L46)
|
[services/search.js:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -130,7 +128,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L40)
|
[services/search.js:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L40)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -150,7 +148,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:22](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L22)
|
[services/search.js:22](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L22)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -172,7 +170,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L34)
|
[services/search.js:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -198,7 +196,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:52](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L52)
|
[services/search.js:52](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L52)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -219,4 +217,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/search.js:59](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/search.js#L59)
|
[services/search.js:59](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/search.js#L59)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: ShippingOptionService
|
# Class: ShippingOptionService
|
||||||
|
|
||||||
Provides layer to manipulate profiles.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`ShippingOptionService`](ShippingOptionService.md)\>
|
- `TransactionBaseService`<[`ShippingOptionService`](ShippingOptionService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<ShippingOptionService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:39](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L39)
|
[services/shipping-option.ts:39](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L39)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:36](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L36)
|
[services/shipping-option.ts:36](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L36)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L34)
|
[services/shipping-option.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:33](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L33)
|
[services/shipping-option.ts:33](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L33)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L30)
|
[services/shipping-option.ts:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -100,7 +98,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:31](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L31)
|
[services/shipping-option.ts:31](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L31)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -110,7 +108,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:32](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L32)
|
[services/shipping-option.ts:32](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L32)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -124,7 +122,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:37](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L37)
|
[services/shipping-option.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L37)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -132,25 +130,20 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ **addRequirement**(`optionId`, `requirement`): `Promise`<`ShippingOption`\>
|
▸ **addRequirement**(`optionId`, `requirement`): `Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
Adds a requirement to a shipping option. Only 1 requirement of each type
|
|
||||||
is allowed.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `optionId` | `string` | the option to add the requirement to. |
|
| `optionId` | `string` | |
|
||||||
| `requirement` | `ShippingOptionRequirement` | the requirement for the option. |
|
| `requirement` | `ShippingOptionRequirement` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingOption`\>
|
`Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
the result of update
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:627](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L627)
|
[services/shipping-option.ts:627](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L627)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -158,10 +151,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -173,23 +162,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -197,25 +184,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`data`): `Promise`<`ShippingOption`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `CreateShippingOptionInput` | the data to create shipping options |
|
| `data` | `CreateShippingOptionInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingOption`\>
|
`Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
the result of the create operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:384](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L384)
|
[services/shipping-option.ts:384](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L384)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -223,25 +204,21 @@ ___
|
|||||||
|
|
||||||
▸ **createShippingMethod**(`optionId`, `data`, `config`): `Promise`<`ShippingMethod`\>
|
▸ **createShippingMethod**(`optionId`, `data`, `config`): `Promise`<`ShippingMethod`\>
|
||||||
|
|
||||||
Creates a shipping method for a given cart.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `optionId` | `string` | the id of the option to use for the method. |
|
| `optionId` | `string` | |
|
||||||
| `data` | `object` | the optional provider data to use. |
|
| `data` | `object` | |
|
||||||
| `config` | `CreateShippingMethodDto` | the cart to create the shipping method for. |
|
| `config` | `CreateShippingMethodDto` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingMethod`\>
|
`Promise`<`ShippingMethod`\>
|
||||||
|
|
||||||
the resulting shipping method.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:259](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L259)
|
[services/shipping-option.ts:259](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L259)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -249,23 +226,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`optionId`): `Promise`<`void` \| `ShippingOption`\>
|
▸ **delete**(`optionId`): `Promise`<`void` \| `ShippingOption`\>
|
||||||
|
|
||||||
Deletes a profile with a given profile id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `optionId` | `string` | the id of the profile to delete. Must be castable as an ObjectId |
|
| `optionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void` \| `ShippingOption`\>
|
`Promise`<`void` \| `ShippingOption`\>
|
||||||
|
|
||||||
the result of the delete operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:605](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L605)
|
[services/shipping-option.ts:605](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L605)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -273,23 +246,19 @@ ___
|
|||||||
|
|
||||||
▸ **deleteShippingMethods**(`shippingMethods`): `Promise`<`ShippingMethod`[]\>
|
▸ **deleteShippingMethods**(`shippingMethods`): `Promise`<`ShippingMethod`[]\>
|
||||||
|
|
||||||
Removes a given shipping method
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `shippingMethods` | `ShippingMethod` \| `ShippingMethod`[] | the shipping method to remove |
|
| `shippingMethods` | `ShippingMethod` \| `ShippingMethod`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingMethod`[]\>
|
`Promise`<`ShippingMethod`[]\>
|
||||||
|
|
||||||
removed shipping methods
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:239](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L239)
|
[services/shipping-option.ts:239](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L239)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -297,27 +266,21 @@ ___
|
|||||||
|
|
||||||
▸ **getPrice_**(`option`, `data`, `cart`): `Promise`<`number`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `option` | `ShippingOption` | the shipping option to retrieve the price for. |
|
| `option` | `ShippingOption` | |
|
||||||
| `data` | `object` | the shipping data to retrieve the price. |
|
| `data` | `object` | |
|
||||||
| `cart` | `undefined` \| `Cart` \| `Order` | the context in which the price should be retrieved. |
|
| `cart` | `undefined` \| `Order` \| `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`number`\>
|
`Promise`<`number`\>
|
||||||
|
|
||||||
the price of the shipping option.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:686](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L686)
|
[services/shipping-option.ts:686](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L686)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -329,18 +292,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`ShippingMethod`\> | the query object for find |
|
| `selector` | `Selector`<`ShippingMethod`\> | |
|
||||||
| `config` | `FindConfig`<`ShippingOption`\> | config object |
|
| `config` | `FindConfig`<`ShippingOption`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingOption`[]\>
|
`Promise`<`ShippingOption`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:130](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L130)
|
[services/shipping-option.ts:130](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L130)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -352,18 +313,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `Selector`<`ShippingMethod`\> | the query object for find |
|
| `selector` | `Selector`<`ShippingMethod`\> | |
|
||||||
| `config` | `FindConfig`<`ShippingOption`\> | config object |
|
| `config` | `FindConfig`<`ShippingOption`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`ShippingOption`[], `number`]\>
|
`Promise`<[`ShippingOption`[], `number`]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:149](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L149)
|
[services/shipping-option.ts:149](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L149)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -371,23 +330,19 @@ ___
|
|||||||
|
|
||||||
▸ **removeRequirement**(`requirementId`): `Promise`<`void` \| `ShippingOptionRequirement`\>
|
▸ **removeRequirement**(`requirementId`): `Promise`<`void` \| `ShippingOptionRequirement`\>
|
||||||
|
|
||||||
Removes a requirement from a shipping option
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `requirementId` | `any` | the id of the requirement to remove |
|
| `requirementId` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void` \| `ShippingOptionRequirement`\>
|
`Promise`<`void` \| `ShippingOptionRequirement`\>
|
||||||
|
|
||||||
the result of update
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:656](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L656)
|
[services/shipping-option.ts:656](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L656)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -395,15 +350,12 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`optionId`, `options?`): `Promise`<`ShippingOption`\>
|
▸ **retrieve**(`optionId`, `options?`): `Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
Gets a profile by id.
|
|
||||||
Throws in case of DB Error and if profile was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `optionId` | `any` | the id of the profile to get. |
|
| `optionId` | `any` | |
|
||||||
| `options` | `Object` | the options to get a profile |
|
| `options` | `Object` | |
|
||||||
| `options.relations?` | `string`[] | - |
|
| `options.relations?` | `string`[] | - |
|
||||||
| `options.select?` | keyof `ShippingOption`[] | - |
|
| `options.select?` | keyof `ShippingOption`[] | - |
|
||||||
|
|
||||||
@@ -411,11 +363,9 @@ Throws in case of DB Error and if profile was not found.
|
|||||||
|
|
||||||
`Promise`<`ShippingOption`\>
|
`Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
the profile document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:170](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L170)
|
[services/shipping-option.ts:170](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L170)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -439,7 +389,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -447,26 +397,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`optionId`, `update`): `Promise`<`ShippingOption`\>
|
▸ **update**(`optionId`, `update`): `Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `optionId` | `string` | the id of the option. Must be a string that can be casted to an ObjectId |
|
| `optionId` | `string` | |
|
||||||
| `update` | `UpdateShippingOptionInput` | an object with the update values. |
|
| `update` | `UpdateShippingOptionInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingOption`\>
|
`Promise`<`ShippingOption`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:498](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L498)
|
[services/shipping-option.ts:498](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L498)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -474,25 +418,20 @@ ___
|
|||||||
|
|
||||||
▸ **updateShippingMethod**(`id`, `update`): `Promise`<`undefined` \| `ShippingMethod`\>
|
▸ **updateShippingMethod**(`id`, `update`): `Promise`<`undefined` \| `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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the shipping method to update |
|
| `id` | `string` | |
|
||||||
| `update` | `ShippingMethodUpdate` | the values to update the method with |
|
| `update` | `ShippingMethodUpdate` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`undefined` \| `ShippingMethod`\>
|
`Promise`<`undefined` \| `ShippingMethod`\>
|
||||||
|
|
||||||
the resulting shipping method
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:210](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L210)
|
[services/shipping-option.ts:210](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L210)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -500,26 +439,20 @@ ___
|
|||||||
|
|
||||||
▸ **validateCartOption**(`option`, `cart`): ``null`` \| `ShippingOption`
|
▸ **validateCartOption**(`option`, `cart`): ``null`` \| `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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `option` | `ShippingOption` | the option object to check |
|
| `option` | `ShippingOption` | |
|
||||||
| `cart` | `Cart` | the cart object to check against |
|
| `cart` | `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
``null`` \| `ShippingOption`
|
``null`` \| `ShippingOption`
|
||||||
|
|
||||||
the validated shipping option
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:337](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L337)
|
[services/shipping-option.ts:337](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L337)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -527,24 +460,20 @@ ___
|
|||||||
|
|
||||||
▸ **validatePriceType_**(`priceType`, `option`): `Promise`<`ShippingOptionPriceType`\>
|
▸ **validatePriceType_**(`priceType`, `option`): `Promise`<`ShippingOptionPriceType`\>
|
||||||
|
|
||||||
Validates a shipping option price
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `priceType` | `ShippingOptionPriceType` | the price to validate |
|
| `priceType` | `ShippingOptionPriceType` | |
|
||||||
| `option` | `ShippingOption` | the option to validate against |
|
| `option` | `ShippingOption` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingOptionPriceType`\>
|
`Promise`<`ShippingOptionPriceType`\>
|
||||||
|
|
||||||
the validated price
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:462](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L462)
|
[services/shipping-option.ts:462](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L462)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -552,24 +481,20 @@ ___
|
|||||||
|
|
||||||
▸ **validateRequirement_**(`requirement`, `optionId?`): `Promise`<`ShippingOptionRequirement`\>
|
▸ **validateRequirement_**(`requirement`, `optionId?`): `Promise`<`ShippingOptionRequirement`\>
|
||||||
|
|
||||||
Validates a requirement
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `requirement` | `ShippingOptionRequirement` | `undefined` | the requirement to validate |
|
| `requirement` | `ShippingOptionRequirement` | `undefined` | |
|
||||||
| `optionId` | `undefined` \| `string` | `undefined` | the id to validate the requirement |
|
| `optionId` | `undefined` \| `string` | `undefined` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingOptionRequirement`\>
|
`Promise`<`ShippingOptionRequirement`\>
|
||||||
|
|
||||||
a validated shipping requirement
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-option.ts:64](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-option.ts#L64)
|
[services/shipping-option.ts:64](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-option.ts#L64)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -593,4 +518,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
# Class: ShippingProfileService
|
# Class: ShippingProfileService
|
||||||
|
|
||||||
Provides layer to manipulate profiles.
|
|
||||||
|
|
||||||
**`implements`** {BaseService}
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -28,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:12](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L12)
|
[services/shipping-profile.js:12](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L12)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -36,25 +32,20 @@ BaseService.constructor
|
|||||||
|
|
||||||
▸ **addProduct**(`profileId`, `productId`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `profileId` | `string` | the profile to add the product to. |
|
| `profileId` | `string` | |
|
||||||
| `productId` | `string` | the product to add. |
|
| `productId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of update
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:343](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L343)
|
[services/shipping-profile.js:343](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L343)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -62,25 +53,20 @@ ___
|
|||||||
|
|
||||||
▸ **addShippingOption**(`profileId`, `optionId`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `profileId` | `string` | the profile to apply the shipping option to |
|
| `profileId` | `string` | |
|
||||||
| `optionId` | `string` | the option to add to the profile |
|
| `optionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the model update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:361](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L361)
|
[services/shipping-profile.js:361](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L361)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -88,23 +74,19 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`profile`): `Promise`<`any`\>
|
▸ **create**(`profile`): `Promise`<`any`\>
|
||||||
|
|
||||||
Creates a new shipping profile.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `profile` | `ShippingProfile` | the shipping profile to create from |
|
| `profile` | `ShippingProfile` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the create operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:235](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L235)
|
[services/shipping-profile.js:235](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L235)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -112,17 +94,13 @@ ___
|
|||||||
|
|
||||||
▸ **createDefault**(): `Promise`<`ShippingProfile`\>
|
▸ **createDefault**(): `Promise`<`ShippingProfile`\>
|
||||||
|
|
||||||
Creates a default shipping profile, if this does not already exist.
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingProfile`\>
|
`Promise`<`ShippingProfile`\>
|
||||||
|
|
||||||
the shipping profile
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:167](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L167)
|
[services/shipping-profile.js:167](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L167)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -130,18 +108,13 @@ ___
|
|||||||
|
|
||||||
▸ **createGiftCardDefault**(): `Promise`<`ShippingProfile`\>
|
▸ **createGiftCardDefault**(): `Promise`<`ShippingProfile`\>
|
||||||
|
|
||||||
Creates a default shipping profile, for gift cards if unless it already
|
|
||||||
exists.
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingProfile`\>
|
`Promise`<`ShippingProfile`\>
|
||||||
|
|
||||||
the shipping profile
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:209](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L209)
|
[services/shipping-profile.js:209](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L209)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -149,25 +122,21 @@ ___
|
|||||||
|
|
||||||
▸ **decorate**(`profile`, `fields`, `expandFields?`): `Profile`
|
▸ **decorate**(`profile`, `fields`, `expandFields?`): `Profile`
|
||||||
|
|
||||||
Decorates a profile.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `profile` | `Profile` | `undefined` | the profile to decorate. |
|
| `profile` | `Profile` | `undefined` | |
|
||||||
| `fields` | `string`[] | `undefined` | the fields to include. |
|
| `fields` | `string`[] | `undefined` | |
|
||||||
| `expandFields` | `string`[] | `[]` | fields to expand. |
|
| `expandFields` | `string`[] | `[]` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Profile`
|
`Profile`
|
||||||
|
|
||||||
return the decorated profile.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:379](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L379)
|
[services/shipping-profile.js:379](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L379)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -175,23 +144,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`profileId`): `Promise`<`any`\>
|
▸ **delete**(`profileId`): `Promise`<`any`\>
|
||||||
|
|
||||||
Deletes a profile with a given profile id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `profileId` | `string` | the id of the profile to delete. Must be castable as an ObjectId |
|
| `profileId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the delete operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:317](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L317)
|
[services/shipping-profile.js:317](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L317)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -199,24 +164,19 @@ ___
|
|||||||
|
|
||||||
▸ **fetchCartOptions**(`cart`): `Promise`<[`ShippingOption`]\>
|
▸ **fetchCartOptions**(`cart`): `Promise`<[`ShippingOption`]\>
|
||||||
|
|
||||||
Finds all the shipping profiles that cover the products in a cart, and
|
|
||||||
validates all options that are available for the cart.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cart` | `Cart` | the cart object to find shipping options for |
|
| `cart` | `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<[`ShippingOption`]\>
|
`Promise`<[`ShippingOption`]\>
|
||||||
|
|
||||||
a list of the available shipping options
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:425](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L425)
|
[services/shipping-profile.js:425](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L425)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -237,7 +197,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:73](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L73)
|
[services/shipping-profile.js:73](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L73)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -245,23 +205,19 @@ ___
|
|||||||
|
|
||||||
▸ **getProfilesInCart_**(`cart`): [`string`]
|
▸ **getProfilesInCart_**(`cart`): [`string`]
|
||||||
|
|
||||||
Returns a list of all the productIds in the cart.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cart` | `Cart` | the cart to extract products from |
|
| `cart` | `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
[`string`]
|
[`string`]
|
||||||
|
|
||||||
a list of product ids
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:406](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L406)
|
[services/shipping-profile.js:406](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L406)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -273,18 +229,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the config object for find |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:64](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L64)
|
[services/shipping-profile.js:64](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L64)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -292,25 +246,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`profileId`, `options?`): `Promise`<`Product`\>
|
▸ **retrieve**(`profileId`, `options?`): `Promise`<`Product`\>
|
||||||
|
|
||||||
Gets a profile by id.
|
|
||||||
Throws in case of DB Error and if profile was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `profileId` | `string` | the id of the profile to get. |
|
| `profileId` | `string` | |
|
||||||
| `options` | `any` | options opf the query. |
|
| `options` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Product`\>
|
`Promise`<`Product`\>
|
||||||
|
|
||||||
the profile document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:121](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L121)
|
[services/shipping-profile.js:121](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L121)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -324,7 +273,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:151](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L151)
|
[services/shipping-profile.js:151](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L151)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -332,17 +281,13 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveGiftCardDefault**(): `any`
|
▸ **retrieveGiftCardDefault**(): `any`
|
||||||
|
|
||||||
Retrieves the default gift card profile
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`any`
|
`any`
|
||||||
|
|
||||||
the shipping profile for gift cards
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:192](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L192)
|
[services/shipping-profile.js:192](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L192)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -350,26 +295,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`profileId`, `update`): `Promise`<`any`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `profileId` | `string` | the id of the profile. Must be a string that can be casted to an ObjectId |
|
| `profileId` | `string` | |
|
||||||
| `update` | `any` | an object with the update values. |
|
| `update` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:263](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L263)
|
[services/shipping-profile.js:263](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L263)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -389,4 +328,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/shipping-profile.js:41](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/shipping-profile.js#L41)
|
[services/shipping-profile.js:41](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/shipping-profile.js#L41)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: StoreService
|
# Class: StoreService
|
||||||
|
|
||||||
Provides layer to manipulate store settings.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`StoreService`](StoreService.md)\>
|
- `TransactionBaseService`<[`StoreService`](StoreService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<StoreService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:33](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L33)
|
[services/store.ts:33](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L33)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L30)
|
[services/store.ts:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:31](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L31)
|
[services/store.ts:31](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L31)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:26](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L26)
|
[services/store.ts:26](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L26)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -90,7 +88,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:29](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L29)
|
[services/store.ts:29](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L29)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -104,7 +102,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L27)
|
[services/store.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L27)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -112,23 +110,19 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ **addCurrency**(`code`): `Promise`<`Store`\>
|
▸ **addCurrency**(`code`): `Promise`<`Store`\>
|
||||||
|
|
||||||
Add a currency to the store
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `code` | `string` | 3 character ISO currency code |
|
| `code` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Store`\>
|
`Promise`<`Store`\>
|
||||||
|
|
||||||
result after update
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:219](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L219)
|
[services/store.ts:219](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L219)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -136,10 +130,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -151,23 +141,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -175,17 +163,13 @@ ___
|
|||||||
|
|
||||||
▸ **create**(): `Promise`<`Store`\>
|
▸ **create**(): `Promise`<`Store`\>
|
||||||
|
|
||||||
Creates a store if it doesn't already exist.
|
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Store`\>
|
`Promise`<`Store`\>
|
||||||
|
|
||||||
The store.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:56](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L56)
|
[services/store.ts:56](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L56)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -205,7 +189,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:113](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L113)
|
[services/store.ts:113](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L113)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -213,23 +197,19 @@ ___
|
|||||||
|
|
||||||
▸ **removeCurrency**(`code`): `Promise`<`any`\>
|
▸ **removeCurrency**(`code`): `Promise`<`any`\>
|
||||||
|
|
||||||
Removes a currency from the store
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `code` | `string` | 3 character ISO currency code |
|
| `code` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
result after update
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:263](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L263)
|
[services/store.ts:263](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L263)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -237,23 +217,19 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`config?`): `Promise`<`Store`\>
|
▸ **retrieve**(`config?`): `Promise`<`Store`\>
|
||||||
|
|
||||||
Retrieve the store settings. There is always a maximum of one store.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `config` | `FindConfig`<`Store`\> | The config object from which the query will be built |
|
| `config` | `FindConfig`<`Store`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Store`\>
|
`Promise`<`Store`\>
|
||||||
|
|
||||||
the store
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:92](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L92)
|
[services/store.ts:92](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L92)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -277,7 +253,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -285,23 +261,19 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`data`): `Promise`<`Store`\>
|
▸ **update**(`data`): `Promise`<`Store`\>
|
||||||
|
|
||||||
Updates a store
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `data` | `UpdateStoreInput` | an object with the update values. |
|
| `data` | `UpdateStoreInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Store`\>
|
`Promise`<`Store`\>
|
||||||
|
|
||||||
resolves to the update result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/store.ts:129](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/store.ts#L129)
|
[services/store.ts:129](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/store.ts#L129)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -325,4 +297,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -27,7 +27,7 @@ TransactionBaseService<
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/strategy-resolver.ts:17](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/strategy-resolver.ts#L17)
|
[services/strategy-resolver.ts:17](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/strategy-resolver.ts#L17)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/strategy-resolver.ts:14](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/strategy-resolver.ts#L14)
|
[services/strategy-resolver.ts:14](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/strategy-resolver.ts#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/strategy-resolver.ts:15](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/strategy-resolver.ts#L15)
|
[services/strategy-resolver.ts:15](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/strategy-resolver.ts#L15)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -83,10 +83,6 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -98,23 +94,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -140,7 +134,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/strategy-resolver.ts:22](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/strategy-resolver.ts#L22)
|
[services/strategy-resolver.ts:22](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/strategy-resolver.ts#L22)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -164,7 +158,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -188,4 +182,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: SwapService
|
# Class: SwapService
|
||||||
|
|
||||||
Handles swaps
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:21](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L21)
|
[services/swap.js:21](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L21)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -50,7 +48,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:9](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L9)
|
[services/swap.js:9](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L9)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -58,25 +56,19 @@ BaseService.constructor
|
|||||||
|
|
||||||
▸ **cancel**(`swapId`): `Promise`<`Swap`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `swapId` | `string` | the id of the swap to cancel. |
|
| `swapId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the canceled swap.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:790](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L790)
|
[services/swap.js:790](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L790)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -84,23 +76,19 @@ ___
|
|||||||
|
|
||||||
▸ **cancelFulfillment**(`fulfillmentId`): `Swap`
|
▸ **cancelFulfillment**(`fulfillmentId`): `Swap`
|
||||||
|
|
||||||
Cancels a fulfillment (if related to a swap)
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `fulfillmentId` | `string` | the ID of the fulfillment to cancel |
|
| `fulfillmentId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Swap`
|
`Swap`
|
||||||
|
|
||||||
updated swap
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:983](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L983)
|
[services/swap.js:983](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L983)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -108,28 +96,23 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`order`, `returnItems`, `additionalItems`, `returnShipping`, `custom?`): `Promise`<`Swap`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to base the swap off. |
|
| `order` | `Order` | |
|
||||||
| `returnItems` | `ReturnItem`[] | the items to return in the swap. |
|
| `returnItems` | `ReturnItem`[] | |
|
||||||
| `additionalItems` | `undefined` \| `PreliminaryLineItem`[] | the items to send to the customer. |
|
| `additionalItems` | `undefined` \| `PreliminaryLineItem`[] | |
|
||||||
| `returnShipping` | `any` | an optional shipping method for returning the returnItems. |
|
| `returnShipping` | `any` | |
|
||||||
| `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. |
|
| `custom` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the newly created swap.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:313](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L313)
|
[services/swap.js:313](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L313)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -137,28 +120,20 @@ ___
|
|||||||
|
|
||||||
▸ **createCart**(`swapId`, `customShippingOptions?`): `Promise`<`Swap`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `swapId` | `string` | `undefined` | the id of the swap to create the cart from |
|
| `swapId` | `string` | `undefined` | |
|
||||||
| `customShippingOptions` | `any`[] | `[]` | the shipping options |
|
| `customShippingOptions` | `any`[] | `[]` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the swap with its cart_id prop set to the id of
|
|
||||||
the new cart.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:544](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L544)
|
[services/swap.js:544](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L544)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -166,25 +141,20 @@ ___
|
|||||||
|
|
||||||
▸ **createFulfillment**(`swapId`, `config?`): `Promise`<`Swap`\>
|
▸ **createFulfillment**(`swapId`, `config?`): `Promise`<`Swap`\>
|
||||||
|
|
||||||
Fulfills the addtional items associated with the swap. Will call the
|
|
||||||
fulfillment providers associated with the shipping methods.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `swapId` | `string` | the id of the swap to fulfill, |
|
| `swapId` | `string` | |
|
||||||
| `config` | `any` | optional configurations, includes optional metadata to attach to the shipment, and a no_notification flag. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the updated swap with new status and fulfillments.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:848](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L848)
|
[services/swap.js:848](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L848)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -192,26 +162,22 @@ ___
|
|||||||
|
|
||||||
▸ **createShipment**(`swapId`, `fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`Swap`\>
|
▸ **createShipment**(`swapId`, `fulfillmentId`, `trackingLinks`, `config?`): `Promise`<`Swap`\>
|
||||||
|
|
||||||
Marks a fulfillment as shipped and attaches tracking numbers.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `swapId` | `string` | the id of the swap that has been shipped. |
|
| `swapId` | `string` | |
|
||||||
| `fulfillmentId` | `string` | the id of the specific fulfillment that has been shipped |
|
| `fulfillmentId` | `string` | |
|
||||||
| `trackingLinks` | `undefined` \| `TrackingLink`[] | the tracking numbers associated with the shipment |
|
| `trackingLinks` | `undefined` \| `TrackingLink`[] | |
|
||||||
| `config` | `any` | optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the updated swap with new fulfillments and status.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:1016](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L1016)
|
[services/swap.js:1016](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L1016)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -219,24 +185,20 @@ ___
|
|||||||
|
|
||||||
▸ **deleteMetadata**(`swapId`, `key`): `Promise`<`any`\>
|
▸ **deleteMetadata**(`swapId`, `key`): `Promise`<`any`\>
|
||||||
|
|
||||||
Dedicated method to delete metadata for a swap.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `swapId` | `string` | the order to delete metadata from. |
|
| `swapId` | `string` | |
|
||||||
| `key` | `string` | key for metadata field |
|
| `key` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
resolves to the updated result.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:1089](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L1089)
|
[services/swap.js:1089](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L1089)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -248,18 +210,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `any` | the query object for find |
|
| `selector` | `any` | |
|
||||||
| `config` | `any` | the configuration used to find the objects. contains relations, skip, and take. |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`any`\>
|
`Promise`<`any`\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:238](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L238)
|
[services/swap.js:238](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L238)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -279,7 +239,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:395](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L395)
|
[services/swap.js:395](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L395)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -291,7 +251,7 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `swapId` | `string` | The id of the swap |
|
| `swapId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -299,7 +259,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:659](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L659)
|
[services/swap.js:659](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L659)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -307,24 +267,19 @@ ___
|
|||||||
|
|
||||||
▸ **registerReceived**(`id`): `Promise`<`Order`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the order with the swap. |
|
| `id` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Order`\>
|
`Promise`<`Order`\>
|
||||||
|
|
||||||
the resulting order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:1114](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L1114)
|
[services/swap.js:1114](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L1114)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -332,24 +287,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Swap`\>
|
▸ **retrieve**(`id`, `config?`): `Promise`<`Swap`\>
|
||||||
|
|
||||||
Retrieves a swap with the given id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `id` | `string` | the id of the swap to retrieve |
|
| `id` | `string` | |
|
||||||
| `config` | `any` | the configuration to retrieve the swap |
|
| `config` | `any` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the swap
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:181](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L181)
|
[services/swap.js:181](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L181)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -357,24 +308,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByCartId**(`cartId`, `relations?`): `Promise`<`Swap`\>
|
▸ **retrieveByCartId**(`cartId`, `relations?`): `Promise`<`Swap`\>
|
||||||
|
|
||||||
Retrieves a swap based on its associated cart id
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `cartId` | `string` | `undefined` | the cart id that the swap's cart has |
|
| `cartId` | `string` | `undefined` | |
|
||||||
| `relations` | `string`[] | `[]` | the relations to retrieve swap |
|
| `relations` | `string`[] | `[]` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`Swap`\>
|
`Promise`<`Swap`\>
|
||||||
|
|
||||||
the swap
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:216](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L216)
|
[services/swap.js:216](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L216)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -394,7 +341,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:114](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L114)
|
[services/swap.js:114](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L114)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -415,7 +362,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:511](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L511)
|
[services/swap.js:511](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L511)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -423,26 +370,20 @@ ___
|
|||||||
|
|
||||||
▸ **validateReturnItems_**(`order`, `returnItems`): `ReturnItems`[]
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `OrderLike` | the order to return from |
|
| `order` | `OrderLike` | |
|
||||||
| `returnItems` | `ReturnItem`[] | the items to return |
|
| `returnItems` | `ReturnItem`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`ReturnItems`[]
|
`ReturnItems`[]
|
||||||
|
|
||||||
the validated returnItems
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:269](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L269)
|
[services/swap.js:269](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L269)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -462,4 +403,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/swap.js:86](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/swap.js#L86)
|
[services/swap.js:86](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/swap.js#L86)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:6](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L6)
|
[services/system-payment-provider.js:6](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L6)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:4](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L4)
|
[services/system-payment-provider.js:4](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L4)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:22](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L22)
|
[services/system-payment-provider.js:22](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L22)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L46)
|
[services/system-payment-provider.js:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:38](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L38)
|
[services/system-payment-provider.js:38](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L38)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:10](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L10)
|
[services/system-payment-provider.js:10](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L10)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L34)
|
[services/system-payment-provider.js:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:18](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L18)
|
[services/system-payment-provider.js:18](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L18)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:14](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L14)
|
[services/system-payment-provider.js:14](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L14)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L42)
|
[services/system-payment-provider.js:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L42)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:30](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L30)
|
[services/system-payment-provider.js:30](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L30)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -234,4 +234,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/system-payment-provider.js:26](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/system-payment-provider.js#L26)
|
[services/system-payment-provider.js:26](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/system-payment-provider.js#L26)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: TaxProviderService
|
# Class: TaxProviderService
|
||||||
|
|
||||||
Finds tax providers and assists in tax related operations.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -26,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:49](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L49)
|
[services/tax-provider.ts:49](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L49)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:40](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L40)
|
[services/tax-provider.ts:40](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L40)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:41](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L41)
|
[services/tax-provider.ts:41](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L41)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:47](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L47)
|
[services/tax-provider.ts:47](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L47)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -66,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:45](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L45)
|
[services/tax-provider.ts:45](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L45)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:44](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L44)
|
[services/tax-provider.ts:44](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L44)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:46](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L46)
|
[services/tax-provider.ts:46](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L46)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -96,7 +94,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L43)
|
[services/tax-provider.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L43)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -106,7 +104,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:42](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L42)
|
[services/tax-provider.ts:42](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L42)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -126,58 +124,49 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:103](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L103)
|
[services/tax-provider.ts:103](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L103)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### createShippingTaxLines
|
### createShippingTaxLines
|
||||||
|
|
||||||
▸ **createShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
▸ **createShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<(`LineItemTaxLine` \| `ShippingMethodTaxLine`)[]\>
|
||||||
|
|
||||||
Persists the tax lines relevant for a shipping method to the database. Used
|
|
||||||
for return shipping methods.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `shippingMethod` | `ShippingMethod` | the shipping method to create tax lines for |
|
| `shippingMethod` | `ShippingMethod` | |
|
||||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
| `calculationContext` | `TaxCalculationContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
`Promise`<(`LineItemTaxLine` \| `ShippingMethodTaxLine`)[]\>
|
||||||
|
|
||||||
the newly created tax lines
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:171](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L171)
|
[services/tax-provider.ts:171](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L171)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### createTaxLines
|
### createTaxLines
|
||||||
|
|
||||||
▸ **createTaxLines**(`cartOrLineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
▸ **createTaxLines**(`cartOrLineItems`, `calculationContext`): `Promise`<(`LineItemTaxLine` \| `ShippingMethodTaxLine`)[]\>
|
||||||
|
|
||||||
Persists the tax lines relevant for an order to the database.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrLineItems` | `Cart` \| `LineItem`[] | the cart or line items to create tax lines for |
|
| `cartOrLineItems` | `Cart` \| `LineItem`[] | |
|
||||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
| `calculationContext` | `TaxCalculationContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
`Promise`<(`LineItemTaxLine` \| `ShippingMethodTaxLine`)[]\>
|
||||||
|
|
||||||
the newly created tax lines
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:121](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L121)
|
[services/tax-provider.ts:121](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L121)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -185,24 +174,20 @@ ___
|
|||||||
|
|
||||||
▸ `Private` **getCacheEntry**(`productId`, `regionId`): `Promise`<``null`` \| `TaxServiceRate`[]\>
|
▸ `Private` **getCacheEntry**(`productId`, `regionId`): `Promise`<``null`` \| `TaxServiceRate`[]\>
|
||||||
|
|
||||||
Gets the cache results for a set of ids
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product id to cache |
|
| `productId` | `string` | |
|
||||||
| `regionId` | `string` | the region id to cache |
|
| `regionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<``null`` \| `TaxServiceRate`[]\>
|
`Promise`<``null`` \| `TaxServiceRate`[]\>
|
||||||
|
|
||||||
the cached result or null
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:454](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L454)
|
[services/tax-provider.ts:454](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L454)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -210,24 +195,20 @@ ___
|
|||||||
|
|
||||||
▸ `Private` **getCacheKey**(`productId`, `regionId`): `string`
|
▸ `Private` **getCacheKey**(`productId`, `regionId`): `string`
|
||||||
|
|
||||||
The cache key to get cache hits by.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product id to cache |
|
| `productId` | `string` | |
|
||||||
| `regionId` | `string` | the region id to cache |
|
| `regionId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
the cache key to use for the id set
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:423](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L423)
|
[services/tax-provider.ts:423](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L423)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -235,25 +216,20 @@ ___
|
|||||||
|
|
||||||
▸ **getRegionRatesForProduct**(`productId`, `region`): `Promise`<`TaxServiceRate`[]\>
|
▸ **getRegionRatesForProduct**(`productId`, `region`): `Promise`<`TaxServiceRate`[]\>
|
||||||
|
|
||||||
Gets the tax rates configured for a product. The rates are cached between
|
|
||||||
calls.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product id to get rates for |
|
| `productId` | `string` | |
|
||||||
| `region` | `RegionDetails` | the region to get configured rates for. |
|
| `region` | `RegionDetails` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TaxServiceRate`[]\>
|
`Promise`<`TaxServiceRate`[]\>
|
||||||
|
|
||||||
the tax rates configured for the shipping option.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:378](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L378)
|
[services/tax-provider.ts:378](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L378)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -261,25 +237,20 @@ ___
|
|||||||
|
|
||||||
▸ **getRegionRatesForShipping**(`optionId`, `regionDetails`): `Promise`<`TaxServiceRate`[]\>
|
▸ **getRegionRatesForShipping**(`optionId`, `regionDetails`): `Promise`<`TaxServiceRate`[]\>
|
||||||
|
|
||||||
Gets the tax rates configured for a shipping option. The rates are cached
|
|
||||||
between calls.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `optionId` | `string` | the option id of the shipping method. |
|
| `optionId` | `string` | |
|
||||||
| `regionDetails` | `RegionDetails` | the region to get configured rates for. |
|
| `regionDetails` | `RegionDetails` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TaxServiceRate`[]\>
|
`Promise`<`TaxServiceRate`[]\>
|
||||||
|
|
||||||
the tax rates configured for the shipping option.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:332](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L332)
|
[services/tax-provider.ts:332](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L332)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -287,55 +258,41 @@ ___
|
|||||||
|
|
||||||
▸ **getShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<`ShippingMethodTaxLine`[]\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `shippingMethod` | `ShippingMethod` | the shipping method to get tax lines for |
|
| `shippingMethod` | `ShippingMethod` | |
|
||||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
| `calculationContext` | `TaxCalculationContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingMethodTaxLine`[]\>
|
`Promise`<`ShippingMethodTaxLine`[]\>
|
||||||
|
|
||||||
the computed tax lines
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:190](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L190)
|
[services/tax-provider.ts:190](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L190)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### getTaxLines
|
### getTaxLines
|
||||||
|
|
||||||
▸ **getTaxLines**(`lineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
▸ **getTaxLines**(`lineItems`, `calculationContext`): `Promise`<(`LineItemTaxLine` \| `ShippingMethodTaxLine`)[]\>
|
||||||
|
|
||||||
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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `lineItems` | `LineItem`[] | the cart or order to get tax lines for |
|
| `lineItems` | `LineItem`[] | |
|
||||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
| `calculationContext` | `TaxCalculationContext` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
`Promise`<(`LineItemTaxLine` \| `ShippingMethodTaxLine`)[]\>
|
||||||
|
|
||||||
the computed tax lines
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:242](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L242)
|
[services/tax-provider.ts:242](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L242)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -349,7 +306,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:75](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L75)
|
[services/tax-provider.ts:75](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L75)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -369,7 +326,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:475](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L475)
|
[services/tax-provider.ts:475](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L475)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -377,23 +334,19 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveProvider**(`region`): `ITaxService`
|
▸ **retrieveProvider**(`region`): `ITaxService`
|
||||||
|
|
||||||
Retrieves the relevant tax provider for the given region.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `region` | `Region` | the region to get tax provider for. |
|
| `region` | `Region` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`ITaxService`
|
`ITaxService`
|
||||||
|
|
||||||
the region specific tax provider
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:85](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L85)
|
[services/tax-provider.ts:85](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L85)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -401,25 +354,21 @@ ___
|
|||||||
|
|
||||||
▸ `Private` **setCache**(`productId`, `regionId`, `value`): `Promise`<`void`\>
|
▸ `Private` **setCache**(`productId`, `regionId`, `value`): `Promise`<`void`\>
|
||||||
|
|
||||||
Sets the cache results for a set of ids
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `productId` | `string` | the product id to cache |
|
| `productId` | `string` | |
|
||||||
| `regionId` | `string` | the region id to cache |
|
| `regionId` | `string` | |
|
||||||
| `value` | `TaxServiceRate`[] | tax rates to cache |
|
| `value` | `TaxServiceRate`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
promise that resolves after the cache has been set
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:434](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L434)
|
[services/tax-provider.ts:434](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L434)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -439,4 +388,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-provider.ts:62](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-provider.ts#L62)
|
[services/tax-provider.ts:62](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-provider.ts#L62)
|
||||||
@@ -24,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:27](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L27)
|
[services/tax-rate.ts:27](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L27)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:21](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L21)
|
[services/tax-rate.ts:21](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L21)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:22](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L22)
|
[services/tax-rate.ts:22](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L22)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:23](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L23)
|
[services/tax-rate.ts:23](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L23)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:24](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L24)
|
[services/tax-rate.ts:24](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L24)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:25](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L25)
|
[services/tax-rate.ts:25](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L25)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:197](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L197)
|
[services/tax-rate.ts:197](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L197)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:233](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L233)
|
[services/tax-rate.ts:233](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L233)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:273](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L273)
|
[services/tax-rate.ts:273](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L273)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:104](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L104)
|
[services/tax-rate.ts:104](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L104)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:135](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L135)
|
[services/tax-rate.ts:135](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L135)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:62](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L62)
|
[services/tax-rate.ts:62](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L62)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:73](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L73)
|
[services/tax-rate.ts:73](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L73)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:321](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L321)
|
[services/tax-rate.ts:321](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L321)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:332](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L332)
|
[services/tax-rate.ts:332](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L332)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:143](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L143)
|
[services/tax-rate.ts:143](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L143)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:161](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L161)
|
[services/tax-rate.ts:161](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L161)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:179](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L179)
|
[services/tax-rate.ts:179](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L179)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:84](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L84)
|
[services/tax-rate.ts:84](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L84)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:120](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L120)
|
[services/tax-rate.ts:120](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L120)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -388,4 +388,4 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/tax-rate.ts:43](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/tax-rate.ts#L43)
|
[services/tax-rate.ts:43](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/tax-rate.ts#L43)
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
# Class: TotalsService
|
# Class: TotalsService
|
||||||
|
|
||||||
A service that calculates total and subtotals for orders, carts etc..
|
|
||||||
|
|
||||||
**`implements`** {BaseService}
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `"medusa-interfaces"`
|
- `"medusa-interfaces"`
|
||||||
@@ -28,7 +24,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:90](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L90)
|
[services/totals.ts:90](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L90)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -38,7 +34,7 @@ BaseService.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:88](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L88)
|
[services/totals.ts:88](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L88)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -48,7 +44,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:87](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L87)
|
[services/totals.ts:87](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L87)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -56,27 +52,23 @@ ___
|
|||||||
|
|
||||||
▸ **calculateDiscount_**(`lineItem`, `variant`, `variantPrice`, `value`, `discountType`): `LineDiscount`
|
▸ **calculateDiscount_**(`lineItem`, `variant`, `variantPrice`, `value`, `discountType`): `LineDiscount`
|
||||||
|
|
||||||
Calculates either fixed or percentage discount of a variant
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `lineItem` | `LineItem` | id of line item |
|
| `lineItem` | `LineItem` | |
|
||||||
| `variant` | `string` | id of variant in line item |
|
| `variant` | `string` | |
|
||||||
| `variantPrice` | `number` | price of the variant based on region |
|
| `variantPrice` | `number` | |
|
||||||
| `value` | `number` | discount value |
|
| `value` | `number` | |
|
||||||
| `discountType` | `DiscountRuleType` | the type of discount (fixed or percentage) |
|
| `discountType` | `DiscountRuleType` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`LineDiscount`
|
`LineDiscount`
|
||||||
|
|
||||||
triples of lineitem, variant and applied discount
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:545](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L545)
|
[services/totals.ts:553](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L553)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -84,28 +76,20 @@ ___
|
|||||||
|
|
||||||
▸ **getAllocationItemDiscounts**(`discount`, `cart`): `LineDiscount`[]
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `discount` | `Discount` | the discount to which we do the calculation |
|
| `discount` | `Discount` | |
|
||||||
| `cart` | `Cart` \| `Order` | the cart to calculate discounts for |
|
| `cart` | `Order` \| `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`LineDiscount`[]
|
`LineDiscount`[]
|
||||||
|
|
||||||
array of triples of lineitem, variant and applied discount
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:587](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L587)
|
[services/totals.ts:595](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L595)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -113,26 +97,20 @@ ___
|
|||||||
|
|
||||||
▸ **getAllocationMap**(`orderOrCart`, `options?`): `LineAllocationsMap`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `orderOrCart` | `Cart` \| `Order` | the order or cart to get an allocation map for |
|
| `orderOrCart` | `Order` \| `Cart` | |
|
||||||
| `options` | `AllocationMapOptions` | controls what should be included in allocation map |
|
| `options` | `AllocationMapOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`LineAllocationsMap`
|
`LineAllocationsMap`
|
||||||
|
|
||||||
the allocation map for the line items in the cart or order.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:368](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L368)
|
[services/totals.ts:376](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L376)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -140,24 +118,20 @@ ___
|
|||||||
|
|
||||||
▸ **getCalculationContext**(`cartOrOrder`, `options?`): `TaxCalculationContext`
|
▸ **getCalculationContext**(`cartOrOrder`, `options?`): `TaxCalculationContext`
|
||||||
|
|
||||||
Prepares the calculation context for a tax total calculation.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get the calculation context for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `options` | `CalculationContextOptions` | options to gather context by |
|
| `options` | `CalculationContextOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`TaxCalculationContext`
|
`TaxCalculationContext`
|
||||||
|
|
||||||
the tax calculation context
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:891](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L891)
|
[services/totals.ts:959](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L959)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -165,48 +139,64 @@ ___
|
|||||||
|
|
||||||
▸ **getDiscountTotal**(`cartOrOrder`): `number`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to calculate discounts for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the total discounts amount
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:857](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L857)
|
[services/totals.ts:925](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L925)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
### getGiftCardTotal
|
### getGiftCardTotal
|
||||||
|
|
||||||
▸ **getGiftCardTotal**(`cartOrOrder`): `number`
|
▸ **getGiftCardTotal**(`cartOrOrder`): `Object`
|
||||||
|
|
||||||
Gets the gift card amount on a cart or order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get gift card amount for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`Object`
|
||||||
|
|
||||||
the gift card amount applied to the cart or order
|
| Name | Type |
|
||||||
|
| :------ | :------ |
|
||||||
|
| `tax_total` | `number` |
|
||||||
|
| `total` | `number` |
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:829](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L829)
|
[services/totals.ts:853](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L853)
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
### getGiftCardableAmount
|
||||||
|
|
||||||
|
▸ **getGiftCardableAmount**(`cartOrOrder`): `Promise`<`number`\>
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| :------ | :------ | :------ |
|
||||||
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`<`number`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[services/totals.ts:838](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L838)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -214,25 +204,20 @@ ___
|
|||||||
|
|
||||||
▸ **getLineDiscounts**(`cartOrOrder`, `discount`): `LineDiscountAmount`[]
|
▸ **getLineDiscounts**(`cartOrOrder`, `discount`): `LineDiscountAmount`[]
|
||||||
|
|
||||||
Returns the discount amount allocated to the line items of an order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to get line discount allocations for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `discount` | `Discount` | the discount to use as context for the calculation |
|
| `discount` | `Discount` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`LineDiscountAmount`[]
|
`LineDiscountAmount`[]
|
||||||
|
|
||||||
the allocations that the discount has on the items in the cart or
|
|
||||||
order
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:638](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L638)
|
[services/totals.ts:646](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L646)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -244,7 +229,7 @@ ___
|
|||||||
|
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
| :------ | :------ |
|
| :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` |
|
| `cartOrOrder` | `Order` \| `Cart` |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@@ -252,7 +237,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:615](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L615)
|
[services/totals.ts:623](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L623)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -273,7 +258,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:600](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L600)
|
[services/totals.ts:608](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L608)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -281,24 +266,20 @@ ___
|
|||||||
|
|
||||||
▸ **getLineItemRefund**(`order`, `lineItem`): `number`
|
▸ **getLineItemRefund**(`order`, `lineItem`): `number`
|
||||||
|
|
||||||
The amount that can be refunded for a given line item.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | order to use as context for the calculation |
|
| `order` | `Order` | |
|
||||||
| `lineItem` | `LineItem` | the line item to calculate the refund amount for. |
|
| `lineItem` | `LineItem` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the line item refund amount.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:460](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L460)
|
[services/totals.ts:468](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L468)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -306,26 +287,21 @@ ___
|
|||||||
|
|
||||||
▸ **getLineItemTotal**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`number`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `lineItem` | `LineItem` | the line item to calculate a total for |
|
| `lineItem` | `LineItem` | |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the calculation |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `options` | `GetLineItemTotalOptions` | the options to use for the calculation |
|
| `options` | `GetLineItemTotalOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`number`\>
|
`Promise`<`number`\>
|
||||||
|
|
||||||
the line item total
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:799](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L799)
|
[services/totals.ts:807](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L807)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -333,27 +309,21 @@ ___
|
|||||||
|
|
||||||
▸ **getLineItemTotals**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`LineItemTotals`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `lineItem` | `LineItem` | the line item to calculate totals for |
|
| `lineItem` | `LineItem` | |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the calculation |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `options` | `LineItemTotalsOptions` | the options to evaluate the line item totals for |
|
| `options` | `LineItemTotalsOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`LineItemTotals`\>
|
`Promise`<`LineItemTotals`\>
|
||||||
|
|
||||||
the breakdown of the line item totals
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:684](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L684)
|
[services/totals.ts:692](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L692)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -361,23 +331,19 @@ ___
|
|||||||
|
|
||||||
▸ **getPaidTotal**(`order`): `number`
|
▸ **getPaidTotal**(`order`): `number`
|
||||||
|
|
||||||
Gets the total payments made on an order
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to calculate paid amount for |
|
| `order` | `Order` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the total paid amount
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:125](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L125)
|
[services/totals.ts:129](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L129)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -385,26 +351,20 @@ ___
|
|||||||
|
|
||||||
▸ **getRefundTotal**(`order`, `lineItems`): `number`
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | cart or order to calculate subtotal for |
|
| `order` | `Order` | |
|
||||||
| `lineItems` | `LineItem`[] | the line items to calculate refund total for |
|
| `lineItems` | `LineItem`[] | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the calculated subtotal
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:504](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L504)
|
[services/totals.ts:512](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L512)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -412,23 +372,19 @@ ___
|
|||||||
|
|
||||||
▸ **getRefundedTotal**(`order`): `number`
|
▸ **getRefundedTotal**(`order`): `number`
|
||||||
|
|
||||||
Gets the total refund amount for an order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to get total refund amount for. |
|
| `order` | `Order` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the total refunded amount for an order.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:445](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L445)
|
[services/totals.ts:453](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L453)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -436,26 +392,21 @@ ___
|
|||||||
|
|
||||||
▸ **getShippingMethodTotals**(`shippingMethod`, `cartOrOrder`, `opts?`): `Promise`<`ShippingMethodTotals`\>
|
▸ **getShippingMethodTotals**(`shippingMethod`, `cartOrOrder`, `opts?`): `Promise`<`ShippingMethodTotals`\>
|
||||||
|
|
||||||
Gets the totals breakdown for a shipping method. Fetches tax lines if not
|
|
||||||
already provided.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `shippingMethod` | `ShippingMethod` | the shipping method to get totals breakdown for. |
|
| `shippingMethod` | `ShippingMethod` | |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | the cart or order to use as context for the breakdown |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `opts` | `GetShippingMethodTotalsOptions` | options for what should be included |
|
| `opts` | `GetShippingMethodTotalsOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`ShippingMethodTotals`\>
|
`Promise`<`ShippingMethodTotals`\>
|
||||||
|
|
||||||
An object that breaks down the totals for the shipping method
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:159](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L159)
|
[services/totals.ts:163](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L163)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -463,23 +414,19 @@ ___
|
|||||||
|
|
||||||
▸ **getShippingTotal**(`cartOrOrder`): `number`
|
▸ **getShippingTotal**(`cartOrOrder`): `number`
|
||||||
|
|
||||||
Calculates shipping total
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | cart or order to calculate subtotal for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
shipping total
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:267](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L267)
|
[services/totals.ts:271](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L271)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -487,24 +434,20 @@ ___
|
|||||||
|
|
||||||
▸ **getSubtotal**(`cartOrOrder`, `opts?`): `number`
|
▸ **getSubtotal**(`cartOrOrder`, `opts?`): `number`
|
||||||
|
|
||||||
Calculates subtotal of a given cart or order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | cart or order to calculate subtotal for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `opts` | `SubtotalOptions` | options |
|
| `opts` | `SubtotalOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the calculated subtotal
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:243](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L243)
|
[services/totals.ts:247](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L247)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -512,24 +455,19 @@ ___
|
|||||||
|
|
||||||
▸ **getSwapTotal**(`order`): `number`
|
▸ **getSwapTotal**(`order`): `number`
|
||||||
|
|
||||||
The total paid for swaps. May be negative in case of negative swap
|
|
||||||
difference.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `order` | `Order` | the order to calculate swap total for |
|
| `order` | `Order` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the swap total
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:140](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L140)
|
[services/totals.ts:144](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L144)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -537,25 +475,20 @@ ___
|
|||||||
|
|
||||||
▸ **getTaxTotal**(`cartOrOrder`, `forceTaxes?`): `Promise`<``null`` \| `number`\>
|
▸ **getTaxTotal**(`cartOrOrder`, `forceTaxes?`): `Promise`<``null`` \| `number`\>
|
||||||
|
|
||||||
Calculates tax total
|
|
||||||
Currently based on the Danish tax system
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | `undefined` | cart or order to calculate tax total for |
|
| `cartOrOrder` | `Order` \| `Cart` | `undefined` | |
|
||||||
| `forceTaxes` | `boolean` | `false` | whether taxes should be calculated regardless of region settings |
|
| `forceTaxes` | `boolean` | `false` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<``null`` \| `number`\>
|
`Promise`<``null`` \| `number`\>
|
||||||
|
|
||||||
tax total
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:282](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L282)
|
[services/totals.ts:286](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L286)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -563,24 +496,20 @@ ___
|
|||||||
|
|
||||||
▸ **getTotal**(`cartOrOrder`, `options?`): `Promise`<`number`\>
|
▸ **getTotal**(`cartOrOrder`, `options?`): `Promise`<`number`\>
|
||||||
|
|
||||||
Calculates subtotal of a given cart or order.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `cartOrOrder` | `Cart` \| `Order` | object to calculate total for |
|
| `cartOrOrder` | `Order` \| `Cart` | |
|
||||||
| `options` | `GetTotalsOptions` | options to calculate by |
|
| `options` | `GetTotalsOptions` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`number`\>
|
`Promise`<`number`\>
|
||||||
|
|
||||||
the calculated subtotal
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:106](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L106)
|
[services/totals.ts:106](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L106)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -588,20 +517,16 @@ ___
|
|||||||
|
|
||||||
▸ **rounded**(`value`): `number`
|
▸ **rounded**(`value`): `number`
|
||||||
|
|
||||||
Rounds a number using Math.round.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `value` | `number` | the value to round |
|
| `value` | `number` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`number`
|
`number`
|
||||||
|
|
||||||
the rounded value
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/totals.ts:921](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/totals.ts#L921)
|
[services/totals.ts:989](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/totals.ts#L989)
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Class: UserService
|
# Class: UserService
|
||||||
|
|
||||||
Provides layer to manipulate users.
|
|
||||||
|
|
||||||
## Hierarchy
|
## Hierarchy
|
||||||
|
|
||||||
- `TransactionBaseService`<[`UserService`](UserService.md)\>
|
- `TransactionBaseService`<[`UserService`](UserService.md)\>
|
||||||
@@ -26,7 +24,7 @@ TransactionBaseService<UserService\>.constructor
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:37](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L37)
|
[services/user.ts:37](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L37)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:35](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L35)
|
[services/user.ts:35](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L35)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ TransactionBaseService.manager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:32](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L32)
|
[services/user.ts:32](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L32)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -84,7 +82,7 @@ TransactionBaseService.transactionManager\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:33](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L33)
|
[services/user.ts:33](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L33)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -94,7 +92,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L34)
|
[services/user.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -110,7 +108,7 @@ ___
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:28](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L28)
|
[services/user.ts:28](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L28)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@@ -118,10 +116,6 @@ ___
|
|||||||
|
|
||||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
▸ `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
|
#### Type parameters
|
||||||
|
|
||||||
| Name |
|
| Name |
|
||||||
@@ -133,23 +127,21 @@ transaction manager is created.
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | |
|
||||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`TResult`\>
|
`Promise`<`TResult`\>
|
||||||
|
|
||||||
the result of the transactional work
|
|
||||||
|
|
||||||
#### Inherited from
|
#### Inherited from
|
||||||
|
|
||||||
TransactionBaseService.atomicPhase\_
|
TransactionBaseService.atomicPhase\_
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
[interfaces/transaction-base-service.ts:53](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L53)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -157,25 +149,20 @@ ___
|
|||||||
|
|
||||||
▸ **create**(`user`, `password`): `Promise`<`User`\>
|
▸ **create**(`user`, `password`): `Promise`<`User`\>
|
||||||
|
|
||||||
Creates a user with username being validated.
|
|
||||||
Fails if email is not a valid format.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `user` | `CreateUserInput` | the user to create |
|
| `user` | `CreateUserInput` | |
|
||||||
| `password` | `string` | user's password to hash |
|
| `password` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`\>
|
`Promise`<`User`\>
|
||||||
|
|
||||||
the result of create
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:183](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L183)
|
[services/user.ts:183](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L183)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -183,23 +170,19 @@ ___
|
|||||||
|
|
||||||
▸ **delete**(`userId`): `Promise`<`void`\>
|
▸ **delete**(`userId`): `Promise`<`void`\>
|
||||||
|
|
||||||
Deletes a user from a given user id.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `userId` | `string` | the id of the user to delete. Must be castable as an ObjectId |
|
| `userId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`void`\>
|
`Promise`<`void`\>
|
||||||
|
|
||||||
the result of the delete operation.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:251](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L251)
|
[services/user.ts:251](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L251)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -207,27 +190,19 @@ ___
|
|||||||
|
|
||||||
▸ **generateResetPasswordToken**(`userId`): `Promise`<`string`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `userId` | `string` | the id of the user to reset password for |
|
| `userId` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`string`\>
|
`Promise`<`string`\>
|
||||||
|
|
||||||
the generated JSON web token
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:305](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L305)
|
[services/user.ts:305](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L305)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -235,23 +210,19 @@ ___
|
|||||||
|
|
||||||
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
||||||
|
|
||||||
Hashes a password
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `password` | `string` | the value to hash |
|
| `password` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`string`\>
|
`Promise`<`string`\>
|
||||||
|
|
||||||
hashed password
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:171](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L171)
|
[services/user.ts:171](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L171)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -263,18 +234,16 @@ ___
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `selector` | `FilterableUserProps` | the query object for find |
|
| `selector` | `FilterableUserProps` | |
|
||||||
| `config` | `Object` | the configuration object for the query |
|
| `config` | `Object` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`[]\>
|
`Promise`<`User`[]\>
|
||||||
|
|
||||||
the result of the find operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:68](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L68)
|
[services/user.ts:68](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L68)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -282,25 +251,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieve**(`userId`, `config?`): `Promise`<`User`\>
|
▸ **retrieve**(`userId`, `config?`): `Promise`<`User`\>
|
||||||
|
|
||||||
Gets a user by id.
|
|
||||||
Throws in case of DB Error and if user was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `userId` | `string` | the id of the user to get. |
|
| `userId` | `string` | |
|
||||||
| `config` | `FindConfig`<`User`\> | query configs |
|
| `config` | `FindConfig`<`User`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`\>
|
`Promise`<`User`\>
|
||||||
|
|
||||||
the user document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:84](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L84)
|
[services/user.ts:84](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L84)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -308,25 +272,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByApiToken**(`apiToken`, `relations?`): `Promise`<`User`\>
|
▸ **retrieveByApiToken**(`apiToken`, `relations?`): `Promise`<`User`\>
|
||||||
|
|
||||||
Gets a user by api token.
|
|
||||||
Throws in case of DB Error and if user was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| :------ | :------ | :------ | :------ |
|
| :------ | :------ | :------ | :------ |
|
||||||
| `apiToken` | `string` | `undefined` | the token of the user to get. |
|
| `apiToken` | `string` | `undefined` | |
|
||||||
| `relations` | `string`[] | `[]` | relations to include with the user |
|
| `relations` | `string`[] | `[]` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`\>
|
`Promise`<`User`\>
|
||||||
|
|
||||||
the user document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:111](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L111)
|
[services/user.ts:111](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L111)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -334,25 +293,20 @@ ___
|
|||||||
|
|
||||||
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`User`\>
|
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`User`\>
|
||||||
|
|
||||||
Gets a user by email.
|
|
||||||
Throws in case of DB Error and if user was not found.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `email` | `string` | the email of the user to get. |
|
| `email` | `string` | |
|
||||||
| `config` | `FindConfig`<`User`\> | query config |
|
| `config` | `FindConfig`<`User`\> | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`\>
|
`Promise`<`User`\>
|
||||||
|
|
||||||
the user document.
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:143](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L143)
|
[services/user.ts:143](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L143)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -360,26 +314,20 @@ ___
|
|||||||
|
|
||||||
▸ **setPassword_**(`userId`, `password`): `Promise`<`User`\>
|
▸ **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
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `userId` | `string` | the userId to set password for |
|
| `userId` | `string` | |
|
||||||
| `password` | `string` | the old password to set |
|
| `password` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`\>
|
`Promise`<`User`\>
|
||||||
|
|
||||||
the result of the update operation
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:276](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L276)
|
[services/user.ts:276](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L276)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -403,7 +351,7 @@ TransactionBaseService.shouldRetryTransaction\_
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
[interfaces/transaction-base-service.ts:34](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L34)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -411,24 +359,20 @@ ___
|
|||||||
|
|
||||||
▸ **update**(`userId`, `update`): `Promise`<`User`\>
|
▸ **update**(`userId`, `update`): `Promise`<`User`\>
|
||||||
|
|
||||||
Updates a user.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `userId` | `string` | id of the user to update |
|
| `userId` | `string` | |
|
||||||
| `update` | `UpdateUserInput` | the values to be updated on the user |
|
| `update` | `UpdateUserInput` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`Promise`<`User`\>
|
`Promise`<`User`\>
|
||||||
|
|
||||||
the result of create
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:211](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L211)
|
[services/user.ts:211](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L211)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -436,23 +380,19 @@ ___
|
|||||||
|
|
||||||
▸ **validateEmail_**(`email`): `string`
|
▸ **validateEmail_**(`email`): `string`
|
||||||
|
|
||||||
Used to validate user email.
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :------ | :------ | :------ |
|
| :------ | :------ | :------ |
|
||||||
| `email` | `string` | email to validate |
|
| `email` | `string` | |
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
`string`
|
`string`
|
||||||
|
|
||||||
the validated email
|
|
||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[services/user.ts:50](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/services/user.ts#L50)
|
[services/user.ts:50](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/services/user.ts#L50)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -476,4 +416,4 @@ TransactionBaseService.withTransaction
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/ae5c88b89/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
[interfaces/transaction-base-service.ts:16](https://github.com/medusajs/medusa/blob/32b066d92/packages/medusa/src/interfaces/transaction-base-service.ts#L16)
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
- [RegionService](classes/RegionService.md)
|
- [RegionService](classes/RegionService.md)
|
||||||
- [ReturnReasonService](classes/ReturnReasonService.md)
|
- [ReturnReasonService](classes/ReturnReasonService.md)
|
||||||
- [ReturnService](classes/ReturnService.md)
|
- [ReturnService](classes/ReturnService.md)
|
||||||
|
- [SalesChannelService](classes/SalesChannelService.md)
|
||||||
- [SearchService](classes/SearchService.md)
|
- [SearchService](classes/SearchService.md)
|
||||||
- [ShippingOptionService](classes/ShippingOptionService.md)
|
- [ShippingOptionService](classes/ShippingOptionService.md)
|
||||||
- [ShippingProfileService](classes/ShippingProfileService.md)
|
- [ShippingProfileService](classes/ShippingProfileService.md)
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
This document guides you to install and set up the Next.js Storefront for your Medusa Server.
|
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!
|
## Instant Deployment to Netlify
|
||||||
|
|
||||||
:::
|
Instead of manually following this guide to install then later deploy the Next.js Storefront, you can deploy the Next.js Storefront to Netlify with this button:
|
||||||
|
|
||||||

|
[](https://app.netlify.com/start/deploy?repository=https://github.com/medusajs/nextjs-starter-medusa)
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -16,21 +16,21 @@ This document assumes you already have a Medusa server installed. If you don’t
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1\. Create a new Next.js project using the [Medusa starter template](https://github.com/medusajs/nextjs-starter-medusa):
|
1. Create a new Next.js project using the [Medusa starter template](https://github.com/medusajs/nextjs-starter-medusa):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx create-next-app -e https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront
|
npx create-next-app -e https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront
|
||||||
```
|
```
|
||||||
|
|
||||||
2\. Change to the newly created directory `my-medusa-storefront` and rename the template environment variable file to use environment variables in development:
|
1. Change to the newly created directory `my-medusa-storefront` and rename the template environment variable file to use environment variables in development:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mv .env.template .env.local
|
mv .env.template .env.local
|
||||||
```
|
```
|
||||||
|
|
||||||
3\. Make sure the Medusa server is running, then run the local Next.js server:
|
1. Make sure the Medusa server is running, then run the local Next.js server:
|
||||||
|
|
||||||
```bash npm2yarn
|
```bash
|
||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -38,13 +38,139 @@ Your Next.js storefront is now running at `localhost:8000`!
|
|||||||
|
|
||||||
## Development Notes
|
## Development Notes
|
||||||
|
|
||||||
|
### Toggle Search Engine Feature
|
||||||
|
|
||||||
|
The Next.js storefront by default is compatible with MeiliSearch.
|
||||||
|
|
||||||
|
To enable or disable the search engine, change the value of the feature in `store.config.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"features": {
|
||||||
|
"search": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, restart your Next.js server. Depending on whether you enabled or disabled the search engine, the search bar will appear or disappear in the navigation bar accordingly.
|
||||||
|
|
||||||
|
### MeiliSearch Integration
|
||||||
|
|
||||||
|
If you have the search engine feature enabled, it is expected that you have installed the MeiliSearch plugin on your Medusa server. If not, [follow this guide to install it](../add-plugins/meilisearch.md).
|
||||||
|
|
||||||
|
In your Next.js storefront, set the environment variables necessary for the MeiliSearch integration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
NEXT_PUBLIC_SEARCH_ENDPOINT=<YOUR_MEILISEARCH_URL>
|
||||||
|
NEXT_PUBLIC_SEARCH_API_KEY=<YOUR_API_KEY>
|
||||||
|
NEXT_PUBLIC_SEARCH_INDEX_NAME=products
|
||||||
|
```
|
||||||
|
|
||||||
|
`<YOUR_MEILISEARCH_URL>` is the URL MeiliSearch is running on. The default is `http://127.0.0.1:7700`.
|
||||||
|
|
||||||
|
`NEXT_PUBLIC_SEARCH_INDEX_NAME` is the index name of the products in MeiliSearch. By default, it’s `products`.
|
||||||
|
|
||||||
|
`<YOUR_API_KEY>` is the API key used to search through MeiliSearch indexes. To create a new API Key, make sure that the MeiliSearch service is running and send the following request:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl \
|
||||||
|
-X POST '<MEILISEARCH_URL>/keys' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-H 'Authorization: Bearer <MEILISEARCH_MASTER_KEY>' \
|
||||||
|
--data-binary '{
|
||||||
|
"description": "Search products",
|
||||||
|
"actions": ["search"],
|
||||||
|
"indexes": ["products"],
|
||||||
|
"expiresAt": "2024-01-01T00:00:00Z"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `<MEILISEARCH_URL>` with the URL MeiliSearch is running on and `<MEILISEARCH_MASTER_KEY>` with your MeiliSearch [master key](https://docs.meilisearch.com/learn/security/master_api_keys.html#protecting-a-meilisearch-instance).
|
||||||
|
|
||||||
|
Then, restart the Next.js server. You’ll be able to search through available products by clicking the search icon in the navigation bar.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
To make sure the Next.js storefront properly displays the products in the search result, include in the `displayedAttributes` setting of the MeiliSearch plugin on the Medusa server at least the fields `title`, `handle`, `description`, and `thumbnail`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Algolia Integration
|
||||||
|
|
||||||
|
Instead of using the default MeiliSearch search engine, you can switch to using Algolia. Make sure you start by installing the Algolia plugin on your Medusa server. You can do it by [following this guide](../add-plugins/algolia.md).
|
||||||
|
|
||||||
|
In your Next.js storefront, set the environment variables necessary for the Algolia integration:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NEXT_PUBLIC_SEARCH_APP_ID=<YOUR_APP_ID>
|
||||||
|
NEXT_PUBLIC_SEARCH_API_KEY=<YOUR_SEARCH_API_KEY>
|
||||||
|
NEXT_PUBLIC_SEARCH_INDEX_NAME=products
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_APP_ID>` and `<YOUR_SEARCH_API_KEY>` are the Algolia App ID and Algolia Search API Key respectively. You can retrieve them from Algolia by going to [API Keys](https://www.algolia.com/account/api-keys/all) in your account settings.
|
||||||
|
|
||||||
|
`NEXT_PUBLIC_SEARCH_INDEX_NAME` is the index name of the products in Algolia. By default, it’s `products`.
|
||||||
|
|
||||||
|
Next, change the content of `src/lib/search-client.ts` to the following:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
import algoliasearch from "algoliasearch/lite"
|
||||||
|
|
||||||
|
const appId = process.env.NEXT_PUBLIC_SEARCH_APP_ID || "" // You should add this to your environment variables
|
||||||
|
|
||||||
|
const apiKey = process.env.NEXT_PUBLIC_SEARCH_API_KEY || "test_key"
|
||||||
|
|
||||||
|
export const searchClient = algoliasearch(appId, apiKey)
|
||||||
|
|
||||||
|
export const SEARCH_INDEX_NAME =
|
||||||
|
process.env.NEXT_PUBLIC_INDEX_NAME || "products"
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, restart the Next.js server. You’ll be able to search through available products by clicking the search icon in the navigation bar.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Stripe Payment Integration
|
||||||
|
|
||||||
|
Stripe integration is supported by default. Make sure you have Stripe installed and enabled on your Medusa server first. You can [follow this guide to learn how to install it](../add-plugins/stripe.md).
|
||||||
|
|
||||||
|
Then, in your Next.js storefront, set the environment variable necessary for the Stripe integration:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NEXT_PUBLIC_STRIPE_KEY=<YOUR_PUBLISHABLE_KEY>
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `<YOUR_PUBLISHABLE_KEY>` with your Stripe publishable key. It can be retrieved from your [Stripe dashboard](https://dashboard.stripe.com/) by going to Developers → API Keys.
|
||||||
|
|
||||||
|
If you restart your Next.js server you should be able to pay with Stripe on checkout.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### PayPal Payment Integration
|
||||||
|
|
||||||
|
PayPal integration is supported by default. Make sure you have PayPal installed and enabled on your Medusa server first. You can [follow this guide to learn how to install it](../add-plugins/paypal.md).
|
||||||
|
|
||||||
|
Then, in your Next.js storefront, set the environment variable necessary for the PayPal integration:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NEXT_PUBLIC_PAYPAL_CLIENT_ID=<YOUR_CLIENT_ID>
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `<YOUR_CLIENT_ID>` with your PayPal client ID. You can retrieve it from the [PayPal developer dashboard](https://developer.paypal.com/developer/applications/).
|
||||||
|
|
||||||
|
If you restart your Next.js server you should be able to pay with PayPal on checkout.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Customization
|
### Customization
|
||||||
|
|
||||||
To customize the pages of the storefront, you can customize the files under the `pages` directory.
|
To customize the pages of the storefront, you can customize the files under the `src/pages` directory.
|
||||||
|
|
||||||
To customize the components used in the storefront, you can customize the files under the `components` directory.
|
To customize the components used in the storefront, you can customize the files under the `src/modules` directory.
|
||||||
|
|
||||||
To customize the styles of the storefront, you can customize the `styles` directory.
|
To customize the styles of the storefront, you can customize the `src/styles` directory.
|
||||||
|
|
||||||
### Change Port
|
### Change Port
|
||||||
|
|
||||||
@@ -67,27 +193,25 @@ Then, on your server, update the environment variable `STORE_CORS` to the URL
|
|||||||
STORE_CORS=http://localhost:<PORT>
|
STORE_CORS=http://localhost:<PORT>
|
||||||
```
|
```
|
||||||
|
|
||||||
:::info
|
|
||||||
|
|
||||||
For more details about the Store CORS configuration, check out the [Configure your Server documentation](../usage/configurations.md#storefront-cors).
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
### Development Resources
|
### Development Resources
|
||||||
|
|
||||||
You can learn more about development with Next.js through [their documentation](https://nextjs.org/docs/getting-started).
|
You can learn more about development with Next.js through [their documentation](https://nextjs.org/docs/getting-started).
|
||||||
|
|
||||||
## Storefront Features
|
## Storefront Features
|
||||||
|
|
||||||
- View products and manage your cart.
|
- View all products and manage your cart.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
- Customer authentication and profiles.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
- Full checkout workflow.
|
- Full checkout workflow.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## What’s Next 🚀
|
## 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.
|
- 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).
|
- Learn [how to install Medusa Admin](../admin/quickstart.md).
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# S3 Plugin ACL Error
|
||||||
|
|
||||||
|
If you're using the [S3 Plugin](../add-plugins/s3.md) and, when you upload an image, you receive the following error on your Medusa server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
AccessControlListNotSupported: The bucket does not allow ACLs
|
||||||
|
```
|
||||||
|
|
||||||
|
Try the following:
|
||||||
|
|
||||||
|
1. Go to your S3 Bucket, then choose the Permissions tab.
|
||||||
|
2. Scroll to Object Ownership and click the Edit button.
|
||||||
|
3. Select ACLs enabled and choose for Object Ownership the radio button Bucket owner preferred.
|
||||||
|
4. Click the Save Changes.
|
||||||
|
|
||||||
|
Try uploading again after making this change. Upload should be successful.
|
||||||
@@ -97,6 +97,12 @@ Where `database_type` is `sqlite` and `database_database` is the location you wa
|
|||||||
|
|
||||||
### PostgreSQL Configurations
|
### PostgreSQL Configurations
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
Before getting started with configuring PostgreSQL, you should have created a PostgreSQL `database`. You can check how to create a database in [PostgreSQL's documentation](https://www.postgresql.org/docs/current/sql-createdatabase.html).
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
For PostgreSQL you mainly need 2 configurations:
|
For PostgreSQL you mainly need 2 configurations:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
@@ -256,6 +262,12 @@ ADMIN_CORS=<YOUR_ADMIN_CORS>
|
|||||||
|
|
||||||
Where `<YOUR_ADMIN_CORS>` is the URL of your admin dashboard.
|
Where `<YOUR_ADMIN_CORS>` is the URL of your admin dashboard.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
Make sure that the URL is without a backslash at the end. For example, you should use `http://localhost:7000` instead of `http://localhost:7000/`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Storefront CORS
|
## Storefront CORS
|
||||||
|
|
||||||
Medusa uses CORS to only allow specific origins to access the server. To make sure your Storefront dashboard can access the Medusa server, set this configuration:
|
Medusa uses CORS to only allow specific origins to access the server. To make sure your Storefront dashboard can access the Medusa server, set this configuration:
|
||||||
@@ -279,6 +291,12 @@ STORE_CORS=<YOUR_STORE_CORS>
|
|||||||
|
|
||||||
Where `<YOUR_STORE_CORS>` is the URL of your storefront.
|
Where `<YOUR_STORE_CORS>` is the URL of your storefront.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
Make sure that the URL is without a backslash at the end. For example, you should use `http://localhost:8000` instead of `http://localhost:8000/`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
On your Medusa server, you can use Plugins to add custom features or integrate third-party services. For example, installing a plugin to use Stripe as a payment provider.
|
On your Medusa server, you can use Plugins to add custom features or integrate third-party services. For example, installing a plugin to use Stripe as a payment provider.
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ The server will be installed under the `backend` directory under the project dir
|
|||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
You can learn more about the Contentful starter in the [Contentful Integration documentation](../add-plugins/contentful.md).
|
You can learn more about the Contentful starter in the [Contentful Integration documentation](../add-plugins/contentful/index.md).
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ Learn more about how you can use this plugin in the [documentaion](https://docs.
|
|||||||
"[indexName]": "[meilisearch settings passed to meilisearch's `updateSettings()` method]"
|
"[indexName]": "[meilisearch settings passed to meilisearch's `updateSettings()` method]"
|
||||||
// example
|
// example
|
||||||
products: {
|
products: {
|
||||||
searchableAttributes: ["title", "description", "variant_sku", "type_value"],
|
searchableAttributes: ["title", "description", "variant_sku"],
|
||||||
displayedAttributes: ["title", "description", "variant_sku", "type_value"],
|
displayedAttributes: ["title", "description", "variant_sku", "thumbnail", "handle"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# medusa-plugin-segment
|
||||||
|
|
||||||
|
Segment Plugin to add tracking to your Medusa server.
|
||||||
|
|
||||||
|
Learn more about how you can use this plugin in the [documentaion](https://docs.medusajs.com/add-plugins/segment).
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
write_key: "<YOUR_SEGMENT_WRITE_KEY>"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `<YOUR_SEGMENT_WRITE_KEY>` is the write key of the Segment Source you create for the Medusa server.
|
||||||
@@ -1 +1,7 @@
|
|||||||
build
|
build
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
Binary file not shown.
@@ -18,3 +18,9 @@
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
Binary file not shown.
@@ -64,9 +64,21 @@ module.exports = {
|
|||||||
label: "Docs"
|
label: "Docs"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "docSidebar",
|
type: 'dropdown',
|
||||||
sidebarId: "servicesSidebar",
|
label: 'References',
|
||||||
label: "Services Reference",
|
items: [
|
||||||
|
{
|
||||||
|
href: `https://docs.medusajs.com/api/store`,
|
||||||
|
target: "_self",
|
||||||
|
label: "API Reference",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: "cli/reference",
|
||||||
|
label: "CLI Reference",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: "advanced/backend/subscribers/events-list",
|
||||||
|
label: "Events Reference",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "docSidebar",
|
type: "docSidebar",
|
||||||
@@ -74,9 +86,11 @@ module.exports = {
|
|||||||
label: "JS Client Reference",
|
label: "JS Client Reference",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: `https://docs.medusajs.com/api/store`,
|
type: "docSidebar",
|
||||||
target: "_self",
|
sidebarId: "servicesSidebar",
|
||||||
label: "API Reference",
|
label: "Services Reference",
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: "https://github.com/medusajs/medusa",
|
href: "https://github.com/medusajs/medusa",
|
||||||
@@ -91,15 +105,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
links: [
|
links: [
|
||||||
{
|
|
||||||
title: "Docs",
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
label: "Tutorial",
|
|
||||||
to: "/tutorial/set-up-your-development-environment",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "Community",
|
title: "Community",
|
||||||
items: [
|
items: [
|
||||||
@@ -149,7 +154,8 @@ module.exports = {
|
|||||||
routeBasePath: "/",
|
routeBasePath: "/",
|
||||||
remarkPlugins: [
|
remarkPlugins: [
|
||||||
[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
|
[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
|
||||||
]
|
],
|
||||||
|
showLastUpdateTime: true
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
customCss: require.resolve("./src/css/custom.css"),
|
customCss: require.resolve("./src/css/custom.css"),
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
"clean-node-modules": "rm -rf ../../node_modules",
|
"clean-node-modules": "rm -rf ../../node_modules",
|
||||||
"prestart": "yarn clean-node-modules",
|
"prestart": "yarn clean-node-modules",
|
||||||
"start": "docusaurus clear && docusaurus start",
|
"start": "yarn prestart && docusaurus clear && docusaurus start",
|
||||||
"prebuild": "yarn clean-node-modules",
|
"prebuild": "yarn clean-node-modules",
|
||||||
"build": "docusaurus build",
|
"build": "yarn prestart && docusaurus build",
|
||||||
"swizzle": "docusaurus swizzle",
|
"swizzle": "docusaurus swizzle",
|
||||||
"deploy": "docusaurus deploy",
|
"deploy": "docusaurus deploy",
|
||||||
"clear": "docusaurus clear",
|
"clear": "docusaurus clear",
|
||||||
|
|||||||
+37
-21
@@ -85,17 +85,26 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "deployments/server/deploying-on-heroku",
|
id: "deployments/server/deploying-on-heroku",
|
||||||
label: "Deploy on Heroku"
|
label: "Deploy on Heroku",
|
||||||
|
customProps: {
|
||||||
|
image: 'https://i.imgur.com/xNvxSkf.png'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "deployments/server/deploying-on-digital-ocean",
|
id: "deployments/server/deploying-on-digital-ocean",
|
||||||
label: "Deploy on DigitalOcean"
|
label: "Deploy on DigitalOcean",
|
||||||
|
customProps: {
|
||||||
|
image: 'https://i.imgur.com/aahqJp4.png'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "deployments/server/deploying-on-qovery",
|
id: "deployments/server/deploying-on-qovery",
|
||||||
label: "Deploy on Qovery"
|
label: "Deploy on Qovery",
|
||||||
|
customProps: {
|
||||||
|
image: 'https://i.imgur.com/qOvY2dN.png'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -110,7 +119,10 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "deployments/admin/deploying-on-netlify",
|
id: "deployments/admin/deploying-on-netlify",
|
||||||
label: "Deploy on Netlify"
|
label: "Deploy on Netlify",
|
||||||
|
customProps: {
|
||||||
|
image: 'https://i.imgur.com/gCbsCvX.png'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -125,7 +137,10 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "deployments/storefront/deploying-gatsby-on-netlify",
|
id: "deployments/storefront/deploying-gatsby-on-netlify",
|
||||||
label: "Deploy Gatsby on Netlify"
|
label: "Deploy Gatsby on Netlify",
|
||||||
|
customProps: {
|
||||||
|
image: 'https://i.imgur.com/gCbsCvX.png'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -314,29 +329,25 @@ module.exports = {
|
|||||||
label: "CMS",
|
label: "CMS",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "doc",
|
type: "category",
|
||||||
id: "add-plugins/contentful",
|
|
||||||
label: "Contentful",
|
label: "Contentful",
|
||||||
|
link: {
|
||||||
|
type: "doc",
|
||||||
|
id: "add-plugins/contentful/index",
|
||||||
|
},
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
type: "doc",
|
||||||
|
id: "add-plugins/contentful/customize-contentful",
|
||||||
|
label: "Customize Contentful Integration",
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "add-plugins/strapi",
|
id: "add-plugins/strapi",
|
||||||
label: "Strapi",
|
label: "Strapi",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: "category",
|
|
||||||
label: "Gatsby + Contentful + Medusa",
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
type: "doc",
|
|
||||||
id: "how-to/headless-ecommerce-store-with-gatsby-contentful-medusa",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "doc",
|
|
||||||
id: "how-to/making-your-store-more-powerful-with-contentful",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -454,6 +465,11 @@ module.exports = {
|
|||||||
id: "troubleshooting/signing-in-to-admin",
|
id: "troubleshooting/signing-in-to-admin",
|
||||||
label: "Signing in to Medusa Admin",
|
label: "Signing in to Medusa Admin",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "doc",
|
||||||
|
id: "troubleshooting/s3-acl-error",
|
||||||
|
label: "S3 Plugin ACL Error",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "doc",
|
type: "doc",
|
||||||
id: "troubleshooting/documentation-error",
|
id: "troubleshooting/documentation-error",
|
||||||
|
|||||||
@@ -115,8 +115,7 @@ html[data-theme="dark"] footer:not(.theme-doc-footer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
html[data-theme="dark"] .card {
|
html[data-theme="dark"] .card {
|
||||||
border: 1px solid #fff;
|
border: 1px solid var(--ifm-color-primary);
|
||||||
color: var(--ifm-color-primary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
@@ -286,7 +285,7 @@ details summary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.theme-doc-markdown a:not(.box-link):hover {
|
.theme-doc-markdown a:not(.box-link):hover {
|
||||||
color: var(--ifm-color-primary-darkest);
|
color: rgba(255, 255, 255, 0.8);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import {findFirstCategoryLink, useDocById} from '@docusaurus/theme-common';
|
||||||
|
|
||||||
|
import Link from '@docusaurus/Link';
|
||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
import React from 'react';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import isInternalUrl from '@docusaurus/isInternalUrl';
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
import {translate} from '@docusaurus/Translate';
|
||||||
|
|
||||||
|
function CardContainer({href, children}) {
|
||||||
|
const className = clsx(
|
||||||
|
'card margin-bottom--lg padding--lg',
|
||||||
|
styles.cardContainer,
|
||||||
|
href && styles.cardContainerLink,
|
||||||
|
);
|
||||||
|
return href ? (
|
||||||
|
<Link href={href} className={className}>
|
||||||
|
{children}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div className={className}>{children}</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardLayout({href, icon, title, description}) {
|
||||||
|
return (
|
||||||
|
<CardContainer href={href}>
|
||||||
|
<h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
|
||||||
|
{icon} {title}
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
className={clsx('text--truncate', styles.cardDescription)}
|
||||||
|
title={description}>
|
||||||
|
{description}
|
||||||
|
</div>
|
||||||
|
</CardContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardCategory({item}) {
|
||||||
|
const href = findFirstCategoryLink(item);
|
||||||
|
return (
|
||||||
|
<CardLayout
|
||||||
|
href={href}
|
||||||
|
icon="🗃️"
|
||||||
|
title={item.label}
|
||||||
|
description={translate(
|
||||||
|
{
|
||||||
|
message: '{count} items',
|
||||||
|
id: 'theme.docs.DocCard.categoryDescription',
|
||||||
|
description:
|
||||||
|
'The default description for a category card in the generated index about how many items this category includes',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
count: item.items.length,
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardLink({item}) {
|
||||||
|
let icon;
|
||||||
|
if (item.customProps && item.customProps.image) {
|
||||||
|
icon = <img src={item.customProps.image} alt={item.label} width={24} height={24} />;
|
||||||
|
} else if (item.customProps && item.customProps.icon) {
|
||||||
|
icon = item.customProps.icon;
|
||||||
|
} else {
|
||||||
|
icon = isInternalUrl(item.href) ? '📄️' : '🔗';
|
||||||
|
}
|
||||||
|
|
||||||
|
const doc = useDocById(item.docId ?? undefined);
|
||||||
|
return (
|
||||||
|
<CardLayout
|
||||||
|
href={item.href}
|
||||||
|
icon={icon}
|
||||||
|
title={item.label}
|
||||||
|
description={doc?.description}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DocCard({item}) {
|
||||||
|
switch (item.type) {
|
||||||
|
case 'link':
|
||||||
|
return <CardLink item={item} />;
|
||||||
|
|
||||||
|
case 'category':
|
||||||
|
return <CardCategory item={item} />;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(`unknown item type ${JSON.stringify(item)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.cardContainer {
|
||||||
|
height: 8rem;
|
||||||
|
color: var(--ifm-color-emphasis-800);
|
||||||
|
--ifm-link-color: var(--ifm-color-emphasis-800);
|
||||||
|
--ifm-link-hover-color: var(--ifm-color-emphasis-800);
|
||||||
|
--ifm-link-hover-decoration: none;
|
||||||
|
|
||||||
|
/* box-shadow: var(--ifm-global-shadow-lw); */
|
||||||
|
box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
|
||||||
|
border: 1px solid var(--ifm-color-emphasis-200);
|
||||||
|
transition: box-shadow var(--ifm-transition-fast) ease,
|
||||||
|
background-color var(--ifm-transition-fast) ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardContainer.cardContainerLink:hover {
|
||||||
|
/* box-shadow: var(--ifm-global-shadow-md); */
|
||||||
|
box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='dark'] .cardContainer.cardContainerLink:hover {
|
||||||
|
--ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardContainer:not(.cardContainerLink) {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardTitle {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
min-height: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardTitle img {
|
||||||
|
vertical-align: bottom;
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardDescription {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
min-height: 0.8rem;
|
||||||
|
}
|
||||||
+11765
-8252
File diff suppressed because it is too large.
Load diff
@@ -67,3 +67,9 @@ yarn-error.log
|
|||||||
.pnp.js
|
.pnp.js
|
||||||
# Yarn Integrity file
|
# Yarn Integrity file
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
Binary file not shown.
@@ -63,7 +63,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
resolve: `gatsby-plugin-env-variables`,
|
resolve: `gatsby-plugin-env-variables`,
|
||||||
options: {
|
options: {
|
||||||
allowList: ["ALGOLIA_API_KEY"],
|
allowList: ["ALGOLIA_API_KEY", "ALGOLIA_APP_ID"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
"gatsby-plugin-env-variables": "^2.1.0",
|
"gatsby-plugin-env-variables": "^2.1.0",
|
||||||
"gatsby-plugin-preact": "^5.9.0",
|
"gatsby-plugin-preact": "^5.9.0",
|
||||||
"gatsby-plugin-react-helmet": "^3.3.12",
|
"gatsby-plugin-react-helmet": "^3.3.12",
|
||||||
"gatsby-plugin-sitemap": "^5.15.0",
|
|
||||||
"gatsby-plugin-segment-js": "^3.7.1",
|
"gatsby-plugin-segment-js": "^3.7.1",
|
||||||
|
"gatsby-plugin-sitemap": "^5.15.0",
|
||||||
"gatsby-plugin-theme-ui": "^0.10.1",
|
"gatsby-plugin-theme-ui": "^0.10.1",
|
||||||
"gatsby-remark-autolink-headers": "^4.6.0",
|
"gatsby-remark-autolink-headers": "^4.6.0",
|
||||||
"gatsby-source-filesystem": "^3.9.0",
|
"gatsby-source-filesystem": "^3.9.0",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { convertToKebabCase } from "../../utils/convert-to-kebab-case"
|
|||||||
import { navigate } from "gatsby-link"
|
import { navigate } from "gatsby-link"
|
||||||
|
|
||||||
const algoliaApiKey = process.env.ALGOLIA_API_KEY || "temp"
|
const algoliaApiKey = process.env.ALGOLIA_API_KEY || "temp"
|
||||||
|
const algoliaAppId = process.env.ALGOLIA_APP_ID || "temp"
|
||||||
|
|
||||||
const Search = ({data}) => {
|
const Search = ({data}) => {
|
||||||
const { goTo, api } = useContext(NavigationContext)
|
const { goTo, api } = useContext(NavigationContext)
|
||||||
@@ -72,6 +73,7 @@ const Search = ({data}) => {
|
|||||||
return (
|
return (
|
||||||
<DocSearch
|
<DocSearch
|
||||||
apiKey={algoliaApiKey}
|
apiKey={algoliaApiKey}
|
||||||
|
appId={algoliaAppId}
|
||||||
indexName="medusa-commerce"
|
indexName="medusa-commerce"
|
||||||
hitComponent={({hit, children}) => <HitComponent data={data} hit={hit} children={children} />}
|
hitComponent={({hit, children}) => <HitComponent data={data} hit={hit} children={children} />}
|
||||||
navigator={{
|
navigator={{
|
||||||
|
|||||||
+16631
-12000
File diff suppressed because it is too large.
Load diff
+6028
-3830
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user