Skip to main content

Class: IdempotencyKeyService

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    IdempotencyKeyServiceCopy to Clipboard

Constructors

constructor

new IdempotencyKeyService(__namedParametersCopy to Clipboard)

Parameters

NameType
__namedParametersCopy to ClipboardInjectedDependenciesCopy to Clipboard

Overrides

TransactionBaseService.constructor

Defined in

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

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

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


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

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


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

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


idempotencyKeyRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard idempotencyKeyRepository_: RepositoryCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

Defined in

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


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.manager_

Defined in

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


transactionManager_

ProtectedCopy to Clipboard transactionManager_: undefinedCopy to Clipboard | EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.transactionManager_

Defined in

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

Accessors

activeManager_

ProtectedCopy to Clipboard getCopy to Clipboard activeManager_(): EntityManagerCopy to Clipboard

Returns

EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.activeManager_

Defined in

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

Methods

atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy to Clipboard>

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
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy to Clipboard>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

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


create

create(payloadCopy to Clipboard): PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

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

Parameters

NameTypeDescription
payloadCopy to ClipboardCreateIdempotencyKeyInputCopy to Clipboardpayload of request to create idempotency key for

Returns

PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

the created idempotency key

Defined in

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


initializeRequest

initializeRequest(headerKeyCopy to Clipboard, reqMethodCopy to Clipboard, reqParamsCopy to Clipboard, reqPathCopy to Clipboard): PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

Execute the initial steps in a idempotent request.

Parameters

NameTypeDescription
headerKeyCopy to ClipboardstringCopy to Clipboardpotential idempotency key from header
reqMethodCopy to ClipboardstringCopy to Clipboardmethod of request
reqParamsCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>params of request
reqPathCopy to ClipboardstringCopy to Clipboardpath of request

Returns

PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

the existing or created idempotency key

Defined in

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


lock

lock(idempotencyKeyCopy to Clipboard): PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

Locks an idempotency.

Parameters

NameTypeDescription
idempotencyKeyCopy to ClipboardstringCopy to Clipboardkey to lock

Returns

PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

result of the update operation

Defined in

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


retrieve

retrieve(idempotencyKeyOrSelectorCopy to Clipboard): PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

Retrieves an idempotency key

Parameters

NameTypeDescription
idempotencyKeyOrSelectorCopy to ClipboardstringCopy to Clipboard | SelectorCopy to Clipboard<IdempotencyKeyCopy to Clipboard>key or selector to retrieve

Returns

PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

idempotency key

Defined in

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


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

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


update

update(idempotencyKeyCopy to Clipboard, updateCopy to Clipboard): PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

Locks an idempotency.

Parameters

NameTypeDescription
idempotencyKeyCopy to ClipboardstringCopy to Clipboardkey to update
updateCopy to ClipboardDeepPartialCopy to Clipboard<IdempotencyKeyCopy to Clipboard>update object

Returns

PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

result of the update operation

Defined in

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


withTransaction

withTransaction(transactionManager?Copy to Clipboard): IdempotencyKeyServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

IdempotencyKeyServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

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


workStage

workStage(idempotencyKeyCopy to Clipboard, callbackCopy to Clipboard): PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

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
idempotencyKeyCopy to ClipboardstringCopy to Clipboardcurrent idempotency key
callbackCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<IdempotencyCallbackResultCopy to Clipboard>functionality to execute within the phase

Returns

PromiseCopy to Clipboard<IdempotencyKeyCopy to Clipboard>

new updated idempotency key

Defined in

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

Was this page helpful?