api-ref: custom API reference (#4770)
* initialized next.js project * finished markdown sections * added operation schema component * change page metadata * eslint fixes * fixes related to deployment * added response schema * resolve max stack issue * support for different property types * added support for property types * added loading for components * added more loading * type fixes * added oneOf type * removed console * fix replace with push * refactored everything * use static content for description * fixes and improvements * added code examples section * fix path name * optimizations * fixed tag navigation * add support for admin and store references * general enhancements * optimizations and fixes * fixes and enhancements * added search bar * loading enhancements * added loading * added code blocks * added margin top * add empty response text * fixed oneOf parameters * added path and query parameters * general fixes * added base path env variable * small fix for arrays * enhancements * design enhancements * general enhancements * fix isRequired * added enum values * enhancements * general fixes * general fixes * changed oas generation script * additions to the introduction section * added copy button for code + other enhancements * fix response code block * fix metadata * formatted store introduction * move sidebar logic to Tags component * added test env variables * fix code block bug * added loading animation * added expand param + loading * enhance operation loading * made responsive + improvements * added loading provider * fixed loading * adjustments for small devices * added sidebar label for endpoints * added feedback component * fixed analytics * general fixes * listen to scroll for other headings * added sample env file * update api ref files + support new fields * fix for external docs link * added new sections * fix last item in sidebar not showing * move docs content to www/docs * change redirect url * revert change * resolve build errors * configure rewrites * changed to environment variable url * revert changing environment variable name * add environment variable for API path * fix links * fix tailwind settings * remove vercel file * reconfigured api route * move api page under api * fix page metadata * fix external link in navigation bar * update api spec * updated api specs * fixed google lint error * add max-height on request samples * add padding before loading * fix for one of name * fix undefined types * general fixes * remove response schema example * redesigned navigation bar * redesigned sidebar * fixed up paddings * added feedback component + report issue * fixed up typography, padding, and general styling * redesigned code blocks * optimization * added error timeout * fixes * added indexing with algolia + fixes * fix errors with algolia script * redesign operation sections * fix heading scroll * design fixes * fix padding * fix padding + scroll issues * fix scroll issues * improve scroll performance * fixes for safari * optimization and fixes * fixes to docs + details animation * padding fixes for code block * added tab animation * fixed incorrect link * added selection styling * fix lint errors * redesigned details component * added detailed feedback form * api reference fixes * fix tabs * upgrade + fixes * updated documentation links * optimizations to sidebar items * fix spacing in sidebar item * optimizations and fixes * fix endpoint path styling * remove margin * final fixes * change margin on small devices * generated OAS * fixes for mobile * added feedback modal * optimize dark mode button * fixed color mode useeffect * minimize dom size * use new style system * radius and spacing design system * design fixes * fix eslint errors * added meta files * change cron schedule * fix docusaurus configurations * added operating system to feedback data * change content directory name * fixes to contribution guidelines * revert renaming content * added api-reference to documentation workflow * fixes for search * added dark mode + fixes * oas fixes * handle bugs * added code examples for clients * changed tooltip text * change authentication to card * change page title based on selected section * redesigned mobile navbar * fix icon colors * fix key colors * fix medusa-js installation command * change external regex in algolia * change changeset * fix padding on mobile * fix hydration error * update depedencies
This commit is contained in:
1 parent
16249ec280
commit
914d773d3a
3270 files changed
+22075
-192064
No files matched your search
@@ -0,0 +1 @@
|
||||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
||||
@@ -0,0 +1,310 @@
|
||||
# Class: AnalyticsConfigService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`AnalyticsConfigService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new AnalyticsConfigService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:21](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L21)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### analyticsConfigRepository\_
|
||||
|
||||
• `Protected` `Readonly` **analyticsConfigRepository\_**: `Repository`<`AnalyticsConfig`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:18](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L18)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### userService\_
|
||||
|
||||
• `Protected` `Readonly` **userService\_**: [`UserService`](UserService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:19](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L19)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`userId`, `data`): `Promise`<`AnalyticsConfig`\>
|
||||
|
||||
Creates an analytics config.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `userId` | `string` |
|
||||
| `data` | `CreateAnalyticsConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AnalyticsConfig`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:50](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`userId`): `Promise`<`void`\>
|
||||
|
||||
Deletes an analytics config.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `userId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:94](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L94)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`userId`): `Promise`<`AnalyticsConfig`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `userId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AnalyticsConfig`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L28)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`userId`, `update`): `Promise`<`AnalyticsConfig`\>
|
||||
|
||||
Updates an analytics config. If the config does not exist, it will be created instead.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `userId` | `string` |
|
||||
| `update` | `UpdateAnalyticsConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AnalyticsConfig`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/analytics-config.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/analytics-config.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`AnalyticsConfigService`](AnalyticsConfigService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`AnalyticsConfigService`](AnalyticsConfigService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,331 @@
|
||||
# Class: AuthService
|
||||
|
||||
Can authenticate a user based on email password combination
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`AuthService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new AuthService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L22)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customerService\_
|
||||
|
||||
• `Protected` `Readonly` **customerService\_**: [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### userService\_
|
||||
|
||||
• `Protected` `Readonly` **userService\_**: [`UserService`](UserService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:19](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L19)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### authenticate
|
||||
|
||||
▸ **authenticate**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
||||
|
||||
Authenticates a given user based on an email, password combination. Uses
|
||||
scrypt to match password with hashed value.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the user |
|
||||
| `password` | `string` | the password of the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AuthenticateResult`\>
|
||||
|
||||
success: whether authentication succeeded
|
||||
user: the user document if authentication succeded
|
||||
error: a string with the error message
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:95](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L95)
|
||||
|
||||
___
|
||||
|
||||
### authenticateAPIToken
|
||||
|
||||
▸ **authenticateAPIToken**(`token`): `Promise`<`AuthenticateResult`\>
|
||||
|
||||
Authenticates a given user with an API token
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `token` | `string` | the api_token of the user to authenticate |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AuthenticateResult`\>
|
||||
|
||||
success: whether authentication succeeded
|
||||
user: the user document if authentication succeded
|
||||
error: a string with the error message
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### authenticateCustomer
|
||||
|
||||
▸ **authenticateCustomer**(`email`, `password`): `Promise`<`AuthenticateResult`\>
|
||||
|
||||
Authenticates a customer based on an email, password combination. Uses
|
||||
scrypt to match password with hashed value.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the user |
|
||||
| `password` | `string` | the password of the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`AuthenticateResult`\>
|
||||
|
||||
success: whether authentication succeeded
|
||||
user: the user document if authentication succeded
|
||||
error: a string with the error message
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:144](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L144)
|
||||
|
||||
___
|
||||
|
||||
### comparePassword\_
|
||||
|
||||
▸ `Protected` **comparePassword_**(`password`, `hash`): `Promise`<`boolean`\>
|
||||
|
||||
Verifies if a password is valid given the provided password hash
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `password` | `string` | the raw password to check |
|
||||
| `hash` | `string` | the hash to compare against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
the result of the comparison
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/auth.ts:36](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/auth.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`AuthService`](AuthService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`AuthService`](AuthService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,511 @@
|
||||
# Class: BatchJobService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`BatchJobService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new BatchJobService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:91](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L91)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### batchJobRepository\_
|
||||
|
||||
• `Protected` `Readonly` **batchJobRepository\_**: `Repository`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### batchJobStatusMapToProps
|
||||
|
||||
• `Protected` **batchJobStatusMapToProps**: `Map`<`BatchJobStatus`, { `entityColumnName`: `string` ; `eventType`: `string` }\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### strategyResolver\_
|
||||
|
||||
• `Protected` `Readonly` **strategyResolver\_**: [`StrategyResolverService`](StrategyResolverService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:41](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `COMPLETED` | `string` |
|
||||
| `CONFIRMED` | `string` |
|
||||
| `CREATED` | `string` |
|
||||
| `FAILED` | `string` |
|
||||
| `PRE_PROCESSED` | `string` |
|
||||
| `PROCESSING` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L28)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`batchJobOrId`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:270](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L270)
|
||||
|
||||
___
|
||||
|
||||
### complete
|
||||
|
||||
▸ **complete**(`batchJobOrId`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:252](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L252)
|
||||
|
||||
___
|
||||
|
||||
### confirm
|
||||
|
||||
▸ **confirm**(`batchJobOrId`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:234](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L234)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `BatchJobCreateProps` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:144](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L144)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`BatchJob`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `FilterableBatchJobProps` |
|
||||
| `config` | `FindConfig`<`BatchJob`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`BatchJob`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:132](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L132)
|
||||
|
||||
___
|
||||
|
||||
### prepareBatchJobForProcessing
|
||||
|
||||
▸ **prepareBatchJobForProcessing**(`data`, `req`): `Promise`<`CreateBatchJobInput`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateBatchJobInput` |
|
||||
| `req` | `Request`<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`<`string`, `any`\>\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CreateBatchJobInput`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:367](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L367)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`batchJobId`, `config?`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobId` | `string` |
|
||||
| `config` | `FindConfig`<`BatchJob`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:104](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L104)
|
||||
|
||||
___
|
||||
|
||||
### setFailed
|
||||
|
||||
▸ **setFailed**(`batchJobOrId`, `error?`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
| `error?` | `string` \| `BatchJobResultError` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:341](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L341)
|
||||
|
||||
___
|
||||
|
||||
### setPreProcessingDone
|
||||
|
||||
▸ **setPreProcessingDone**(`batchJobOrId`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:288](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L288)
|
||||
|
||||
___
|
||||
|
||||
### setProcessing
|
||||
|
||||
▸ **setProcessing**(`batchJobOrId`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:321](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L321)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`batchJobOrId`, `data`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
| `data` | `Partial`<`Pick`<`BatchJob`, ``"context"`` \| ``"result"``\>\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:161](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L161)
|
||||
|
||||
___
|
||||
|
||||
### updateStatus
|
||||
|
||||
▸ `Protected` **updateStatus**(`batchJobOrId`, `status`): `Promise`<`BatchJob`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `batchJobOrId` | `string` \| `BatchJob` |
|
||||
| `status` | `BatchJobStatus` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`BatchJob`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/batch-job.ts:200](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/batch-job.ts#L200)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`BatchJobService`](BatchJobService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`BatchJobService`](BatchJobService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,359 @@
|
||||
# Class: ClaimItemService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ClaimItemService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ClaimItemService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L26)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### claimImageRepository\_
|
||||
|
||||
• `Protected` `Readonly` **claimImageRepository\_**: `Repository`<`ClaimImage`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### claimItemRepository\_
|
||||
|
||||
• `Protected` `Readonly` **claimItemRepository\_**: `Repository`<`ClaimItem`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### claimTagRepository\_
|
||||
|
||||
• `Protected` `Readonly` **claimTagRepository\_**: `Repository`<`ClaimTag`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:23](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L23)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:21](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L14)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`ClaimItem`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateClaimItemInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimItem`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`ClaimItem`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ClaimItem`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`ClaimItem`\> | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimItem`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:205](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L205)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`claimItemId`, `config?`): `Promise`<`ClaimItem`\>
|
||||
|
||||
Gets a claim item by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `claimItemId` | `string` | id of ClaimItem to retrieve |
|
||||
| `config` | `FindConfig`<`ClaimItem`\> | configuration for the find operation |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimItem`\>
|
||||
|
||||
the ClaimItem
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:224](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L224)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`ClaimItem`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `any` |
|
||||
| `data` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimItem`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim-item.ts:127](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim-item.ts#L127)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ClaimItemService`](ClaimItemService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ClaimItemService`](ClaimItemService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,639 @@
|
||||
# Class: ClaimService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ClaimService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ClaimService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:86](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L86)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### addressRepository\_
|
||||
|
||||
• `Protected` `Readonly` **addressRepository\_**: `Repository`<`Address`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### claimItemService\_
|
||||
|
||||
• `Protected` `Readonly` **claimItemService\_**: [`ClaimItemService`](ClaimItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:72](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L72)
|
||||
|
||||
___
|
||||
|
||||
### claimRepository\_
|
||||
|
||||
• `Protected` `Readonly` **claimRepository\_**: `Repository`<`ClaimOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:73](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L73)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentProviderService\_**: [`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:74](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L74)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentService\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentService\_**: [`FulfillmentService`](FulfillmentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:75](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L75)
|
||||
|
||||
___
|
||||
|
||||
### lineItemRepository\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemRepository\_**: `Repository`<`LineItem`\> & { `findByReturn`: (`returnId`: `string`) => `Promise`<`LineItem` & { `return_item`: `ReturnItem` }[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:71](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L71)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:76](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L76)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderService\_**: [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:77](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L77)
|
||||
|
||||
___
|
||||
|
||||
### productVariantInventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantInventoryService\_**: [`ProductVariantInventoryService`](ProductVariantInventoryService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:84](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L84)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:78](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### returnService\_
|
||||
|
||||
• `Protected` `Readonly` **returnService\_**: [`ReturnService`](ReturnService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:79](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L79)
|
||||
|
||||
___
|
||||
|
||||
### shippingMethodRepository\_
|
||||
|
||||
• `Protected` `Readonly` **shippingMethodRepository\_**: `Repository`<`ShippingMethod`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:70](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:80](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L80)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:81](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L81)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:82](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L82)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `CREATED` | `string` |
|
||||
| `FULFILLMENT_CREATED` | `string` |
|
||||
| `REFUND_PROCESSED` | `string` |
|
||||
| `SHIPMENT_CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L59)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`id`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:814](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L814)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `fulfillmentId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:662](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L662)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreateClaimInput` | the object containing all data required to create a claim |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
created claim
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:331](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L331)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`id`, `config?`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the object containing all data required to create a claim |
|
||||
| `config` | `Object` | config object |
|
||||
| `config.location_id?` | `string` | - |
|
||||
| `config.metadata?` | `Record`<`string`, `unknown`\> | config metadata |
|
||||
| `config.no_notification?` | `boolean` | config no notification |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
created claim
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:512](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L512)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`id`, `fulfillmentId`, `trackingLinks?`, `config?`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `fulfillmentId` | `string` | `undefined` |
|
||||
| `trackingLinks` | { `tracking_number`: `string` }[] | `[]` |
|
||||
| `config` | `Object` | `undefined` |
|
||||
| `config.metadata` | `Object` | `{}` |
|
||||
| `config.no_notification` | `undefined` | `undefined` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:734](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L734)
|
||||
|
||||
___
|
||||
|
||||
### getRefundTotalForClaimLinesOnOrder
|
||||
|
||||
▸ `Protected` **getRefundTotalForClaimLinesOnOrder**(`order`, `claimItems`): `Promise`<`number`\>
|
||||
|
||||
Finds claim line items on an order and calculates the refund amount.
|
||||
There are three places too look:
|
||||
- Order items
|
||||
- Swap items
|
||||
- Claim items (from previous claims)
|
||||
Note, it will attempt to return early from each of these places to avoid having to iterate over all items every time.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to find claim lines on |
|
||||
| `claimItems` | `CreateClaimItemInput`[] | the claim items to match against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the refund amount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:273](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L273)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`ClaimOrder`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | the query object for find |
|
||||
| `config` | `FindConfig`<`ClaimOrder`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:870](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L870)
|
||||
|
||||
___
|
||||
|
||||
### processRefund
|
||||
|
||||
▸ **processRefund**(`id`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:688](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L688)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`claimId`, `config?`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
Gets an order by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `claimId` | `string` | id of the claim order to retrieve |
|
||||
| `config` | `FindConfig`<`ClaimOrder`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:889](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L889)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `data` | `UpdateClaimInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ClaimOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:125](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L125)
|
||||
|
||||
___
|
||||
|
||||
### validateCreateClaimInput
|
||||
|
||||
▸ `Protected` **validateCreateClaimInput**(`data`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateClaimInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/claim.ts:206](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/claim.ts#L206)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ClaimService`](ClaimService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ClaimService`](ClaimService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,325 @@
|
||||
# Class: CurrencyService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`CurrencyService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CurrencyService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L29)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### currencyRepository\_
|
||||
|
||||
• `Protected` `Readonly` **currencyRepository\_**: `Repository`<`Currency`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:27](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L27)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:21](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L21)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Currency`[], `number`]\>
|
||||
|
||||
Lists currencies based on the provided parameters and includes the count of
|
||||
currencies that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Currency`\> | an object that defines rules to filter currencies by |
|
||||
| `config` | `FindConfig`<`Currency`\> | object that defines the scope for what should be returned |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Currency`[], `number`]\>
|
||||
|
||||
an array containing the currencies as
|
||||
the first element and the total count of products that matches the query
|
||||
as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:78](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCode
|
||||
|
||||
▸ **retrieveByCode**(`code`): `Promise`<`Currency`\>
|
||||
|
||||
Return the currency
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | The code of the currency that must be retrieve |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Currency`\>
|
||||
|
||||
The currency
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:47](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`code`, `data`): `Promise`<`undefined` \| `Currency`\>
|
||||
|
||||
Update a currency
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | The code of the currency to update |
|
||||
| `data` | `UpdateCurrencyInput` | The data that must be updated on the currency |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `Currency`\>
|
||||
|
||||
The updated currency
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/currency.ts:100](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/currency.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`CurrencyService`](CurrencyService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CurrencyService`](CurrencyService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,293 @@
|
||||
# Class: CustomShippingOptionService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`CustomShippingOptionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CustomShippingOptionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/custom-shipping-option.ts:18](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/custom-shipping-option.ts#L18)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customShippingOptionRepository\_
|
||||
|
||||
• `Protected` **customShippingOptionRepository\_**: `Repository`<`CustomShippingOption`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/custom-shipping-option.ts:16](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/custom-shipping-option.ts#L16)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**<`T`, `TResult`\>(`data`): `Promise`<`TResult`\>
|
||||
|
||||
Creates a custom shipping option
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | `CreateCustomShippingOptionInput` \| `CreateCustomShippingOptionInput`[] |
|
||||
| `TResult` | `T` extends `CreateCustomShippingOptionInput`[] ? `CustomShippingOption`[] : `CustomShippingOption` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `T` | the custom shipping option to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
resolves to the creation result
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/custom-shipping-option.ts:80](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/custom-shipping-option.ts#L80)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`CustomShippingOption`[]\>
|
||||
|
||||
Fetches all custom shipping options based on the given selector
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`CustomShippingOption`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`CustomShippingOption`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomShippingOption`[]\>
|
||||
|
||||
custom shipping options matching the query
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/custom-shipping-option.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/custom-shipping-option.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`CustomShippingOption`\>
|
||||
|
||||
Retrieves a specific shipping option.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the custom shipping option to retrieve. |
|
||||
| `config` | `FindConfig`<`CustomShippingOption`\> | any options needed to query for the result. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomShippingOption`\>
|
||||
|
||||
the requested custom shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/custom-shipping-option.ts:31](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/custom-shipping-option.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,438 @@
|
||||
# Class: CustomerGroupService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`CustomerGroupService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CustomerGroupService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `CustomerGroupConstructorProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L24)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customerGroupRepository\_
|
||||
|
||||
• `Protected` `Readonly` **customerGroupRepository\_**: `Repository`<`CustomerGroup`\> & { `addCustomers`: (`groupId`: `string`, `customerIds`: `string`[]) => `Promise`<`CustomerGroup`\> ; `findWithRelationsAndCount`: (`relations`: `FindOptionsRelations`<`CustomerGroup`\>, `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions`) => `Promise`<[`CustomerGroup`[], `number`]\> ; `removeCustomers`: (`groupId`: `string`, `customerIds`: `string`[]) => `Promise`<`DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:21](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### customerService\_
|
||||
|
||||
• `Protected` `Readonly` **customerService\_**: [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCustomers
|
||||
|
||||
▸ **addCustomers**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Add a batch of customers to a customer group at once
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the customer group to add customers to |
|
||||
| `customerIds` | `string` \| `string`[] | customer id's to add to the group |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
the customer group after insertion
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:89](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L89)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`group`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Creates a customer group with the provided data.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `group` | `DeepPartial`<`CustomerGroup`\> | the customer group to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`groupId`): `Promise`<`void`\>
|
||||
|
||||
Remove customer group
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `groupId` | `string` | id of the customer group to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
a promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:153](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L153)
|
||||
|
||||
___
|
||||
|
||||
### handleCreationFail
|
||||
|
||||
▸ `Private` **handleCreationFail**(`id`, `ids`, `error`): `Promise`<`never`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `ids` | `string`[] |
|
||||
| `error` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`never`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:257](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L257)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config`): `Promise`<`CustomerGroup`[]\>
|
||||
|
||||
List customer groups.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`CustomerGroup`\> & { `discount_condition_id?`: `string` ; `q?`: `string` } | the query object for find |
|
||||
| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:176](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L176)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config`): `Promise`<[`CustomerGroup`[], `number`]\>
|
||||
|
||||
Retrieve a list of customer groups and total count of records that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`CustomerGroup`\> & { `discount_condition_id?`: `string` ; `q?`: `string` } | the query object for find |
|
||||
| `config` | `FindConfig`<`CustomerGroup`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`CustomerGroup`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:194](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L194)
|
||||
|
||||
___
|
||||
|
||||
### removeCustomer
|
||||
|
||||
▸ **removeCustomer**(`id`, `customerIds`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Remove list of customers from a customergroup
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the customer group from which the customers are removed |
|
||||
| `customerIds` | `string` \| `string`[] | id's of the customer to remove from group |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
the customergroup with the provided id
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:236](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L236)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`customerGroupId`, `config?`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerGroupId` | `string` |
|
||||
| `config` | `Object` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:35](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`customerGroupId`, `update`): `Promise`<`CustomerGroup`\>
|
||||
|
||||
Update a customer group.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerGroupId` | `string` | id of the customer group |
|
||||
| `update` | `CustomerGroupUpdate` | customer group partial data |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CustomerGroup`\>
|
||||
|
||||
resulting customer group
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer-group.ts:120](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer-group.ts#L120)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`CustomerGroupService`](CustomerGroupService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CustomerGroupService`](CustomerGroupService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,694 @@
|
||||
# Class: CustomerService
|
||||
|
||||
Provides layer to manipulate customers.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`CustomerService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new CustomerService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L46)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### addressRepository\_
|
||||
|
||||
• `Protected` `Readonly` **addressRepository\_**: `Repository`<`Address`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### customerRepository\_
|
||||
|
||||
• `Protected` `Readonly` **customerRepository\_**: `Repository`<`Customer`\> & { `listAndCount`: (`query`: `Omit`<`FindOneOptions`<`Customer`\>, ``"where"`` \| ``"select"`` \| ``"relations"``\> & { `order?`: `FindOptionsOrder`<`Customer`\> ; `relations?`: `FindOptionsRelations`<`Customer`\> ; `select?`: `FindOptionsSelect`<`Customer`\> ; `skip?`: `number` ; `take?`: `number` ; `where`: `FindOptionsWhere`<`Customer`\> \| `FindOptionsWhere`<`Customer`\>[] } & { `where`: `FindOptionsWhere`<`Customer` & { `groups?`: `FindOperator`<`string`[]\> }\> } & `Omit`<`FindManyOptions`<`Customer`\>, ``"where"`` \| ``"select"`` \| ``"relations"``\> & { `order?`: `FindOptionsOrder`<`Customer`\> ; `relations?`: `FindOptionsRelations`<`Customer`\> ; `select?`: `FindOptionsSelect`<`Customer`\> ; `skip?`: `number` ; `take?`: `number` ; `where`: `FindOptionsWhere`<`Customer`\> \| `FindOptionsWhere`<`Customer`\>[] } & { `where`: `FindOptionsWhere`<`Customer` & { `groups?`: `FindOperator`<`string`[]\> }\> }, `q`: `undefined` \| `string`) => `Promise`<[`Customer`[], `number`]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:36](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `PASSWORD_RESET` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L40)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addAddress
|
||||
|
||||
▸ **addAddress**(`customerId`, `address`): `Promise`<`Customer` \| `Address`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `string` |
|
||||
| `address` | `AddressCreatePayload` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer` \| `Address`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:519](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L519)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### count
|
||||
|
||||
▸ **count**(): `Promise`<`number`\>
|
||||
|
||||
Return the total number of documents in database
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the result of the count operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:178](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L178)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customer` | `CreateCustomerInput` | the customer to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the result of create
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:306](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L306)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`customerId`): `Promise`<`void` \| `Customer`\>
|
||||
|
||||
Deletes a customer from a given customer id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the id of the customer to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `Customer`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:565](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L565)
|
||||
|
||||
___
|
||||
|
||||
### generateResetPasswordToken
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the customer to reset the password for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
the generated JSON web token
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### hashPassword\_
|
||||
|
||||
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
||||
|
||||
Hashes a password
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `password` | `string` | the value to hash |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
hashed password
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:293](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L293)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`Customer`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Customer`\> & { `groups?`: `string`[] ; `q?`: `string` } | the query object for find |
|
||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:111](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L111)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Customer`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Customer`\> & { `groups?`: `string`[] ; `q?`: `string` } | the query object for find |
|
||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Customer`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:143](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L143)
|
||||
|
||||
___
|
||||
|
||||
### listByEmail
|
||||
|
||||
▸ **listByEmail**(`email`, `config?`): `Promise`<`Customer`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `email` | `string` |
|
||||
| `config` | `FindConfig`<`Customer`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:249](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L249)
|
||||
|
||||
___
|
||||
|
||||
### removeAddress
|
||||
|
||||
▸ **removeAddress**(`customerId`, `addressId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `string` |
|
||||
| `addressId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:502](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L502)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`customerId`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
Gets a customer by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the id of the customer to get. |
|
||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the customer document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:274](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L274)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByEmail
|
||||
|
||||
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
Gets a registered customer by email.
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the customer to get. |
|
||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the customer document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:216](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L216)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByPhone
|
||||
|
||||
▸ **retrieveByPhone**(`phone`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
Gets a customer by phone.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `phone` | `string` | the phone of the customer to get. |
|
||||
| `config` | `FindConfig`<`Customer`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
the customer document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:261](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L261)
|
||||
|
||||
___
|
||||
|
||||
### retrieveRegisteredByEmail
|
||||
|
||||
▸ **retrieveRegisteredByEmail**(`email`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `email` | `string` |
|
||||
| `config` | `FindConfig`<`Customer`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:239](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L239)
|
||||
|
||||
___
|
||||
|
||||
### retrieveUnregisteredByEmail
|
||||
|
||||
▸ **retrieveUnregisteredByEmail**(`email`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `email` | `string` |
|
||||
| `config` | `FindConfig`<`Customer`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:230](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L230)
|
||||
|
||||
___
|
||||
|
||||
### retrieve\_
|
||||
|
||||
▸ `Private` **retrieve_**(`selector`, `config?`): `Promise`<`Customer`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`Customer`\> |
|
||||
| `config` | `FindConfig`<`Customer`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:185](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L185)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`customerId`, `update`): `Promise`<`Customer`\>
|
||||
|
||||
Updates a customer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customerId` | `string` | the id of the variant. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `UpdateCustomerInput` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Customer`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:362](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L362)
|
||||
|
||||
___
|
||||
|
||||
### updateAddress
|
||||
|
||||
▸ **updateAddress**(`customerId`, `addressId`, `address`): `Promise`<`Address`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `string` |
|
||||
| `addressId` | `string` |
|
||||
| `address` | `StorePostCustomersCustomerAddressesAddressReq` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Address`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:474](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L474)
|
||||
|
||||
___
|
||||
|
||||
### updateBillingAddress\_
|
||||
|
||||
▸ **updateBillingAddress_**(`customer`, `addressOrId`): `Promise`<`void`\>
|
||||
|
||||
Updates the customers' billing address.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `customer` | `Customer` | the Customer to update |
|
||||
| `addressOrId` | `undefined` \| `string` \| `DeepPartial`<`Address`\> | the value to set the billing address to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/customer.ts:422](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/customer.ts#L422)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,328 @@
|
||||
# Class: DiscountConditionService
|
||||
|
||||
Provides layer to manipulate discount conditions.
|
||||
|
||||
**`Implements`**
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`DiscountConditionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new DiscountConditionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L34)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### discountConditionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **discountConditionRepository\_**: `Repository`<`DiscountCondition`\> & { `addConditionResources`: (`conditionId`: `string`, `resourceIds`: (`string` \| { `id`: `string` })[], `type`: `DiscountConditionType`, `overrideExisting`: `boolean`) => `Promise`<(`DiscountConditionProduct` \| `DiscountConditionProductType` \| `DiscountConditionProductCollection` \| `DiscountConditionProductTag` \| `DiscountConditionCustomerGroup`)[]\> ; `canApplyForCustomer`: (`discountRuleId`: `string`, `customerId`: `string`) => `Promise`<`boolean`\> ; `findOneWithDiscount`: (`conditionId`: `string`, `discountId`: `string`) => `Promise`<`undefined` \| `DiscountCondition` & { `discount`: `Discount` }\> ; `getJoinTableResourceIdentifiers`: (`type`: `string`) => { `conditionTable`: `DiscountConditionResourceType` ; `joinTable`: `string` ; `joinTableForeignKey`: `DiscountConditionJoinTableForeignKey` ; `joinTableKey`: `string` ; `resourceKey`: `string` } ; `isValidForProduct`: (`discountRuleId`: `string`, `productId`: `string`) => `Promise`<`boolean`\> ; `queryConditionTable`: (`__namedParameters`: `Object`) => `Promise`<`number`\> ; `removeConditionResources`: (`id`: `string`, `type`: `DiscountConditionType`, `resourceIds`: (`string` \| { `id`: `string` })[]) => `Promise`<`void` \| `DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:31](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:32](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`discountConditionId`): `Promise`<`void` \| `DiscountCondition`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountConditionId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `DiscountCondition`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:217](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L217)
|
||||
|
||||
___
|
||||
|
||||
### removeResources
|
||||
|
||||
▸ **removeResources**(`data`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `Omit`<`DiscountConditionInput`, ``"id"``\> & { `id`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:184](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L184)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`conditionId`, `config?`): `Promise`<`DiscountCondition`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `conditionId` | `string` |
|
||||
| `config?` | `FindConfig`<`DiscountCondition`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DiscountCondition`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### upsertCondition
|
||||
|
||||
▸ **upsertCondition**(`data`, `overrideExisting?`): `Promise`<(`DiscountConditionProduct` \| `DiscountConditionProductType` \| `DiscountConditionProductCollection` \| `DiscountConditionProductTag` \| `DiscountConditionCustomerGroup`)[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `DiscountConditionInput` | `undefined` |
|
||||
| `overrideExisting` | `boolean` | `true` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`DiscountConditionProduct` \| `DiscountConditionProductType` \| `DiscountConditionProductCollection` \| `DiscountConditionProductTag` \| `DiscountConditionCustomerGroup`)[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:111](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L111)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`DiscountConditionService`](DiscountConditionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`DiscountConditionService`](DiscountConditionService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### resolveConditionType\_
|
||||
|
||||
▸ `Static` `Protected` **resolveConditionType_**(`data`): `undefined` \| { `resource_ids`: (`string` \| { `id`: `string` })[] ; `type`: `DiscountConditionType` }
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `DiscountConditionInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`undefined` \| { `resource_ids`: (`string` \| { `id`: `string` })[] ; `type`: `DiscountConditionType` }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount-condition.ts:74](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount-condition.ts#L74)
|
||||
@@ -0,0 +1,857 @@
|
||||
# Class: DiscountService
|
||||
|
||||
Provides layer to manipulate discounts.
|
||||
|
||||
**`Implements`**
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`DiscountService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new DiscountService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:71](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L71)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customerService\_
|
||||
|
||||
• `Protected` `Readonly` **customerService\_**: [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### discountConditionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **discountConditionRepository\_**: `Repository`<`DiscountCondition`\> & { `addConditionResources`: (`conditionId`: `string`, `resourceIds`: (`string` \| { `id`: `string` })[], `type`: `DiscountConditionType`, `overrideExisting`: `boolean`) => `Promise`<(`DiscountConditionProduct` \| `DiscountConditionProductType` \| `DiscountConditionProductCollection` \| `DiscountConditionProductTag` \| `DiscountConditionCustomerGroup`)[]\> ; `canApplyForCustomer`: (`discountRuleId`: `string`, `customerId`: `string`) => `Promise`<`boolean`\> ; `findOneWithDiscount`: (`conditionId`: `string`, `discountId`: `string`) => `Promise`<`undefined` \| `DiscountCondition` & { `discount`: `Discount` }\> ; `getJoinTableResourceIdentifiers`: (`type`: `string`) => { `conditionTable`: `DiscountConditionResourceType` ; `joinTable`: `string` ; `joinTableForeignKey`: `DiscountConditionJoinTableForeignKey` ; `joinTableKey`: `string` ; `resourceKey`: `string` } ; `isValidForProduct`: (`discountRuleId`: `string`, `productId`: `string`) => `Promise`<`boolean`\> ; `queryConditionTable`: (`__namedParameters`: `Object`) => `Promise`<`number`\> ; `removeConditionResources`: (`id`: `string`, `type`: `DiscountConditionType`, `resourceIds`: (`string` \| { `id`: `string` })[]) => `Promise`<`void` \| `DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:62](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### discountConditionService\_
|
||||
|
||||
• `Protected` `Readonly` **discountConditionService\_**: [`DiscountConditionService`](DiscountConditionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:63](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
### discountRepository\_
|
||||
|
||||
• `Protected` `Readonly` **discountRepository\_**: `Repository`<`Discount`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:57](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### discountRuleRepository\_
|
||||
|
||||
• `Protected` `Readonly` **discountRuleRepository\_**: `Repository`<`DiscountRule`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L59)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### giftCardRepository\_
|
||||
|
||||
• `Protected` `Readonly` **giftCardRepository\_**: `Repository`<`GiftCard`\> & { `listGiftCardsAndCount`: (`query`: `ExtendedFindConfig`<`GiftCard`\>, `q?`: `string`) => `Promise`<[`GiftCard`[], `number`]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### newTotalsService\_
|
||||
|
||||
• `Protected` `Readonly` **newTotalsService\_**: [`NewTotalsService`](NewTotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:66](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L64)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addRegion
|
||||
|
||||
▸ **addRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
||||
|
||||
Adds a region to the discount regions array.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount |
|
||||
| `regionId` | `string` | id of region to add |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:503](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L503)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### calculateDiscountForLineItem
|
||||
|
||||
▸ **calculateDiscountForLineItem**(`discountId`, `lineItem`, `calculationContextData`): `Promise`<`number`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountId` | `string` |
|
||||
| `lineItem` | `LineItem` |
|
||||
| `calculationContextData` | `CalculationContextData` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:605](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L605)
|
||||
|
||||
___
|
||||
|
||||
### canApplyForCustomer
|
||||
|
||||
▸ **canApplyForCustomer**(`discountRuleId`, `customerId`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountRuleId` | `string` |
|
||||
| `customerId` | `undefined` \| `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:797](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L797)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`discount`): `Promise`<`Discount`\>
|
||||
|
||||
Creates a discount with provided data given that the data is validated.
|
||||
Normalizes discount code to uppercase.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discount` | `CreateDiscountInput` | the discount data to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:178](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L178)
|
||||
|
||||
___
|
||||
|
||||
### createDynamicCode
|
||||
|
||||
▸ **createDynamicCode**(`discountId`, `data`): `Promise`<`Discount`\>
|
||||
|
||||
Creates a dynamic code for a discount id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | the id of the discount to create a code for |
|
||||
| `data` | `CreateDynamicDiscountInput` | the object containing a code to identify the discount by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the newly created dynamic code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:431](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L431)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`discountId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a discount idempotently
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:563](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L563)
|
||||
|
||||
___
|
||||
|
||||
### deleteDynamicCode
|
||||
|
||||
▸ **deleteDynamicCode**(`discountId`, `code`): `Promise`<`void`\>
|
||||
|
||||
Deletes a dynamic code for a discount id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | the id of the discount to create a code for |
|
||||
| `code` | `string` | the code to identify the discount by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the newly created dynamic code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:482](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L482)
|
||||
|
||||
___
|
||||
|
||||
### hasCustomersGroupCondition
|
||||
|
||||
▸ **hasCustomersGroupCondition**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:750](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L750)
|
||||
|
||||
___
|
||||
|
||||
### hasExpired
|
||||
|
||||
▸ **hasExpired**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:766](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L766)
|
||||
|
||||
___
|
||||
|
||||
### hasNotStarted
|
||||
|
||||
▸ **hasNotStarted**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:762](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L762)
|
||||
|
||||
___
|
||||
|
||||
### hasReachedLimit
|
||||
|
||||
▸ **hasReachedLimit**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:756](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L756)
|
||||
|
||||
___
|
||||
|
||||
### isDisabled
|
||||
|
||||
▸ **isDisabled**(`discount`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:774](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L774)
|
||||
|
||||
___
|
||||
|
||||
### isValidForRegion
|
||||
|
||||
▸ **isValidForRegion**(`discount`, `region_id`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discount` | `Discount` |
|
||||
| `region_id` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:778](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L778)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`Discount`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableDiscountProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:125](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L125)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`Discount`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableDiscountProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Discount`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:142](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L142)
|
||||
|
||||
___
|
||||
|
||||
### listByCodes
|
||||
|
||||
▸ **listByCodes**(`discountCodes`, `config?`): `Promise`<`Discount`[]\>
|
||||
|
||||
List all the discounts corresponding to the given codes
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountCodes` | `string`[] | discount codes of discounts to retrieve |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`[]\>
|
||||
|
||||
the discounts
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:307](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L307)
|
||||
|
||||
___
|
||||
|
||||
### removeRegion
|
||||
|
||||
▸ **removeRegion**(`discountId`, `regionId`): `Promise`<`Discount`\>
|
||||
|
||||
Removes a region from the discount regions array.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount |
|
||||
| `regionId` | `string` | id of region to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:538](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L538)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`discountId`, `config?`): `Promise`<`Discount`\>
|
||||
|
||||
Gets a discount by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | id of discount to retrieve |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:244](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L244)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCode
|
||||
|
||||
▸ **retrieveByCode**(`discountCode`, `config?`): `Promise`<`Discount`\>
|
||||
|
||||
Gets the discount by discount code.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountCode` | `string` | discount code of discount to retrieve |
|
||||
| `config` | `FindConfig`<`Discount`\> | the config object containing query settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:278](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L278)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`discountId`, `update`): `Promise`<`Discount`\>
|
||||
|
||||
Updates a discount.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountId` | `string` | discount id of discount to update |
|
||||
| `update` | `UpdateDiscountInput` | the data to update the discount with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Discount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:338](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L338)
|
||||
|
||||
___
|
||||
|
||||
### validateDiscountForCartOrThrow
|
||||
|
||||
▸ **validateDiscountForCartOrThrow**(`cart`, `discount`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cart` | `Cart` |
|
||||
| `discount` | `Discount` \| `Discount`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:678](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L678)
|
||||
|
||||
___
|
||||
|
||||
### validateDiscountForProduct
|
||||
|
||||
▸ **validateDiscountForProduct**(`discountRuleId`, `productId`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `discountRuleId` | `string` |
|
||||
| `productId` | `undefined` \| `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:577](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L577)
|
||||
|
||||
___
|
||||
|
||||
### validateDiscountRule\_
|
||||
|
||||
▸ **validateDiscountRule_**<`T`\>(`discountRule`): `T`
|
||||
|
||||
Creates a discount rule with provided data given that the data is validated.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | extends `Object` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discountRule` | `T` | the discount rule to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`T`
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/discount.ts:107](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/discount.ts#L107)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`DiscountService`](DiscountService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`DiscountService`](DiscountService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,512 @@
|
||||
# Class: DraftOrderService
|
||||
|
||||
Handles draft orders
|
||||
|
||||
**`Implements`**
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`DraftOrderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new DraftOrderService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L67)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### cartService\_
|
||||
|
||||
• `Protected` `Readonly` **cartService\_**: [`CartService`](CartService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:61](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L61)
|
||||
|
||||
___
|
||||
|
||||
### customShippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **customShippingOptionService\_**: [`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### draftOrderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **draftOrderRepository\_**: `Repository`<`DraftOrder`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:57](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:62](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### orderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **orderRepository\_**: `Repository`<`Order`\> & { `findOneWithRelations`: (`relations`: `FindOptionsRelations`<`Order`\>, `optionsWithoutRelations`: `Omit`<`FindManyOptions`<`Order`\>, ``"relations"``\>) => `Promise`<`Order`\> ; `findWithRelations`: (`relations`: `FindOptionsRelations`<`Order`\>, `optionsWithoutRelations`: `Omit`<`FindManyOptions`<`Order`\>, ``"relations"``\>) => `Promise`<`Order`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L59)
|
||||
|
||||
___
|
||||
|
||||
### paymentRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentRepository\_**: `Repository`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### productVariantService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:63](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L64)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L52)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Creates a draft order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `DraftOrderCreateProps` | data to create draft order from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the created draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:260](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L260)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`draftOrderId`): `Promise`<`undefined` \| `DraftOrder`\>
|
||||
|
||||
Deletes draft order idempotently.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `draftOrderId` | `string` | id of draft order to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `DraftOrder`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:156](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L156)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`DraftOrder`[]\>
|
||||
|
||||
Lists draft orders
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | query object for find |
|
||||
| `config` | `FindConfig`<`DraftOrder`\> | configurable attributes for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`[]\>
|
||||
|
||||
list of draft orders
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:238](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L238)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`DraftOrder`[], `number`]\>
|
||||
|
||||
Lists draft orders alongside the count
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `any` | query selector to filter draft orders |
|
||||
| `config` | `FindConfig`<`DraftOrder`\> | query config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`DraftOrder`[], `number`]\>
|
||||
|
||||
draft orders
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:180](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L180)
|
||||
|
||||
___
|
||||
|
||||
### registerCartCompletion
|
||||
|
||||
▸ **registerCartCompletion**(`draftOrderId`, `orderId`): `Promise`<`UpdateResult`\>
|
||||
|
||||
Registers a draft order as completed, when an order has been completed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `draftOrderId` | `string` | id of draft order to complete |
|
||||
| `orderId` | `string` | id of order completed from draft order cart |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`UpdateResult`\>
|
||||
|
||||
the created order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:420](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L420)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`draftOrderId`, `config?`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Retrieves a draft order with the given id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `draftOrderId` | `string` | id of the draft order to retrieve |
|
||||
| `config` | `FindConfig`<`DraftOrder`\> | query object for findOne |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:98](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L98)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCartId
|
||||
|
||||
▸ **retrieveByCartId**(`cartId`, `config?`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Retrieves a draft order based on its associated cart id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartId` | `string` | cart id that the draft orders's cart has |
|
||||
| `config` | `FindConfig`<`DraftOrder`\> | query object for findOne |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:131](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L131)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`DraftOrder`\>
|
||||
|
||||
Updates a draft order with the given data
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the draft order |
|
||||
| `data` | `Object` | values to update the order with |
|
||||
| `data.no_notification_order` | `boolean` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DraftOrder`\>
|
||||
|
||||
the updated draft order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/draft-order.ts:449](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/draft-order.ts#L449)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`DraftOrderService`](DraftOrderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`DraftOrderService`](DraftOrderService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,433 @@
|
||||
# Class: EventBusService
|
||||
|
||||
Can keep track of multiple subscribers to different events and run the
|
||||
subscribers when events happen. Events will run asynchronously.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`EventBusService`**
|
||||
|
||||
## Implements
|
||||
|
||||
- `IEventBusService`
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new EventBusService**(`__namedParameters`, `config`, `isSingleton?`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` | `undefined` |
|
||||
| `config` | `any` | `undefined` |
|
||||
| `isSingleton` | `boolean` | `true` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:32](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L32)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### config\_
|
||||
|
||||
• `Protected` `Readonly` **config\_**: `ConfigModule`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### enqueue\_
|
||||
|
||||
• `Protected` **enqueue\_**: `Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:30](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L30)
|
||||
|
||||
___
|
||||
|
||||
### eventBusModuleService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusModuleService\_**: `IEventBusModuleService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:27](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L27)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### shouldEnqueuerRun
|
||||
|
||||
• `Protected` **shouldEnqueuerRun**: `boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### stagedJobService\_
|
||||
|
||||
• `Protected` `Readonly` **stagedJobService\_**: [`StagedJobService`](StagedJobService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### emit
|
||||
|
||||
▸ **emit**<`T`\>(`data`): `Promise`<`void` \| `StagedJob`[]\>
|
||||
|
||||
Calls all subscribers when an event occurs.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `EmitData`<`T`\>[] | The data to use to process the events |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `StagedJob`[]\>
|
||||
|
||||
the jobs from our queue
|
||||
|
||||
#### Implementation of
|
||||
|
||||
EventBusTypes.IEventBusService.emit
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:112](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L112)
|
||||
|
||||
▸ **emit**<`T`\>(`eventName`, `data`, `options?`): `Promise`<`void` \| `StagedJob`\>
|
||||
|
||||
Calls all subscribers when an event occurs.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the name of the event to be process. |
|
||||
| `data` | `T` | the data to send to the subscriber. |
|
||||
| `options?` | `Record`<`string`, `unknown`\> | options to add the job with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `StagedJob`\>
|
||||
|
||||
the job from our queue
|
||||
|
||||
#### Implementation of
|
||||
|
||||
EventBusTypes.IEventBusService.emit
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:121](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L121)
|
||||
|
||||
___
|
||||
|
||||
### enqueuer\_
|
||||
|
||||
▸ **enqueuer_**(): `Promise`<`void`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:185](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L185)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### startEnqueuer
|
||||
|
||||
▸ **startEnqueuer**(): `void`
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:175](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L175)
|
||||
|
||||
___
|
||||
|
||||
### stopEnqueuer
|
||||
|
||||
▸ **stopEnqueuer**(): `Promise`<`void`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:180](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L180)
|
||||
|
||||
___
|
||||
|
||||
### subscribe
|
||||
|
||||
▸ **subscribe**(`event`, `subscriber`, `context?`): [`EventBusService`](EventBusService.md)
|
||||
|
||||
Adds a function to a list of event subscribers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` \| `symbol` | the event that the subscriber will listen for. |
|
||||
| `subscriber` | `Subscriber`<`unknown`\> | the function to be called when a certain event happens. Subscribers must return a Promise. |
|
||||
| `context?` | `SubscriberContext` | subscriber context |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`EventBusService`](EventBusService.md)
|
||||
|
||||
this
|
||||
|
||||
#### Implementation of
|
||||
|
||||
EventBusTypes.IEventBusService.subscribe
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:78](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### unsubscribe
|
||||
|
||||
▸ **unsubscribe**(`event`, `subscriber`, `context`): [`EventBusService`](EventBusService.md)
|
||||
|
||||
Removes function from the list of event subscribers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` \| `symbol` | the event of the subcriber. |
|
||||
| `subscriber` | `Subscriber`<`unknown`\> | the function to be removed |
|
||||
| `context` | `SubscriberContext` | subscriber context |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`EventBusService`](EventBusService.md)
|
||||
|
||||
this
|
||||
|
||||
#### Implementation of
|
||||
|
||||
EventBusTypes.IEventBusService.unsubscribe
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:98](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L98)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Implementation of
|
||||
|
||||
EventBusTypes.IEventBusService.withTransaction
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/event-bus.ts:49](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/event-bus.ts#L49)
|
||||
@@ -0,0 +1,473 @@
|
||||
# Class: FulfillmentProviderService
|
||||
|
||||
Helps retrive fulfillment providers
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`FulfillmentProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new FulfillmentProviderService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `FulfillmentProviderContainer` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:44](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L44)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### container\_
|
||||
|
||||
• `Protected` `Readonly` **container\_**: `FulfillmentProviderContainer`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentProviderRepository\_**: `Repository`<`FulfillmentProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### calculatePrice
|
||||
|
||||
▸ **calculatePrice**(`option`, `data`, `cart?`): `Promise`<`number`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `ShippingOption` |
|
||||
| `data` | `Record`<`string`, `unknown`\> |
|
||||
| `cart?` | `Order` \| `Cart` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:147](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
### canCalculate
|
||||
|
||||
▸ **canCalculate**(`option`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `CalculateOptionPriceInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:122](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L122)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillment`): `Promise`<`Fulfillment`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `fulfillment` | `Fulfillment` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Fulfillment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:140](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L140)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`method`, `items`, `order`, `fulfillment`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `method` | `ShippingMethod` |
|
||||
| `items` | `LineItem`[] |
|
||||
| `order` | `CreateFulfillmentOrder` |
|
||||
| `fulfillment` | `Omit`<`Fulfillment`, ``"beforeInsert"``\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:107](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L107)
|
||||
|
||||
___
|
||||
|
||||
### createReturn
|
||||
|
||||
▸ **createReturn**(`returnOrder`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnOrder` | `CreateReturnType` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:165](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L165)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(): `Promise`<`FulfillmentProvider`[]\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`FulfillmentProvider`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### listFulfillmentOptions
|
||||
|
||||
▸ **listFulfillmentOptions**(`providerIds`): `Promise`<`FulfillmentOptions`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providerIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`FulfillmentOptions`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:75](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L75)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providers` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:53](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### retrieveDocuments
|
||||
|
||||
▸ **retrieveDocuments**(`providerId`, `fulfillmentData`, `documentType`): `Promise`<`any`\>
|
||||
|
||||
Fetches documents from the fulfillment provider
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerId` | `string` | the id of the provider |
|
||||
| `fulfillmentData` | `Record`<`string`, `unknown`\> | the data relating to the fulfillment |
|
||||
| `documentType` | ``"label"`` \| ``"invoice"`` | the typ of |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
document to fetch
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:184](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L184)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider
|
||||
|
||||
▸ **retrieveProvider**(`providerId`): `any`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerId` | `string` | the provider id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
the payment fulfillment provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:96](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L96)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### validateFulfillmentData
|
||||
|
||||
▸ **validateFulfillmentData**(`option`, `data`, `cart`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `ShippingOption` |
|
||||
| `data` | `Record`<`string`, `unknown`\> |
|
||||
| `cart` | `Record`<`string`, `unknown`\> \| `Cart` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:127](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L127)
|
||||
|
||||
___
|
||||
|
||||
### validateOption
|
||||
|
||||
▸ **validateOption**(`option`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `ShippingOption` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment-provider.ts:160](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment-provider.ts#L160)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,466 @@
|
||||
# Class: FulfillmentService
|
||||
|
||||
Handles Fulfillments
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`FulfillmentService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new FulfillmentService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:47](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L47)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentProviderService\_**: [`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentRepository\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentRepository\_**: `Repository`<`Fulfillment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:41](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### lineItemRepository\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemRepository\_**: `Repository`<`LineItem`\> & { `findByReturn`: (`returnId`: `string`) => `Promise`<`LineItem` & { `return_item`: `ReturnItem` }[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### productVariantInventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantInventoryService\_**: [`ProductVariantInventoryService`](ProductVariantInventoryService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### shippingProfileService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingProfileService\_**: [`ShippingProfileService`](ShippingProfileService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### trackingLinkRepository\_
|
||||
|
||||
• `Protected` `Readonly` **trackingLinkRepository\_**: `Repository`<`TrackingLink`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentOrId` | `string` \| `Fulfillment` | the fulfillment object or id. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Fulfillment`\>
|
||||
|
||||
the result of the save operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:260](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L260)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `CreateFulfillmentOrder` | order to create fulfillment for |
|
||||
| `itemsToFulfill` | `FulFillmentItemType`[] | the items in the order to fulfill |
|
||||
| `custom` | `Partial`<`Fulfillment`\> | potential custom values to add |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Fulfillment`[]\>
|
||||
|
||||
the created fulfillments
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:205](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L205)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`fulfillmentId`, `trackingLinks?`, `config?`): `Promise`<`Fulfillment`\>
|
||||
|
||||
Creates a shipment by marking a fulfillment as shipped. Adds
|
||||
tracking links and potentially more metadata.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentId` | `string` | the fulfillment to ship |
|
||||
| `trackingLinks?` | { `tracking_number`: `string` }[] | tracking links for the shipment |
|
||||
| `config` | `CreateShipmentConfig` | potential configuration settings, such as no_notification and metadata |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Fulfillment`\>
|
||||
|
||||
the shipped fulfillment
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:312](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L312)
|
||||
|
||||
___
|
||||
|
||||
### getFulfillmentItems\_
|
||||
|
||||
▸ **getFulfillmentItems_**(`order`, `items`): `Promise`<(``null`` \| `LineItem`)[]\>
|
||||
|
||||
Retrieves the order line items, given an array of items.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `CreateFulfillmentOrder` | the order to get line items from |
|
||||
| `items` | `FulFillmentItemType`[] | the items to get |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(``null`` \| `LineItem`)[]\>
|
||||
|
||||
the line items generated by the transformer.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:109](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L109)
|
||||
|
||||
___
|
||||
|
||||
### partitionItems\_
|
||||
|
||||
▸ **partitionItems_**(`shippingMethods`, `items`): `FulfillmentItemPartition`[]
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingMethods` | `ShippingMethod`[] |
|
||||
| `items` | `LineItem`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`FulfillmentItemPartition`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:70](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`fulfillmentId`, `config?`): `Promise`<`Fulfillment`\>
|
||||
|
||||
Retrieves a fulfillment by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentId` | `string` | the id of the fulfillment to retrieve |
|
||||
| `config` | `FindConfig`<`Fulfillment`\> | optional values to include with fulfillmentRepository query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Fulfillment`\>
|
||||
|
||||
the fulfillment
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:167](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L167)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### validateFulfillmentLineItem\_
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `item` | `undefined` \| `LineItem` | the line item to check has sufficient fulfillable quantity. |
|
||||
| `quantity` | `number` | the quantity that is requested to be fulfilled. |
|
||||
|
||||
#### Returns
|
||||
|
||||
``null`` \| `LineItem`
|
||||
|
||||
a line item that has the requested fulfillment quantity
|
||||
set.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/fulfillment.ts:134](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/fulfillment.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`FulfillmentService`](FulfillmentService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`FulfillmentService`](FulfillmentService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,510 @@
|
||||
# Class: GiftCardService
|
||||
|
||||
Provides layer to manipulate gift cards.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`GiftCardService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new GiftCardService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L39)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:33](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
### giftCardRepository\_
|
||||
|
||||
• `Protected` `Readonly` **giftCardRepository\_**: `Repository`<`GiftCard`\> & { `listGiftCardsAndCount`: (`query`: `ExtendedFindConfig`<`GiftCard`\>, `q?`: `string`) => `Promise`<[`GiftCard`[], `number`]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### giftCardTransactionRepo\_
|
||||
|
||||
• `Protected` `Readonly` **giftCardTransactionRepo\_**: `Repository`<`GiftCardTransaction`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:31](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:32](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:35](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L35)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`giftCard`): `Promise`<`GiftCard`\>
|
||||
|
||||
Creates a gift card with provided data given that the data is validated.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCard` | `CreateGiftCardInput` | the gift card data to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:122](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L122)
|
||||
|
||||
___
|
||||
|
||||
### createTransaction
|
||||
|
||||
▸ **createTransaction**(`data`): `Promise`<`string`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateGiftCardTransactionInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:106](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L106)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`giftCardId`): `Promise`<`void` \| `GiftCard`\>
|
||||
|
||||
Deletes a gift card idempotently
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCardId` | `string` | id of gift card to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `GiftCard`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:295](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L295)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`GiftCard`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `QuerySelector`<`GiftCard`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`GiftCard`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:98](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L98)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`GiftCard`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `QuerySelector`<`GiftCard`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`GiftCard`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`GiftCard`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:74](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L74)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`giftCardId`, `config?`): `Promise`<`GiftCard`\>
|
||||
|
||||
Gets a gift card by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCardId` | `string` | id of gift card to retrieve |
|
||||
| `config` | `FindConfig`<`GiftCard`\> | optional values to include with gift card query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
the gift card
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:215](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L215)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCode
|
||||
|
||||
▸ **retrieveByCode**(`code`, `config?`): `Promise`<`GiftCard`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `code` | `string` |
|
||||
| `config` | `FindConfig`<`GiftCard`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:229](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L229)
|
||||
|
||||
___
|
||||
|
||||
### retrieve\_
|
||||
|
||||
▸ `Protected` **retrieve_**(`selector`, `config?`): `Promise`<`GiftCard`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`GiftCard`\> |
|
||||
| `config` | `FindConfig`<`GiftCard`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:182](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L182)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`giftCardId`, `update`): `Promise`<`GiftCard`\>
|
||||
|
||||
Updates a giftCard.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `giftCardId` | `string` | giftCard id of giftCard to update |
|
||||
| `update` | `UpdateGiftCardInput` | the data to update the giftCard with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GiftCard`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:249](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L249)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`GiftCardService`](GiftCardService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`GiftCardService`](GiftCardService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### generateCode
|
||||
|
||||
▸ `Static` **generateCode**(): `string`
|
||||
|
||||
Generates a 16 character gift card code
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the generated gift card code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### resolveTaxRate
|
||||
|
||||
▸ `Static` `Protected` **resolveTaxRate**(`giftCardTaxRate`, `region`): ``null`` \| `number`
|
||||
|
||||
The tax_rate of the giftcard can depend on whether regions tax gift cards, an input
|
||||
provided by the user or the tax rate. Based on these conditions, tax_rate changes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `giftCardTaxRate` | ``null`` \| `number` |
|
||||
| `region` | `Region` |
|
||||
|
||||
#### Returns
|
||||
|
||||
``null`` \| `number`
|
||||
|
||||
the tax rate for the gift card
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/gift-card.ts:161](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/gift-card.ts#L161)
|
||||
@@ -0,0 +1,367 @@
|
||||
# Class: IdempotencyKeyService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`IdempotencyKeyService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new IdempotencyKeyService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L25)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### idempotencyKeyRepository\_
|
||||
|
||||
• `Protected` `Readonly` **idempotencyKeyRepository\_**: `Repository`<`IdempotencyKey`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:23](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L23)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`payload`): `Promise`<`IdempotencyKey`\>
|
||||
|
||||
Creates an idempotency key for a request.
|
||||
If no idempotency key is provided in request, we will create a unique
|
||||
identifier.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `payload` | `CreateIdempotencyKeyInput` | payload of request to create idempotency key for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKey`\>
|
||||
|
||||
the created idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### initializeRequest
|
||||
|
||||
▸ **initializeRequest**(`headerKey`, `reqMethod`, `reqParams`, `reqPath`): `Promise`<`IdempotencyKey`\>
|
||||
|
||||
Execute the initial steps in a idempotent request.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `headerKey` | `string` | potential idempotency key from header |
|
||||
| `reqMethod` | `string` | method of request |
|
||||
| `reqParams` | `Record`<`string`, `unknown`\> | params of request |
|
||||
| `reqPath` | `string` | path of request |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKey`\>
|
||||
|
||||
the existing or created idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### lock
|
||||
|
||||
▸ **lock**(`idempotencyKey`): `Promise`<`IdempotencyKey`\>
|
||||
|
||||
Locks an idempotency.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | key to lock |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKey`\>
|
||||
|
||||
result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:138](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L138)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`idempotencyKeyOrSelector`): `Promise`<`IdempotencyKey`\>
|
||||
|
||||
Retrieves an idempotency key
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKeyOrSelector` | `string` \| `Selector`<`IdempotencyKey`\> | key or selector to retrieve |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKey`\>
|
||||
|
||||
idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:86](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L86)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`idempotencyKey`, `update`): `Promise`<`IdempotencyKey`\>
|
||||
|
||||
Locks an idempotency.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | key to update |
|
||||
| `update` | `DeepPartial`<`IdempotencyKey`\> | update object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKey`\>
|
||||
|
||||
result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:167](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L167)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`IdempotencyKeyService`](IdempotencyKeyService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`IdempotencyKeyService`](IdempotencyKeyService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### workStage
|
||||
|
||||
▸ **workStage**(`idempotencyKey`, `callback`): `Promise`<`IdempotencyKey`\>
|
||||
|
||||
Performs an atomic work stage.
|
||||
An atomic work stage contains some related functionality, that needs to be
|
||||
transactionally executed in isolation. An idempotent request will
|
||||
always consist of 2 or more of these phases. The required phases are
|
||||
"started" and "finished".
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idempotencyKey` | `string` | current idempotency key |
|
||||
| `callback` | (`transactionManager`: `EntityManager`) => `Promise`<`IdempotencyCallbackResult`\> | functionality to execute within the phase |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IdempotencyKey`\>
|
||||
|
||||
new updated idempotency key
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/idempotency-key.ts:196](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/idempotency-key.ts#L196)
|
||||
@@ -0,0 +1,424 @@
|
||||
# Class: LineItemAdjustmentService
|
||||
|
||||
Provides layer to manipulate line item adjustments.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`LineItemAdjustmentService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new LineItemAdjustmentService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `LineItemAdjustmentServiceProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:36](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L36)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### discountService
|
||||
|
||||
• `Private` `Readonly` **discountService**: [`DiscountService`](DiscountService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### lineItemAdjustmentRepo\_
|
||||
|
||||
• `Private` `Readonly` **lineItemAdjustmentRepo\_**: `Repository`<`LineItemAdjustment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:33](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`LineItemAdjustment`\>
|
||||
|
||||
Creates a line item adjustment
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `Partial`<`LineItemAdjustment`\> | the line item adjustment to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemAdjustment`\>
|
||||
|
||||
line item adjustment
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:86](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L86)
|
||||
|
||||
___
|
||||
|
||||
### createAdjustmentForLineItem
|
||||
|
||||
▸ **createAdjustmentForLineItem**(`cart`, `lineItem`): `Promise`<`LineItemAdjustment`[]\>
|
||||
|
||||
Creates adjustment for a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cart` | `Cart` | the cart object holding discounts |
|
||||
| `lineItem` | `LineItem` | the line item for which a line item adjustment might be created |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemAdjustment`[]\>
|
||||
|
||||
a line item adjustment or undefined if no adjustment was created
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:262](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L262)
|
||||
|
||||
___
|
||||
|
||||
### createAdjustments
|
||||
|
||||
▸ **createAdjustments**(`cart`, `lineItem?`): `Promise`<`LineItemAdjustment`[] \| `LineItemAdjustment`[][]\>
|
||||
|
||||
Creates adjustment for a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cart` | `Cart` | the cart object holding discounts |
|
||||
| `lineItem?` | `LineItem` | the line item for which a line item adjustment might be created |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemAdjustment`[] \| `LineItemAdjustment`[][]\>
|
||||
|
||||
if a lineItem was given, returns a line item adjustment or undefined if no adjustment was created
|
||||
otherwise returns an array of line item adjustments for each line item in the cart
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:290](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L290)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`selectorOrIds`): `Promise`<`void`\>
|
||||
|
||||
Deletes line item adjustments matching a selector
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selectorOrIds` | `string` \| `string`[] \| `FilterableLineItemAdjustmentProps` & { `discount_id?`: `FindOperator`<``null`` \| `string`\> } | the query object for find or the line item adjustment id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:153](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L153)
|
||||
|
||||
___
|
||||
|
||||
### generateAdjustments
|
||||
|
||||
▸ **generateAdjustments**(`calculationContextData`, `generatedLineItem`, `context`): `Promise`<`GeneratedAdjustment`[]\>
|
||||
|
||||
Creates adjustment for a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `calculationContextData` | `CalculationContextData` | the calculationContextData object holding discounts |
|
||||
| `generatedLineItem` | `LineItem` | the line item for which a line item adjustment might be created |
|
||||
| `context` | `AdjustmentContext` | the line item for which a line item adjustment might be created |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`GeneratedAdjustment`[]\>
|
||||
|
||||
a line item adjustment or undefined if no adjustment was created
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:188](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L188)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`LineItemAdjustment`[]\>
|
||||
|
||||
Lists line item adjustments
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableLineItemAdjustmentProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`LineItemAdjustment`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemAdjustment`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:136](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L136)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`lineItemAdjustmentId`, `config?`): `Promise`<`LineItemAdjustment`\>
|
||||
|
||||
Retrieves a line item adjustment by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItemAdjustmentId` | `string` | the id of the line item adjustment to retrieve |
|
||||
| `config` | `FindConfig`<`LineItemAdjustment`\> | the config to retrieve the line item adjustment by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemAdjustment`\>
|
||||
|
||||
the line item adjustment.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:53](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`LineItemAdjustment`\>
|
||||
|
||||
Creates a line item adjustment
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the line item adjustment id to update |
|
||||
| `data` | `Partial`<`LineItemAdjustment`\> | the line item adjustment to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemAdjustment`\>
|
||||
|
||||
line item adjustment
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item-adjustment.ts:104](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item-adjustment.ts#L104)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`LineItemAdjustmentService`](LineItemAdjustmentService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`LineItemAdjustmentService`](LineItemAdjustmentService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,619 @@
|
||||
# Class: LineItemService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`LineItemService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new LineItemService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L56)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### cartRepository\_
|
||||
|
||||
• `Protected` `Readonly` **cartRepository\_**: `Repository`<`Cart`\> & { `findOneWithRelations`: (`relations`: `FindOptionsRelations`<`Cart`\>, `optionsWithoutRelations`: `Omit`<`FindManyOptions`<`Cart`\>, ``"relations"``\>) => `Promise`<`Cart`\> ; `findWithRelations`: (`relations`: `FindOptionsRelations`<`Cart`\>, `optionsWithoutRelations`: `Omit`<`FindManyOptions`<`Cart`\>, ``"relations"``\>) => `Promise`<`Cart`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:47](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### itemTaxLineRepo\_
|
||||
|
||||
• `Protected` `Readonly` **itemTaxLineRepo\_**: `Repository`<`LineItemTaxLine`\> & { `deleteForCart`: (`cartId`: `string`) => `Promise`<`void`\> ; `upsertLines`: (`lines`: `LineItemTaxLine`[]) => `Promise`<`LineItemTaxLine`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### lineItemAdjustmentService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemAdjustmentService\_**: [`LineItemAdjustmentService`](LineItemAdjustmentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:53](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### lineItemRepository\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemRepository\_**: `Repository`<`LineItem`\> & { `findByReturn`: (`returnId`: `string`) => `Promise`<`LineItem` & { `return_item`: `ReturnItem` }[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### pricingService\_
|
||||
|
||||
• `Protected` `Readonly` **pricingService\_**: [`PricingService`](PricingService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:50](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:49](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### productVariantService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:48](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:51](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L51)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:54](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L54)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cloneTo
|
||||
|
||||
▸ **cloneTo**(`ids`, `data?`, `options?`): `Promise`<`LineItem`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `ids` | `string` \| `string`[] |
|
||||
| `data` | `DeepPartial`<`LineItem`\> |
|
||||
| `options` | `Object` |
|
||||
| `options.setOriginalLineItemId?` | `boolean` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:514](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L514)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**<`T`, `TResult`\>(`data`): `Promise`<`TResult`\>
|
||||
|
||||
Create a line item
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | `LineItem` \| `LineItem`[] |
|
||||
| `TResult` | `T` extends `LineItem`[] ? `LineItem`[] : `LineItem` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `T` | the line item object to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the created line item
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:392](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L392)
|
||||
|
||||
___
|
||||
|
||||
### createReturnLines
|
||||
|
||||
▸ **createReturnLines**(`returnId`, `cartId`): `Promise`<`LineItem`[]\>
|
||||
|
||||
Creates return line items for a given cart based on the return items in a
|
||||
return.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `returnId` | `string` | the id to generate return items from. |
|
||||
| `cartId` | `string` | the cart to assign the return line items to. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
the created line items
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:130](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L130)
|
||||
|
||||
___
|
||||
|
||||
### createTaxLine
|
||||
|
||||
▸ **createTaxLine**(`args`): `LineItemTaxLine`
|
||||
|
||||
Create a line item tax line.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `args` | `DeepPartial`<`LineItemTaxLine`\> | tax line partial passed to the repo create method |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineItemTaxLine`
|
||||
|
||||
a new line item tax line
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:506](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L506)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`id`): `Promise`<`undefined` \| ``null`` \| `LineItem`\>
|
||||
|
||||
Deletes a line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the line item to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| ``null`` \| `LineItem`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:465](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L465)
|
||||
|
||||
___
|
||||
|
||||
### deleteWithTaxLines
|
||||
|
||||
▸ **deleteWithTaxLines**(`id`): `Promise`<`undefined` \| ``null`` \| `LineItem`\>
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
no the cascade on the entity takes care of it
|
||||
Deletes a line item with the tax lines.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the line item to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| ``null`` \| `LineItem`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:485](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L485)
|
||||
|
||||
___
|
||||
|
||||
### generate
|
||||
|
||||
▸ **generate**<`T`, `TResult`\>(`variantIdOrData`, `regionIdOrContext`, `quantity?`, `context?`): `Promise`<`TResult`\>
|
||||
|
||||
Generate a single or multiple line item without persisting the data into the db
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | `string` \| `GenerateInputData` \| `GenerateInputData`[] |
|
||||
| `TResult` | `T` extends `string` ? `LineItem` : `T` extends `LineItem` ? `LineItem` : `LineItem`[] |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variantIdOrData` | `T` |
|
||||
| `regionIdOrContext` | `T` extends `string` ? `string` : `GenerateLineItemContext` |
|
||||
| `quantity?` | `number` |
|
||||
| `context` | `GenerateLineItemContext` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:191](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L191)
|
||||
|
||||
___
|
||||
|
||||
### generateLineItem
|
||||
|
||||
▸ `Protected` **generateLineItem**(`variant`, `quantity`, `context`): `Promise`<`LineItem`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variant` | `Object` |
|
||||
| `variant.id` | `string` |
|
||||
| `variant.product` | `Object` |
|
||||
| `variant.product.discountable` | `boolean` |
|
||||
| `variant.product.is_giftcard` | `boolean` |
|
||||
| `variant.product.thumbnail` | ``null`` \| `string` |
|
||||
| `variant.product.title` | `string` |
|
||||
| `variant.product_id` | `string` |
|
||||
| `variant.title` | `string` |
|
||||
| `quantity` | `number` |
|
||||
| `context` | `GenerateLineItemContext` & { `variantPricing`: `ProductVariantPricing` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:316](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L316)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`LineItem`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`LineItem`\> |
|
||||
| `config` | `FindConfig`<`LineItem`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:83](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L83)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`LineItem`\>
|
||||
|
||||
Retrieves a line item by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the line item to retrieve |
|
||||
| `config` | `Object` | the config to be used at query building |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`\>
|
||||
|
||||
the line item
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:104](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L104)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`idOrSelector`, `data`): `Promise`<`LineItem`[]\>
|
||||
|
||||
Updates a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `idOrSelector` | `string` \| `Selector`<`LineItem`\> | the id or selector of the line item(s) to update |
|
||||
| `data` | `Partial`<`LineItem`\> | the properties to update the line item(s) |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem`[]\>
|
||||
|
||||
the updated line item(s)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:422](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L422)
|
||||
|
||||
___
|
||||
|
||||
### validateGenerateArguments
|
||||
|
||||
▸ `Protected` **validateGenerateArguments**<`T`, `TResult`\>(`variantIdOrData`, `regionIdOrContext`, `quantity?`): `void`
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | `string` \| `GenerateInputData` \| `GenerateInputData`[] |
|
||||
| `TResult` | `T` extends `string` ? `LineItem` : `T` extends `LineItem` ? `LineItem` : `LineItem`[] |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variantIdOrData` | `string` \| `T` |
|
||||
| `regionIdOrContext` | `T` extends `string` ? `string` : `GenerateLineItemContext` |
|
||||
| `quantity?` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/line-item.ts:585](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/line-item.ts#L585)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,248 @@
|
||||
# Class: MiddlewareService
|
||||
|
||||
Orchestrates dynamic middleware registered through the Medusa Middleware API
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new MiddlewareService**()
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L22)
|
||||
|
||||
## Properties
|
||||
|
||||
### postAuthentication\_
|
||||
|
||||
• `Protected` `Readonly` **postAuthentication\_**: `middlewareType`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:17](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L17)
|
||||
|
||||
___
|
||||
|
||||
### preAuthentication\_
|
||||
|
||||
• `Protected` `Readonly` **preAuthentication\_**: `middlewareType`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:18](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L18)
|
||||
|
||||
___
|
||||
|
||||
### preCartCreation\_
|
||||
|
||||
• `Protected` `Readonly` **preCartCreation\_**: `RequestHandler`<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`<`string`, `any`\>\>[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:19](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L19)
|
||||
|
||||
___
|
||||
|
||||
### routers
|
||||
|
||||
• `Protected` `Readonly` **routers**: `Record`<`string`, `Router`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L20)
|
||||
|
||||
## Methods
|
||||
|
||||
### addPostAuthentication
|
||||
|
||||
▸ **addPostAuthentication**(`middleware`, `options`): `void`
|
||||
|
||||
Adds a middleware function to be called after authentication is completed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `middleware` | `middlewareHandlerType` | the middleware function. Should return a middleware function. |
|
||||
| `options` | `Record`<`string`, `unknown`\> | the arguments that will be passed to the middleware |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
void
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### addPreAuthentication
|
||||
|
||||
▸ **addPreAuthentication**(`middleware`, `options`): `void`
|
||||
|
||||
Adds a middleware function to be called before authentication is completed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `middleware` | `middlewareHandlerType` | the middleware function. Should return a middleware function. |
|
||||
| `options` | `Record`<`string`, `unknown`\> | the arguments that will be passed to the middleware |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
void
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:79](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L79)
|
||||
|
||||
___
|
||||
|
||||
### addPreCartCreation
|
||||
|
||||
▸ **addPreCartCreation**(`middleware`): `void`
|
||||
|
||||
Adds a middleware function to be called before cart creation
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `middleware` | `RequestHandler`<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`<`string`, `any`\>\> | the middleware function. Should return a middleware function. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:96](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L96)
|
||||
|
||||
___
|
||||
|
||||
### addRouter
|
||||
|
||||
▸ **addRouter**(`path`, `router`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `path` | `string` |
|
||||
| `router` | `Router` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### getRouters
|
||||
|
||||
▸ **getRouters**(`path`): `Router`[]
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `path` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Router`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### usePostAuthentication
|
||||
|
||||
▸ **usePostAuthentication**(`app`): `void`
|
||||
|
||||
Adds post authentication middleware to an express app.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `app` | `Router` | the express app to add the middleware to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:106](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L106)
|
||||
|
||||
___
|
||||
|
||||
### usePreAuthentication
|
||||
|
||||
▸ **usePreAuthentication**(`app`): `void`
|
||||
|
||||
Adds pre authentication middleware to an express app.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `app` | `Router` | the express app to add the middleware to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:117](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L117)
|
||||
|
||||
___
|
||||
|
||||
### usePreCartCreation
|
||||
|
||||
▸ **usePreCartCreation**(): `RequestHandler`<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`<`string`, `any`\>\>[]
|
||||
|
||||
#### Returns
|
||||
|
||||
`RequestHandler`<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`<`string`, `any`\>\>[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:123](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L123)
|
||||
|
||||
___
|
||||
|
||||
### validateMiddleware\_
|
||||
|
||||
▸ **validateMiddleware_**(`fn`): `void`
|
||||
|
||||
Validates a middleware function, throws if fn is not of type function.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fn` | `unknown` | the middleware function to validate. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
nothing if the middleware is a function
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/middleware.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/middleware.ts#L43)
|
||||
@@ -0,0 +1,509 @@
|
||||
# Class: NewTotalsService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`NewTotalsService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new NewTotalsService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L67)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L64)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### taxCalculationStrategy\_
|
||||
|
||||
• `Protected` `Readonly` **taxCalculationStrategy\_**: `ITaxCalculationStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:63](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### getGiftCardTotals
|
||||
|
||||
▸ **getGiftCardTotals**(`giftCardableAmount`, `__namedParameters`): `Promise`<{ `tax_total`: `number` ; `total`: `number` }\>
|
||||
|
||||
Calculate and return the gift cards totals
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `giftCardableAmount` | `number` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.giftCardTransactions?` | `GiftCardTransaction`[] |
|
||||
| `__namedParameters.giftCards?` | `GiftCard`[] |
|
||||
| `__namedParameters.region` | `Region` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `tax_total`: `number` ; `total`: `number` }\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:447](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L447)
|
||||
|
||||
___
|
||||
|
||||
### getGiftCardTransactionsTotals
|
||||
|
||||
▸ **getGiftCardTransactionsTotals**(`__namedParameters`): `Object`
|
||||
|
||||
Calculate and return the gift cards totals based on their transactions
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.giftCardTransactions` | `GiftCardTransaction`[] |
|
||||
| `__namedParameters.region` | `Object` |
|
||||
| `__namedParameters.region.gift_cards_taxable` | `boolean` |
|
||||
| `__namedParameters.region.tax_rate` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `tax_total` | `number` |
|
||||
| `total` | `number` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:526](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L526)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemRefund
|
||||
|
||||
▸ **getLineItemRefund**(`lineItem`, `__namedParameters`): `number`
|
||||
|
||||
Return the amount that can be refund on a line item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `lineItem` | `Object` |
|
||||
| `lineItem.id` | `string` |
|
||||
| `lineItem.includes_tax` | `boolean` |
|
||||
| `lineItem.quantity` | `number` |
|
||||
| `lineItem.tax_lines` | `LineItemTaxLine`[] |
|
||||
| `lineItem.unit_price` | `number` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.taxRate?` | ``null`` \| `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:333](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L333)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemRefundLegacy
|
||||
|
||||
▸ `Protected` **getLineItemRefundLegacy**(`lineItem`, `__namedParameters`): `number`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `lineItem` | `Object` |
|
||||
| `lineItem.id` | `string` |
|
||||
| `lineItem.includes_tax` | `boolean` |
|
||||
| `lineItem.quantity` | `number` |
|
||||
| `lineItem.unit_price` | `number` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.taxRate` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:403](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L403)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotals
|
||||
|
||||
▸ **getLineItemTotals**(`items`, `__namedParameters`): `Promise`<{ `[lineItemId: string]`: `LineItemTotals`; }\>
|
||||
|
||||
Calculate and return the items totals for either the legacy calculation or the new calculation
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `items` | `LineItem` \| `LineItem`[] |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.includeTax?` | `boolean` |
|
||||
| `__namedParameters.taxRate?` | ``null`` \| `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `[lineItemId: string]`: `LineItemTotals`; }\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:87](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L87)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotalsLegacy
|
||||
|
||||
▸ `Protected` **getLineItemTotalsLegacy**(`item`, `__namedParameters`): `Promise`<`LineItemTotals`\>
|
||||
|
||||
Calculate and return the legacy calculated totals using the tax rate
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `item` | `LineItem` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.lineItemAllocation` | `Object` |
|
||||
| `__namedParameters.lineItemAllocation.discount?` | `DiscountAllocation` |
|
||||
| `__namedParameters.lineItemAllocation.gift_card?` | `GiftCardAllocation` |
|
||||
| `__namedParameters.taxRate` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemTotals`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:254](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L254)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotals\_
|
||||
|
||||
▸ `Protected` **getLineItemTotals_**(`item`, `__namedParameters`): `Promise`<`LineItemTotals`\>
|
||||
|
||||
Calculate and return the totals for an item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `item` | `LineItem` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.includeTax?` | `boolean` |
|
||||
| `__namedParameters.lineItemAllocation` | `Object` |
|
||||
| `__namedParameters.lineItemAllocation.discount?` | `DiscountAllocation` |
|
||||
| `__namedParameters.lineItemAllocation.gift_card?` | `GiftCardAllocation` |
|
||||
| `__namedParameters.taxLines?` | `LineItemTaxLine`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemTotals`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:147](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
### getShippingMethodTotals
|
||||
|
||||
▸ **getShippingMethodTotals**(`shippingMethods`, `__namedParameters`): `Promise`<{ `[shippingMethodId: string]`: `ShippingMethodTotals`; }\>
|
||||
|
||||
Calculate and return the shipping methods totals for either the legacy calculation or the new calculation
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingMethods` | `ShippingMethod` \| `ShippingMethod`[] |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.discounts?` | `Discount`[] |
|
||||
| `__namedParameters.includeTax?` | `boolean` |
|
||||
| `__namedParameters.taxRate?` | ``null`` \| `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `[shippingMethodId: string]`: `ShippingMethodTotals`; }\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:572](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L572)
|
||||
|
||||
___
|
||||
|
||||
### getShippingMethodTotalsLegacy
|
||||
|
||||
▸ `Protected` **getShippingMethodTotalsLegacy**(`shippingMethod`, `__namedParameters`): `Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
Calculate and return the shipping method totals legacy using teh tax rate
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.discounts?` | `Discount`[] |
|
||||
| `__namedParameters.taxRate` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:729](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L729)
|
||||
|
||||
___
|
||||
|
||||
### getShippingMethodTotals\_
|
||||
|
||||
▸ `Protected` **getShippingMethodTotals_**(`shippingMethod`, `__namedParameters`): `Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
Calculate and return the shipping method totals
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` |
|
||||
| `__namedParameters` | `Object` |
|
||||
| `__namedParameters.calculationContext` | `TaxCalculationContext` |
|
||||
| `__namedParameters.discounts?` | `Discount`[] |
|
||||
| `__namedParameters.includeTax?` | `boolean` |
|
||||
| `__namedParameters.taxLines?` | `ShippingMethodTaxLine`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/new-totals.ts:646](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/new-totals.ts#L646)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`NewTotalsService`](NewTotalsService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`NewTotalsService`](NewTotalsService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,388 @@
|
||||
# Class: NoteService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`NoteService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new NoteService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L28)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### noteRepository\_
|
||||
|
||||
• `Protected` `Readonly` **noteRepository\_**: `Repository`<`Note`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:19](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L19)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`, `config?`): `Promise`<`Note`\>
|
||||
|
||||
Creates a note associated with a given author
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreateNoteInput` | the note to create |
|
||||
| `config` | `Object` | any configurations if needed, including meta data |
|
||||
| `config.metadata` | `Record`<`string`, `unknown`\> | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Note`\>
|
||||
|
||||
resolves to the creation result
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:119](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L119)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`noteId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a given note
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `noteId` | `string` | id of the note to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:177](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L177)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`Note`[]\>
|
||||
|
||||
Fetches all notes related to the given selector
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Note`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`Note`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Note`[]\>
|
||||
|
||||
notes related to the given search.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:77](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L77)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Note`[], `number`]\>
|
||||
|
||||
Fetches all notes related to the given selector
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Note`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`Note`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Note`[], `number`]\>
|
||||
|
||||
notes related to the given search.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:98](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L98)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`noteId`, `config?`): `Promise`<`Note`\>
|
||||
|
||||
Retrieves a specific note.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `noteId` | `string` | the id of the note to retrieve. |
|
||||
| `config` | `FindConfig`<`Note`\> | any options needed to query for the result. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Note`\>
|
||||
|
||||
which resolves to the requested note.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`noteId`, `value`): `Promise`<`Note`\>
|
||||
|
||||
Updates a given note with a new value
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `noteId` | `string` | the id of the note to update |
|
||||
| `value` | `string` | the new value |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Note`\>
|
||||
|
||||
resolves to the updated element
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/note.ts:155](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/note.ts#L155)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`NoteService`](NoteService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`NoteService`](NoteService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,510 @@
|
||||
# Class: NotificationService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`NotificationService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new NotificationService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L34)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### attachmentGenerator\_
|
||||
|
||||
• `Protected` **attachmentGenerator\_**: `unknown` = `null`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### container\_
|
||||
|
||||
• `Protected` `Readonly` **container\_**: `InjectedDependencies` & {}
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### logger\_
|
||||
|
||||
• `Protected` `Readonly` **logger\_**: `Logger`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### notificationProviderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **notificationProviderRepository\_**: `Repository`<`NotificationProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:32](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### notificationRepository\_
|
||||
|
||||
• `Protected` `Readonly` **notificationRepository\_**: `Repository`<`Notification`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:30](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L30)
|
||||
|
||||
___
|
||||
|
||||
### subscribers\_
|
||||
|
||||
• `Protected` **subscribers\_**: `Object` = `{}`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### handleEvent
|
||||
|
||||
▸ **handleEvent**(`eventName`, `data`): `Promise`<`undefined` \| `void` \| `Notification`[]\>
|
||||
|
||||
Handles an event by relaying the event data to the subscribing providers.
|
||||
The result of the notification send will be persisted in the database in
|
||||
order to allow for resends. Will log any errors that are encountered.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the event to handle |
|
||||
| `data` | `Record`<`string`, `unknown`\> | the data the event was sent with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `void` \| `Notification`[]\>
|
||||
|
||||
the result of notification subscribed
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:185](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L185)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`Notification`[]\>
|
||||
|
||||
Retrieves a list of notifications.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Notification`\> | the params to select the notifications by. |
|
||||
| `config` | `FindConfig`<`Notification`\> | the configuration to apply to the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Notification`[]\>
|
||||
|
||||
the notifications that satisfy the query.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:78](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Notification`[], `number`]\>
|
||||
|
||||
Retrieves a list of notifications and total count.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Notification`\> | the params to select the notifications by. |
|
||||
| `config` | `FindConfig`<`Notification`\> | the configuration to apply to the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Notification`[], `number`]\>
|
||||
|
||||
the notifications that satisfy the query as well as the count.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:97](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L97)
|
||||
|
||||
___
|
||||
|
||||
### registerAttachmentGenerator
|
||||
|
||||
▸ **registerAttachmentGenerator**(`service`): `void`
|
||||
|
||||
Registers an attachment generator to the service. The generator can be
|
||||
used to generate on demand invoices or other documents.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `service` | `unknown` | the service to assign to the attachmentGenerator |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providerIds`): `Promise`<`void`\>
|
||||
|
||||
Takes a list of notification provider ids and persists them in the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerIds` | `string`[] | a list of provider ids |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### resend
|
||||
|
||||
▸ **resend**(`id`, `config?`): `Promise`<`Notification`\>
|
||||
|
||||
Resends a notification by retrieving a prior notification and calling the
|
||||
underlying provider's resendNotification method.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the notification |
|
||||
| `config` | `FindConfig`<`Notification`\> | any configuration that might override the previous send |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Notification`\>
|
||||
|
||||
the newly created notification
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:265](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L265)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`Notification`\>
|
||||
|
||||
Retrieves a notification with a given id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the notification |
|
||||
| `config` | `FindConfig`<`Notification`\> | the configuration to apply to the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Notification`\>
|
||||
|
||||
the notification
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:118](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L118)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider\_
|
||||
|
||||
▸ `Protected` **retrieveProvider_**(`id`): `AbstractNotificationService`
|
||||
|
||||
Finds a provider with a given id. Will throw a NOT_FOUND error if the
|
||||
resolution fails.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the provider |
|
||||
|
||||
#### Returns
|
||||
|
||||
`AbstractNotificationService`
|
||||
|
||||
the notification provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:166](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L166)
|
||||
|
||||
___
|
||||
|
||||
### send
|
||||
|
||||
▸ **send**(`event`, `eventData`, `providerId`): `Promise`<`undefined` \| `Notification`\>
|
||||
|
||||
Sends a notification, by calling the given provider's sendNotification
|
||||
method. Persists the Notification in the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `event` | `string` | the name of the event |
|
||||
| `eventData` | `Record`<`string`, `unknown`\> | the data the event was sent with |
|
||||
| `providerId` | `string` | the provider that should hande the event. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `Notification`\>
|
||||
|
||||
the created notification
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:217](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L217)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### subscribe
|
||||
|
||||
▸ **subscribe**(`eventName`, `providerId`): `void`
|
||||
|
||||
Subscribes a given provider to an event.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `eventName` | `string` | the event to subscribe to |
|
||||
| `providerId` | `string` | the provider that the event will be sent to |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/notification.ts:145](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/notification.ts#L145)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`NotificationService`](NotificationService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`NotificationService`](NotificationService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,412 @@
|
||||
# Class: OauthService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`OauthService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new OauthService**(`cradle`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cradle` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L28)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### container\_
|
||||
|
||||
• `Protected` **container\_**: `InjectedDependencies`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### oauthRepository\_
|
||||
|
||||
• `Protected` **oauthRepository\_**: `Repository`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `TOKEN_GENERATED` | `string` |
|
||||
| `TOKEN_REFRESHED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:19](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L19)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateOauthInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:87](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L87)
|
||||
|
||||
___
|
||||
|
||||
### generateToken
|
||||
|
||||
▸ **generateToken**(`appName`, `code`, `state`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appName` | `string` |
|
||||
| `code` | `string` |
|
||||
| `state` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:121](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L121)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`): `Promise`<`Oauth`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`Oauth`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:79](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L79)
|
||||
|
||||
___
|
||||
|
||||
### refreshToken
|
||||
|
||||
▸ **refreshToken**(`appName`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appName` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:155](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L155)
|
||||
|
||||
___
|
||||
|
||||
### registerOauthApp
|
||||
|
||||
▸ **registerOauthApp**(`appDetails`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appDetails` | `CreateOauthInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:111](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L111)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`oauthId`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `oauthId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:54](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L54)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByName
|
||||
|
||||
▸ **retrieveByName**(`appName`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `appName` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:36](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `update`): `Promise`<`Oauth`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `update` | `UpdateOauthInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Oauth`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/oauth.ts:100](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/oauth.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`OauthService`](OauthService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`OauthService`](OauthService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,341 @@
|
||||
# Class: OrderEditItemChangeService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`OrderEditItemChangeService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new OrderEditItemChangeService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:33](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L33)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: `IEventBusService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:30](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L30)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### orderItemChangeRepository\_
|
||||
|
||||
• `Protected` `Readonly` **orderItemChangeRepository\_**: `Repository`<`OrderItemChange`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L28)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:31](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L22)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`OrderItemChange`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateOrderEditItemChangeInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderItemChange`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:81](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L81)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`itemChangeIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `itemChangeIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:97](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L97)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`OrderItemChange`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`OrderItemChange`\> |
|
||||
| `config` | `FindConfig`<`OrderItemChange`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderItemChange`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`OrderItemChange`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `config` | `FindConfig`<`OrderItemChange`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderItemChange`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit-item-change.ts:48](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit-item-change.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`OrderEditItemChangeService`](OrderEditItemChangeService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`OrderEditItemChangeService`](OrderEditItemChangeService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,731 @@
|
||||
# Class: OrderEditService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`OrderEditService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new OrderEditService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:75](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L75)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### inventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **inventoryService\_**: `undefined` \| `IInventoryService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:73](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L73)
|
||||
|
||||
___
|
||||
|
||||
### lineItemAdjustmentService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemAdjustmentService\_**: [`LineItemAdjustmentService`](LineItemAdjustmentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:71](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L71)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### newTotalsService\_
|
||||
|
||||
• `Protected` `Readonly` **newTotalsService\_**: [`NewTotalsService`](NewTotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### orderEditItemChangeService\_
|
||||
|
||||
• `Protected` `Readonly` **orderEditItemChangeService\_**: [`OrderEditItemChangeService`](OrderEditItemChangeService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:72](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L72)
|
||||
|
||||
___
|
||||
|
||||
### orderEditRepository\_
|
||||
|
||||
• `Protected` `Readonly` **orderEditRepository\_**: `Repository`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:63](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
### orderService\_
|
||||
|
||||
• `Protected` `Readonly` **orderService\_**: [`OrderService`](OrderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:70](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:66](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CANCELED` | `string` |
|
||||
| `CONFIRMED` | `string` |
|
||||
| `CREATED` | `string` |
|
||||
| `DECLINED` | `string` |
|
||||
| `REQUESTED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:54](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L54)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addLineItem
|
||||
|
||||
▸ **addLineItem**(`orderEditId`, `data`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `data` | `AddOrderEditLineItemInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:541](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L541)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`orderEditId`, `context?`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `context` | `Object` |
|
||||
| `context.canceledBy?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:687](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L687)
|
||||
|
||||
___
|
||||
|
||||
### confirm
|
||||
|
||||
▸ **confirm**(`orderEditId`, `context?`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `context` | `Object` |
|
||||
| `context.confirmedBy?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:726](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L726)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`, `context`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateOrderEditInput` |
|
||||
| `context` | `Object` |
|
||||
| `context.createdBy` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:162](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L162)
|
||||
|
||||
___
|
||||
|
||||
### decline
|
||||
|
||||
▸ **decline**(`orderEditId`, `context`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `context` | `Object` |
|
||||
| `context.declinedBy?` | `string` |
|
||||
| `context.declinedReason?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:260](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L260)
|
||||
|
||||
___
|
||||
|
||||
### decorateTotals
|
||||
|
||||
▸ **decorateTotals**(`orderEdit`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEdit` | `OrderEdit` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:490](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L490)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`id`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:238](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L238)
|
||||
|
||||
___
|
||||
|
||||
### deleteClonedItems
|
||||
|
||||
▸ `Protected` **deleteClonedItems**(`orderEditId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:808](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L808)
|
||||
|
||||
___
|
||||
|
||||
### deleteItemChange
|
||||
|
||||
▸ **deleteItemChange**(`orderEditId`, `itemChangeId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `itemChangeId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:613](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L613)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`OrderEdit`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`OrderEdit`\> |
|
||||
| `config?` | `FindConfig`<`OrderEdit`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:154](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`OrderEdit`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`OrderEdit`\> & { `q?`: `string` } |
|
||||
| `config?` | `FindConfig`<`OrderEdit`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`OrderEdit`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:130](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L130)
|
||||
|
||||
___
|
||||
|
||||
### refreshAdjustments
|
||||
|
||||
▸ **refreshAdjustments**(`orderEditId`, `config?`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderEditId` | `string` | `undefined` |
|
||||
| `config` | `Object` | `undefined` |
|
||||
| `config.preserveCustomAdjustments` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:439](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L439)
|
||||
|
||||
___
|
||||
|
||||
### removeLineItem
|
||||
|
||||
▸ **removeLineItem**(`orderEditId`, `lineItemId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `lineItemId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:382](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L382)
|
||||
|
||||
___
|
||||
|
||||
### requestConfirmation
|
||||
|
||||
▸ **requestConfirmation**(`orderEditId`, `context?`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `context` | `Object` |
|
||||
| `context.requestedBy?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:645](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L645)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`orderEditId`, `config?`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `config` | `FindConfig`<`OrderEdit`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:102](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L102)
|
||||
|
||||
___
|
||||
|
||||
### retrieveActive
|
||||
|
||||
▸ `Protected` **retrieveActive**(`orderId`, `config?`): `Promise`<`undefined` \| ``null`` \| `OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderId` | `string` |
|
||||
| `config` | `FindConfig`<`OrderEdit`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| ``null`` \| `OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:788](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L788)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`orderEditId`, `data`): `Promise`<`OrderEdit`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `data` | `DeepPartial`<`OrderEdit`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`OrderEdit`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:211](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L211)
|
||||
|
||||
___
|
||||
|
||||
### updateLineItem
|
||||
|
||||
▸ **updateLineItem**(`orderEditId`, `itemId`, `data`): `Promise`<`void`\>
|
||||
|
||||
Create or update order edit item change line item and apply the quantity
|
||||
- If the item change already exists then update the quantity of the line item as well as the line adjustments
|
||||
- If the item change does not exist then create the item change of type update and apply the quantity as well as update the line adjustments
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEditId` | `string` |
|
||||
| `itemId` | `string` |
|
||||
| `data` | `Object` |
|
||||
| `data.quantity` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:309](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L309)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`OrderEditService`](OrderEditService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`OrderEditService`](OrderEditService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### isOrderEditActive
|
||||
|
||||
▸ `Static` `Private` **isOrderEditActive**(`orderEdit`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `orderEdit` | `OrderEdit` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/order-edit.ts:860](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/order-edit.ts#L860)
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,508 @@
|
||||
# Class: PaymentCollectionService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`PaymentCollectionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new PaymentCollectionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L46)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customerService\_
|
||||
|
||||
• `Protected` `Readonly` **customerService\_**: [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### paymentCollectionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentCollectionRepository\_**: `Repository`<`PaymentCollection`\> & { `getPaymentCollectionIdByPaymentId`: (`paymentId`: `string`, `config`: `FindManyOptions`<`PaymentCollection`\>) => `Promise`<`PaymentCollection`\> ; `getPaymentCollectionIdBySessionId`: (`sessionId`: `string`, `config`: `FindManyOptions`<`PaymentCollection`\>) => `Promise`<`PaymentCollection`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:44](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L44)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderService\_**: [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:41](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `PAYMENT_AUTHORIZED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:33](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L33)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### authorizePaymentSessions
|
||||
|
||||
▸ **authorizePaymentSessions**(`paymentCollectionId`, `sessionIds`, `context?`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Authorizes the payment sessions of a payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection |
|
||||
| `sessionIds` | `string`[] | array of payment session ids to be authorized |
|
||||
| `context` | `Record`<`string`, `unknown`\> | additional data required by payment providers |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment collection and its payment session.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:528](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L528)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Creates a new payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreatePaymentCollectionInput` | info to create the payment collection |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment collection created.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:103](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L103)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`paymentCollectionId`): `Promise`<`undefined` \| `PaymentCollection`\>
|
||||
|
||||
Deletes a payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection to be removed |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `PaymentCollection`\>
|
||||
|
||||
the payment collection removed.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:172](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L172)
|
||||
|
||||
___
|
||||
|
||||
### isValidTotalAmount
|
||||
|
||||
▸ `Private` **isValidTotalAmount**(`total`, `sessionsInput`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `total` | `number` |
|
||||
| `sessionsInput` | `PaymentCollectionsSessionsBatchInput`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:210](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L210)
|
||||
|
||||
___
|
||||
|
||||
### markAsAuthorized
|
||||
|
||||
▸ **markAsAuthorized**(`paymentCollectionId`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Marks a payment collection as authorized bypassing the payment flow.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment session authorized.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:499](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L499)
|
||||
|
||||
___
|
||||
|
||||
### refreshPaymentSession
|
||||
|
||||
▸ **refreshPaymentSession**(`paymentCollectionId`, `sessionId`, `customerId`): `Promise`<`PaymentSession`\>
|
||||
|
||||
Removes and recreate a payment session of a payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection |
|
||||
| `sessionId` | `string` | the id of the payment session to be replaced |
|
||||
| `customerId` | `string` | the id of the customer |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
the new payment session created.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:406](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L406)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`paymentCollectionId`, `config?`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Retrieves a payment collection by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection |
|
||||
| `config` | `FindConfig`<`PaymentCollection`\> | the config to retrieve the payment collection |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment collection.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### setPaymentSession
|
||||
|
||||
▸ **setPaymentSession**(`paymentCollectionId`, `sessionInput`, `customerId`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Manages a single payment sessions of a payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection |
|
||||
| `sessionInput` | `PaymentCollectionsSessionsInput` | object containing payment session info |
|
||||
| `customerId` | `string` | the id of the customer |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment collection and its payment session.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:360](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L360)
|
||||
|
||||
___
|
||||
|
||||
### setPaymentSessionsBatch
|
||||
|
||||
▸ **setPaymentSessionsBatch**(`paymentCollectionOrId`, `sessionsInput`, `customerId`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Manages multiple payment sessions of a payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionOrId` | `string` \| `PaymentCollection` | the id of the payment collection |
|
||||
| `sessionsInput` | `PaymentCollectionsSessionsBatchInput`[] | array containing payment session info |
|
||||
| `customerId` | `string` | the id of the customer |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment collection and its payment sessions.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:225](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L225)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`paymentCollectionId`, `data`): `Promise`<`PaymentCollection`\>
|
||||
|
||||
Updates a payment collection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentCollectionId` | `string` | the id of the payment collection to update |
|
||||
| `data` | `DeepPartial`<`PaymentCollection`\> | info to be updated |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentCollection`\>
|
||||
|
||||
the payment collection updated.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-collection.ts:138](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-collection.ts#L138)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`PaymentCollectionService`](PaymentCollectionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PaymentCollectionService`](PaymentCollectionService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,858 @@
|
||||
# Class: PaymentProviderService
|
||||
|
||||
Helps retrieve payment providers
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`PaymentProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new PaymentProviderService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:70](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L70)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### container\_
|
||||
|
||||
• `Protected` `Readonly` **container\_**: `InjectedDependencies`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:55](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### customerService\_
|
||||
|
||||
• `Protected` `Readonly` **customerService\_**: [`CustomerService`](CustomerService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### logger\_
|
||||
|
||||
• `Protected` `Readonly` **logger\_**: `Logger`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:66](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderRepository\_**: `Repository`<`PaymentProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### paymentRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentRepository\_**: `Repository`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L59)
|
||||
|
||||
___
|
||||
|
||||
### paymentSessionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentSessionRepository\_**: `Repository`<`PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### refundRepository\_
|
||||
|
||||
• `Protected` `Readonly` **refundRepository\_**: `Repository`<`Refund`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L64)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
___
|
||||
|
||||
### paymentService\_
|
||||
|
||||
• `Protected` `get` **paymentService_**(): [`PaymentService`](PaymentService.md)
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PaymentService`](PaymentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L60)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### authorizePayment
|
||||
|
||||
▸ **authorizePayment**(`paymentSession`, `context`): `Promise`<`undefined` \| `PaymentSession`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentSession` | `PaymentSession` |
|
||||
| `context` | `Record`<`string`, `unknown`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:523](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L523)
|
||||
|
||||
___
|
||||
|
||||
### buildPaymentProcessorContext
|
||||
|
||||
▸ `Protected` **buildPaymentProcessorContext**(`cartOrData`): `Cart` & `PaymentContext`
|
||||
|
||||
Build the create session context for both legacy and new API
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cartOrData` | `Cart` \| `PaymentSessionInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Cart` & `PaymentContext`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:845](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L845)
|
||||
|
||||
___
|
||||
|
||||
### cancelPayment
|
||||
|
||||
▸ **cancelPayment**(`paymentObj`): `Promise`<`Payment`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentObj` | `Partial`<`Payment`\> & { `id`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:602](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L602)
|
||||
|
||||
___
|
||||
|
||||
### capturePayment
|
||||
|
||||
▸ **capturePayment**(`paymentObj`): `Promise`<`Payment`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentObj` | `Partial`<`Payment`\> & { `id`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:641](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L641)
|
||||
|
||||
___
|
||||
|
||||
### createPayment
|
||||
|
||||
▸ **createPayment**(`data`): `Promise`<`Payment`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreatePaymentInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:471](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L471)
|
||||
|
||||
___
|
||||
|
||||
### createSession
|
||||
|
||||
▸ **createSession**(`providerId`, `cart`): `Promise`<`PaymentSession`\>
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providerId` | `string` |
|
||||
| `cart` | `Cart` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:205](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L205)
|
||||
|
||||
▸ **createSession**(`sessionInput`): `Promise`<`PaymentSession`\>
|
||||
|
||||
Creates a payment session with the given provider.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `sessionInput` | `PaymentSessionInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:211](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L211)
|
||||
|
||||
___
|
||||
|
||||
### deleteSession
|
||||
|
||||
▸ **deleteSession**(`paymentSession`): `Promise`<`undefined` \| `PaymentSession`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentSession` | `PaymentSession` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:402](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L402)
|
||||
|
||||
___
|
||||
|
||||
### getStatus
|
||||
|
||||
▸ **getStatus**(`payment`): `Promise`<`PaymentSessionStatus`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `payment` | `Payment` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSessionStatus`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:630](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L630)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(): `Promise`<`PaymentProvider`[]\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentProvider`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:102](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L102)
|
||||
|
||||
___
|
||||
|
||||
### listPayments
|
||||
|
||||
▸ **listPayments**(`selector`, `config?`): `Promise`<`Payment`[]\>
|
||||
|
||||
List all the payments according to the given selector and config.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `Selector`<`Payment`\> |
|
||||
| `config` | `FindConfig`<`Payment`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:154](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### processUpdateRequestsData
|
||||
|
||||
▸ `Protected` **processUpdateRequestsData**(`data?`, `paymentResponse`): `Promise`<`void`\>
|
||||
|
||||
Process the collected data. Can be used every time we need to process some collected data returned by the provider
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `Object` |
|
||||
| `data.customer?` | `Object` |
|
||||
| `data.customer.id?` | `string` |
|
||||
| `paymentResponse` | `Record`<`string`, `unknown`\> \| `PaymentSessionResponse` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:935](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L935)
|
||||
|
||||
___
|
||||
|
||||
### refreshSession
|
||||
|
||||
▸ **refreshSession**(`paymentSession`, `sessionInput`): `Promise`<`PaymentSession`\>
|
||||
|
||||
Refreshes a payment session with the given provider.
|
||||
This means, that we delete the current one and create a new.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentSession` | `Object` | the payment session object to update |
|
||||
| `paymentSession.data` | `Record`<`string`, `unknown`\> | - |
|
||||
| `paymentSession.id` | `string` | - |
|
||||
| `paymentSession.provider_id` | `string` | - |
|
||||
| `sessionInput` | `PaymentSessionInput` | |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
the payment session
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:301](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L301)
|
||||
|
||||
___
|
||||
|
||||
### refundFromPayment
|
||||
|
||||
▸ **refundFromPayment**(`payment`, `amount`, `reason`, `note?`): `Promise`<`Refund`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `payment` | `Payment` |
|
||||
| `amount` | `number` |
|
||||
| `reason` | `string` |
|
||||
| `note?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Refund`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:771](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L771)
|
||||
|
||||
___
|
||||
|
||||
### refundPayment
|
||||
|
||||
▸ **refundPayment**(`payObjs`, `amount`, `reason`, `note?`): `Promise`<`Refund`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `payObjs` | `Payment`[] |
|
||||
| `amount` | `number` |
|
||||
| `reason` | `string` |
|
||||
| `note?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Refund`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:672](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L672)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providerIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providerIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:83](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L83)
|
||||
|
||||
___
|
||||
|
||||
### retrievePayment
|
||||
|
||||
▸ **retrievePayment**(`paymentId`, `relations?`): `Promise`<`Payment`\>
|
||||
|
||||
Retrieve a payment entity with the given id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentId` | `string` | `undefined` |
|
||||
| `relations` | `string`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:114](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L114)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider
|
||||
|
||||
▸ **retrieveProvider**<`TProvider`\>(`providerId`): `TProvider` extends `AbstractPaymentService` ? `AbstractPaymentService` : `TProvider` extends `AbstractPaymentProcessor` ? `AbstractPaymentProcessor` : `any`
|
||||
|
||||
Finds a provider given an id
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `TProvider` | extends `unknown` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `providerId` | `string` | the id of the provider to get |
|
||||
|
||||
#### Returns
|
||||
|
||||
`TProvider` extends `AbstractPaymentService` ? `AbstractPaymentService` : `TProvider` extends `AbstractPaymentProcessor` ? `AbstractPaymentProcessor` : `any`
|
||||
|
||||
the payment provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:442](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L442)
|
||||
|
||||
___
|
||||
|
||||
### retrieveRefund
|
||||
|
||||
▸ **retrieveRefund**(`id`, `config?`): `Promise`<`Refund`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `config` | `FindConfig`<`Refund`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Refund`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:822](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L822)
|
||||
|
||||
___
|
||||
|
||||
### retrieveSession
|
||||
|
||||
▸ **retrieveSession**(`paymentSessionId`, `relations?`): `Promise`<`PaymentSession`\>
|
||||
|
||||
Return the payment session for the given id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentSessionId` | `string` | `undefined` |
|
||||
| `relations` | `string`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:172](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L172)
|
||||
|
||||
___
|
||||
|
||||
### saveSession
|
||||
|
||||
▸ `Protected` **saveSession**(`providerId`, `data`): `Promise`<`PaymentSession`\>
|
||||
|
||||
Create or update a Payment session data.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providerId` | `string` |
|
||||
| `data` | `Object` |
|
||||
| `data.amount?` | `number` |
|
||||
| `data.cartId?` | `string` |
|
||||
| `data.isInitiated?` | `boolean` |
|
||||
| `data.isSelected?` | `boolean` |
|
||||
| `data.payment_session_id?` | `string` |
|
||||
| `data.sessionData` | `Record`<`string`, `unknown`\> |
|
||||
| `data.status?` | `PaymentSessionStatus` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:887](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L887)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### throwFromPaymentProcessorError
|
||||
|
||||
▸ `Private` **throwFromPaymentProcessorError**(`errObj`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `errObj` | `PaymentProcessorError` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:954](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L954)
|
||||
|
||||
___
|
||||
|
||||
### updatePayment
|
||||
|
||||
▸ **updatePayment**(`paymentId`, `data`): `Promise`<`Payment`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentId` | `string` |
|
||||
| `data` | `Object` |
|
||||
| `data.order_id?` | `string` |
|
||||
| `data.swap_id?` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:512](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L512)
|
||||
|
||||
___
|
||||
|
||||
### updateSession
|
||||
|
||||
▸ **updateSession**(`paymentSession`, `sessionInput`): `Promise`<`PaymentSession`\>
|
||||
|
||||
Update a payment session with the given provider.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentSession` | `Object` | The paymentSession to update |
|
||||
| `paymentSession.data` | `Record`<`string`, `unknown`\> | - |
|
||||
| `paymentSession.id` | `string` | - |
|
||||
| `paymentSession.provider_id` | `string` | - |
|
||||
| `sessionInput` | `Cart` \| `PaymentSessionInput` | |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
the payment session
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:342](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L342)
|
||||
|
||||
___
|
||||
|
||||
### updateSessionData
|
||||
|
||||
▸ **updateSessionData**(`paymentSession`, `data`): `Promise`<`PaymentSession`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `paymentSession` | `PaymentSession` |
|
||||
| `data` | `Record`<`string`, `unknown`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PaymentSession`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment-provider.ts:569](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment-provider.ts#L569)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,380 @@
|
||||
# Class: PaymentService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`PaymentService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new PaymentService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L39)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:27](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L27)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderService\_**: [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L28)
|
||||
|
||||
___
|
||||
|
||||
### paymentRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentRepository\_**: `Repository`<`Payment`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `PAYMENT_CAPTURED` | `string` |
|
||||
| `PAYMENT_CAPTURE_FAILED` | `string` |
|
||||
| `REFUND_CREATED` | `string` |
|
||||
| `REFUND_FAILED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:30](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L30)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### capture
|
||||
|
||||
▸ **capture**(`paymentOrId`): `Promise`<`Payment`\>
|
||||
|
||||
Captures a payment.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentOrId` | `string` \| `Payment` | the id or the class instance of the payment |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
the payment captured.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:153](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L153)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`paymentInput`): `Promise`<`Payment`\>
|
||||
|
||||
Created a new payment.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentInput` | `PaymentDataInput` | info to create the payment |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
the payment created.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:92](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L92)
|
||||
|
||||
___
|
||||
|
||||
### refund
|
||||
|
||||
▸ **refund**(`paymentOrId`, `amount`, `reason`, `note?`): `Promise`<`Refund`\>
|
||||
|
||||
refunds a payment.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentOrId` | `string` \| `Payment` | the id or the class instance of the payment |
|
||||
| `amount` | `number` | the amount to be refunded from the payment |
|
||||
| `reason` | `string` | the refund reason |
|
||||
| `note?` | `string` | additional note of the refund |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Refund`\>
|
||||
|
||||
the refund created.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:202](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L202)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`paymentId`, `config?`): `Promise`<`Payment`\>
|
||||
|
||||
Retrieves a payment by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentId` | `string` | the id of the payment |
|
||||
| `config` | `FindConfig`<`Payment`\> | the config to retrieve the payment |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
the payment.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`paymentId`, `data`): `Promise`<`Payment`\>
|
||||
|
||||
Updates a payment in order to link it to an order or a swap.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `paymentId` | `string` | the id of the payment |
|
||||
| `data` | `Object` | order_id or swap_id to link the payment |
|
||||
| `data.order_id?` | `string` | - |
|
||||
| `data.swap_id?` | `string` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Payment`\>
|
||||
|
||||
the payment updated.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/payment.ts:121](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/payment.ts#L121)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`PaymentService`](PaymentService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PaymentService`](PaymentService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,647 @@
|
||||
# Class: PriceListService
|
||||
|
||||
Provides layer to manipulate product tags.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`PriceListService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new PriceListService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `PriceListConstructorProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:51](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L51)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customerGroupService\_
|
||||
|
||||
• `Protected` `Readonly` **customerGroupService\_**: [`CustomerGroupService`](CustomerGroupService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:49](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### moneyAmountRepo\_
|
||||
|
||||
• `Protected` `Readonly` **moneyAmountRepo\_**: `Repository`<`MoneyAmount`\> & { `addPriceListPrices`: (`priceListId`: `string`, `prices`: `PriceListPriceCreateInput`[], `overrideExisting`: `boolean`) => `Promise`<`MoneyAmount`[]\> ; `deletePriceListPrices`: (`priceListId`: `string`, `moneyAmountIds`: `string`[]) => `Promise`<`void`\> ; `deleteVariantPricesNotIn`: (`variantIdOrData`: `string` \| { `prices`: `ProductVariantPrice`[] ; `variantId`: `string` }[], `prices?`: `Price`[]) => `Promise`<`void`\> ; `findManyForVariantInPriceList`: (`variant_id`: `string`, `price_list_id`: `string`, `requiresPriceList`: `boolean`) => `Promise`<[`MoneyAmount`[], `number`]\> ; `findManyForVariantInRegion`: (`variant_id`: `string`, `region_id?`: `string`, `currency_code?`: `string`, `customer_id?`: `string`, `include_discount_prices?`: `boolean`, `include_tax_inclusive_pricing`: `boolean`) => `Promise`<[`MoneyAmount`[], `number`]\> ; `findManyForVariantsInRegion`: (`variant_ids`: `string` \| `string`[], `region_id?`: `string`, `currency_code?`: `string`, `customer_id?`: `string`, `include_discount_prices?`: `boolean`, `include_tax_inclusive_pricing`: `boolean`) => `Promise`<[`Record`<`string`, `MoneyAmount`[]\>, `number`]\> ; `findVariantPricesNotIn`: (`variantId`: `string`, `prices`: `Price`[]) => `Promise`<`MoneyAmount`[]\> ; `insertBulk`: (`data`: `_QueryDeepPartialEntity`<`MoneyAmount`\>[]) => `Promise`<`MoneyAmount`[]\> ; `updatePriceListPrices`: (`priceListId`: `string`, `updates`: `PriceListPriceUpdateInput`[]) => `Promise`<`MoneyAmount`[]\> ; `upsertVariantCurrencyPrice`: (`variantId`: `string`, `price`: `Price`) => `Promise`<`MoneyAmount`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:47](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### priceListRepo\_
|
||||
|
||||
• `Protected` `Readonly` **priceListRepo\_**: `Repository`<`PriceList`\> & { `listAndCount`: (`query`: `ExtendedFindConfig`<`PriceList`\>, `q?`: `string`) => `Promise`<[`PriceList`[], `number`]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:44](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L44)
|
||||
|
||||
___
|
||||
|
||||
### productVariantRepo\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantRepo\_**: `Repository`<`ProductVariant`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:48](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### variantService\_
|
||||
|
||||
• `Protected` `Readonly` **variantService\_**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L45)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCurrencyFromRegion
|
||||
|
||||
▸ `Protected` **addCurrencyFromRegion**<`T`\>(`prices`): `Promise`<`T`[]\>
|
||||
|
||||
Add `currency_code` to an MA record if `region_id`is passed.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | extends `PriceListPriceUpdateInput` \| `PriceListPriceCreateInput` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `prices` | `T`[] | a list of PriceListPrice(Create/Update)Input records |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`T`[]\>
|
||||
|
||||
updated `prices` list
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:492](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L492)
|
||||
|
||||
___
|
||||
|
||||
### addPrices
|
||||
|
||||
▸ **addPrices**(`id`, `prices`, `replace?`): `Promise`<`PriceList`\>
|
||||
|
||||
Adds prices to a price list in bulk, optionally replacing all existing prices
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` | id of the price list |
|
||||
| `prices` | `PriceListPriceCreateInput`[] | `undefined` | prices to add |
|
||||
| `replace` | `boolean` | `false` | whether to replace existing prices |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PriceList`\>
|
||||
|
||||
updated Price List
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:212](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L212)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### clearPrices
|
||||
|
||||
▸ **clearPrices**(`id`): `Promise`<`void`\>
|
||||
|
||||
Removes all prices from a price list and deletes the removed prices in bulk
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the price list |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
updated Price List
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:252](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L252)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`priceListObject`): `Promise`<`PriceList`\>
|
||||
|
||||
Creates a Price List
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `priceListObject` | `CreatePriceListInput` | the Price List to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PriceList`\>
|
||||
|
||||
created Price List
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:113](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L113)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`id`): `Promise`<`void`\>
|
||||
|
||||
Deletes a Price List
|
||||
Will never fail due to delete being idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the price list |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:266](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L266)
|
||||
|
||||
___
|
||||
|
||||
### deletePrices
|
||||
|
||||
▸ **deletePrices**(`id`, `priceIds`): `Promise`<`void`\>
|
||||
|
||||
Removes prices from a price list and deletes the removed prices in bulk
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the price list |
|
||||
| `priceIds` | `string`[] | ids of the prices to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
updated Price List
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:237](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L237)
|
||||
|
||||
___
|
||||
|
||||
### deleteProductPrices
|
||||
|
||||
▸ **deleteProductPrices**(`priceListId`, `productIds`): `Promise`<[`string`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `priceListId` | `string` |
|
||||
| `productIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`string`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:419](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L419)
|
||||
|
||||
___
|
||||
|
||||
### deleteVariantPrices
|
||||
|
||||
▸ **deleteVariantPrices**(`priceListId`, `variantIds`): `Promise`<[`string`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `priceListId` | `string` |
|
||||
| `variantIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`string`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:456](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L456)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`PriceList`[]\>
|
||||
|
||||
Lists Price Lists
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterablePriceListProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`PriceList`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PriceList`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:286](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L286)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`PriceList`[], `number`]\>
|
||||
|
||||
Lists Price Lists and adds count
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterablePriceListProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`PriceList`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`PriceList`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:300](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L300)
|
||||
|
||||
___
|
||||
|
||||
### listProducts
|
||||
|
||||
▸ **listProducts**(`priceListId`, `selector?`, `config?`, `requiresPriceList?`): `Promise`<[`Product`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `priceListId` | `string` | `undefined` |
|
||||
| `selector` | `FilterableProductProps` \| `Selector`<`Product`\> | `{}` |
|
||||
| `config` | `FindConfig`<`Product`\> | `undefined` |
|
||||
| `requiresPriceList` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Product`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:337](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L337)
|
||||
|
||||
___
|
||||
|
||||
### listVariants
|
||||
|
||||
▸ **listVariants**(`priceListId`, `selector?`, `config?`, `requiresPriceList?`): `Promise`<[`ProductVariant`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `priceListId` | `string` | `undefined` |
|
||||
| `selector` | `FilterableProductVariantProps` | `{}` |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> | `undefined` |
|
||||
| `requiresPriceList` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductVariant`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:385](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L385)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`priceListId`, `config?`): `Promise`<`PriceList`\>
|
||||
|
||||
Retrieves a product tag by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `priceListId` | `string` | the id of the product tag to retrieve |
|
||||
| `config` | `FindConfig`<`PriceList`\> | the config to retrieve the tag by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PriceList`\>
|
||||
|
||||
the collection.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:80](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L80)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `update`): `Promise`<`PriceList`\>
|
||||
|
||||
Updates a Price List
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the Product List to update |
|
||||
| `update` | `UpdatePriceListInput` | the update to apply |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PriceList`\>
|
||||
|
||||
updated Price List
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:161](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L161)
|
||||
|
||||
___
|
||||
|
||||
### upsertCustomerGroups\_
|
||||
|
||||
▸ `Protected` **upsertCustomerGroups_**(`priceListId`, `customerGroups`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `priceListId` | `string` |
|
||||
| `customerGroups` | { `id`: `string` }[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/price-list.ts:316](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/price-list.ts#L316)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`PriceListService`](PriceListService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PriceListService`](PriceListService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,576 @@
|
||||
# Class: PricingService
|
||||
|
||||
Allows retrieval of prices.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`PricingService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new PricingService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L42)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### priceSelectionStrategy
|
||||
|
||||
• `Protected` `Readonly` **priceSelectionStrategy**: `IPriceSelectionStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### productVariantService
|
||||
|
||||
• `Protected` `Readonly` **productVariantService**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### regionService
|
||||
|
||||
• `Protected` `Readonly` **regionService**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:36](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### calculateTaxes
|
||||
|
||||
▸ **calculateTaxes**(`variantPricing`, `productRates`): `TaxedPricing`
|
||||
|
||||
Gets the prices for a product variant
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantPricing` | `ProductVariantPricing` | the prices retrieved from a variant |
|
||||
| `productRates` | `TaxServiceRate`[] | the tax rates that the product has applied |
|
||||
|
||||
#### Returns
|
||||
|
||||
`TaxedPricing`
|
||||
|
||||
The tax related variant prices.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:101](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L101)
|
||||
|
||||
___
|
||||
|
||||
### collectPricingContext
|
||||
|
||||
▸ **collectPricingContext**(`context`): `Promise`<`PricingContext`\>
|
||||
|
||||
Collects additional information necessary for completing the price
|
||||
selection.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PricingContext`\>
|
||||
|
||||
The pricing context
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### getProductPricing
|
||||
|
||||
▸ **getProductPricing**(`product`, `context`): `Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||
|
||||
Gets all the variant prices for a product. All the product's variants will
|
||||
be fetched.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `product` | `Pick`<`Product`, ``"id"`` \| ``"variants"``\> | the product to get pricing for. |
|
||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||
|
||||
A map of variant ids to their corresponding prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:419](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L419)
|
||||
|
||||
___
|
||||
|
||||
### getProductPricingById
|
||||
|
||||
▸ **getProductPricingById**(`productId`, `context`): `Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||
|
||||
Gets all the variant prices for a product by the product id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product to get prices for |
|
||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `ProductVariantPricing`\>\>
|
||||
|
||||
A map of variant ids to their corresponding prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:437](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L437)
|
||||
|
||||
___
|
||||
|
||||
### getProductPricing\_
|
||||
|
||||
▸ `Private` **getProductPricing_**(`data`, `context`): `Promise`<`Map`<`string`, `Record`<`string`, `ProductVariantPricing`\>\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | { `productId`: `string` ; `variants`: `ProductVariant`[] }[] |
|
||||
| `context` | `PricingContext` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Map`<`string`, `Record`<`string`, `ProductVariantPricing`\>\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:362](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L362)
|
||||
|
||||
___
|
||||
|
||||
### getProductVariantPricing
|
||||
|
||||
▸ **getProductVariantPricing**(`variant`, `context`): `Promise`<`ProductVariantPricing`\>
|
||||
|
||||
Gets the prices for a product variant.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variant` | `Pick`<`ProductVariant`, ``"id"`` \| ``"product_id"``\> | |
|
||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantPricing`\>
|
||||
|
||||
The product variant prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:216](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L216)
|
||||
|
||||
___
|
||||
|
||||
### getProductVariantPricingById
|
||||
|
||||
▸ **getProductVariantPricingById**(`variantId`, `context`): `Promise`<`ProductVariantPricing`\>
|
||||
|
||||
Gets the prices for a product variant by a variant id.
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
Use [getProductVariantsPricing](PricingService.md#getproductvariantspricing) instead.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to get prices for |
|
||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantPricing`\>
|
||||
|
||||
The product variant prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:265](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L265)
|
||||
|
||||
___
|
||||
|
||||
### getProductVariantPricing\_
|
||||
|
||||
▸ `Private` **getProductVariantPricing_**(`data`, `context`): `Promise`<`Map`<`string`, `ProductVariantPricing`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | { `quantity?`: `number` ; `variantId`: `string` }[] |
|
||||
| `context` | `PricingContext` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Map`<`string`, `ProductVariantPricing`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:163](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L163)
|
||||
|
||||
___
|
||||
|
||||
### getProductVariantsPricing
|
||||
|
||||
▸ **getProductVariantsPricing**(`data`, `context`): `Promise`<{ `[variant_id: string]`: `ProductVariantPricing`; }\>
|
||||
|
||||
Gets the prices for a collection of variants.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | { `quantity?`: `number` ; `variantId`: `string` }[] | |
|
||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `[variant_id: string]`: `ProductVariantPricing`; }\>
|
||||
|
||||
The product variant prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:310](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L310)
|
||||
|
||||
___
|
||||
|
||||
### getShippingOptionPricing
|
||||
|
||||
▸ **getShippingOptionPricing**(`shippingOption`, `context`): `Promise`<`PricedShippingOption`\>
|
||||
|
||||
Gets the prices for a shipping option.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingOption` | `ShippingOption` | the shipping option to get prices for |
|
||||
| `context` | `PriceSelectionContext` \| `PricingContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PricedShippingOption`\>
|
||||
|
||||
The shipping option prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:526](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L526)
|
||||
|
||||
___
|
||||
|
||||
### setProductPrices
|
||||
|
||||
▸ **setProductPrices**(`products`, `context?`): `Promise`<(`Product` \| `PricedProduct`)[]\>
|
||||
|
||||
Set additional prices on a list of products.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `products` | `Product`[] | list of products on which to set additional prices |
|
||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`Product` \| `PricedProduct`)[]\>
|
||||
|
||||
A list of products with variants decorated with prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:486](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L486)
|
||||
|
||||
___
|
||||
|
||||
### setShippingOptionPrices
|
||||
|
||||
▸ **setShippingOptionPrices**(`shippingOptions`, `context?`): `Promise`<`PricedShippingOption`[]\>
|
||||
|
||||
Set additional prices on a list of shipping options.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingOptions` | `ShippingOption`[] | list of shipping options on which to set additional prices |
|
||||
| `context` | `Omit`<`PriceSelectionContext`, ``"region_id"``\> | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PricedShippingOption`[]\>
|
||||
|
||||
A list of shipping options with prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:588](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L588)
|
||||
|
||||
___
|
||||
|
||||
### setVariantPrices
|
||||
|
||||
▸ **setVariantPrices**(`variants`, `context?`): `Promise`<`PricedVariant`[]\>
|
||||
|
||||
Set additional prices on a list of product variants.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variants` | `ProductVariant`[] | |
|
||||
| `context` | `PriceSelectionContext` | the price selection context to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`PricedVariant`[]\>
|
||||
|
||||
A list of products with variants decorated with prices
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/pricing.ts:459](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/pricing.ts#L459)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`PricingService`](PricingService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`PricingService`](PricingService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,563 @@
|
||||
# Class: ProductCategoryService
|
||||
|
||||
Provides layer to manipulate product categories.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ProductCategoryService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductCategoryService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L40)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:32](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### productCategoryRepo\_
|
||||
|
||||
• `Protected` `Readonly` **productCategoryRepo\_**: `TreeRepository`<`ProductCategory`\> & { `addProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`void`\> ; `findOneWithDescendants`: (`query`: `FindOneOptions`<`ProductCategory`\>, `treeScope`: `QuerySelector`<`ProductCategory`\>) => `Promise`<``null`` \| `ProductCategory`\> ; `getFreeTextSearchResultsAndCount`: (`options`: `ExtendedFindConfig`<`ProductCategory`\>, `q?`: `string`, `treeScope`: `QuerySelector`<`ProductCategory`\>, `includeTree`: `boolean`) => `Promise`<[`ProductCategory`[], `number`]\> ; `removeProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:31](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L34)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addProducts
|
||||
|
||||
▸ **addProducts**(`productCategoryId`, `productIds`): `Promise`<`void`\>
|
||||
|
||||
Add a batch of product to a product category
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryId` | `string` | The id of the product category on which to add the products |
|
||||
| `productIds` | `string`[] | The products ids to attach to the product category |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the product category on which the products have been added
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:314](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L314)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`productCategoryInput`): `Promise`<`ProductCategory`\>
|
||||
|
||||
Creates a product category
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryInput` | `CreateProductCategoryInput` | parameters to create a product category |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCategory`\>
|
||||
|
||||
created product category
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:187](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L187)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`productCategoryId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a product category
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryId` | `string` | is the id of the product category to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
a promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:268](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L268)
|
||||
|
||||
___
|
||||
|
||||
### fetchReorderConditions
|
||||
|
||||
▸ `Protected` **fetchReorderConditions**(`productCategory`, `input`, `shouldDeleteElement?`): `ReorderConditions`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategory` | `ProductCategory` | `undefined` |
|
||||
| `input` | `UpdateProductCategoryInput` | `undefined` |
|
||||
| `shouldDeleteElement` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ReorderConditions`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:349](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L349)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`, `treeSelector?`): `Promise`<[`ProductCategory`[], `number`]\>
|
||||
|
||||
Lists product category based on the provided parameters and includes the count of
|
||||
product category that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `TreeQuerySelector`<`ProductCategory`\> | Filter options for product category. |
|
||||
| `config` | `FindConfig`<`ProductCategory`\> | Configuration for query. |
|
||||
| `treeSelector` | `QuerySelector`<`ProductCategory`\> | Filter options for product category tree relations |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductCategory`[], `number`]\>
|
||||
|
||||
an array containing the product category as
|
||||
the first element and the total count of product category that matches the query
|
||||
as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:61](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L61)
|
||||
|
||||
___
|
||||
|
||||
### performReordering
|
||||
|
||||
▸ `Protected` **performReordering**(`repository`, `conditions`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `repository` | `TreeRepository`<`ProductCategory`\> & { `addProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`void`\> ; `findOneWithDescendants`: (`query`: `FindOneOptions`<`ProductCategory`\>, `treeScope`: `QuerySelector`<`ProductCategory`\>) => `Promise`<``null`` \| `ProductCategory`\> ; `getFreeTextSearchResultsAndCount`: (`options`: `ExtendedFindConfig`<`ProductCategory`\>, `q?`: `string`, `treeScope`: `QuerySelector`<`ProductCategory`\>, `includeTree`: `boolean`) => `Promise`<[`ProductCategory`[], `number`]\> ; `removeProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`DeleteResult`\> } |
|
||||
| `conditions` | `ReorderConditions` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:377](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L377)
|
||||
|
||||
___
|
||||
|
||||
### removeProducts
|
||||
|
||||
▸ **removeProducts**(`productCategoryId`, `productIds`): `Promise`<`void`\>
|
||||
|
||||
Remove a batch of product from a product category
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryId` | `string` | The id of the product category on which to remove the products |
|
||||
| `productIds` | `string`[] | The products ids to remove from the product category |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the product category on which the products have been removed
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:333](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L333)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`productCategoryId`, `config?`, `selector?`, `treeSelector?`): `Promise`<`ProductCategory`\>
|
||||
|
||||
Retrieves a product category by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryId` | `string` | the id of the product category to retrieve. |
|
||||
| `config` | `FindConfig`<`ProductCategory`\> | the config of the product category to retrieve. |
|
||||
| `selector` | `Selector`<`ProductCategory`\> | |
|
||||
| `treeSelector` | `QuerySelector`<`ProductCategory`\> | |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCategory`\>
|
||||
|
||||
the product category.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:139](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L139)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByHandle
|
||||
|
||||
▸ **retrieveByHandle**(`handle`, `config?`, `selector?`, `treeSelector?`): `Promise`<`ProductCategory`\>
|
||||
|
||||
Retrieves a product category by handle.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `handle` | `string` | the handle of the category |
|
||||
| `config` | `FindConfig`<`ProductCategory`\> | the config of the product category to retrieve. |
|
||||
| `selector` | `Selector`<`ProductCategory`\> | |
|
||||
| `treeSelector` | `QuerySelector`<`ProductCategory`\> | |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCategory`\>
|
||||
|
||||
the product category.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:165](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L165)
|
||||
|
||||
___
|
||||
|
||||
### retrieve\_
|
||||
|
||||
▸ `Protected` **retrieve_**(`config?`, `selector?`, `treeSelector?`): `Promise`<`ProductCategory`\>
|
||||
|
||||
A generic retrieve for fining product categories by different attributes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | `FindConfig`<`ProductCategory`\> | the config of the product category to retrieve. |
|
||||
| `selector` | `Selector`<`ProductCategory`\> | |
|
||||
| `treeSelector` | `QuerySelector`<`ProductCategory`\> | |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCategory`\>
|
||||
|
||||
the product category.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:102](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L102)
|
||||
|
||||
___
|
||||
|
||||
### shiftSiblings
|
||||
|
||||
▸ `Protected` **shiftSiblings**(`repository`, `conditions`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `repository` | `TreeRepository`<`ProductCategory`\> & { `addProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`void`\> ; `findOneWithDescendants`: (`query`: `FindOneOptions`<`ProductCategory`\>, `treeScope`: `QuerySelector`<`ProductCategory`\>) => `Promise`<``null`` \| `ProductCategory`\> ; `getFreeTextSearchResultsAndCount`: (`options`: `ExtendedFindConfig`<`ProductCategory`\>, `q?`: `string`, `treeScope`: `QuerySelector`<`ProductCategory`\>, `includeTree`: `boolean`) => `Promise`<[`ProductCategory`[], `number`]\> ; `removeProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`DeleteResult`\> } |
|
||||
| `conditions` | `ReorderConditions` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:415](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L415)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### transformParentIdToEntity
|
||||
|
||||
▸ `Protected` **transformParentIdToEntity**(`productCategoryInput`): `Promise`<`CreateProductCategoryInput` \| `UpdateProductCategoryInput`\>
|
||||
|
||||
Accepts an input object and transforms product_category_id
|
||||
into product_category entity.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryInput` | `CreateProductCategoryInput` \| `UpdateProductCategoryInput` | params used to create/update |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CreateProductCategoryInput` \| `UpdateProductCategoryInput`\>
|
||||
|
||||
transformed productCategoryInput
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:513](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L513)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`productCategoryId`, `productCategoryInput`): `Promise`<`ProductCategory`\>
|
||||
|
||||
Updates a product category
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productCategoryId` | `string` | id of product category to update |
|
||||
| `productCategoryInput` | `UpdateProductCategoryInput` | parameters to update in product category |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCategory`\>
|
||||
|
||||
updated product category
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-category.ts:221](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-category.ts#L221)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ProductCategoryService`](ProductCategoryService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductCategoryService`](ProductCategoryService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,471 @@
|
||||
# Class: ProductCollectionService
|
||||
|
||||
Provides layer to manipulate product collections.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ProductCollectionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductCollectionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:49](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L49)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:36](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L36)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### productCollectionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productCollectionRepository\_**: `Repository`<`ProductCollection`\> & { `findAndCountByDiscountConditionId`: (`conditionId`: `string`, `query`: `ExtendedFindConfig`<`ProductCollection`\>) => `Promise`<[`ProductCollection`[], `number`]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### productRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productRepository\_**: `Repository`<`Product`\> & { `_applyCategoriesQuery`: (`qb`: `SelectQueryBuilder`<`Product`\>, `__namedParameters`: `Object`) => `SelectQueryBuilder`<`Product`\> ; `_findWithRelations`: (`__namedParameters`: { `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions` ; `relations`: `string`[] ; `shouldCount`: `boolean` ; `withDeleted`: `boolean` }) => `Promise`<[`Product`[], `number`]\> ; `bulkAddToCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `bulkRemoveFromCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `findOneWithRelations`: (`relations`: `string`[], `optionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<`Product`\> ; `findWithRelations`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions`, `withDeleted`: `boolean`) => `Promise`<`Product`[]\> ; `findWithRelationsAndCount`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<[`Product`[], `number`]\> ; `getFreeTextSearchResultsAndCount`: (`q`: `string`, `options`: `FindWithoutRelationsOptions`, `relations`: `string`[]) => `Promise`<[`Product`[], `number`]\> ; `isProductInSalesChannels`: (`id`: `string`, `salesChannelIds`: `string`[]) => `Promise`<`boolean`\> ; `queryProducts`: (`optionsWithoutRelations`: `FindWithoutRelationsOptions`, `shouldCount`: `boolean`) => `Promise`<[`Product`[], `number`]\> ; `queryProductsWithIds`: (`__namedParameters`: { `entityIds`: `string`[] ; `groupedRelations`: { `[toplevel: string]`: `string`[]; } ; `order?`: { `[column: string]`: ``"ASC"`` \| ``"DESC"``; } ; `select?`: keyof `Product`[] ; `where?`: `FindOptionsWhere`<`Product`\> ; `withDeleted?`: `boolean` }) => `Promise`<`Product`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `PRODUCTS_ADDED` | `string` |
|
||||
| `PRODUCTS_REMOVED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:41](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L41)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addProducts
|
||||
|
||||
▸ **addProducts**(`collectionId`, `productIds`): `Promise`<`ProductCollection`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `collectionId` | `string` |
|
||||
| `productIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:216](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L216)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`collection`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Creates a product collection
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collection` | `CreateProductCollection` | the collection to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
created collection
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:128](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L128)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`collectionId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a product collection idempotently
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionId` | `string` | id of collection to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:192](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L192)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`ProductCollection`[]\>
|
||||
|
||||
Lists product collections
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ProductCollection`\> & { `discount_condition_id?`: `string` ; `q?`: `string` } | `{}` | the query object for find |
|
||||
| `config` | `Object` | `undefined` | the config to be used for find |
|
||||
| `config.skip` | `number` | `0` | - |
|
||||
| `config.take` | `number` | `20` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:274](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L274)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`ProductCollection`[], `number`]\>
|
||||
|
||||
Lists product collections and add count.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `ListAndCountSelector` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductCollection`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductCollection`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:291](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L291)
|
||||
|
||||
___
|
||||
|
||||
### removeProducts
|
||||
|
||||
▸ **removeProducts**(`collectionId`, `productIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `collectionId` | `string` |
|
||||
| `productIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:242](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L242)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`collectionId`, `config?`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Retrieves a product collection by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionId` | `string` | the id of the collection to retrieve. |
|
||||
| `config` | `FindConfig`<`ProductCollection`\> | the config of the collection to retrieve. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
the collection.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByHandle
|
||||
|
||||
▸ **retrieveByHandle**(`collectionHandle`, `config?`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Retrieves a product collection by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionHandle` | `string` | the handle of the collection to retrieve. |
|
||||
| `config` | `FindConfig`<`ProductCollection`\> | query config for request |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
the collection.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:102](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L102)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`collectionId`, `update`): `Promise`<`ProductCollection`\>
|
||||
|
||||
Updates a product collection
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `collectionId` | `string` | id of collection to update |
|
||||
| `update` | `UpdateProductCollection` | update object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductCollection`\>
|
||||
|
||||
update collection
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-collection.ts:154](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-collection.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ProductCollectionService`](ProductCollectionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductCollectionService`](ProductCollectionService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,880 @@
|
||||
# Class: ProductService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ProductService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:80](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L80)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:70](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:71](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L71)
|
||||
|
||||
___
|
||||
|
||||
### imageRepository\_
|
||||
|
||||
• `Protected` `Readonly` **imageRepository\_**: `Repository`<`Image`\> & { `insertBulk`: (`data`: `_QueryDeepPartialEntity`<`Image`\>[]) => `Promise`<`Image`[]\> ; `upsertImages`: (`imageUrls`: `string`[]) => `Promise`<`Image`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### productCategoryRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productCategoryRepository\_**: `TreeRepository`<`ProductCategory`\> & { `addProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`void`\> ; `findOneWithDescendants`: (`query`: `FindOneOptions`<`ProductCategory`\>, `treeScope`: `QuerySelector`<`ProductCategory`\>) => `Promise`<``null`` \| `ProductCategory`\> ; `getFreeTextSearchResultsAndCount`: (`options`: `ExtendedFindConfig`<`ProductCategory`\>, `q?`: `string`, `treeScope`: `QuerySelector`<`ProductCategory`\>, `includeTree`: `boolean`) => `Promise`<[`ProductCategory`[], `number`]\> ; `removeProducts`: (`productCategoryId`: `string`, `productIds`: `string`[]) => `Promise`<`DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### productOptionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productOptionRepository\_**: `Repository`<`ProductOption`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### productRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productRepository\_**: `Repository`<`Product`\> & { `_applyCategoriesQuery`: (`qb`: `SelectQueryBuilder`<`Product`\>, `__namedParameters`: `Object`) => `SelectQueryBuilder`<`Product`\> ; `_findWithRelations`: (`__namedParameters`: { `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions` ; `relations`: `string`[] ; `shouldCount`: `boolean` ; `withDeleted`: `boolean` }) => `Promise`<[`Product`[], `number`]\> ; `bulkAddToCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `bulkRemoveFromCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `findOneWithRelations`: (`relations`: `string`[], `optionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<`Product`\> ; `findWithRelations`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions`, `withDeleted`: `boolean`) => `Promise`<`Product`[]\> ; `findWithRelationsAndCount`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<[`Product`[], `number`]\> ; `getFreeTextSearchResultsAndCount`: (`q`: `string`, `options`: `FindWithoutRelationsOptions`, `relations`: `string`[]) => `Promise`<[`Product`[], `number`]\> ; `isProductInSalesChannels`: (`id`: `string`, `salesChannelIds`: `string`[]) => `Promise`<`boolean`\> ; `queryProducts`: (`optionsWithoutRelations`: `FindWithoutRelationsOptions`, `shouldCount`: `boolean`) => `Promise`<[`Product`[], `number`]\> ; `queryProductsWithIds`: (`__namedParameters`: { `entityIds`: `string`[] ; `groupedRelations`: { `[toplevel: string]`: `string`[]; } ; `order?`: { `[column: string]`: ``"ASC"`` \| ``"DESC"``; } ; `select?`: keyof `Product`[] ; `where?`: `FindOptionsWhere`<`Product`\> ; `withDeleted?`: `boolean` }) => `Promise`<`Product`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:61](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L61)
|
||||
|
||||
___
|
||||
|
||||
### productTagRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productTagRepository\_**: `Repository`<`ProductTag`\> & { `findAndCountByDiscountConditionId`: (`conditionId`: `string`, `query`: `ExtendedFindConfig`<`ProductTag`\>) => `Promise`<[`ProductTag`[], `number`]\> ; `insertBulk`: (`data`: `_QueryDeepPartialEntity`<`ProductTag`\>[]) => `Promise`<`ProductTag`[]\> ; `listTagsByUsage`: (`take`: `number`) => `Promise`<`ProductTag`[]\> ; `upsertTags`: (`tags`: `UpsertTagsInput`) => `Promise`<`ProductTag`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L64)
|
||||
|
||||
___
|
||||
|
||||
### productTypeRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productTypeRepository\_**: `Repository`<`ProductType`\> & { `findAndCountByDiscountConditionId`: (`conditionId`: `string`, `query`: `ExtendedFindConfig`<`ProductType`\>) => `Promise`<[`ProductType`[], `number`]\> ; `upsertType`: (`type?`: `UpsertTypeInput`) => `Promise`<``null`` \| `ProductType`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:63](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
### productVariantRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantRepository\_**: `Repository`<`ProductVariant`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:62](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### productVariantService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### searchService\_
|
||||
|
||||
• `Protected` `Readonly` **searchService\_**: [`SearchService`](SearchService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` `Readonly` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:74](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L74)
|
||||
|
||||
___
|
||||
|
||||
### IndexName
|
||||
|
||||
▪ `Static` `Readonly` **IndexName**: ``"products"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:73](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L73)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addOption
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product to apply the new option to |
|
||||
| `optionTitle` | `string` | the display title of the option, e.g. "Size" |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the model update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:699](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L699)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### count
|
||||
|
||||
▸ **count**(`selector?`): `Promise`<`number`\>
|
||||
|
||||
Return the total number of documents in database
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Product`\> | the selector to choose products by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the result of the count operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:186](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L186)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`productObject`): `Promise`<`Product`\>
|
||||
|
||||
Creates a product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productObject` | `CreateProductInput` | the product to create |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
resolves to the creation result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:419](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L419)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`productId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a product from a given product id. The product's associated
|
||||
variants will also be deleted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:660](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L660)
|
||||
|
||||
___
|
||||
|
||||
### deleteOption
|
||||
|
||||
▸ **deleteOption**(`productId`, `optionId`): `Promise`<`void` \| `Product`\>
|
||||
|
||||
Delete an option from a product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product to delete an option from |
|
||||
| `optionId` | `string` | the option to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `Product`\>
|
||||
|
||||
the updated product
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:864](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L864)
|
||||
|
||||
___
|
||||
|
||||
### filterProductsBySalesChannel
|
||||
|
||||
▸ **filterProductsBySalesChannel**(`productIds`, `salesChannelId`, `config?`): `Promise`<`Product`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productIds` | `string`[] |
|
||||
| `salesChannelId` | `string` |
|
||||
| `config` | `FindProductConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:344](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L344)
|
||||
|
||||
___
|
||||
|
||||
### isProductInSalesChannels
|
||||
|
||||
▸ **isProductInSalesChannels**(`id`, `salesChannelIds`): `Promise`<`boolean`\>
|
||||
|
||||
Check if the product is assigned to at least one of the provided sales channels.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | product id |
|
||||
| `salesChannelIds` | `string`[] | an array of sales channel ids |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:397](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L397)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`Product`[]\>
|
||||
|
||||
Lists products based on the provided parameters.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `ProductSelector` | an object that defines rules to filter products by |
|
||||
| `config` | `FindProductConfig` | object that defines the scope for what should be returned |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:117](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L117)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Product`[], `number`]\>
|
||||
|
||||
Lists products based on the provided parameters and includes the count of
|
||||
products that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `ProductSelector` | an object that defines rules to filter products by |
|
||||
| `config` | `FindProductConfig` | object that defines the scope for what should be returned |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Product`[], `number`]\>
|
||||
|
||||
an array containing the products as
|
||||
the first element and the total count of products that matches the query
|
||||
as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:141](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L141)
|
||||
|
||||
___
|
||||
|
||||
### listTagsByUsage
|
||||
|
||||
▸ **listTagsByUsage**(`take?`): `Promise`<`ProductTag`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `take` | `number` | `10` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductTag`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:383](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L383)
|
||||
|
||||
___
|
||||
|
||||
### listTypes
|
||||
|
||||
▸ **listTypes**(): `Promise`<`ProductType`[]\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductType`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:375](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L375)
|
||||
|
||||
___
|
||||
|
||||
### prepareListQuery\_
|
||||
|
||||
▸ `Protected` **prepareListQuery_**(`selector`, `config`): `Object`
|
||||
|
||||
Temporary method to be used in place we need custom query strategy to prevent typeorm bug
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `FilterableProductProps` \| `Selector`<`Product`\> |
|
||||
| `config` | `FindProductConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Object`
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `q` | `string` |
|
||||
| `query` | `FindWithoutRelationsOptions` |
|
||||
| `relations` | keyof `Product`[] |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:972](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L972)
|
||||
|
||||
___
|
||||
|
||||
### reorderVariants
|
||||
|
||||
▸ **reorderVariants**(`productId`, `variantOrder`): `Promise`<`Product`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productId` | `string` |
|
||||
| `variantOrder` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:742](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L742)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`productId`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by id.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | id of the product to get. |
|
||||
| `config` | `FindProductConfig` | object that defines what should be included in the query response |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:202](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L202)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByExternalId
|
||||
|
||||
▸ **retrieveByExternalId**(`externalId`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by external id.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `externalId` | `string` | handle of the product to get. |
|
||||
| `config` | `FindProductConfig` | details about what to get from the product |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:246](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L246)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByHandle
|
||||
|
||||
▸ **retrieveByHandle**(`productHandle`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by handle.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productHandle` | `string` | handle of the product to get. |
|
||||
| `config` | `FindProductConfig` | details about what to get from the product |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:225](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L225)
|
||||
|
||||
___
|
||||
|
||||
### retrieveOptionByTitle
|
||||
|
||||
▸ **retrieveOptionByTitle**(`title`, `productId`): `Promise`<``null`` \| `ProductOption`\>
|
||||
|
||||
Retrieve product's option by title.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `title` | `string` | title of the option |
|
||||
| `productId` | `string` | id of a product |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `ProductOption`\>
|
||||
|
||||
product option
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:845](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L845)
|
||||
|
||||
___
|
||||
|
||||
### retrieveVariants
|
||||
|
||||
▸ **retrieveVariants**(`productId`, `config?`): `Promise`<`ProductVariant`[]\>
|
||||
|
||||
Gets all variants belonging to a product.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product to get variants from. |
|
||||
| `config` | `FindProductConfig` | The config to select and configure relations etc... |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[]\>
|
||||
|
||||
an array of variants
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:326](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L326)
|
||||
|
||||
___
|
||||
|
||||
### retrieve\_
|
||||
|
||||
▸ **retrieve_**(`selector`, `config?`): `Promise`<`Product`\>
|
||||
|
||||
Gets a product by selector.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Product`\> | selector object |
|
||||
| `config` | `FindProductConfig` | object that defines what should be included in the query response |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:268](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L268)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the id of the product. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `UpdateProductInput` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:528](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L528)
|
||||
|
||||
___
|
||||
|
||||
### updateOption
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productId` | `string` | the product whose option we are updating |
|
||||
| `optionId` | `string` | the id of the option we are updating |
|
||||
| `data` | `ProductOptionInput` | the data to update the option with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`\>
|
||||
|
||||
the updated product
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:788](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L788)
|
||||
|
||||
___
|
||||
|
||||
### updateShippingProfile
|
||||
|
||||
▸ **updateShippingProfile**(`productIds`, `profileId`): `Promise`<`Product`[]\>
|
||||
|
||||
Assign a product to a profile, if a profile id null is provided then detach the product from the profile
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productIds` | `string` \| `string`[] | ID or IDs of the products to update |
|
||||
| `profileId` | ``null`` \| `string` | Shipping profile ID to update the shipping options with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Product`[]\>
|
||||
|
||||
updated products
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product.ts:935](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product.ts#L935)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ProductService`](ProductService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductService`](ProductService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,288 @@
|
||||
# Class: ProductTypeService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ProductTypeService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductTypeService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-type.ts:12](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-type.ts#L12)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### typeRepository\_
|
||||
|
||||
• `Protected` `Readonly` **typeRepository\_**: `Repository`<`ProductType`\> & { `findAndCountByDiscountConditionId`: (`conditionId`: `string`, `query`: `ExtendedFindConfig`<`ProductType`\>) => `Promise`<[`ProductType`[], `number`]\> ; `upsertType`: (`type?`: `UpsertTypeInput`) => `Promise`<``null`` \| `ProductType`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-type.ts:10](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-type.ts#L10)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`ProductType`[]\>
|
||||
|
||||
Lists product types
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ProductType`\> & { `discount_condition_id?`: `string` ; `q?`: `string` } | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductType`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductType`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-type.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-type.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`ProductType`[], `number`]\>
|
||||
|
||||
Lists product types and adds count.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ProductType`\> & { `discount_condition_id?`: `string` ; `q?`: `string` } | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductType`\> | the config to be used for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductType`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-type.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-type.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`id`, `config?`): `Promise`<`ProductType`\>
|
||||
|
||||
Gets a product type by id.
|
||||
Throws in case of DB Error and if product was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | id of the product to get. |
|
||||
| `config` | `FindConfig`<`ProductType`\> | object that defines what should be included in the query response |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductType`\>
|
||||
|
||||
the result of the find one operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-type.ts:27](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-type.ts#L27)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ProductTypeService`](ProductTypeService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductTypeService`](ProductTypeService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,700 @@
|
||||
# Class: ProductVariantInventoryService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ProductVariantInventoryService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductVariantInventoryService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:50](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L50)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### cacheService\_
|
||||
|
||||
• `Protected` `Readonly` **cacheService\_**: `ICacheService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:48](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: `IEventBusService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:47](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### inventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **inventoryService\_**: `IInventoryService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### productVariantService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantService\_**: [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:44](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L44)
|
||||
|
||||
___
|
||||
|
||||
### salesChannelInventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **salesChannelInventoryService\_**: [`SalesChannelInventoryService`](SalesChannelInventoryService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### salesChannelLocationService\_
|
||||
|
||||
• `Protected` `Readonly` **salesChannelLocationService\_**: [`SalesChannelLocationService`](SalesChannelLocationService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### stockLocationService\_
|
||||
|
||||
• `Protected` `Readonly` **stockLocationService\_**: `IStockLocationService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L40)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### adjustInventory
|
||||
|
||||
▸ **adjustInventory**(`variantId`, `locationId`, `quantity`): `Promise`<`void`\>
|
||||
|
||||
Adjusts inventory of a variant on a location
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | variant id |
|
||||
| `locationId` | `string` | location id |
|
||||
| `quantity` | `number` | quantity to adjust |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:740](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L740)
|
||||
|
||||
___
|
||||
|
||||
### adjustReservationsQuantityByLineItem
|
||||
|
||||
▸ **adjustReservationsQuantityByLineItem**(`lineItemId`, `variantId`, `locationId`, `quantity`): `Promise`<`void`\>
|
||||
|
||||
Adjusts the quantity of reservations for a line item by a given amount.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItemId` | `string` | The ID of the line item |
|
||||
| `variantId` | `string` | The ID of the variant |
|
||||
| `locationId` | `string` | The ID of the location to prefer adjusting quantities at |
|
||||
| `quantity` | `number` | The amount to adjust the quantity by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:530](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L530)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### attachInventoryItem
|
||||
|
||||
▸ **attachInventoryItem**(`attachments`): `Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
Attach a variant to an inventory item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `attachments` | { `inventoryItemId`: `string` ; `requiredQuantity?`: `number` ; `variantId`: `string` }[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
the variant inventory item
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:257](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L257)
|
||||
|
||||
▸ **attachInventoryItem**(`variantId`, `inventoryItemId`, `requiredQuantity?`): `Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variantId` | `string` |
|
||||
| `inventoryItemId` | `string` |
|
||||
| `requiredQuantity?` | `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:264](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L264)
|
||||
|
||||
___
|
||||
|
||||
### confirmInventory
|
||||
|
||||
▸ **confirmInventory**(`variantId`, `quantity`, `context?`): `Promise`<`Boolean`\>
|
||||
|
||||
confirms if requested inventory is available
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | id of the variant to confirm inventory for |
|
||||
| `quantity` | `number` | quantity of inventory to confirm is available |
|
||||
| `context` | `Object` | optionally include a sales channel if applicable |
|
||||
| `context.salesChannelId?` | ``null`` \| `string` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Boolean`\>
|
||||
|
||||
boolean indicating if inventory is available
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:76](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L76)
|
||||
|
||||
___
|
||||
|
||||
### deleteReservationsByLineItem
|
||||
|
||||
▸ **deleteReservationsByLineItem**(`lineItemId`, `variantId`, `quantity`): `Promise`<`void`\>
|
||||
|
||||
delete a reservation of variant quantity
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItemId` | `string` \| `string`[] | line item id |
|
||||
| `variantId` | `string` | variant id |
|
||||
| `quantity` | `number` | quantity to release |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:705](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L705)
|
||||
|
||||
___
|
||||
|
||||
### detachInventoryItem
|
||||
|
||||
▸ **detachInventoryItem**(`inventoryItemId`, `variantId?`): `Promise`<`void`\>
|
||||
|
||||
Remove a variant from an inventory item
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `inventoryItemId` | `string` | inventory item id |
|
||||
| `variantId?` | `string` | variant id or undefined if all the variants will be affected |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:409](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L409)
|
||||
|
||||
___
|
||||
|
||||
### getAvailabilityContext
|
||||
|
||||
▸ `Private` **getAvailabilityContext**(`variants`, `salesChannelId`, `existingContext?`): `Promise`<`Required`<`AvailabilityContext`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variants` | `string`[] |
|
||||
| `salesChannelId` | `undefined` \| `string` \| `string`[] |
|
||||
| `existingContext` | `AvailabilityContext` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Required`<`AvailabilityContext`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:843](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L843)
|
||||
|
||||
___
|
||||
|
||||
### getVariantQuantityFromVariantInventoryItems
|
||||
|
||||
▸ **getVariantQuantityFromVariantInventoryItems**(`variantInventoryItems`, `channelId`): `Promise`<`number`\>
|
||||
|
||||
Get the quantity of a variant from a list of variantInventoryItems
|
||||
The inventory quantity of the variant should be equal to the inventory
|
||||
item with the smallest stock, adjusted for quantity required to fulfill
|
||||
the given variant.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantInventoryItems` | `ProductVariantInventoryItem`[] | List of inventoryItems for a given variant, These must all be for the same variant |
|
||||
| `channelId` | `string` | Sales channel id to fetch availability for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
The available quantity of the variant from the inventoryItems
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:954](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L954)
|
||||
|
||||
___
|
||||
|
||||
### listByItem
|
||||
|
||||
▸ **listByItem**(`itemIds`): `Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
list registered inventory items
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `itemIds` | `string`[] | list inventory item ids |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
list of inventory items
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:179](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L179)
|
||||
|
||||
___
|
||||
|
||||
### listByVariant
|
||||
|
||||
▸ **listByVariant**(`variantId`): `Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
List inventory items for a specific variant
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` \| `string`[] | variant id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantInventoryItem`[]\>
|
||||
|
||||
variant inventory items for the variant id
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:196](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L196)
|
||||
|
||||
___
|
||||
|
||||
### listInventoryItemsByVariant
|
||||
|
||||
▸ **listInventoryItemsByVariant**(`variantId`): `Promise`<`InventoryItemDTO`[]\>
|
||||
|
||||
lists inventory items for a given variant
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | variant id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`InventoryItemDTO`[]\>
|
||||
|
||||
lidt of inventory items for the variant
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:235](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L235)
|
||||
|
||||
___
|
||||
|
||||
### listVariantsByItem
|
||||
|
||||
▸ **listVariantsByItem**(`itemId`): `Promise`<`ProductVariant`[]\>
|
||||
|
||||
lists variant by inventory item id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `itemId` | `string` | item id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[]\>
|
||||
|
||||
a list of product variants that are associated with the item id
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:217](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L217)
|
||||
|
||||
___
|
||||
|
||||
### reserveQuantity
|
||||
|
||||
▸ **reserveQuantity**(`variantId`, `quantity`, `context?`): `Promise`<`void` \| `ReservationItemDTO`[]\>
|
||||
|
||||
Reserves a quantity of a variant
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | variant id |
|
||||
| `quantity` | `number` | quantity to reserve |
|
||||
| `context` | `ReserveQuantityContext` | optional parameters |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `ReservationItemDTO`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:439](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L439)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`inventoryItemId`, `variantId`): `Promise`<`ProductVariantInventoryItem`\>
|
||||
|
||||
Retrieves a product variant inventory item by its inventory item ID and variant ID.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `inventoryItemId` | `string` | The ID of the inventory item to retrieve. |
|
||||
| `variantId` | `string` | The ID of the variant to retrieve. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariantInventoryItem`\>
|
||||
|
||||
A promise that resolves with the product variant inventory item.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:152](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L152)
|
||||
|
||||
___
|
||||
|
||||
### setProductAvailability
|
||||
|
||||
▸ **setProductAvailability**(`products`, `salesChannelId`): `Promise`<(`Product` \| `PricedProduct`)[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `products` | (`Product` \| `PricedProduct`)[] |
|
||||
| `salesChannelId` | `undefined` \| `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`Product` \| `PricedProduct`)[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:910](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L910)
|
||||
|
||||
___
|
||||
|
||||
### setVariantAvailability
|
||||
|
||||
▸ **setVariantAvailability**(`variants`, `salesChannelId`, `availabilityContext?`): `Promise`<`ProductVariant`[] \| `PricedVariant`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variants` | `ProductVariant`[] \| `PricedVariant`[] |
|
||||
| `salesChannelId` | `undefined` \| `string` \| `string`[] |
|
||||
| `availabilityContext` | `AvailabilityContext` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[] \| `PricedVariant`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:784](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L784)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### validateInventoryAtLocation
|
||||
|
||||
▸ **validateInventoryAtLocation**(`items`, `locationId`): `Promise`<`void`\>
|
||||
|
||||
Validate stock at a location for fulfillment items
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `items` | `Omit`<`LineItem`, ``"beforeInsert"``\>[] | Fulfillment Line items to validate quantities for |
|
||||
| `locationId` | `string` | Location to validate stock at |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
nothing if successful, throws error if not
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant-inventory.ts:640](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant-inventory.ts#L640)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ProductVariantInventoryService`](ProductVariantInventoryService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductVariantInventoryService`](ProductVariantInventoryService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,883 @@
|
||||
# Class: ProductVariantService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ProductVariantService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ProductVariantService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:75](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L75)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### cartRepository\_
|
||||
|
||||
• `Protected` `Readonly` **cartRepository\_**: `Repository`<`Cart`\> & { `findOneWithRelations`: (`relations`: `FindOptionsRelations`<`Cart`\>, `optionsWithoutRelations`: `Omit`<`FindManyOptions`<`Cart`\>, ``"relations"``\>) => `Promise`<`Cart`\> ; `findWithRelations`: (`relations`: `FindOptionsRelations`<`Cart`\>, `optionsWithoutRelations`: `Omit`<`FindManyOptions`<`Cart`\>, ``"relations"``\>) => `Promise`<`Cart`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:73](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L73)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### moneyAmountRepository\_
|
||||
|
||||
• `Protected` `Readonly` **moneyAmountRepository\_**: `Repository`<`MoneyAmount`\> & { `addPriceListPrices`: (`priceListId`: `string`, `prices`: `PriceListPriceCreateInput`[], `overrideExisting`: `boolean`) => `Promise`<`MoneyAmount`[]\> ; `deletePriceListPrices`: (`priceListId`: `string`, `moneyAmountIds`: `string`[]) => `Promise`<`void`\> ; `deleteVariantPricesNotIn`: (`variantIdOrData`: `string` \| { `prices`: `ProductVariantPrice`[] ; `variantId`: `string` }[], `prices?`: `Price`[]) => `Promise`<`void`\> ; `findManyForVariantInPriceList`: (`variant_id`: `string`, `price_list_id`: `string`, `requiresPriceList`: `boolean`) => `Promise`<[`MoneyAmount`[], `number`]\> ; `findManyForVariantInRegion`: (`variant_id`: `string`, `region_id?`: `string`, `currency_code?`: `string`, `customer_id?`: `string`, `include_discount_prices?`: `boolean`, `include_tax_inclusive_pricing`: `boolean`) => `Promise`<[`MoneyAmount`[], `number`]\> ; `findManyForVariantsInRegion`: (`variant_ids`: `string` \| `string`[], `region_id?`: `string`, `currency_code?`: `string`, `customer_id?`: `string`, `include_discount_prices?`: `boolean`, `include_tax_inclusive_pricing`: `boolean`) => `Promise`<[`Record`<`string`, `MoneyAmount`[]\>, `number`]\> ; `findVariantPricesNotIn`: (`variantId`: `string`, `prices`: `Price`[]) => `Promise`<`MoneyAmount`[]\> ; `insertBulk`: (`data`: `_QueryDeepPartialEntity`<`MoneyAmount`\>[]) => `Promise`<`MoneyAmount`[]\> ; `updatePriceListPrices`: (`priceListId`: `string`, `updates`: `PriceListPriceUpdateInput`[]) => `Promise`<`MoneyAmount`[]\> ; `upsertVariantCurrencyPrice`: (`variantId`: `string`, `price`: `Price`) => `Promise`<`MoneyAmount`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:70](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### priceSelectionStrategy\_
|
||||
|
||||
• `Protected` `Readonly` **priceSelectionStrategy\_**: `IPriceSelectionStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### productOptionValueRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productOptionValueRepository\_**: `Repository`<`ProductOptionValue`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:72](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L72)
|
||||
|
||||
___
|
||||
|
||||
### productRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productRepository\_**: `Repository`<`Product`\> & { `_applyCategoriesQuery`: (`qb`: `SelectQueryBuilder`<`Product`\>, `__namedParameters`: `Object`) => `SelectQueryBuilder`<`Product`\> ; `_findWithRelations`: (`__namedParameters`: { `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions` ; `relations`: `string`[] ; `shouldCount`: `boolean` ; `withDeleted`: `boolean` }) => `Promise`<[`Product`[], `number`]\> ; `bulkAddToCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `bulkRemoveFromCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `findOneWithRelations`: (`relations`: `string`[], `optionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<`Product`\> ; `findWithRelations`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions`, `withDeleted`: `boolean`) => `Promise`<`Product`[]\> ; `findWithRelationsAndCount`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<[`Product`[], `number`]\> ; `getFreeTextSearchResultsAndCount`: (`q`: `string`, `options`: `FindWithoutRelationsOptions`, `relations`: `string`[]) => `Promise`<[`Product`[], `number`]\> ; `isProductInSalesChannels`: (`id`: `string`, `salesChannelIds`: `string`[]) => `Promise`<`boolean`\> ; `queryProducts`: (`optionsWithoutRelations`: `FindWithoutRelationsOptions`, `shouldCount`: `boolean`) => `Promise`<[`Product`[], `number`]\> ; `queryProductsWithIds`: (`__namedParameters`: { `entityIds`: `string`[] ; `groupedRelations`: { `[toplevel: string]`: `string`[]; } ; `order?`: { `[column: string]`: ``"ASC"`` \| ``"DESC"``; } ; `select?`: keyof `Product`[] ; `where?`: `FindOptionsWhere`<`Product`\> ; `withDeleted?`: `boolean` }) => `Promise`<`Product`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:66](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### productVariantRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantRepository\_**: `Repository`<`ProductVariant`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L59)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addOptionValue
|
||||
|
||||
▸ **addOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
||||
|
||||
Adds option value to a variant.
|
||||
Fails when product with variant does not exist or
|
||||
if that product does not have an option with the given
|
||||
option id. Fails if given variant is not found.
|
||||
Option value must be of type string or number.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the variant to decorate. |
|
||||
| `optionId` | `string` | the option from product. |
|
||||
| `optionValue` | `string` | option value to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductOptionValue`\>
|
||||
|
||||
the result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:836](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L836)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**<`TVariants`, `TOutput`\>(`productOrProductId`, `variants`): `Promise`<`TOutput`\>
|
||||
|
||||
Creates an unpublished product variant. Will validate against parent product
|
||||
to ensure that the variant can in fact be created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `TVariants` | extends `CreateProductVariantInput` \| `CreateProductVariantInput`[] |
|
||||
| `TOutput` | `TVariants` extends `CreateProductVariantInput`[] ? `CreateProductVariantInput`[] : `CreateProductVariantInput` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productOrProductId` | `string` \| `Product` | the product the variant will be added to |
|
||||
| `variants` | `CreateProductVariantInput` \| `CreateProductVariantInput`[] | |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TOutput`\>
|
||||
|
||||
resolves to the creation result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:168](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L168)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`variantIds`): `Promise`<`void`\>
|
||||
|
||||
Deletes variant or variants.
|
||||
Will never fail due to delete being idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantIds` | `string` \| `string`[] | the id of the variant to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:1006](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L1006)
|
||||
|
||||
___
|
||||
|
||||
### deleteOptionValue
|
||||
|
||||
▸ **deleteOptionValue**(`variantId`, `optionId`): `Promise`<`void`\>
|
||||
|
||||
Deletes option value from given variant.
|
||||
Will never fail due to delete being idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the variant to decorate. |
|
||||
| `optionId` | `string` | the option from product. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:863](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L863)
|
||||
|
||||
___
|
||||
|
||||
### getFreeTextQueryBuilder\_
|
||||
|
||||
▸ **getFreeTextQueryBuilder_**(`variantRepo`, `query`, `q?`): `SelectQueryBuilder`<`ProductVariant`\>
|
||||
|
||||
Lists variants based on the provided parameters and includes the count of
|
||||
variants that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantRepo` | `Repository`<`ProductVariant`\> | the variant repository |
|
||||
| `query` | `FindWithRelationsOptions` | object that defines the scope for what should be returned |
|
||||
| `q?` | `string` | free text query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`SelectQueryBuilder`<`ProductVariant`\>
|
||||
|
||||
an array containing the products as the first element and the total
|
||||
count of products that matches the query as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:1069](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L1069)
|
||||
|
||||
___
|
||||
|
||||
### getRegionPrice
|
||||
|
||||
▸ **getRegionPrice**(`variantId`, `context`): `Promise`<``null`` \| `number`\>
|
||||
|
||||
Gets the price specific to a region. If no region specific money amount
|
||||
exists the function will try to use a currency price. If no default
|
||||
currency price exists the function will throw an error.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to get price from |
|
||||
| `context` | `GetRegionPriceContext` | context for getting region price |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `number`\>
|
||||
|
||||
the price specific to the region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:711](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L711)
|
||||
|
||||
___
|
||||
|
||||
### isVariantInSalesChannels
|
||||
|
||||
▸ **isVariantInSalesChannels**(`id`, `salesChannelIds`): `Promise`<`boolean`\>
|
||||
|
||||
Check if the variant is assigned to at least one of the provided sales channels.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | product variant id |
|
||||
| `salesChannelIds` | `string`[] | an array of sales channel ids |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:1044](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L1044)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`ProductVariant`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductVariantProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:952](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L952)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`ProductVariant`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableProductVariantProps` | the query object for find |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ProductVariant`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:891](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L891)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`variantId`, `config?`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Gets a product variant by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the product to get. |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
the product document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:104](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L104)
|
||||
|
||||
___
|
||||
|
||||
### retrieveBySKU
|
||||
|
||||
▸ **retrieveBySKU**(`sku`, `config?`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Gets a product variant by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `sku` | `string` | The unique stock keeping unit used to identify the product variant. |
|
||||
| `config` | `FindConfig`<`ProductVariant`\> & `PriceSelectionContext` | query config object for variant retrieval. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
the product document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:132](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L132)
|
||||
|
||||
___
|
||||
|
||||
### setCurrencyPrice
|
||||
|
||||
▸ **setCurrencyPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
use addOrUpdateCurrencyPrices instead
|
||||
Sets the default price for the given currency.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to set prices for |
|
||||
| `price` | `ProductVariantPrice` | the price for the variant |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`MoneyAmount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:777](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L777)
|
||||
|
||||
___
|
||||
|
||||
### setRegionPrice
|
||||
|
||||
▸ **setRegionPrice**(`variantId`, `price`): `Promise`<`MoneyAmount`\>
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
use addOrUpdateRegionPrices instead
|
||||
Sets the default price of a specific region
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of the variant to update |
|
||||
| `price` | `ProductVariantPrice` | the price for the variant. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`MoneyAmount`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:740](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L740)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`variantData`): `Promise`<`ProductVariant`[]\>
|
||||
|
||||
Updates a collection of variant.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantData` | { `updateData`: `UpdateProductVariantInput` ; `variant`: `ProductVariant` }[] | a collection of variant and the data to update. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[]\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:266](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L266)
|
||||
|
||||
▸ **update**(`variantOrVariantId`, `update`): `Promise`<`ProductVariant`\>
|
||||
|
||||
Updates a variant.
|
||||
Price updates should use dedicated methods.
|
||||
The function will throw, if price updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantOrVariantId` | `string` \| `Partial`<`ProductVariant`\> | variant or id of a variant. |
|
||||
| `update` | `UpdateProductVariantInput` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:281](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L281)
|
||||
|
||||
▸ **update**(`variantOrVariantId`, `update`): `Promise`<`ProductVariant`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variantOrVariantId` | `string` \| `Partial`<`ProductVariant`\> |
|
||||
| `update` | `UpdateProductVariantInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:286](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L286)
|
||||
|
||||
___
|
||||
|
||||
### updateBatch
|
||||
|
||||
▸ `Protected` **updateBatch**(`variantData`): `Promise`<`ProductVariant`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `variantData` | `UpdateProductVariantData`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductVariant`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:340](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L340)
|
||||
|
||||
___
|
||||
|
||||
### updateOptionValue
|
||||
|
||||
▸ **updateOptionValue**(`variantId`, `optionId`, `optionValue`): `Promise`<`ProductOptionValue`\>
|
||||
|
||||
Updates variant's option value.
|
||||
Option value must be of type string or number.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the variant to decorate. |
|
||||
| `optionId` | `string` | the option from product. |
|
||||
| `optionValue` | `string` | option value to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductOptionValue`\>
|
||||
|
||||
the result of the update operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:798](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L798)
|
||||
|
||||
___
|
||||
|
||||
### updateVariantPrices
|
||||
|
||||
▸ **updateVariantPrices**(`data`): `Promise`<`void`\>
|
||||
|
||||
Updates variant/prices collection.
|
||||
Deletes any prices that are not in the update object, and is not associated with a price list.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `UpdateVariantPricesData`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:438](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L438)
|
||||
|
||||
▸ **updateVariantPrices**(`variantId`, `prices`): `Promise`<`void`\>
|
||||
|
||||
Updates a variant's prices.
|
||||
Deletes any prices that are not in the update object, and is not associated with a price list.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `variantId` | `string` | the id of variant |
|
||||
| `prices` | `ProductVariantPrice`[] | the update prices |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
empty promise
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:447](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L447)
|
||||
|
||||
___
|
||||
|
||||
### updateVariantPricesBatch
|
||||
|
||||
▸ `Protected` **updateVariantPricesBatch**(`data`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `UpdateVariantPricesData`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:467](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L467)
|
||||
|
||||
___
|
||||
|
||||
### upsertCurrencyPrices
|
||||
|
||||
▸ **upsertCurrencyPrices**(`data`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | { `price`: `WithRequiredProperty`<`ProductVariantPrice`, ``"currency_code"``\> ; `variantId`: `string` }[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:619](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L619)
|
||||
|
||||
___
|
||||
|
||||
### upsertRegionPrices
|
||||
|
||||
▸ **upsertRegionPrices**(`data`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `UpdateVariantRegionPriceData`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:540](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L540)
|
||||
|
||||
___
|
||||
|
||||
### validateVariantsToCreate\_
|
||||
|
||||
▸ `Protected` **validateVariantsToCreate_**(`product`, `variants`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `product` | `Product` |
|
||||
| `variants` | `CreateProductVariantInput`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/product-variant.ts:1104](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/product-variant.ts#L1104)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ProductVariantService`](ProductVariantService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,795 @@
|
||||
# Class: RegionService
|
||||
|
||||
Provides layer to manipulate regions.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`RegionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new RegionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L64)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### countryRepository\_
|
||||
|
||||
• `Protected` `Readonly` **countryRepository\_**: `Repository`<`Country`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### currencyRepository\_
|
||||
|
||||
• `Protected` `Readonly` **currencyRepository\_**: `Repository`<`Currency`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:57](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:51](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L51)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:49](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentProviderRepository\_**: `Repository`<`FulfillmentProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:61](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L61)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentProviderService\_**: [`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:54](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L54)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderRepository\_**: `Repository`<`PaymentProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L59)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderService\_**: [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:53](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### regionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **regionRepository\_**: `Repository`<`Region`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:55](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### storeService\_
|
||||
|
||||
• `Protected` `Readonly` **storeService\_**: [`StoreService`](StoreService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderRepository\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderRepository\_**: `Repository`<`TaxProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:62](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L43)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCountry
|
||||
|
||||
▸ **addCountry**(`regionId`, `code`): `Promise`<`Region`\>
|
||||
|
||||
Adds a country to the region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to add a country to |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the updated Region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:577](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L577)
|
||||
|
||||
___
|
||||
|
||||
### addFulfillmentProvider
|
||||
|
||||
▸ **addFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`Region`\>
|
||||
|
||||
Adds a fulfillment provider that is available in the region. Fails if the
|
||||
provider doesn't exist.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to add the provider to |
|
||||
| `providerId` | `string` | the provider to add to the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the updated Region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:705](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L705)
|
||||
|
||||
___
|
||||
|
||||
### addPaymentProvider
|
||||
|
||||
▸ **addPaymentProvider**(`regionId`, `providerId`): `Promise`<`Region`\>
|
||||
|
||||
Adds a payment provider that is available in the region. Fails if the
|
||||
provider doesn't exist.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to add the provider to |
|
||||
| `providerId` | `string` | the provider to add to the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the updated Region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:656](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L656)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`Region`\>
|
||||
|
||||
Creates a region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreateRegionInput` | the unvalidated region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the newly created region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:100](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`regionId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the delete operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:546](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L546)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`Region`[]\>
|
||||
|
||||
Lists all regions based on a query
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Region`\> | query object for find |
|
||||
| `config` | `FindConfig`<`Region`\> | configuration settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`[]\>
|
||||
|
||||
result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:505](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L505)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector?`, `config?`): `Promise`<[`Region`[], `number`]\>
|
||||
|
||||
Lists all regions based on a query and returns them along with count
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Region`\> | query object for find |
|
||||
| `config` | `FindConfig`<`Region`\> | configuration settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Region`[], `number`]\>
|
||||
|
||||
result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:524](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L524)
|
||||
|
||||
___
|
||||
|
||||
### removeCountry
|
||||
|
||||
▸ **removeCountry**(`regionId`, `code`): `Promise`<`Region`\>
|
||||
|
||||
Removes a country from a Region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to remove from |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the updated Region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:615](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L615)
|
||||
|
||||
___
|
||||
|
||||
### removeFulfillmentProvider
|
||||
|
||||
▸ **removeFulfillmentProvider**(`regionId`, `providerId`): `Promise`<`Region`\>
|
||||
|
||||
Removes a fulfillment provider from a region. Is idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to remove the provider from |
|
||||
| `providerId` | `string` | the provider to remove from the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the updated Region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:791](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L791)
|
||||
|
||||
___
|
||||
|
||||
### removePaymentProvider
|
||||
|
||||
▸ **removePaymentProvider**(`regionId`, `providerId`): `Promise`<`Region`\>
|
||||
|
||||
Removes a payment provider from a region. Is idempotent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to remove the provider from |
|
||||
| `providerId` | `string` | the provider to remove from the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the updated Region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:752](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L752)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`regionId`, `config?`): `Promise`<`Region`\>
|
||||
|
||||
Retrieves a region by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the id of the region to retrieve |
|
||||
| `config` | `FindConfig`<`Region`\> | configuration settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the region
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:470](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L470)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCountryCode
|
||||
|
||||
▸ **retrieveByCountryCode**(`code`, `config?`): `Promise`<`Region`\>
|
||||
|
||||
Retrieve a region by country code.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code |
|
||||
| `config` | `FindConfig`<`Region`\> | region find config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
a Region with country code
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:416](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L416)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByName
|
||||
|
||||
▸ **retrieveByName**(`name`): `Promise`<`Region`\>
|
||||
|
||||
Retrieves a region by name.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `name` | `string` | the name of the region to retrieve |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
region with the matching name
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:450](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L450)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`regionId`, `update`): `Promise`<`Region`\>
|
||||
|
||||
Updates a region
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionId` | `string` | the region to update |
|
||||
| `update` | `UpdateRegionInput` | the data to update the region with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Region`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:171](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L171)
|
||||
|
||||
___
|
||||
|
||||
### validateCountry
|
||||
|
||||
▸ `Protected` **validateCountry**(`code`, `regionId`): `Promise`<`Country`\>
|
||||
|
||||
Validates a country code. Will normalize the code before checking for
|
||||
existence.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | a 2 digit alphanumeric ISO country code |
|
||||
| `regionId` | `string` | the id of the current region to check against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Country`\>
|
||||
|
||||
the validated Country
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:367](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L367)
|
||||
|
||||
___
|
||||
|
||||
### validateCurrency
|
||||
|
||||
▸ `Protected` **validateCurrency**(`currencyCode`): `Promise`<`void`\>
|
||||
|
||||
Validates a currency code. Will throw if the currency code doesn't exist.
|
||||
|
||||
**`Throws`**
|
||||
|
||||
if the provided currency code is invalid
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `currencyCode` | `string` | an ISO currency code |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
void
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:342](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L342)
|
||||
|
||||
___
|
||||
|
||||
### validateFields
|
||||
|
||||
▸ `Protected` **validateFields**<`T`\>(`regionData`, `id?`): `Promise`<`DeepPartial`<`Region`\>\>
|
||||
|
||||
Validates fields for creation and updates. If the region already exists
|
||||
the id can be passed to check that country updates are allowed.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `T` | extends `UpdateRegionInput` \| `CreateRegionInput` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `regionData` | `Omit`<`T`, ``"metadata"`` \| ``"currency_code"``\> | the region data to validate |
|
||||
| `id?` | `T` extends `UpdateRegionInput` ? `string` : `undefined` | optional id of the region to check against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`DeepPartial`<`Region`\>\>
|
||||
|
||||
the validated region data
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:240](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L240)
|
||||
|
||||
___
|
||||
|
||||
### validateTaxRate
|
||||
|
||||
▸ `Protected` **validateTaxRate**(`taxRate`): `void`
|
||||
|
||||
Validates a tax rate. Will throw if the tax rate is not between 0 and 1.
|
||||
|
||||
**`Throws`**
|
||||
|
||||
if the tax rate isn't number between 0-100
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `taxRate` | `number` | a number representing the tax rate of the region |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
void
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/region.ts:326](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/region.ts#L326)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`RegionService`](RegionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`RegionService`](RegionService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,321 @@
|
||||
# Class: ReturnReasonService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ReturnReasonService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ReturnReasonService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:18](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L18)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### retReasonRepo\_
|
||||
|
||||
• `Protected` `Readonly` **retReasonRepo\_**: `Repository`<`ReturnReason`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:16](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L16)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`ReturnReason`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateReturnReason` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ReturnReason`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`returnReasonId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnReasonId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:113](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L113)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`ReturnReason`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ReturnReason`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`ReturnReason`\> | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ReturnReason`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:68](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`returnReasonId`, `config?`): `Promise`<`ReturnReason`\>
|
||||
|
||||
Gets an order by id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `returnReasonId` | `string` | id of order to retrieve |
|
||||
| `config` | `FindConfig`<`ReturnReason`\> | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ReturnReason`\>
|
||||
|
||||
the order document
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:87](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L87)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`ReturnReason`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `data` | `UpdateReturnReason` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ReturnReason`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return-reason.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return-reason.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ReturnReasonService`](ReturnReasonService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ReturnReasonService`](ReturnReasonService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,605 @@
|
||||
# Class: ReturnService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ReturnService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ReturnService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:64](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L64)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentProviderService\_**: [`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:58](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:55](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### orderService\_
|
||||
|
||||
• `Protected` `Readonly` **orderService\_**: [`OrderService`](OrderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### productVariantInventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantInventoryService\_**: [`ProductVariantInventoryService`](ProductVariantInventoryService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:62](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L62)
|
||||
|
||||
___
|
||||
|
||||
### returnItemRepository\_
|
||||
|
||||
• `Protected` `Readonly` **returnItemRepository\_**: `Repository`<`ReturnItem`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:54](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L54)
|
||||
|
||||
___
|
||||
|
||||
### returnReasonService\_
|
||||
|
||||
• `Protected` `Readonly` **returnReasonService\_**: [`ReturnReasonService`](ReturnReasonService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:59](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L59)
|
||||
|
||||
___
|
||||
|
||||
### returnRepository\_
|
||||
|
||||
• `Protected` `Readonly` **returnRepository\_**: `Repository`<`Return`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:53](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:57](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L52)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`returnId`): `Promise`<`Return`\>
|
||||
|
||||
Cancels a return if possible. Returns can be canceled if it has not been received.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `returnId` | `string` | the id of the return to cancel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
the updated Return
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:178](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L178)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`Return`\>
|
||||
|
||||
Creates a return request for an order, with given items, and a shipping
|
||||
method. If no refund amount is provided the refund amount is calculated from
|
||||
the return lines and the shipping cost.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreateReturnInput` | data to use for the return e.g. shipping_method, items or refund_amount |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
the created return
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:363](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L363)
|
||||
|
||||
___
|
||||
|
||||
### fulfill
|
||||
|
||||
▸ **fulfill**(`returnId`): `Promise`<`Return`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:507](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L507)
|
||||
|
||||
___
|
||||
|
||||
### getFulfillmentItems
|
||||
|
||||
▸ `Protected` **getFulfillmentItems**(`order`, `items`, `transformer`): `Promise`<`LineItem` & { `note?`: `string` ; `reason_id?`: `string` }[]\>
|
||||
|
||||
Retrieves the order line items, given an array of items
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to get line items from |
|
||||
| `items` | `OrdersReturnItem`[] | the items to get |
|
||||
| `transformer` | `Transformer` | a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItem` & { `note?`: `string` ; `reason_id?`: `string` }[]\>
|
||||
|
||||
the line items generated by the transformer.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:101](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L101)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`Return`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Return`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`Return`\> | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:141](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L141)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Return`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Return`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`Return`\> | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Return`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:158](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L158)
|
||||
|
||||
___
|
||||
|
||||
### receive
|
||||
|
||||
▸ **receive**(`returnId`, `receivedItems`, `refundAmount?`, `allowMismatch?`, `context?`): `Promise`<`Return`\>
|
||||
|
||||
Registers a previously requested return as received. This will create a
|
||||
refund to the customer. If the returned items don't match the requested
|
||||
items the return status will be updated to requires_action. This behaviour
|
||||
is useful in sitautions where a custom refund amount is requested, but the
|
||||
retuned items are not matching the requested items. Setting the
|
||||
allowMismatch argument to true, will process the return, ignoring any
|
||||
mismatches.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `returnId` | `string` | `undefined` | the orderId to return to |
|
||||
| `receivedItems` | `OrdersReturnItem`[] | `undefined` | the items received after return. |
|
||||
| `refundAmount?` | `number` | `undefined` | the amount to return |
|
||||
| `allowMismatch` | `boolean` | `false` | whether to ignore return/received product mismatch |
|
||||
| `context` | `Object` | `{}` | - |
|
||||
| `context.locationId?` | `string` | `undefined` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:580](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L580)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`returnId`, `config?`): `Promise`<`Return`\>
|
||||
|
||||
Retrieves a return by its id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `returnId` | `string` | the id of the return to retrieve |
|
||||
| `config` | `FindConfig`<`Return`\> | the config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
the return
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:276](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L276)
|
||||
|
||||
___
|
||||
|
||||
### retrieveBySwap
|
||||
|
||||
▸ **retrieveBySwap**(`swapId`, `relations?`): `Promise`<`Return`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | `undefined` |
|
||||
| `relations` | `string`[] | `[]` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:304](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L304)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`returnId`, `update`): `Promise`<`Return`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnId` | `string` |
|
||||
| `update` | `UpdateReturnInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Return`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:329](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L329)
|
||||
|
||||
___
|
||||
|
||||
### validateReturnLineItem
|
||||
|
||||
▸ `Protected` **validateReturnLineItem**(`item?`, `quantity?`, `additional?`): `DeepPartial`<`LineItem`\>
|
||||
|
||||
Checks that a given quantity of a line item can be returned. Fails if the
|
||||
item is undefined or if the returnable quantity of the item is lower, than
|
||||
the quantity that is requested to be returned.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `item?` | `LineItem` | `undefined` | the line item to check has sufficient returnable quantity. |
|
||||
| `quantity` | `number` | `0` | the quantity that is requested to be returned. |
|
||||
| `additional` | `Object` | `{}` | the quantity that is requested to be returned. |
|
||||
| `additional.note?` | `string` | `undefined` | - |
|
||||
| `additional.reason_id?` | `string` | `undefined` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`DeepPartial`<`LineItem`\>
|
||||
|
||||
a line item where the quantity is set to the requested
|
||||
return quantity.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:234](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L234)
|
||||
|
||||
___
|
||||
|
||||
### validateReturnStatuses
|
||||
|
||||
▸ `Protected` **validateReturnStatuses**(`order`): `void`
|
||||
|
||||
Checks that an order has the statuses necessary to complete a return.
|
||||
fulfillment_status cannot be not_fulfilled or returned.
|
||||
payment_status must be captured.
|
||||
|
||||
**`Throws`**
|
||||
|
||||
when statuses are not sufficient for returns.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to check statuses on |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/return.ts:204](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/return.ts#L204)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ReturnService`](ReturnService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ReturnService`](ReturnService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,257 @@
|
||||
# Class: SalesChannelInventoryService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`SalesChannelInventoryService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SalesChannelInventoryService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-inventory.ts:18](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-inventory.ts#L18)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: `IEventBusService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-inventory.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-inventory.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### inventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **inventoryService\_**: `IInventoryService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-inventory.ts:16](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-inventory.ts#L16)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### salesChannelLocationService\_
|
||||
|
||||
• `Protected` `Readonly` **salesChannelLocationService\_**: [`SalesChannelLocationService`](SalesChannelLocationService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-inventory.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-inventory.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### retrieveAvailableItemQuantity
|
||||
|
||||
▸ **retrieveAvailableItemQuantity**(`salesChannelId`, `inventoryItemId`): `Promise`<`number`\>
|
||||
|
||||
Retrieves the available quantity of an item across all sales channel locations
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` | Sales channel id |
|
||||
| `inventoryItemId` | `string` | Item id |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
available quantity of item across all sales channel locations
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-inventory.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-inventory.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`SalesChannelInventoryService`](SalesChannelInventoryService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`SalesChannelInventoryService`](SalesChannelInventoryService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,332 @@
|
||||
# Class: SalesChannelLocationService
|
||||
|
||||
Service for managing the stock locations of sales channels
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`SalesChannelLocationService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SalesChannelLocationService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L24)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: `IEventBusService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:21](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### salesChannelService\_
|
||||
|
||||
• `Protected` `Readonly` **salesChannelService\_**: [`SalesChannelService`](SalesChannelService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### stockLocationService\_
|
||||
|
||||
• `Protected` `Readonly` **stockLocationService\_**: `IStockLocationService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### associateLocation
|
||||
|
||||
▸ **associateLocation**(`salesChannelId`, `locationId`): `Promise`<`void`\>
|
||||
|
||||
Associates a sales channel with a stock location.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` | The ID of the sales channel. |
|
||||
| `locationId` | `string` | The ID of the stock location. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
A promise that resolves when the association has been created.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:72](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L72)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### listLocationIds
|
||||
|
||||
▸ **listLocationIds**(`salesChannelId`): `Promise`<`string`[]\>
|
||||
|
||||
Lists the stock locations associated with a sales channel.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` \| `string`[] | The ID of the sales channel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`[]\>
|
||||
|
||||
A promise that resolves with an array of location IDs.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:103](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L103)
|
||||
|
||||
___
|
||||
|
||||
### listSalesChannelIds
|
||||
|
||||
▸ **listSalesChannelIds**(`locationId`): `Promise`<`string`[]\>
|
||||
|
||||
Lists the sales channels associated with a stock location.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `locationId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`[]\>
|
||||
|
||||
A promise that resolves with an array of sales channel IDs.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:132](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L132)
|
||||
|
||||
___
|
||||
|
||||
### removeLocation
|
||||
|
||||
▸ **removeLocation**(`locationId`, `salesChannelId?`): `Promise`<`void`\>
|
||||
|
||||
Removes an association between a sales channel and a stock location.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `locationId` | `string` | The ID of the stock location. |
|
||||
| `salesChannelId?` | `string` | The ID of the sales channel or undefined if all the sales channel will be affected. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
A promise that resolves when the association has been removed.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel-location.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel-location.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`SalesChannelLocationService`](SalesChannelLocationService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`SalesChannelLocationService`](SalesChannelLocationService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,511 @@
|
||||
# Class: SalesChannelService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`SalesChannelService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SalesChannelService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L34)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### eventBusService\_
|
||||
|
||||
• `Protected` `Readonly` **eventBusService\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:31](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L31)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### salesChannelRepository\_
|
||||
|
||||
• `Protected` `Readonly` **salesChannelRepository\_**: `Repository`<`SalesChannel`\> & { `addProducts`: (`salesChannelId`: `string`, `productIds`: `string`[]) => `Promise`<`void`\> ; `getFreeTextSearchResultsAndCount`: (`q`: `string`, `options`: `ExtendedFindConfig`<`SalesChannel`\>) => `Promise`<[`SalesChannel`[], `number`]\> ; `removeProducts`: (`salesChannelId`: `string`, `productIds`: `string`[]) => `Promise`<`DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:30](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L30)
|
||||
|
||||
___
|
||||
|
||||
### storeService\_
|
||||
|
||||
• `Protected` `Readonly` **storeService\_**: [`StoreService`](StoreService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:32](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L24)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addProducts
|
||||
|
||||
▸ **addProducts**(`salesChannelId`, `productIds`): `Promise`<`SalesChannel`\>
|
||||
|
||||
Add a batch of product to a sales channel
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` | The id of the sales channel on which to add the products |
|
||||
| `productIds` | `string`[] | The products ids to attach to the sales channel |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
the sales channel on which the products have been added
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:332](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L332)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`SalesChannel`\>
|
||||
|
||||
Creates a SalesChannel
|
||||
|
||||
This feature is under development and may change in the future.
|
||||
To use this feature please enable the corresponding feature flag in your medusa backend project.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateSalesChannelInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
the created channel
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:168](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L168)
|
||||
|
||||
___
|
||||
|
||||
### createDefault
|
||||
|
||||
▸ **createDefault**(): `Promise`<`SalesChannel`\>
|
||||
|
||||
Creates a default sales channel, if this does not already exist.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
the sales channel
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:258](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L258)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`salesChannelId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a sales channel from
|
||||
This feature is under development and may change in the future.
|
||||
To use this feature please enable the corresponding feature flag in your medusa backend project.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` | the id of the sales channel to delete |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:219](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L219)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`SalesChannel`[], `number`]\>
|
||||
|
||||
Lists sales channels based on the provided parameters and includes the count of
|
||||
sales channels that match the query.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `QuerySelector`<`SalesChannel`\> |
|
||||
| `config` | `FindConfig`<`SalesChannel`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`SalesChannel`[], `number`]\>
|
||||
|
||||
an array containing the sales channels as
|
||||
the first element and the total count of sales channels that matches the query
|
||||
as the second element.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:134](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### removeProducts
|
||||
|
||||
▸ **removeProducts**(`salesChannelId`, `productIds`): `Promise`<`SalesChannel`\>
|
||||
|
||||
Remove a batch of product from a sales channel
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` | The id of the sales channel on which to remove the products |
|
||||
| `productIds` | `string`[] | The products ids to remove from the sales channel |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
the sales channel on which the products have been removed
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:311](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L311)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`salesChannelId`, `config?`): `Promise`<`SalesChannel`\>
|
||||
|
||||
Retrieve a SalesChannel by id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `salesChannelId` | `string` | id of the channel to retrieve |
|
||||
| `config` | `FindConfig`<`SalesChannel`\> | SC config This feature is under development and may change in the future. To use this feature please enable the corresponding feature flag in your medusa backend project. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
a sales channel
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:92](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L92)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByName
|
||||
|
||||
▸ **retrieveByName**(`name`, `config?`): `Promise`<`unknown`\>
|
||||
|
||||
Find a sales channel by name.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `name` | `string` | of the sales channel |
|
||||
| `config` | `FindConfig`<`SalesChannel`\> | find config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`unknown`\>
|
||||
|
||||
a sales channel with matching name
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:113](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L113)
|
||||
|
||||
___
|
||||
|
||||
### retrieveDefault
|
||||
|
||||
▸ **retrieveDefault**(): `Promise`<`SalesChannel`\>
|
||||
|
||||
Retrieves the default sales channel.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
the sales channel
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:288](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L288)
|
||||
|
||||
___
|
||||
|
||||
### retrieve\_
|
||||
|
||||
▸ `Protected` **retrieve_**(`selector`, `config?`): `Promise`<`SalesChannel`\>
|
||||
|
||||
A generic retrieve used to find a sales channel by different attributes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`SalesChannel`\> | SC selector |
|
||||
| `config` | `FindConfig`<`SalesChannel`\> | find config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
a single SC matching the query or throws
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:54](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L54)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`salesChannelId`, `data`): `Promise`<`SalesChannel`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `salesChannelId` | `string` |
|
||||
| `data` | `Partial`<`CreateSalesChannelInput`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`SalesChannel`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/sales-channel.ts:185](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/sales-channel.ts#L185)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`SalesChannelService`](SalesChannelService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`SalesChannelService`](SalesChannelService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,285 @@
|
||||
# Class: SearchService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `AbstractSearchService`
|
||||
|
||||
↳ **`SearchService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SearchService**(`__namedParameters`, `options`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
| `options` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:16](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L16)
|
||||
|
||||
## Properties
|
||||
|
||||
### isDefault
|
||||
|
||||
• **isDefault**: `boolean` = `true`
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.isDefault
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:11](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L11)
|
||||
|
||||
___
|
||||
|
||||
### logger\_
|
||||
|
||||
• `Protected` `Readonly` **logger\_**: `Logger`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### options\_
|
||||
|
||||
• `Protected` `Readonly` **options\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.options\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L14)
|
||||
|
||||
## Accessors
|
||||
|
||||
### options
|
||||
|
||||
• `get` **options**(): `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
AbstractSearchService.options
|
||||
|
||||
#### Defined in
|
||||
|
||||
utils/dist/search/abstract-service.d.ts:5
|
||||
|
||||
## Methods
|
||||
|
||||
### addDocuments
|
||||
|
||||
▸ **addDocuments**(`indexName`, `documents`, `type`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
| `documents` | `unknown` |
|
||||
| `type` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.addDocuments
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### createIndex
|
||||
|
||||
▸ **createIndex**(`indexName`, `options`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
| `options` | `unknown` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.createIndex
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L28)
|
||||
|
||||
___
|
||||
|
||||
### deleteAllDocuments
|
||||
|
||||
▸ **deleteAllDocuments**(`indexName`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.deleteAllDocuments
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:69](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### deleteDocument
|
||||
|
||||
▸ **deleteDocument**(`indexName`, `document_id`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
| `document_id` | `string` \| `number` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.deleteDocument
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:60](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L60)
|
||||
|
||||
___
|
||||
|
||||
### getIndex
|
||||
|
||||
▸ **getIndex**(`indexName`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.getIndex
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### replaceDocuments
|
||||
|
||||
▸ **replaceDocuments**(`indexName`, `documents`, `type`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
| `documents` | `unknown` |
|
||||
| `type` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.replaceDocuments
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:50](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### search
|
||||
|
||||
▸ **search**(`indexName`, `query`, `options`): `Promise`<{ `hits`: `unknown`[] }\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
| `query` | `unknown` |
|
||||
| `options` | `unknown` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `hits`: `unknown`[] }\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.search
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:75](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L75)
|
||||
|
||||
___
|
||||
|
||||
### updateSettings
|
||||
|
||||
▸ **updateSettings**(`indexName`, `settings`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `indexName` | `string` |
|
||||
| `settings` | `unknown` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Overrides
|
||||
|
||||
AbstractSearchService.updateSettings
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/search.ts:86](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/search.ts#L86)
|
||||
@@ -0,0 +1,688 @@
|
||||
# Class: ShippingOptionService
|
||||
|
||||
Provides layer to manipulate profiles.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ShippingOptionService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ShippingOptionService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:52](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L52)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:50](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L50)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### methodRepository\_
|
||||
|
||||
• `Protected` `Readonly` **methodRepository\_**: `Repository`<`ShippingMethod`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:49](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
### optionRepository\_
|
||||
|
||||
• `Protected` `Readonly` **optionRepository\_**: `Repository`<`ShippingOption`\> & { `upsertShippingProfile`: (`shippingOptionIds`: `string`[], `shippingProfileId`: `string`) => `Promise`<`ShippingOption`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:48](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L48)
|
||||
|
||||
___
|
||||
|
||||
### providerService\_
|
||||
|
||||
• `Protected` `Readonly` **providerService\_**: [`FulfillmentProviderService`](FulfillmentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:44](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L44)
|
||||
|
||||
___
|
||||
|
||||
### regionService\_
|
||||
|
||||
• `Protected` `Readonly` **regionService\_**: [`RegionService`](RegionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### requirementRepository\_
|
||||
|
||||
• `Protected` `Readonly` **requirementRepository\_**: `Repository`<`ShippingOptionRequirement`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:47](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addRequirement
|
||||
|
||||
▸ **addRequirement**(`optionId`, `requirement`): `Promise`<`ShippingOption`\>
|
||||
|
||||
Adds a requirement to a shipping option. Only 1 requirement of each type
|
||||
is allowed.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the option to add the requirement to. |
|
||||
| `requirement` | `ShippingOptionRequirement` | the requirement for the option. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:693](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L693)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`ShippingOption`\>
|
||||
|
||||
Creates a new shipping option. Used both for outbound and inbound shipping
|
||||
options. The difference is registered by the `is_return` field which
|
||||
defaults to false.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `CreateShippingOptionInput` | the data to create shipping options |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:431](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L431)
|
||||
|
||||
___
|
||||
|
||||
### createShippingMethod
|
||||
|
||||
▸ **createShippingMethod**(`optionId`, `data`, `config`): `Promise`<`ShippingMethod`\>
|
||||
|
||||
Creates a shipping method for a given cart.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the option to use for the method. |
|
||||
| `data` | `Record`<`string`, `unknown`\> | the optional provider data to use. |
|
||||
| `config` | `CreateShippingMethodDto` | the cart to create the shipping method for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethod`\>
|
||||
|
||||
the resulting shipping method.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:258](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L258)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`optionId`): `Promise`<`void` \| `ShippingOption`\>
|
||||
|
||||
Deletes a profile with a given profile id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the profile to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `ShippingOption`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:671](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L671)
|
||||
|
||||
___
|
||||
|
||||
### deleteShippingMethods
|
||||
|
||||
▸ **deleteShippingMethods**(`shippingMethods`): `Promise`<`ShippingMethod`[]\>
|
||||
|
||||
Removes a given shipping method
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethods` | `ShippingMethod` \| `ShippingMethod`[] | the shipping method to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethod`[]\>
|
||||
|
||||
removed shipping methods
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:238](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L238)
|
||||
|
||||
___
|
||||
|
||||
### getPrice\_
|
||||
|
||||
▸ **getPrice_**(`option`, `data`, `cart`): `Promise`<`number`\>
|
||||
|
||||
Returns the amount to be paid for a shipping method. Will ask the
|
||||
fulfillment provider to calculate the price if the shipping option has the
|
||||
price type "calculated".
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `option` | `ShippingOption` | the shipping option to retrieve the price for. |
|
||||
| `data` | `Record`<`string`, `unknown`\> | the shipping data to retrieve the price. |
|
||||
| `cart` | `undefined` \| `Order` \| `Cart` | the context in which the price should be retrieved. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the price of the shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:771](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L771)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`ShippingOption`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ShippingOption`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`ShippingOption`\> | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:145](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L145)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`ShippingOption`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ShippingOption`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`ShippingOption`\> | config object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`ShippingOption`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:160](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L160)
|
||||
|
||||
___
|
||||
|
||||
### removeRequirement
|
||||
|
||||
▸ **removeRequirement**(`requirementId`): `Promise`<`void` \| `ShippingOptionRequirement`\>
|
||||
|
||||
Removes a requirement from a shipping option
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `requirementId` | `any` | the id of the requirement to remove |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `ShippingOptionRequirement`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:722](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L722)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`optionId`, `options?`): `Promise`<`ShippingOption`\>
|
||||
|
||||
Gets a profile by id.
|
||||
Throws in case of DB Error and if profile was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `any` | the id of the profile to get. |
|
||||
| `options` | `FindConfig`<`ShippingOption`\> | the options to get a profile |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`\>
|
||||
|
||||
the profile document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:177](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L177)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the id of the option. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `UpdateShippingOptionInput` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:559](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L559)
|
||||
|
||||
___
|
||||
|
||||
### updateShippingMethod
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the id of the shipping method to update |
|
||||
| `update` | `ShippingMethodUpdate` | the values to update the method with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`undefined` \| `ShippingMethod`\>
|
||||
|
||||
the resulting shipping method
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:211](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L211)
|
||||
|
||||
___
|
||||
|
||||
### updateShippingProfile
|
||||
|
||||
▸ **updateShippingProfile**(`optionIds`, `profileId`): `Promise`<`ShippingOption`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionIds` | `string` \| `string`[] | ID or IDs of the shipping options to update |
|
||||
| `profileId` | `string` | Shipping profile ID to update the shipping options with |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`[]\>
|
||||
|
||||
updated shipping options
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:747](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L747)
|
||||
|
||||
___
|
||||
|
||||
### validateAndMutatePrice
|
||||
|
||||
▸ `Private` **validateAndMutatePrice**(`option`, `priceInput`): `Promise`<`CreateShippingOptionInput` \| `Omit`<`ShippingOption`, ``"beforeInsert"``\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `option` | `ShippingOption` \| `CreateShippingOptionInput` |
|
||||
| `priceInput` | `ValidatePriceTypeAndAmountInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`CreateShippingOptionInput` \| `Omit`<`ShippingOption`, ``"beforeInsert"``\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:388](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L388)
|
||||
|
||||
___
|
||||
|
||||
### validateCartOption
|
||||
|
||||
▸ **validateCartOption**(`option`, `cart`): `Promise`<``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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `option` | `ShippingOption` | the option object to check |
|
||||
| `cart` | `Cart` | the cart object to check against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `ShippingOption`\>
|
||||
|
||||
the validated shipping option
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:346](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L346)
|
||||
|
||||
___
|
||||
|
||||
### validatePriceType\_
|
||||
|
||||
▸ **validatePriceType_**(`priceType`, `option`): `Promise`<`ShippingOptionPriceType`\>
|
||||
|
||||
Validates a shipping option price
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `priceType` | `ShippingOptionPriceType` | the price to validate |
|
||||
| `option` | `ShippingOption` | the option to validate against |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOptionPriceType`\>
|
||||
|
||||
the validated price
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:519](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L519)
|
||||
|
||||
___
|
||||
|
||||
### validateRequirement\_
|
||||
|
||||
▸ **validateRequirement_**(`requirement`, `optionId?`): `Promise`<`ShippingOptionRequirement`\>
|
||||
|
||||
Validates a requirement
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `requirement` | `ShippingOptionRequirement` | `undefined` | the requirement to validate |
|
||||
| `optionId` | `undefined` \| `string` | `undefined` | the id to validate the requirement |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOptionRequirement`\>
|
||||
|
||||
a validated shipping requirement
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-option.ts:77](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-option.ts#L77)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,620 @@
|
||||
# Class: ShippingProfileService
|
||||
|
||||
Provides layer to manipulate profiles.
|
||||
|
||||
**`Implements`**
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`ShippingProfileService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new ShippingProfileService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L45)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### customShippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **customShippingOptionService\_**: [`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### productRepository\_
|
||||
|
||||
• `Protected` `Readonly` **productRepository\_**: `Repository`<`Product`\> & { `_applyCategoriesQuery`: (`qb`: `SelectQueryBuilder`<`Product`\>, `__namedParameters`: `Object`) => `SelectQueryBuilder`<`Product`\> ; `_findWithRelations`: (`__namedParameters`: { `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions` ; `relations`: `string`[] ; `shouldCount`: `boolean` ; `withDeleted`: `boolean` }) => `Promise`<[`Product`[], `number`]\> ; `bulkAddToCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `bulkRemoveFromCollection`: (`productIds`: `string`[], `collectionId`: `string`) => `Promise`<`Product`[]\> ; `findOneWithRelations`: (`relations`: `string`[], `optionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<`Product`\> ; `findWithRelations`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `string`[] \| `FindWithoutRelationsOptions`, `withDeleted`: `boolean`) => `Promise`<`Product`[]\> ; `findWithRelationsAndCount`: (`relations`: `string`[], `idsOrOptionsWithoutRelations`: `FindWithoutRelationsOptions`) => `Promise`<[`Product`[], `number`]\> ; `getFreeTextSearchResultsAndCount`: (`q`: `string`, `options`: `FindWithoutRelationsOptions`, `relations`: `string`[]) => `Promise`<[`Product`[], `number`]\> ; `isProductInSalesChannels`: (`id`: `string`, `salesChannelIds`: `string`[]) => `Promise`<`boolean`\> ; `queryProducts`: (`optionsWithoutRelations`: `FindWithoutRelationsOptions`, `shouldCount`: `boolean`) => `Promise`<[`Product`[], `number`]\> ; `queryProductsWithIds`: (`__namedParameters`: { `entityIds`: `string`[] ; `groupedRelations`: { `[toplevel: string]`: `string`[]; } ; `order?`: { `[column: string]`: ``"ASC"`` \| ``"DESC"``; } ; `select?`: keyof `Product`[] ; `where?`: `FindOptionsWhere`<`Product`\> ; `withDeleted?`: `boolean` }) => `Promise`<`Product`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### shippingProfileRepository\_
|
||||
|
||||
• `Protected` `Readonly` **shippingProfileRepository\_**: `Repository`<`ShippingProfile`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addProduct
|
||||
|
||||
▸ **addProduct**(`profileId`, `productId`): `Promise`<`ShippingProfile`\>
|
||||
|
||||
**`Deprecated`**
|
||||
|
||||
use [addProducts](ShippingProfileService.md#addproducts) instead
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `profileId` | `string` |
|
||||
| `productId` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:345](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L345)
|
||||
|
||||
___
|
||||
|
||||
### addProducts
|
||||
|
||||
▸ **addProducts**(`profileId`, `productId`): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Adds a product or an array of products to the profile.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the profile to add the products to. |
|
||||
| `productId` | `string` \| `string`[] | the ID of the product or multiple products to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:358](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L358)
|
||||
|
||||
___
|
||||
|
||||
### addShippingOption
|
||||
|
||||
▸ **addShippingOption**(`profileId`, `optionId`): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Adds a shipping option to the profile. The shipping option can be used to
|
||||
fulfill the products in the products field.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the profile to apply the shipping option to |
|
||||
| `optionId` | `string` \| `string`[] | the ID of the option or multiple options to add to the profile |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the result of the model update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:401](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L401)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`profile`): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Creates a new shipping profile.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profile` | `CreateShippingProfile` | the shipping profile to create from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the result of the create operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:249](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L249)
|
||||
|
||||
___
|
||||
|
||||
### createDefault
|
||||
|
||||
▸ **createDefault**(): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Creates a default shipping profile, if this does not already exist.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the shipping profile
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:179](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L179)
|
||||
|
||||
___
|
||||
|
||||
### createGiftCardDefault
|
||||
|
||||
▸ **createGiftCardDefault**(): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Creates a default shipping profile, for gift cards if unless it already
|
||||
exists.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the shipping profile
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:223](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L223)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`profileId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a profile with a given profile id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the id of the profile to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:323](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L323)
|
||||
|
||||
___
|
||||
|
||||
### fetchCartOptions
|
||||
|
||||
▸ **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
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cart` | `any` | the cart object to find shipping options for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`[]\>
|
||||
|
||||
a list of the available shipping options
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:426](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L426)
|
||||
|
||||
___
|
||||
|
||||
### fetchOptionsByProductIds
|
||||
|
||||
▸ **fetchOptionsByProductIds**(`productIds`, `filter`): `Promise`<`ShippingOption`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productIds` | `string`[] |
|
||||
| `filter` | `Selector`<`ShippingOption`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingOption`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:82](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L82)
|
||||
|
||||
___
|
||||
|
||||
### getProfilesInCart
|
||||
|
||||
▸ `Protected` **getProfilesInCart**(`cart`): `string`[]
|
||||
|
||||
Returns a list of all the productIds in the cart.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cart` | `Cart` | the cart to extract products from |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`[]
|
||||
|
||||
a list of product ids
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:492](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L492)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector?`, `config?`): `Promise`<`ShippingProfile`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`ShippingProfile`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`ShippingProfile`\> | the config object for find |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### removeProducts
|
||||
|
||||
▸ **removeProducts**(`profileId`, `productId`): `Promise`<`void` \| `ShippingProfile`\>
|
||||
|
||||
Removes a product or an array of products from the profile.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | ``null`` \| `string` | the profile to add the products to. |
|
||||
| `productId` | `string` \| `string`[] | the ID of the product or multiple products to add. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void` \| `ShippingProfile`\>
|
||||
|
||||
the result of update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:380](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L380)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`profileId`, `options?`): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Gets a profile by id.
|
||||
Throws in case of DB Error and if profile was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the id of the profile to get. |
|
||||
| `options` | `FindConfig`<`ShippingProfile`\> | options opf the query. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
the profile document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:134](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### retrieveDefault
|
||||
|
||||
▸ **retrieveDefault**(): `Promise`<``null`` \| `ShippingProfile`\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `ShippingProfile`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:163](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L163)
|
||||
|
||||
___
|
||||
|
||||
### retrieveGiftCardDefault
|
||||
|
||||
▸ **retrieveGiftCardDefault**(): `Promise`<``null`` \| `ShippingProfile`\>
|
||||
|
||||
Retrieves the default gift card profile
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `ShippingProfile`\>
|
||||
|
||||
the shipping profile for gift cards
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:206](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L206)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`profileId`, `update`): `Promise`<`ShippingProfile`\>
|
||||
|
||||
Updates a profile. Metadata updates and product updates should use
|
||||
dedicated methods, e.g. `setMetadata`, `addProduct`, etc. The function
|
||||
will throw errors if metadata or product updates are attempted.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `profileId` | `string` | the id of the profile. Must be a string that can be casted to an ObjectId |
|
||||
| `update` | `UpdateShippingProfile` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingProfile`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/shipping-profile.ts:284](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/shipping-profile.ts#L284)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`ShippingProfileService`](ShippingProfileService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`ShippingProfileService`](ShippingProfileService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,274 @@
|
||||
# Class: StagedJobService
|
||||
|
||||
Provides layer to manipulate users.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`StagedJobService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new StagedJobService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `StagedJobServiceProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/staged-job.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/staged-job.ts#L22)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### stagedJobRepository\_
|
||||
|
||||
• `Protected` **stagedJobRepository\_**: `Repository`<`StagedJob`\> & { `insertBulk`: (`jobToCreates`: `_QueryDeepPartialEntity`<`StagedJob`\>[]) => `Promise`<`StagedJob`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/staged-job.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/staged-job.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`StagedJob`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `EmitData`<`unknown`\> \| `EmitData`<`unknown`\>[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`StagedJob`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/staged-job.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/staged-job.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`stagedJobIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `stagedJobIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/staged-job.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/staged-job.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`config`): `Promise`<`StagedJob`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `config` | `FindConfig`<`StagedJob`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`StagedJob`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/staged-job.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/staged-job.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`StagedJobService`](StagedJobService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`StagedJobService`](StagedJobService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,368 @@
|
||||
# Class: StoreService
|
||||
|
||||
Provides layer to manipulate store settings.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`StoreService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new StoreService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:28](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L28)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### currencyRepository\_
|
||||
|
||||
• `Protected` `Readonly` **currencyRepository\_**: `Repository`<`Currency`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### storeRepository\_
|
||||
|
||||
• `Protected` `Readonly` **storeRepository\_**: `Repository`<`Store`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addCurrency
|
||||
|
||||
▸ **addCurrency**(`code`): `Promise`<`Store`\>
|
||||
|
||||
Add a currency to the store
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | 3 character ISO currency code |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Store`\>
|
||||
|
||||
result after update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:208](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L208)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(): `Promise`<`Store`\>
|
||||
|
||||
Creates a store if it doesn't already exist.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Store`\>
|
||||
|
||||
The store.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
### getDefaultCurrency\_
|
||||
|
||||
▸ `Protected` **getDefaultCurrency_**(`code`): `Partial`<`Currency`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `code` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Partial`<`Currency`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:100](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
### removeCurrency
|
||||
|
||||
▸ **removeCurrency**(`code`): `Promise`<`any`\>
|
||||
|
||||
Removes a currency from the store
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `code` | `string` | 3 character ISO currency code |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
result after update
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:252](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L252)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`config?`): `Promise`<`Store`\>
|
||||
|
||||
Retrieve the store settings. There is always a maximum of one store.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | `FindConfig`<`Store`\> | The config object from which the query will be built |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Store`\>
|
||||
|
||||
the store
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:83](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L83)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`data`): `Promise`<`Store`\>
|
||||
|
||||
Updates a store
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `data` | `UpdateStoreInput` | an object with the update values. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Store`\>
|
||||
|
||||
resolves to the update result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/store.ts:116](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/store.ts#L116)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`StoreService`](StoreService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`StoreService`](StoreService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,232 @@
|
||||
# Class: StrategyResolverService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`StrategyResolverService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new StrategyResolverService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `InjectedDependencies` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/strategy-resolver.ts:11](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/strategy-resolver.ts#L11)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### container
|
||||
|
||||
• `Protected` `Readonly` **container**: `InjectedDependencies`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/strategy-resolver.ts:11](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/strategy-resolver.ts#L11)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### resolveBatchJobByType
|
||||
|
||||
▸ **resolveBatchJobByType**(`type`): `AbstractBatchJobStrategy`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `type` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`AbstractBatchJobStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/strategy-resolver.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/strategy-resolver.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`StrategyResolverService`](StrategyResolverService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`StrategyResolverService`](StrategyResolverService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,793 @@
|
||||
# Class: SwapService
|
||||
|
||||
Handles swaps
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`SwapService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SwapService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:91](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L91)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### cartService\_
|
||||
|
||||
• `Protected` `Readonly` **cartService\_**: [`CartService`](CartService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:77](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L77)
|
||||
|
||||
___
|
||||
|
||||
### customShippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **customShippingOptionService\_**: [`CustomShippingOptionService`](CustomShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:87](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L87)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:78](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### fulfillmentService\_
|
||||
|
||||
• `Protected` `Readonly` **fulfillmentService\_**: [`FulfillmentService`](FulfillmentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:83](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L83)
|
||||
|
||||
___
|
||||
|
||||
### lineItemAdjustmentService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemAdjustmentService\_**: [`LineItemAdjustmentService`](LineItemAdjustmentService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:86](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L86)
|
||||
|
||||
___
|
||||
|
||||
### lineItemService\_
|
||||
|
||||
• `Protected` `Readonly` **lineItemService\_**: [`LineItemService`](LineItemService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:82](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L82)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### orderService\_
|
||||
|
||||
• `Protected` `Readonly` **orderService\_**: [`OrderService`](OrderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:79](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L79)
|
||||
|
||||
___
|
||||
|
||||
### paymentProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **paymentProviderService\_**: [`PaymentProviderService`](PaymentProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:85](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L85)
|
||||
|
||||
___
|
||||
|
||||
### productVariantInventoryService\_
|
||||
|
||||
• `Protected` `Readonly` **productVariantInventoryService\_**: [`ProductVariantInventoryService`](ProductVariantInventoryService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:89](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L89)
|
||||
|
||||
___
|
||||
|
||||
### returnService\_
|
||||
|
||||
• `Protected` `Readonly` **returnService\_**: [`ReturnService`](ReturnService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:80](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L80)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:84](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L84)
|
||||
|
||||
___
|
||||
|
||||
### swapRepository\_
|
||||
|
||||
• `Protected` `Readonly` **swapRepository\_**: `Repository`<`Swap`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:75](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L75)
|
||||
|
||||
___
|
||||
|
||||
### totalsService\_
|
||||
|
||||
• `Protected` `Readonly` **totalsService\_**: [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:81](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L81)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `FULFILLMENT_CREATED` | `string` |
|
||||
| `PAYMENT_CAPTURED` | `string` |
|
||||
| `PAYMENT_CAPTURE_FAILED` | `string` |
|
||||
| `PAYMENT_COMPLETED` | `string` |
|
||||
| `PROCESS_REFUND_FAILED` | `string` |
|
||||
| `RECEIVED` | `string` |
|
||||
| `REFUND_PROCESSED` | `string` |
|
||||
| `SHIPMENT_CREATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:63](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L63)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### areReturnItemsValid
|
||||
|
||||
▸ `Protected` **areReturnItemsValid**(`returnItems`): `Promise`<`boolean`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `returnItems` | `WithRequiredProperty`<`Partial`<`ReturnItem`\>, ``"item_id"``\>[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`boolean`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:1240](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L1240)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### cancel
|
||||
|
||||
▸ **cancel**(`swapId`): `Promise`<`Swap`\>
|
||||
|
||||
Cancels a given swap if possible. A swap can only be canceled if all
|
||||
related returns, fulfillments, and payments have been canceled. If a swap
|
||||
is associated with a refund, it cannot be canceled.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap to cancel. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the canceled swap.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:857](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L857)
|
||||
|
||||
___
|
||||
|
||||
### cancelFulfillment
|
||||
|
||||
▸ **cancelFulfillment**(`fulfillmentId`): `Promise`<`Swap`\>
|
||||
|
||||
Cancels a fulfillment (if related to a swap)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `fulfillmentId` | `string` | the ID of the fulfillment to cancel |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
updated swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:1059](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L1059)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`order`, `returnItems`, `additionalItems?`, `returnShipping?`, `custom?`): `Promise`<`Swap`\>
|
||||
|
||||
Creates a swap from an order, with given return items, additional items
|
||||
and an optional return shipping method.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to base the swap off |
|
||||
| `returnItems` | `WithRequiredProperty`<`Partial`<`ReturnItem`\>, ``"item_id"``\>[] | the items to return in the swap |
|
||||
| `additionalItems?` | `Pick`<`LineItem`, ``"variant_id"`` \| ``"quantity"``\>[] | the items to send to the customer |
|
||||
| `returnShipping?` | `Object` | an optional shipping method for returning the returnItems |
|
||||
| `returnShipping.option_id` | `string` | - |
|
||||
| `returnShipping.price?` | `number` | - |
|
||||
| `custom` | `Object` | 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.allow_backorder?` | `boolean` | - |
|
||||
| `custom.idempotency_key?` | `string` | - |
|
||||
| `custom.location_id?` | `string` | - |
|
||||
| `custom.no_notification?` | `boolean` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the newly created swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:321](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L321)
|
||||
|
||||
___
|
||||
|
||||
### createCart
|
||||
|
||||
▸ **createCart**(`swapId`, `customShippingOptions?`, `context?`): `Promise`<`Swap`\>
|
||||
|
||||
Creates a cart from the given swap. The cart can be used to pay
|
||||
for differences associated with the swap. The swap represented by the
|
||||
swapId must belong to the order. Fails if there is already a cart on the
|
||||
swap.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `swapId` | `string` | `undefined` | the id of the swap to create the cart from |
|
||||
| `customShippingOptions` | { `option_id`: `string` ; `price`: `number` }[] | `[]` | the shipping options |
|
||||
| `context` | `Object` | `{}` | - |
|
||||
| `context.sales_channel_id?` | `string` | `undefined` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the swap with its cart_id prop set to the id of the new cart.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:577](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L577)
|
||||
|
||||
___
|
||||
|
||||
### createFulfillment
|
||||
|
||||
▸ **createFulfillment**(`swapId`, `config?`): `Promise`<`Swap`\>
|
||||
|
||||
Fulfills the additional items associated with the swap. Will call the
|
||||
fulfillment providers associated with the shipping methods.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap to fulfill, |
|
||||
| `config` | `CreateShipmentConfig` | optional configurations, includes optional metadata to attach to the shipment, and a no_notification flag. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the updated swap with new status and fulfillments.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:919](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L919)
|
||||
|
||||
___
|
||||
|
||||
### createShipment
|
||||
|
||||
▸ **createShipment**(`swapId`, `fulfillmentId`, `trackingLinks?`, `config?`): `Promise`<`Swap`\>
|
||||
|
||||
Marks a fulfillment as shipped and attaches tracking numbers.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap that has been shipped. |
|
||||
| `fulfillmentId` | `string` | the id of the specific fulfillment that has been shipped |
|
||||
| `trackingLinks?` | { `tracking_number`: `string` }[] | the tracking numbers associated with the shipment |
|
||||
| `config` | `CreateShipmentConfig` | optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the updated swap with new fulfillments and status.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:1090](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L1090)
|
||||
|
||||
___
|
||||
|
||||
### deleteMetadata
|
||||
|
||||
▸ **deleteMetadata**(`swapId`, `key`): `Promise`<`Swap`\>
|
||||
|
||||
Dedicated method to delete metadata for a swap.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the order to delete metadata from. |
|
||||
| `key` | `string` | key for metadata field |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
resolves to the updated result.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:1168](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L1168)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`Swap`[]\>
|
||||
|
||||
List swaps.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Swap`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`Swap`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:273](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L273)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`Swap`[], `number`]\>
|
||||
|
||||
List swaps.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `Selector`<`Swap`\> | the query object for find |
|
||||
| `config` | `FindConfig`<`Swap`\> | the configuration used to find the objects. contains relations, skip, and take. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Swap`[], `number`]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:293](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L293)
|
||||
|
||||
___
|
||||
|
||||
### processDifference
|
||||
|
||||
▸ **processDifference**(`swapId`): `Promise`<`Swap`\>
|
||||
|
||||
Process difference for the requested swap.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | id of a swap being processed |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
processed swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:421](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L421)
|
||||
|
||||
___
|
||||
|
||||
### registerCartCompletion
|
||||
|
||||
▸ **registerCartCompletion**(`swapId`): `Promise`<`Swap`\>
|
||||
|
||||
Register a cart completion
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | The id of the swap |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
swap related to the cart
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:724](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L724)
|
||||
|
||||
___
|
||||
|
||||
### registerReceived
|
||||
|
||||
▸ **registerReceived**(`id`): `Promise`<`Swap`\>
|
||||
|
||||
Registers the swap return items as received so that they cannot be used
|
||||
as a part of other swaps/returns.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `any` | the id of the order with the swap. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the resulting order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:1206](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L1206)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`swapId`, `config?`): `Promise`<`Swap`\>
|
||||
|
||||
Retrieves a swap with the given id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | the id of the swap to retrieve |
|
||||
| `config` | `Omit`<`FindConfig`<`Swap`\>, ``"select"``\> & { `select?`: `string`[] } | the configuration to retrieve the swap |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:203](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L203)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByCartId
|
||||
|
||||
▸ **retrieveByCartId**(`cartId`, `relations?`): `Promise`<`Swap`\>
|
||||
|
||||
Retrieves a swap based on its associated cart id
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `cartId` | `string` | `undefined` | the cart id that the swap's cart has |
|
||||
| `relations` | `undefined` \| `string`[] | `[]` | the relations to retrieve swap |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
the swap
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:246](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L246)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### transformQueryForCart
|
||||
|
||||
▸ `Protected` **transformQueryForCart**(`config`): `Omit`<`FindConfig`<`Swap`\>, ``"select"``\> & { `select?`: `string`[] } & { `cartRelations`: `undefined` \| `string`[] ; `cartSelects`: `undefined` \| keyof `Cart`[] }
|
||||
|
||||
Transform find config object for retrieval.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | `Omit`<`FindConfig`<`Swap`\>, ``"select"``\> & { `select?`: `string`[] } | parsed swap find config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Omit`<`FindConfig`<`Swap`\>, ``"select"``\> & { `select?`: `string`[] } & { `cartRelations`: `undefined` \| `string`[] ; `cartSelects`: `undefined` \| keyof `Cart`[] }
|
||||
|
||||
transformed find swap config
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:130](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L130)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`swapId`, `update`): `Promise`<`Swap`\>
|
||||
|
||||
Update the swap record.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `swapId` | `string` | id of a swap to update |
|
||||
| `update` | `Partial`<`Swap`\> | new data |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Swap`\>
|
||||
|
||||
updated swap record
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/swap.ts:544](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/swap.ts#L544)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`SwapService`](SwapService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`SwapService`](SwapService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,412 @@
|
||||
# Class: SystemPaymentProviderService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`SystemPaymentProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new SystemPaymentProviderService**(`_`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L6)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### identifier
|
||||
|
||||
▪ `Static` **identifier**: `string` = `"system"`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:4](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L4)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### authorizePayment
|
||||
|
||||
▸ **authorizePayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:22](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### cancelPayment
|
||||
|
||||
▸ **cancelPayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:46](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
### capturePayment
|
||||
|
||||
▸ **capturePayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### createPayment
|
||||
|
||||
▸ **createPayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:10](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L10)
|
||||
|
||||
___
|
||||
|
||||
### deletePayment
|
||||
|
||||
▸ **deletePayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### getPaymentData
|
||||
|
||||
▸ **getPaymentData**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:18](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L18)
|
||||
|
||||
___
|
||||
|
||||
### getStatus
|
||||
|
||||
▸ **getStatus**(`_`): `Promise`<`string`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### refundPayment
|
||||
|
||||
▸ **refundPayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### updatePayment
|
||||
|
||||
▸ **updatePayment**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:30](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L30)
|
||||
|
||||
___
|
||||
|
||||
### updatePaymentData
|
||||
|
||||
▸ **updatePaymentData**(`_`): `Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `_` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Record`<`string`, `unknown`\>\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/system-payment-provider.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/system-payment-provider.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`SystemPaymentProviderService`](SystemPaymentProviderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`SystemPaymentProviderService`](SystemPaymentProviderService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,579 @@
|
||||
# Class: TaxProviderService
|
||||
|
||||
Finds tax providers and assists in tax related operations.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`TaxProviderService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TaxProviderService**(`container`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `container` | `AwilixContainer`<`any`\> |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L45)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### cacheService\_
|
||||
|
||||
• `Protected` `Readonly` **cacheService\_**: `ICacheService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:38](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### container\_
|
||||
|
||||
• `Protected` `Readonly` **container\_**: `AwilixContainer`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: `IEventBusService`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### smTaxLineRepo\_
|
||||
|
||||
• `Protected` `Readonly` **smTaxLineRepo\_**: `Repository`<`ShippingMethodTaxLine`\> & { `deleteForCart`: (`cartId`: `string`) => `Promise`<`void`\> ; `upsertLines`: (`lines`: `ShippingMethodTaxLine`[]) => `Promise`<`ShippingMethodTaxLine`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:41](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### taxLineRepo\_
|
||||
|
||||
• `Protected` `Readonly` **taxLineRepo\_**: `Repository`<`LineItemTaxLine`\> & { `deleteForCart`: (`cartId`: `string`) => `Promise`<`void`\> ; `upsertLines`: (`lines`: `LineItemTaxLine`[]) => `Promise`<`LineItemTaxLine`[]\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderRepo\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderRepo\_**: `Repository`<`TaxProvider`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### taxRateService\_
|
||||
|
||||
• `Protected` `Readonly` **taxRateService\_**: [`TaxRateService`](TaxRateService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:39](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### clearLineItemsTaxLines
|
||||
|
||||
▸ **clearLineItemsTaxLines**(`itemIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `itemIds` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:89](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L89)
|
||||
|
||||
___
|
||||
|
||||
### clearTaxLines
|
||||
|
||||
▸ **clearTaxLines**(`cartId`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cartId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:97](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L97)
|
||||
|
||||
___
|
||||
|
||||
### createShippingTaxLines
|
||||
|
||||
▸ **createShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
Persists the tax lines relevant for a shipping method to the database. Used
|
||||
for return shipping methods.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` | the shipping method to create tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
the newly created tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:171](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L171)
|
||||
|
||||
___
|
||||
|
||||
### createTaxLines
|
||||
|
||||
▸ **createTaxLines**(`cartOrLineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
Persists the tax lines relevant for an order to the database.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrLineItems` | `Cart` \| `LineItem`[] | the cart or line items to create tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
the newly created tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:117](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L117)
|
||||
|
||||
___
|
||||
|
||||
### getCacheKey
|
||||
|
||||
▸ `Private` **getCacheKey**(`id`, `regionId`): `string`
|
||||
|
||||
The cache key to get cache hits by.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | the entity id to cache |
|
||||
| `regionId` | `string` | the region id to cache |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
the cache key to use for the id set
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:499](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L499)
|
||||
|
||||
___
|
||||
|
||||
### getRegionRatesForProduct
|
||||
|
||||
▸ **getRegionRatesForProduct**(`productIds`, `region`): `Promise`<`Map`<`string`, `TaxServiceRate`[]\>\>
|
||||
|
||||
Gets the tax rates configured for a product. The rates are cached between
|
||||
calls.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `productIds` | `string` \| `string`[] | |
|
||||
| `region` | `RegionDetails` | the region to get configured rates for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Map`<`string`, `TaxServiceRate`[]\>\>
|
||||
|
||||
the tax rates configured for the shipping option. A map by product id
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:434](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L434)
|
||||
|
||||
___
|
||||
|
||||
### getRegionRatesForShipping
|
||||
|
||||
▸ **getRegionRatesForShipping**(`optionId`, `regionDetails`): `Promise`<`TaxServiceRate`[]\>
|
||||
|
||||
Gets the tax rates configured for a shipping option. The rates are cached
|
||||
between calls.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `optionId` | `string` | the option id of the shipping method. |
|
||||
| `regionDetails` | `RegionDetails` | the region to get configured rates for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxServiceRate`[]\>
|
||||
|
||||
the tax rates configured for the shipping option.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:387](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L387)
|
||||
|
||||
___
|
||||
|
||||
### getShippingTaxLines
|
||||
|
||||
▸ **getShippingTaxLines**(`shippingMethod`, `calculationContext`): `Promise`<`ShippingMethodTaxLine`[]\>
|
||||
|
||||
Gets the relevant tax lines for a shipping method. Note: this method
|
||||
doesn't persist the tax lines. Use createShippingTaxLines if you wish to
|
||||
persist the tax lines to the DB layer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` | the shipping method to get tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethodTaxLine`[]\>
|
||||
|
||||
the computed tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:192](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L192)
|
||||
|
||||
___
|
||||
|
||||
### getTaxLines
|
||||
|
||||
▸ **getTaxLines**(`lineItems`, `calculationContext`): `Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
Gets the relevant tax lines for an order or cart. If an order is provided
|
||||
the order's tax lines will be returned. If a cart is provided the tax lines
|
||||
will be computed from the tax rules and potentially a 3rd party tax plugin.
|
||||
Note: this method doesn't persist the tax lines. Use createTaxLines if you
|
||||
wish to persist the tax lines to the DB layer.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItems` | `LineItem`[] | the cart or order to get tax lines for |
|
||||
| `calculationContext` | `TaxCalculationContext` | the calculation context to get tax lines by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<(`ShippingMethodTaxLine` \| `LineItemTaxLine`)[]\>
|
||||
|
||||
the computed tax lines
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:246](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L246)
|
||||
|
||||
___
|
||||
|
||||
### getTaxLinesMap
|
||||
|
||||
▸ `Protected` **getTaxLinesMap**(`items`, `calculationContext`): `Promise`<`TaxLinesMaps`\>
|
||||
|
||||
Return a map of tax lines for line items and shipping methods
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `items` | `LineItem`[] |
|
||||
| `calculationContext` | `TaxCalculationContext` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxLinesMaps`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:350](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L350)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(): `Promise`<`TaxProvider`[]\>
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxProvider`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:57](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### registerInstalledProviders
|
||||
|
||||
▸ **registerInstalledProviders**(`providers`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `providers` | `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:503](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L503)
|
||||
|
||||
___
|
||||
|
||||
### retrieveProvider
|
||||
|
||||
▸ **retrieveProvider**(`region`): `ITaxService`
|
||||
|
||||
Retrieves the relevant tax provider for the given region.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `region` | `Region` | the region to get tax provider for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`ITaxService`
|
||||
|
||||
the region specific tax provider
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-provider.ts:67](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-provider.ts#L67)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,536 @@
|
||||
# Class: TaxRateService
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`TaxRateService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TaxRateService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `Object` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:29](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L29)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### productService\_
|
||||
|
||||
• `Protected` `Readonly` **productService\_**: [`ProductService`](ProductService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:24](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### productTypeService\_
|
||||
|
||||
• `Protected` `Readonly` **productTypeService\_**: [`ProductTypeService`](ProductTypeService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:25](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### shippingOptionService\_
|
||||
|
||||
• `Protected` `Readonly` **shippingOptionService\_**: [`ShippingOptionService`](ShippingOptionService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:26](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### taxRateRepository\_
|
||||
|
||||
• `Protected` `Readonly` **taxRateRepository\_**: `Repository`<`TaxRate`\> & { `addToProduct`: (`id`: `string`, `productIds`: `string`[], `overrideExisting`: `boolean`) => `Promise`<`ProductTaxRate`[]\> ; `addToProductType`: (`id`: `string`, `productTypeIds`: `string`[], `overrideExisting`: `boolean`) => `Promise`<`ProductTypeTaxRate`[]\> ; `addToShippingOption`: (`id`: `string`, `optionIds`: `string`[], `overrideExisting`: `boolean`) => `Promise`<`ShippingTaxRate`[]\> ; `applyResolutionsToQueryBuilder`: (`qb`: `SelectQueryBuilder`<`TaxRate`\>, `resolverFields`: `string`[]) => `SelectQueryBuilder`<`TaxRate`\> ; `findAndCountWithResolution`: (`findOptions`: `FindManyOptions`<`TaxRate`\>) => `Promise`<[`TaxRate`[], `number`]\> ; `findOneWithResolution`: (`findOptions`: `FindManyOptions`<`TaxRate`\>) => `Promise`<``null`` \| `TaxRate`\> ; `findWithResolution`: (`findOptions`: `FindManyOptions`<`TaxRate`\>) => `Promise`<`TaxRate`[]\> ; `getFindQueryBuilder`: (`findOptions`: `FindManyOptions`<`TaxRate`\>) => `SelectQueryBuilder`<`TaxRate`\> ; `listByProduct`: (`productId`: `string`, `config`: `TaxRateListByConfig`) => `Promise`<`TaxRate`[]\> ; `listByShippingOption`: (`optionId`: `string`) => `Promise`<`TaxRate`[]\> ; `removeFromProduct`: (`id`: `string`, `productIds`: `string`[]) => `Promise`<`DeleteResult`\> ; `removeFromProductType`: (`id`: `string`, `productTypeIds`: `string`[]) => `Promise`<`DeleteResult`\> ; `removeFromShippingOption`: (`id`: `string`, `optionIds`: `string`[]) => `Promise`<`DeleteResult`\> }
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:27](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L27)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### addToProduct
|
||||
|
||||
▸ **addToProduct**(`id`, `productIds`, `replace?`): `Promise`<`ProductTaxRate` \| `ProductTaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `productIds` | `string` \| `string`[] | `undefined` |
|
||||
| `replace` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductTaxRate` \| `ProductTaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:190](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L190)
|
||||
|
||||
___
|
||||
|
||||
### addToProductType
|
||||
|
||||
▸ **addToProductType**(`id`, `productTypeIds`, `replace?`): `Promise`<`ProductTypeTaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `productTypeIds` | `string` \| `string`[] | `undefined` |
|
||||
| `replace` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ProductTypeTaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:226](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L226)
|
||||
|
||||
___
|
||||
|
||||
### addToShippingOption
|
||||
|
||||
▸ **addToShippingOption**(`id`, `optionIds`, `replace?`): `Promise`<`ShippingTaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value |
|
||||
| :------ | :------ | :------ |
|
||||
| `id` | `string` | `undefined` |
|
||||
| `optionIds` | `string` \| `string`[] | `undefined` |
|
||||
| `replace` | `boolean` | `false` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingTaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:266](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L266)
|
||||
|
||||
___
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`data`): `Promise`<`TaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `CreateTaxRateInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:93](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L93)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`id`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:124](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L124)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `FilterableTaxRateProps` |
|
||||
| `config` | `FindConfig`<`TaxRate`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:44](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L44)
|
||||
|
||||
___
|
||||
|
||||
### listAndCount
|
||||
|
||||
▸ **listAndCount**(`selector`, `config?`): `Promise`<[`TaxRate`[], `number`]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `selector` | `FilterableTaxRateProps` |
|
||||
| `config` | `FindConfig`<`TaxRate`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`TaxRate`[], `number`]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:55](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### listByProduct
|
||||
|
||||
▸ **listByProduct**(`productId`, `config`): `Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `productId` | `string` |
|
||||
| `config` | `TaxRateListByConfig` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:314](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L314)
|
||||
|
||||
___
|
||||
|
||||
### listByShippingOption
|
||||
|
||||
▸ **listByShippingOption**(`shippingOptionId`): `Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `shippingOptionId` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:325](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L325)
|
||||
|
||||
___
|
||||
|
||||
### removeFromProduct
|
||||
|
||||
▸ **removeFromProduct**(`id`, `productIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `productIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:136](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L136)
|
||||
|
||||
___
|
||||
|
||||
### removeFromProductType
|
||||
|
||||
▸ **removeFromProductType**(`id`, `typeIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `typeIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:154](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
### removeFromShippingOption
|
||||
|
||||
▸ **removeFromShippingOption**(`id`, `optionIds`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `optionIds` | `string` \| `string`[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:172](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L172)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`taxRateId`, `config?`): `Promise`<`TaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `taxRateId` | `string` |
|
||||
| `config` | `FindConfig`<`TaxRate`\> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:66](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`id`, `data`): `Promise`<`TaxRate`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
| `data` | `UpdateTaxRateInput` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxRate`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/tax-rate.ts:109](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/tax-rate.ts#L109)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`TaxRateService`](TaxRateService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TaxRateService`](TaxRateService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,79 @@
|
||||
# Class: TokenService
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TokenService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `InjectedDependencies` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/token.ts:16](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/token.ts#L16)
|
||||
|
||||
## Properties
|
||||
|
||||
### configModule\_
|
||||
|
||||
• `Protected` `Readonly` **configModule\_**: `ConfigModule`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/token.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/token.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### RESOLUTION\_KEY
|
||||
|
||||
▪ `Static` **RESOLUTION\_KEY**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/token.ts:12](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/token.ts#L12)
|
||||
|
||||
## Methods
|
||||
|
||||
### signToken
|
||||
|
||||
▸ **signToken**(`data`, `options?`): `string`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `data` | `string` \| `object` \| `Buffer` |
|
||||
| `options?` | `SignOptions` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/token.ts:34](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/token.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### verifyToken
|
||||
|
||||
▸ **verifyToken**(`token`, `options?`): `string` \| `Jwt` \| `JwtPayload`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `token` | `string` |
|
||||
| `options?` | `VerifyOptions` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`string` \| `Jwt` \| `JwtPayload`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/token.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/token.ts#L20)
|
||||
@@ -0,0 +1,836 @@
|
||||
# Class: TotalsService
|
||||
|
||||
A service that calculates total and subtotals for orders, carts etc..
|
||||
|
||||
**`Implements`**
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`TotalsService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new TotalsService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `TotalsServiceProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:112](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L112)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:110](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L110)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### newTotalsService\_
|
||||
|
||||
• `Protected` `Readonly` **newTotalsService\_**: [`NewTotalsService`](NewTotalsService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:108](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
### taxCalculationStrategy\_
|
||||
|
||||
• `Protected` `Readonly` **taxCalculationStrategy\_**: `ITaxCalculationStrategy`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:109](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L109)
|
||||
|
||||
___
|
||||
|
||||
### taxProviderService\_
|
||||
|
||||
• `Protected` `Readonly` **taxProviderService\_**: [`TaxProviderService`](TaxProviderService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:107](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L107)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### calculateDiscount\_
|
||||
|
||||
▸ **calculateDiscount_**(`lineItem`, `variant`, `variantPrice`, `value`, `discountType`): `LineDiscount`
|
||||
|
||||
Calculates either fixed or percentage discount of a variant
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItem` | `LineItem` | id of line item |
|
||||
| `variant` | `string` | id of variant in line item |
|
||||
| `variantPrice` | `number` | price of the variant based on region |
|
||||
| `value` | `number` | discount value |
|
||||
| `discountType` | `DiscountRuleType` | the type of discount (fixed or percentage) |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineDiscount`
|
||||
|
||||
triples of lineitem, variant and applied discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:626](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L626)
|
||||
|
||||
___
|
||||
|
||||
### getAllocationItemDiscounts
|
||||
|
||||
▸ **getAllocationItemDiscounts**(`discount`, `cart`): `LineDiscount`[]
|
||||
|
||||
If the rule of a discount has allocation="item", then we need
|
||||
to calculate discount on each item in the cart. Furthermore, we need to
|
||||
make sure to only apply the discount on valid variants. And finally we
|
||||
return ether an array of percentages discounts or fixed discounts
|
||||
alongside the variant on which the discount was applied.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `discount` | `Discount` | the discount to which we do the calculation |
|
||||
| `cart` | `Order` \| `Cart` | the cart to calculate discounts for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineDiscount`[]
|
||||
|
||||
array of triples of lineitem, variant and applied discount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:668](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L668)
|
||||
|
||||
___
|
||||
|
||||
### getAllocationMap
|
||||
|
||||
▸ **getAllocationMap**(`orderOrCart`, `options?`): `Promise`<`LineAllocationsMap`\>
|
||||
|
||||
Gets a map of discounts and gift cards that apply to line items in an
|
||||
order. The function calculates the amount of a discount or gift card that
|
||||
applies to a specific line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `orderOrCart` | `Object` | the order or cart to get an allocation map for |
|
||||
| `orderOrCart.claims?` | `ClaimOrder`[] | - |
|
||||
| `orderOrCart.discounts?` | `Discount`[] | - |
|
||||
| `orderOrCart.items` | `LineItem`[] | - |
|
||||
| `orderOrCart.swaps?` | `Swap`[] | - |
|
||||
| `options` | `AllocationMapOptions` | controls what should be included in allocation map |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineAllocationsMap`\>
|
||||
|
||||
the allocation map for the line items in the cart or order.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:435](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L435)
|
||||
|
||||
___
|
||||
|
||||
### getCalculationContext
|
||||
|
||||
▸ **getCalculationContext**(`calculationContextData`, `options?`): `Promise`<`TaxCalculationContext`\>
|
||||
|
||||
Prepares the calculation context for a tax total calculation.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `calculationContextData` | `CalculationContextData` | the calculationContextData to get the calculation context for |
|
||||
| `options` | `CalculationContextOptions` | options to gather context by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TaxCalculationContext`\>
|
||||
|
||||
the tax calculation context
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:1027](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L1027)
|
||||
|
||||
___
|
||||
|
||||
### getDiscountTotal
|
||||
|
||||
▸ **getDiscountTotal**(`cartOrOrder`): `Promise`<`number`\>
|
||||
|
||||
Calculates the total discount amount for each of the different supported
|
||||
discount types. If discounts aren't present or invalid returns 0.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | the cart or order to calculate discounts for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the total discounts amount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:1005](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L1005)
|
||||
|
||||
___
|
||||
|
||||
### getGiftCardTotal
|
||||
|
||||
▸ **getGiftCardTotal**(`cartOrOrder`, `opts?`): `Promise`<{ `tax_total`: `number` ; `total`: `number` }\>
|
||||
|
||||
Gets the gift card amount on a cart or order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | the cart or order to get gift card amount for |
|
||||
| `opts` | `Object` | - |
|
||||
| `opts.gift_cardable?` | `number` | - |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<{ `tax_total`: `number` ; `total`: `number` }\>
|
||||
|
||||
the gift card amount applied to the cart or order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:974](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L974)
|
||||
|
||||
___
|
||||
|
||||
### getGiftCardableAmount
|
||||
|
||||
▸ **getGiftCardableAmount**(`cartOrOrder`): `Promise`<`number`\>
|
||||
|
||||
Gets the amount that can be gift carded on a cart. In regions where gift
|
||||
cards are taxable this amount should exclude taxes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | the cart or order to get gift card amount for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the gift card amount applied to the cart or order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:957](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L957)
|
||||
|
||||
___
|
||||
|
||||
### getLineDiscounts
|
||||
|
||||
▸ **getLineDiscounts**(`cartOrOrder`, `discount?`): `LineDiscountAmount`[]
|
||||
|
||||
Returns the discount amount allocated to the line items of an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Object` | the cart or order to get line discount allocations for |
|
||||
| `cartOrOrder.claims?` | `ClaimOrder`[] | - |
|
||||
| `cartOrOrder.items` | `LineItem`[] | - |
|
||||
| `cartOrOrder.swaps?` | `Swap`[] | - |
|
||||
| `discount?` | `Discount` | the discount to use as context for the calculation |
|
||||
|
||||
#### Returns
|
||||
|
||||
`LineDiscountAmount`[]
|
||||
|
||||
the allocations that the discount has on the items in the cart or
|
||||
order
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:719](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L719)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemAdjustmentsTotal
|
||||
|
||||
▸ **getLineItemAdjustmentsTotal**(`cartOrOrder`): `number`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:696](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L696)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemDiscountAdjustment
|
||||
|
||||
▸ **getLineItemDiscountAdjustment**(`lineItem`, `discount`): `number`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `lineItem` | `LineItem` |
|
||||
| `discount` | `Discount` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:681](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L681)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemRefund
|
||||
|
||||
▸ **getLineItemRefund**(`order`, `lineItem`): `Promise`<`number`\>
|
||||
|
||||
The amount that can be refunded for a given line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | order to use as context for the calculation |
|
||||
| `lineItem` | `LineItem` | the line item to calculate the refund amount for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the line item refund amount.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:504](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L504)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotal
|
||||
|
||||
▸ **getLineItemTotal**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`number`\>
|
||||
|
||||
Gets a total for a line item. The total can take gift cards, discounts and
|
||||
taxes into account. This can be controlled through the options.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItem` | `LineItem` | the line item to calculate a total for |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | the cart or order to use as context for the calculation |
|
||||
| `options` | `GetLineItemTotalOptions` | the options to use for the calculation |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the line item total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:930](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L930)
|
||||
|
||||
___
|
||||
|
||||
### getLineItemTotals
|
||||
|
||||
▸ **getLineItemTotals**(`lineItem`, `cartOrOrder`, `options?`): `Promise`<`LineItemTotals`\>
|
||||
|
||||
Breaks down the totals related to a line item; these are the subtotal, the
|
||||
amount of discount applied to the line item, the amount of a gift card
|
||||
applied to a line item and the amount of tax applied to a line item.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `lineItem` | `LineItem` | the line item to calculate totals for |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | the cart or order to use as context for the calculation |
|
||||
| `options` | `LineItemTotalsOptions` | the options to evaluate the line item totals for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`LineItemTotals`\>
|
||||
|
||||
the breakdown of the line item totals
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:775](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L775)
|
||||
|
||||
___
|
||||
|
||||
### getPaidTotal
|
||||
|
||||
▸ **getPaidTotal**(`order`): `number`
|
||||
|
||||
Gets the total payments made on an order
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to calculate paid amount for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the total paid amount
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:157](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L157)
|
||||
|
||||
___
|
||||
|
||||
### getRefundTotal
|
||||
|
||||
▸ **getRefundTotal**(`order`, `lineItems`): `Promise`<`number`\>
|
||||
|
||||
Calculates refund total of line items.
|
||||
If any of the items to return have been discounted, we need to
|
||||
apply the discount again before refunding them.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | cart or order to calculate subtotal for |
|
||||
| `lineItems` | `LineItem`[] | the line items to calculate refund total for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the calculated subtotal
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:583](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L583)
|
||||
|
||||
___
|
||||
|
||||
### getRefundedTotal
|
||||
|
||||
▸ **getRefundedTotal**(`order`): `number`
|
||||
|
||||
Gets the total refund amount for an order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to get total refund amount for. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the total refunded amount for an order.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:489](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L489)
|
||||
|
||||
___
|
||||
|
||||
### getShippingMethodTotals
|
||||
|
||||
▸ **getShippingMethodTotals**(`shippingMethod`, `cartOrOrder`, `opts?`): `Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
Gets the totals breakdown for a shipping method. Fetches tax lines if not
|
||||
already provided.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `shippingMethod` | `ShippingMethod` | the shipping method to get totals breakdown for. |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | the cart or order to use as context for the breakdown |
|
||||
| `opts` | `GetShippingMethodTotalsOptions` | options for what should be included |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`ShippingMethodTotals`\>
|
||||
|
||||
An object that breaks down the totals for the shipping method
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:191](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L191)
|
||||
|
||||
___
|
||||
|
||||
### getShippingTotal
|
||||
|
||||
▸ **getShippingTotal**(`cartOrOrder`): `Promise`<`number`\>
|
||||
|
||||
Calculates shipping total
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | cart or order to calculate subtotal for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
shipping total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:319](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L319)
|
||||
|
||||
___
|
||||
|
||||
### getSubtotal
|
||||
|
||||
▸ **getSubtotal**(`cartOrOrder`, `opts?`): `Promise`<`number`\>
|
||||
|
||||
Calculates subtotal of a given cart or order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | cart or order to calculate subtotal for |
|
||||
| `opts` | `SubtotalOptions` | options |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the calculated subtotal
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:283](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L283)
|
||||
|
||||
___
|
||||
|
||||
### getSwapTotal
|
||||
|
||||
▸ **getSwapTotal**(`order`): `number`
|
||||
|
||||
The total paid for swaps. May be negative in case of negative swap
|
||||
difference.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `order` | `Order` | the order to calculate swap total for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the swap total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:172](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L172)
|
||||
|
||||
___
|
||||
|
||||
### getTaxTotal
|
||||
|
||||
▸ **getTaxTotal**(`cartOrOrder`, `forceTaxes?`): `Promise`<``null`` \| `number`\>
|
||||
|
||||
Calculates tax total
|
||||
Currently based on the Danish tax system
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | `undefined` | cart or order to calculate tax total for |
|
||||
| `forceTaxes` | `boolean` | `false` | whether taxes should be calculated regardless of region settings |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<``null`` \| `number`\>
|
||||
|
||||
tax total
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:346](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L346)
|
||||
|
||||
___
|
||||
|
||||
### getTotal
|
||||
|
||||
▸ **getTotal**(`cartOrOrder`, `options?`): `Promise`<`number`\>
|
||||
|
||||
Calculates total of a given cart or order.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `cartOrOrder` | `Order` \| `Cart` | object to calculate total for |
|
||||
| `options` | `GetTotalsOptions` | options to calculate by |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`number`\>
|
||||
|
||||
the calculated subtotal
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:134](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L134)
|
||||
|
||||
___
|
||||
|
||||
### rounded
|
||||
|
||||
▸ **rounded**(`value`): `number`
|
||||
|
||||
Rounds a number using Math.round.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `value` | `number` | the value to round |
|
||||
|
||||
#### Returns
|
||||
|
||||
`number`
|
||||
|
||||
the rounded value
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/totals.ts:1057](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/totals.ts#L1057)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TotalsService`](TotalsService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,518 @@
|
||||
# Class: UserService
|
||||
|
||||
Provides layer to manipulate users.
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- `TransactionBaseService`
|
||||
|
||||
↳ **`UserService`**
|
||||
|
||||
## Constructors
|
||||
|
||||
### constructor
|
||||
|
||||
• **new UserService**(`__namedParameters`)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `__namedParameters` | `UserServiceProps` |
|
||||
|
||||
#### Overrides
|
||||
|
||||
TransactionBaseService.constructor
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:45](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L45)
|
||||
|
||||
## Properties
|
||||
|
||||
### \_\_configModule\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_configModule\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_configModule\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:14](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### \_\_container\_\_
|
||||
|
||||
• `Protected` `Readonly` **\_\_container\_\_**: `any`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_container\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:13](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### \_\_moduleDeclaration\_\_
|
||||
|
||||
• `Protected` `Optional` `Readonly` **\_\_moduleDeclaration\_\_**: `Record`<`string`, `unknown`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.\_\_moduleDeclaration\_\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:15](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
### analyticsConfigService\_
|
||||
|
||||
• `Protected` `Readonly` **analyticsConfigService\_**: [`AnalyticsConfigService`](AnalyticsConfigService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:40](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### eventBus\_
|
||||
|
||||
• `Protected` `Readonly` **eventBus\_**: [`EventBusService`](EventBusService.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:42](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### featureFlagRouter\_
|
||||
|
||||
• `Protected` `Readonly` **featureFlagRouter\_**: `FlagRouter`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:43](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### manager\_
|
||||
|
||||
• `Protected` **manager\_**: `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.manager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:5](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
### transactionManager\_
|
||||
|
||||
• `Protected` **transactionManager\_**: `undefined` \| `EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.transactionManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:6](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### userRepository\_
|
||||
|
||||
• `Protected` `Readonly` **userRepository\_**: `Repository`<`User`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:41](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L41)
|
||||
|
||||
___
|
||||
|
||||
### Events
|
||||
|
||||
▪ `Static` **Events**: `Object`
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `CREATED` | `string` |
|
||||
| `DELETED` | `string` |
|
||||
| `PASSWORD_RESET` | `string` |
|
||||
| `UPDATED` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:33](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L33)
|
||||
|
||||
## Accessors
|
||||
|
||||
### activeManager\_
|
||||
|
||||
• `Protected` `get` **activeManager_**(): `EntityManager`
|
||||
|
||||
#### Returns
|
||||
|
||||
`EntityManager`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.activeManager\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:8](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L8)
|
||||
|
||||
## Methods
|
||||
|
||||
### atomicPhase\_
|
||||
|
||||
▸ `Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
|
||||
|
||||
Wraps some work within a transactional block. If the service already has
|
||||
a transaction manager attached this will be reused, otherwise a new
|
||||
transaction manager is created.
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `TResult` |
|
||||
| `TError` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `work` | (`transactionManager`: `EntityManager`) => `Promise`<`TResult`\> | the transactional work to be done |
|
||||
| `isolationOrErrorHandler?` | `IsolationLevel` \| (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | the isolation level to be used for the work. |
|
||||
| `maybeErrorHandlerOrDontFail?` | (`error`: `TError`) => `Promise`<`void` \| `TResult`\> | Potential error handler |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`TResult`\>
|
||||
|
||||
the result of the transactional work
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.atomicPhase\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:56](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**(`user`, `password`): `Promise`<`User`\>
|
||||
|
||||
Creates a user with username being validated.
|
||||
Fails if email is not a valid format.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `user` | `CreateUserInput` | the user to create |
|
||||
| `password` | `string` | user's password to hash |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the result of create
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:171](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L171)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`userId`): `Promise`<`void`\>
|
||||
|
||||
Deletes a user from a given user id.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the id of the user to delete. Must be castable as an ObjectId |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
the result of the delete operation.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:263](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L263)
|
||||
|
||||
___
|
||||
|
||||
### generateResetPasswordToken
|
||||
|
||||
▸ **generateResetPasswordToken**(`userId`): `Promise`<`string`\>
|
||||
|
||||
Generate a JSON Web token, that will be sent to a user, that wishes to
|
||||
reset password.
|
||||
The token will be signed with the users current password hash as a secret
|
||||
a long side a payload with userId and the expiry time for the token, which
|
||||
is always 15 minutes.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the id of the user to reset password for |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
the generated JSON web token
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:327](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L327)
|
||||
|
||||
___
|
||||
|
||||
### hashPassword\_
|
||||
|
||||
▸ **hashPassword_**(`password`): `Promise`<`string`\>
|
||||
|
||||
Hashes a password
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `password` | `string` | the value to hash |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`\>
|
||||
|
||||
hashed password
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:159](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L159)
|
||||
|
||||
___
|
||||
|
||||
### list
|
||||
|
||||
▸ **list**(`selector`, `config?`): `Promise`<`User`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `selector` | `FilterableUserProps` | the query object for find |
|
||||
| `config` | `Object` | the configuration object for the query |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`[]\>
|
||||
|
||||
the result of the find operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:65](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### retrieve
|
||||
|
||||
▸ **retrieve**(`userId`, `config?`): `Promise`<`User`\>
|
||||
|
||||
Gets a user by id.
|
||||
Throws in case of DB Error and if user was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the id of the user to get. |
|
||||
| `config` | `FindConfig`<`User`\> | query configs |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the user document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:77](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L77)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByApiToken
|
||||
|
||||
▸ **retrieveByApiToken**(`apiToken`, `relations?`): `Promise`<`User`\>
|
||||
|
||||
Gets a user by api token.
|
||||
Throws in case of DB Error and if user was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------ | :------ | :------ | :------ |
|
||||
| `apiToken` | `string` | `undefined` | the token of the user to get. |
|
||||
| `relations` | `string`[] | `[]` | relations to include with the user. |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the user document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:107](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L107)
|
||||
|
||||
___
|
||||
|
||||
### retrieveByEmail
|
||||
|
||||
▸ **retrieveByEmail**(`email`, `config?`): `Promise`<`User`\>
|
||||
|
||||
Gets a user by email.
|
||||
Throws in case of DB Error and if user was not found.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `email` | `string` | the email of the user to get. |
|
||||
| `config` | `FindConfig`<`User`\> | query config |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the user document.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:135](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L135)
|
||||
|
||||
___
|
||||
|
||||
### setPassword\_
|
||||
|
||||
▸ **setPassword_**(`userId`, `password`): `Promise`<`User`\>
|
||||
|
||||
Sets a password for a user
|
||||
Fails if no user exists with userId and if the hashing of the new
|
||||
password does not work.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | the userId to set password for |
|
||||
| `password` | `string` | the old password to set |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the result of the update operation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:298](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L298)
|
||||
|
||||
___
|
||||
|
||||
### shouldRetryTransaction\_
|
||||
|
||||
▸ `Protected` **shouldRetryTransaction_**(`err`): `boolean`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `err` | `Record`<`string`, `unknown`\> \| { `code`: `string` } |
|
||||
|
||||
#### Returns
|
||||
|
||||
`boolean`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.shouldRetryTransaction\_
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:37](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
### update
|
||||
|
||||
▸ **update**(`userId`, `update`): `Promise`<`User`\>
|
||||
|
||||
Updates a user.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `userId` | `string` | id of the user to update |
|
||||
| `update` | `UpdateUserInput` | the values to be updated on the user |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`User`\>
|
||||
|
||||
the result of create
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/services/user.ts:217](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/services/user.ts#L217)
|
||||
|
||||
___
|
||||
|
||||
### withTransaction
|
||||
|
||||
▸ **withTransaction**(`transactionManager?`): [`UserService`](UserService.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `transactionManager?` | `EntityManager` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`UserService`](UserService.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
TransactionBaseService.withTransaction
|
||||
|
||||
#### Defined in
|
||||
|
||||
[medusa/src/interfaces/transaction-base-service.ts:20](https://github.com/medusajs/medusa/blob/755f9cf30/packages/medusa/src/interfaces/transaction-base-service.ts#L20)
|
||||
@@ -0,0 +1,62 @@
|
||||
# Services Reference
|
||||
|
||||
## Classes
|
||||
|
||||
- [AnalyticsConfigService](classes/AnalyticsConfigService.md)
|
||||
- [AuthService](classes/AuthService.md)
|
||||
- [BatchJobService](classes/BatchJobService.md)
|
||||
- [CartService](classes/CartService.md)
|
||||
- [ClaimItemService](classes/ClaimItemService.md)
|
||||
- [ClaimService](classes/ClaimService.md)
|
||||
- [CurrencyService](classes/CurrencyService.md)
|
||||
- [CustomShippingOptionService](classes/CustomShippingOptionService.md)
|
||||
- [CustomerGroupService](classes/CustomerGroupService.md)
|
||||
- [CustomerService](classes/CustomerService.md)
|
||||
- [DiscountConditionService](classes/DiscountConditionService.md)
|
||||
- [DiscountService](classes/DiscountService.md)
|
||||
- [DraftOrderService](classes/DraftOrderService.md)
|
||||
- [EventBusService](classes/EventBusService.md)
|
||||
- [FulfillmentProviderService](classes/FulfillmentProviderService.md)
|
||||
- [FulfillmentService](classes/FulfillmentService.md)
|
||||
- [GiftCardService](classes/GiftCardService.md)
|
||||
- [IdempotencyKeyService](classes/IdempotencyKeyService.md)
|
||||
- [LineItemAdjustmentService](classes/LineItemAdjustmentService.md)
|
||||
- [LineItemService](classes/LineItemService.md)
|
||||
- [MiddlewareService](classes/MiddlewareService.md)
|
||||
- [NewTotalsService](classes/NewTotalsService.md)
|
||||
- [NoteService](classes/NoteService.md)
|
||||
- [NotificationService](classes/NotificationService.md)
|
||||
- [OauthService](classes/OauthService.md)
|
||||
- [OrderEditItemChangeService](classes/OrderEditItemChangeService.md)
|
||||
- [OrderEditService](classes/OrderEditService.md)
|
||||
- [OrderService](classes/OrderService.md)
|
||||
- [PaymentCollectionService](classes/PaymentCollectionService.md)
|
||||
- [PaymentProviderService](classes/PaymentProviderService.md)
|
||||
- [PaymentService](classes/PaymentService.md)
|
||||
- [PriceListService](classes/PriceListService.md)
|
||||
- [PricingService](classes/PricingService.md)
|
||||
- [ProductCategoryService](classes/ProductCategoryService.md)
|
||||
- [ProductCollectionService](classes/ProductCollectionService.md)
|
||||
- [ProductService](classes/ProductService.md)
|
||||
- [ProductTypeService](classes/ProductTypeService.md)
|
||||
- [ProductVariantInventoryService](classes/ProductVariantInventoryService.md)
|
||||
- [ProductVariantService](classes/ProductVariantService.md)
|
||||
- [RegionService](classes/RegionService.md)
|
||||
- [ReturnReasonService](classes/ReturnReasonService.md)
|
||||
- [ReturnService](classes/ReturnService.md)
|
||||
- [SalesChannelInventoryService](classes/SalesChannelInventoryService.md)
|
||||
- [SalesChannelLocationService](classes/SalesChannelLocationService.md)
|
||||
- [SalesChannelService](classes/SalesChannelService.md)
|
||||
- [SearchService](classes/SearchService.md)
|
||||
- [ShippingOptionService](classes/ShippingOptionService.md)
|
||||
- [ShippingProfileService](classes/ShippingProfileService.md)
|
||||
- [StagedJobService](classes/StagedJobService.md)
|
||||
- [StoreService](classes/StoreService.md)
|
||||
- [StrategyResolverService](classes/StrategyResolverService.md)
|
||||
- [SwapService](classes/SwapService.md)
|
||||
- [SystemPaymentProviderService](classes/SystemPaymentProviderService.md)
|
||||
- [TaxProviderService](classes/TaxProviderService.md)
|
||||
- [TaxRateService](classes/TaxRateService.md)
|
||||
- [TokenService](classes/TokenService.md)
|
||||
- [TotalsService](classes/TotalsService.md)
|
||||
- [UserService](classes/UserService.md)
|
||||
Reference in new issue
Block a user