Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
8.9 KiB
displayed_sidebar
| displayed_sidebar |
|---|
| jsClientSidebar |
Class: IdempotencyKeyService
internal.internal.IdempotencyKeyService
Hierarchy
-
↳
IdempotencyKeyService
Properties
__configModule__
• Protected Optional Readonly __configModule__: Record<string, unknown>
Inherited from
TransactionBaseService.configModule
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:5
__container__
• Protected Readonly __container__: any
Inherited from
TransactionBaseService.container
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:4
__moduleDeclaration__
• Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>
Inherited from
TransactionBaseService.moduleDeclaration
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:6
idempotencyKeyRepository_
• Protected Readonly idempotencyKeyRepository_: Repository<IdempotencyKey>
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:12
manager_
• Protected manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:7
transactionManager_
• Protected transactionManager_: undefined | EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:8
Accessors
activeManager_
• Protected get activeManager_(): EntityManager
Returns
EntityManager
Inherited from
TransactionBaseService.activeManager_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.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/dist/interfaces/transaction-base-service.d.ts:24
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
| Name | Type | Description |
|---|---|---|
payload |
CreateIdempotencyKeyInput |
payload of request to create idempotency key for |
Returns
Promise<IdempotencyKey>
the created idempotency key
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:30
initializeRequest
▸ initializeRequest(headerKey, reqMethod, reqParams, reqPath): Promise<IdempotencyKey>
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 |
Record<string, unknown> |
params of request |
reqPath |
string |
path of request |
Returns
Promise<IdempotencyKey>
the existing or created idempotency key
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:22
lock
▸ lock(idempotencyKey): Promise<IdempotencyKey>
Locks an idempotency.
Parameters
| Name | Type | Description |
|---|---|---|
idempotencyKey |
string |
key to lock |
Returns
Promise<IdempotencyKey>
result of the update operation
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:42
retrieve
▸ retrieve(idempotencyKeyOrSelector): Promise<IdempotencyKey>
Retrieves an idempotency key
Parameters
| Name | Type | Description |
|---|---|---|
idempotencyKeyOrSelector |
string | Selector<IdempotencyKey> |
key or selector to retrieve |
Returns
Promise<IdempotencyKey>
idempotency key
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:36
shouldRetryTransaction_
▸ Protected shouldRetryTransaction_(err): boolean
Parameters
| Name | Type |
|---|---|
err |
Record<string, unknown> | { code: string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:12
update
▸ update(idempotencyKey, update): Promise<IdempotencyKey>
Locks an idempotency.
Parameters
| Name | Type | Description |
|---|---|---|
idempotencyKey |
string |
key to update |
update |
DeepPartial<IdempotencyKey> |
update object |
Returns
Promise<IdempotencyKey>
result of the update operation
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:49
withTransaction
▸ withTransaction(transactionManager?): IdempotencyKeyService
Parameters
| Name | Type |
|---|---|
transactionManager? |
EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:11
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
| Name | Type | Description |
|---|---|---|
idempotencyKey |
string |
current idempotency key |
callback |
(transactionManager: EntityManager) => Promise<IdempotencyCallbackResult> |
functionality to execute within the phase |
Returns
Promise<IdempotencyKey>
new updated idempotency key
Defined in
packages/medusa/dist/services/idempotency-key.d.ts:60