Files
medusa-store/docs/content/references/services/classes/IdempotencyKeyService.md
Shahed Nasser 02d5c1da88 docs: update Typedoc and regenerate references (#1994)
* generated new services reference

* changed from automatic push to automated pull request

* updated typedoc, regenerated JS Client reference

* regenerated the reference after updating typedoc

* added action for js client
2022-08-04 17:29:52 +03:00

7.2 KiB

Class: IdempotencyKeyService

Hierarchy

  • TransactionBaseService

    IdempotencyKeyService

Constructors

constructor

new IdempotencyKeyService(__namedParameters)

Parameters

Name Type
__namedParameters Object

Overrides

TransactionBaseService.constructor

Defined in

packages/medusa/src/services/idempotency-key.js:8

Properties

configModule

Protected Optional Readonly configModule: Record<string, unknown>

Inherited from

TransactionBaseService.configModule

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:13


container

Protected Readonly container: any

Inherited from

TransactionBaseService.container

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:12


transactionManager_

Protected Abstract transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:9

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

packages/medusa/src/interfaces/transaction-base-service.ts:53


create

create(payload): Promise<IdempotencyKeyModel>

Creates an idempotency key for a request. If no idempotency key is provided in request, we will create a unique identifier.

Parameters

Name Type Description
payload any payload of request to create idempotency key for

Returns

Promise<IdempotencyKeyModel>

the created idempotency key

Defined in

packages/medusa/src/services/idempotency-key.js:52


initializeRequest

initializeRequest(headerKey, reqMethod, reqParams, reqPath): Promise<IdempotencyKeyModel>

Execute the initial steps in a idempotent request.

Parameters

Name Type Description
headerKey string potential idempotency key from header
reqMethod string method of request
reqParams string params of request
reqPath string path of request

Returns

Promise<IdempotencyKeyModel>

the existing or created idempotency key

Defined in

packages/medusa/src/services/idempotency-key.js:26


lock

lock(idempotencyKey): Promise<any>

Locks an idempotency.

Parameters

Name Type Description
idempotencyKey string key to lock

Returns

Promise<any>

result of the update operation

Defined in

packages/medusa/src/services/idempotency-key.js:90


retrieve

retrieve(idempotencyKey): Promise<IdempotencyKeyModel>

Retrieves an idempotency key

Parameters

Name Type Description
idempotencyKey string key to retrieve

Returns

Promise<IdempotencyKeyModel>

idempotency key

Defined in

packages/medusa/src/services/idempotency-key.js:73


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name Type
err Record<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:34


update

update(idempotencyKey, update): Promise<any>

Locks an idempotency.

Parameters

Name Type Description
idempotencyKey string key to update
update any update object

Returns

Promise<any>

result of the update operation

Defined in

packages/medusa/src/services/idempotency-key.js:117


withTransaction

withTransaction(transactionManager?): any

Parameters

Name Type
transactionManager? EntityManager

Returns

any

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:16


workStage

workStage(idempotencyKey, func): IdempotencyKeyModel

Performs an atomic work stage. An atomic work stage contains some related functionality, that needs to be transactionally executed in isolation. An idempotent request will always consist of 2 or more of these phases. The required phases are "started" and "finished".

Parameters

Name Type Description
idempotencyKey string current idempotency key
func Function functionality to execute within the phase

Returns

IdempotencyKeyModel

new updated idempotency key

Defined in

packages/medusa/src/services/idempotency-key.js:144