Files
medusa-store/www/apps/docs/content/references/services/classes/BatchJobService.mdx
Shahed Nasser c51dce164d docs: general fixes to references (#5653)
* fixed typedoc plugin's escape strategy

* move props comments to the associated property

* regenerate references
2023-11-17 19:36:58 +02:00

854 lines
17 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# BatchJobService
## Constructors
### constructor
`**new BatchJobService**(«destructured»)`
#### Parameters
<ParameterTypes parameters={[
{
"name": "__namedParameters",
"type": "[InjectedDependencies](../types/InjectedDependencies-2.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Properties
<ParameterTypes parameters={[
{
"name": "__configModule__",
"type": "`Record<string, unknown>`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "`Record<string, unknown>`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "batchJobRepository_",
"type": "Repository&#60;[BatchJob](BatchJob.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "batchJobStatusMapToProps",
"type": "Map&#60;[BatchJobStatus](../enums/BatchJobStatus.mdx), &#123; entityColumnName: string ; eventType: string &#125;&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "eventBus_",
"type": "[EventBusService](EventBusService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager_",
"type": "EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "strategyResolver_",
"type": "[StrategyResolverService](StrategyResolverService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "transactionManager_",
"type": "`undefined` \\| EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "Events",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "Events.CANCELED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.canceled\"",
"expandable": false,
"children": []
},
{
"name": "Events.COMPLETED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.completed\"",
"expandable": false,
"children": []
},
{
"name": "Events.CONFIRMED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.confirmed\"",
"expandable": false,
"children": []
},
{
"name": "Events.CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.created\"",
"expandable": false,
"children": []
},
{
"name": "Events.FAILED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.failed\"",
"expandable": false,
"children": []
},
{
"name": "Events.PRE_PROCESSED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.pre_processed\"",
"expandable": false,
"children": []
},
{
"name": "Events.PROCESSING",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.processing\"",
"expandable": false,
"children": []
},
{
"name": "Events.UPDATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"batch.updated\"",
"expandable": false,
"children": []
}
]} />
## Accessors
### activeManager\_
`Protected get**activeManager_**(): EntityManager`
#### Returns
EntityManager
<ParameterTypes parameters={[
{
"name": "EntityManager",
"type": "EntityManager",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
## Methods
### atomicPhase\_
`Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;`
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.
<ParameterTypes parameters={[
{
"name": "TResult",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "TError",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Parameters
<ParameterTypes parameters={[
{
"name": "work",
"type": "(`transactionManager`: EntityManager) => Promise&#60;TResult&#62;",
"description": "the transactional work to be done",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "isolationOrErrorHandler",
"type": "`IsolationLevel` \\| (`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
"description": "the isolation level to be used for the work.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "maybeErrorHandlerOrDontFail",
"type": "(`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
"description": "Potential error handler",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;TResult&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;TResult&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the transactional work",
"expandable": false,
"children": []
}
]} />
___
### cancel
`**cancel**(batchJobOrId): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### complete
`**complete**(batchJobOrId): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### confirm
`**confirm**(batchJobOrId): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### create
`**create**(data): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "data",
"type": "[BatchJobCreateProps](../types/BatchJobCreateProps.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### listAndCount
`**listAndCount**(selector?, config?): Promise&#60;[[BatchJob](BatchJob.mdx)[], number]&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "selector",
"type": "[FilterableBatchJobProps](FilterableBatchJobProps.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[BatchJob](BatchJob.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[[BatchJob](BatchJob.mdx)[], number]&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[[BatchJob](BatchJob.mdx)[], number]&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### prepareBatchJobForProcessing
`**prepareBatchJobForProcessing**(data, req): Promise&#60;[CreateBatchJobInput](../types/CreateBatchJobInput.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "data",
"type": "[CreateBatchJobInput](../types/CreateBatchJobInput.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "req",
"type": "Request&#60;ParamsDictionary, any, any, ParsedQs, Record&#60;string, any&#62;&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[CreateBatchJobInput](../types/CreateBatchJobInput.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[CreateBatchJobInput](../types/CreateBatchJobInput.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### retrieve
`**retrieve**(batchJobId, config?): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobId",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[BatchJob](BatchJob.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### setFailed
`**setFailed**(batchJobOrId, error?): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "error",
"type": "`string` \\| [BatchJobResultError](../types/BatchJobResultError.mdx)",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### setPreProcessingDone
`**setPreProcessingDone**(batchJobOrId): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### setProcessing
`**setProcessing**(batchJobOrId): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### shouldRetryTransaction\_
`Protected **shouldRetryTransaction_**(err): boolean`
#### Parameters
<ParameterTypes parameters={[
{
"name": "err",
"type": "`Record<string, unknown>` \\| ``{ code: string }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`boolean`
<ParameterTypes parameters={[
{
"name": "boolean",
"type": "`boolean`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### update
`**update**(batchJobOrId, data): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "data",
"type": "[Partial](../types/Partial.mdx)&#60;[Pick](../types/Pick.mdx)&#60;[BatchJob](BatchJob.mdx), \"context\" \\| \"result\"&#62;&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### updateStatus
`Protected **updateStatus**(batchJobOrId, status): Promise&#60;[BatchJob](BatchJob.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "batchJobOrId",
"type": "`string` \\| [BatchJob](BatchJob.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[BatchJobStatus](../enums/BatchJobStatus.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[BatchJob](BatchJob.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[BatchJob](BatchJob.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### withTransaction
`**withTransaction**(transactionManager?): [BatchJobService](BatchJobService.mdx)`
#### Parameters
<ParameterTypes parameters={[
{
"name": "transactionManager",
"type": "EntityManager",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
[BatchJobService](BatchJobService.mdx)
<ParameterTypes parameters={[
{
"name": "BatchJobService",
"type": "[BatchJobService](BatchJobService.mdx)",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />