Skip to main content

Class: IdempotencyKeyService

Hierarchy​

  • TransactionBaseService

    ↳ IdempotencyKeyService

Constructors​

constructor​

• new IdempotencyKeyService(__namedParameters)

Parameters​

NameType
__namedParametersInjectedDependencies

Overrides​

TransactionBaseService.constructor

Defined in​

medusa/src/services/idempotency-key.ts:25

Properties​

__configModule__​

• Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from​

TransactionBaseService.__configModule__

Defined in​

medusa/src/interfaces/transaction-base-service.ts:14


__container__​

• Protected Readonly __container__: any

Inherited from​

TransactionBaseService.__container__

Defined in​

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


__moduleDeclaration__​

• Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from​

TransactionBaseService.__moduleDeclaration__

Defined in​

medusa/src/interfaces/transaction-base-service.ts:15


idempotencyKeyRepository_​

• Protected Readonly idempotencyKeyRepository_: Repository<IdempotencyKey>

Defined in​

medusa/src/services/idempotency-key.ts:23


manager_​

• Protected manager_: EntityManager

Inherited from​

TransactionBaseService.manager_

Defined in​

medusa/src/interfaces/transaction-base-service.ts:5


transactionManager_​

• Protected transactionManager_: undefined | EntityManager

Inherited from​

TransactionBaseService.transactionManager_

Defined in​

medusa/src/interfaces/transaction-base-service.ts:6

Accessors​

activeManager_​

• Protected get activeManager_(): EntityManager

Returns​

EntityManager

Inherited from​

TransactionBaseService.activeManager_

Defined in​

medusa/src/interfaces/transaction-base-service.ts:8

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​

NameTypeDescription
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


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​

NameTypeDescription
payloadCreateIdempotencyKeyInputpayload of request to create idempotency key for

Returns​

Promise<IdempotencyKey>

the created idempotency key

Defined in​

medusa/src/services/idempotency-key.ts:68


initializeRequest​

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

Execute the initial steps in a idempotent request.

Parameters​

NameTypeDescription
headerKeystringpotential idempotency key from header
reqMethodstringmethod of request
reqParamsRecord<string, unknown>params of request
reqPathstringpath of request

Returns​

Promise<IdempotencyKey>

the existing or created idempotency key

Defined in​

medusa/src/services/idempotency-key.ts:40


lock​

▸ lock(idempotencyKey): Promise<IdempotencyKey>

Locks an idempotency.

Parameters​

NameTypeDescription
idempotencyKeystringkey to lock

Returns​

Promise<IdempotencyKey>

result of the update operation

Defined in​

medusa/src/services/idempotency-key.ts:138


retrieve​

▸ retrieve(idempotencyKeyOrSelector): Promise<IdempotencyKey>

Retrieves an idempotency key

Parameters​

NameTypeDescription
idempotencyKeyOrSelectorstring | Selector<IdempotencyKey>key or selector to retrieve

Returns​

Promise<IdempotencyKey>

idempotency key

Defined in​

medusa/src/services/idempotency-key.ts:86


shouldRetryTransaction_​

▸ Protected shouldRetryTransaction_(err): boolean

Parameters​

NameType
errRecord<string, unknown> | { code: string }

Returns​

boolean

Inherited from​

TransactionBaseService.shouldRetryTransaction_

Defined in​

medusa/src/interfaces/transaction-base-service.ts:37


update​

▸ update(idempotencyKey, update): Promise<IdempotencyKey>

Locks an idempotency.

Parameters​

NameTypeDescription
idempotencyKeystringkey to update
updateDeepPartial<IdempotencyKey>update object

Returns​

Promise<IdempotencyKey>

result of the update operation

Defined in​

medusa/src/services/idempotency-key.ts:167


withTransaction​

▸ withTransaction(transactionManager?): IdempotencyKeyService

Parameters​

NameType
transactionManager?EntityManager

Returns​

IdempotencyKeyService

Inherited from​

TransactionBaseService.withTransaction

Defined in​

medusa/src/interfaces/transaction-base-service.ts:20


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​

NameTypeDescription
idempotencyKeystringcurrent 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

Was this section helpful?