6.6 KiB
Class: StoreService
Provides layer to manipulate store settings.
Hierarchy
-
TransactionBaseService<StoreService>↳
StoreService
Constructors
constructor
• new StoreService(__namedParameters)
Parameters
| Name | Type |
|---|---|
__namedParameters |
InjectedDependencies |
Overrides
TransactionBaseService<StoreService>.constructor
Defined in
Properties
configModule
• Protected Optional Readonly configModule: Record<string, unknown>
Inherited from
TransactionBaseService.configModule
container
• Protected Readonly container: unknown
Inherited from
TransactionBaseService.container
currencyRepository_
• Protected Readonly currencyRepository_: typeof CurrencyRepository
Defined in
eventBus_
• Protected Readonly eventBus_: EventBusService
Defined in
manager_
• Protected manager_: EntityManager
Overrides
TransactionBaseService.manager_
Defined in
storeRepository_
• Protected Readonly storeRepository_: typeof StoreRepository
Defined in
transactionManager_
• Protected transactionManager_: EntityManager
Overrides
TransactionBaseService.transactionManager_
Defined in
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
atomicPhase_
▸ Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type parameters
| Name |
|---|
TResult |
TError |
Parameters
| Name | Type | Description |
|---|---|---|
work |
(transactionManager: EntityManager) => Promise<TResult> |
the transactional work to be done |
isolationOrErrorHandler? |
IsolationLevel | (error: TError) => Promise<void | TResult> |
the isolation level to be used for the work. |
maybeErrorHandlerOrDontFail? |
(error: TError) => Promise<void | TResult> |
Potential error handler |
Returns
Promise<TResult>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
interfaces/transaction-base-service.ts:53
create
▸ create(): Promise<Store>
Creates a store if it doesn't already exist.
Returns
Promise<Store>
The store.
Defined in
getDefaultCurrency_
▸ Protected getDefaultCurrency_(code): Partial<Currency>
Parameters
| Name | Type |
|---|---|
code |
string |
Returns
Partial<Currency>
Defined in
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
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
shouldRetryTransaction_
▸ Protected shouldRetryTransaction_(err): boolean
Parameters
| Name | Type |
|---|---|
err |
Record<string, unknown> | { code: string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
interfaces/transaction-base-service.ts:34
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
withTransaction
▸ withTransaction(transactionManager?): StoreService
Parameters
| Name | Type |
|---|---|
transactionManager? |
EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction