* fixed typedoc plugin's escape strategy * move props comments to the associated property * regenerate references
638 lines
14 KiB
Plaintext
638 lines
14 KiB
Plaintext
---
|
|
displayed_sidebar: servicesSidebar
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# LineItemAdjustmentService
|
|
|
|
Provides layer to manipulate line item adjustments.
|
|
|
|
## Constructors
|
|
|
|
### constructor
|
|
|
|
`**new LineItemAdjustmentService**(«destructured»)`
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "__namedParameters",
|
|
"type": "[LineItemAdjustmentServiceProps](../types/LineItemAdjustmentServiceProps.mdx)",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
## Properties
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "__configModule__",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "__container__",
|
|
"type": "`any`",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "__moduleDeclaration__",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "discountService",
|
|
"type": "[DiscountService](DiscountService.mdx)",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lineItemAdjustmentRepo_",
|
|
"type": "Repository<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "manager_",
|
|
"type": "EntityManager",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "transactionManager_",
|
|
"type": "`undefined` \\| EntityManager",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
## Accessors
|
|
|
|
### activeManager\_
|
|
|
|
`Protected get**activeManager_**(): EntityManager`
|
|
|
|
#### Returns
|
|
|
|
EntityManager
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "EntityManager",
|
|
"type": "EntityManager",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
## Methods
|
|
|
|
### atomicPhase\_
|
|
|
|
`Protected **atomicPhase_**<TypeParameter TResult, TypeParameter 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.
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "TResult",
|
|
"type": "`object`",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "TError",
|
|
"type": "`object`",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "work",
|
|
"type": "(`transactionManager`: EntityManager) => Promise<TResult>",
|
|
"description": "the transactional work to be done",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "isolationOrErrorHandler",
|
|
"type": "`IsolationLevel` \\| (`error`: `TError`) => Promise<void \\| TResult>",
|
|
"description": "the isolation level to be used for the work.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "maybeErrorHandlerOrDontFail",
|
|
"type": "(`error`: `TError`) => Promise<void \\| TResult>",
|
|
"description": "Potential error handler",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<TResult>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<TResult>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "the result of the transactional work",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### create
|
|
|
|
`**create**(data): Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>`
|
|
|
|
Creates a line item adjustment
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "data",
|
|
"type": "[Partial](../types/Partial.mdx)<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"description": "the line item adjustment to create",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "line item adjustment",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### createAdjustmentForLineItem
|
|
|
|
`**createAdjustmentForLineItem**(cart, lineItem): Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[]>`
|
|
|
|
Creates adjustment for a line item
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "cart",
|
|
"type": "[Cart](Cart.mdx)",
|
|
"description": "the cart object holding discounts",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lineItem",
|
|
"type": "[LineItem](LineItem.mdx)",
|
|
"description": "the line item for which a line item adjustment might be created",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[]>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[]>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "a line item adjustment or undefined if no adjustment was created",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### createAdjustments
|
|
|
|
`**createAdjustments**(cart, lineItem?): Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[] \| [LineItemAdjustment](LineItemAdjustment.mdx)[][]>`
|
|
|
|
Creates adjustment for a line item
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "cart",
|
|
"type": "[Cart](Cart.mdx)",
|
|
"description": "the cart object holding discounts",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lineItem",
|
|
"type": "[LineItem](LineItem.mdx)",
|
|
"description": "the line item for which a line item adjustment might be created",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[] \| [LineItemAdjustment](LineItemAdjustment.mdx)[][]>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[] \\| [LineItemAdjustment](LineItemAdjustment.mdx)[][]>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "if a lineItem was given, returns a line item adjustment or undefined if no adjustment was created\notherwise returns an array of line item adjustments for each line item in the cart",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### delete
|
|
|
|
`**delete**(selectorOrIds): Promise<void>`
|
|
|
|
Deletes line item adjustments matching a selector
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "selectorOrIds",
|
|
"type": "`string` \\| `string`[] \\| [FilterableLineItemAdjustmentProps](FilterableLineItemAdjustmentProps.mdx) & ``{ discount_id?: FindOperator<null \\| string> }``",
|
|
"description": "the query object for find or the line item adjustment id",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<void>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<void>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "the result of the delete operation",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### generateAdjustments
|
|
|
|
`**generateAdjustments**(calculationContextData, generatedLineItem, context): Promise<[GeneratedAdjustment](../types/GeneratedAdjustment.mdx)[]>`
|
|
|
|
Creates adjustment for a line item
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "calculationContextData",
|
|
"type": "[CalculationContextData](../types/CalculationContextData.mdx)",
|
|
"description": "the calculationContextData object holding discounts",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "generatedLineItem",
|
|
"type": "[LineItem](LineItem.mdx)",
|
|
"description": "the line item for which a line item adjustment might be created",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "context",
|
|
"type": "[AdjustmentContext](../types/AdjustmentContext.mdx)",
|
|
"description": "the line item for which a line item adjustment might be created",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[GeneratedAdjustment](../types/GeneratedAdjustment.mdx)[]>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[GeneratedAdjustment](../types/GeneratedAdjustment.mdx)[]>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "a line item adjustment or undefined if no adjustment was created",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### list
|
|
|
|
`**list**(selector?, config?): Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[]>`
|
|
|
|
Lists line item adjustments
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "selector",
|
|
"type": "[FilterableLineItemAdjustmentProps](FilterableLineItemAdjustmentProps.mdx)",
|
|
"description": "the query object for find",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "config",
|
|
"type": "[FindConfig](../interfaces/FindConfig.mdx)<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"description": "the config to be used for find",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[]>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[LineItemAdjustment](LineItemAdjustment.mdx)[]>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "the result of the find operation",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### retrieve
|
|
|
|
`**retrieve**(lineItemAdjustmentId, config?): Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>`
|
|
|
|
Retrieves a line item adjustment by id.
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "lineItemAdjustmentId",
|
|
"type": "`string`",
|
|
"description": "the id of the line item adjustment to retrieve",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "config",
|
|
"type": "[FindConfig](../interfaces/FindConfig.mdx)<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"description": "the config to retrieve the line item adjustment by",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "the line item adjustment.",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### shouldRetryTransaction\_
|
|
|
|
`Protected **shouldRetryTransaction_**(err): boolean`
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "err",
|
|
"type": "`Record<string, unknown>` \\| ``{ code: string }``",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
`boolean`
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "boolean",
|
|
"type": "`boolean`",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"description": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### update
|
|
|
|
`**update**(id, data): Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>`
|
|
|
|
Creates a line item adjustment
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "the line item adjustment id to update",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "data",
|
|
"type": "[Partial](../types/Partial.mdx)<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"description": "the line item adjustment to create",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "Promise",
|
|
"type": "Promise<[LineItemAdjustment](LineItemAdjustment.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "line item adjustment",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### withTransaction
|
|
|
|
`**withTransaction**(transactionManager?): [LineItemAdjustmentService](LineItemAdjustmentService.mdx)`
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "transactionManager",
|
|
"type": "EntityManager",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
[LineItemAdjustmentService](LineItemAdjustmentService.mdx)
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "LineItemAdjustmentService",
|
|
"type": "[LineItemAdjustmentService](LineItemAdjustmentService.mdx)",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|