# OperationDefinition

Source: /tuil/docs/reference/packages/operations/api/operation-definition
Locale: en

interface exported by @mwillbanks/tuil-operations.



{/* Generated by tooling/docs/generate-reference.ts. */}

## interface [#interface]

Public interface exported by `@mwillbanks/tuil-operations`.

```ts
export interface OperationDefinition<TResult = unknown> {
  readonly id: string;
  readonly title: string;
  readonly description?: string;
  readonly metadata?: Readonly<Record<string, unknown>>;
  readonly retries?: number;
  readonly retryDelay?: number;
  readonly timeout?: number;
  readonly run: (context: OperationContext) => TResult | Promise<TResult>;
  readonly rollback?: OperationRollback<TResult>;
}
```

## Members [#members]

| Member        | Type                                                                                                | Required | Description                                                                                                                                  | Related types                                                                   |
| ------------- | --------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `id`          | `string`                                                                                            | Yes      | The `id` member uses the `string` contract.                                                                                                  | —                                                                               |
| `title`       | `string`                                                                                            | Yes      | The `title` member uses the `string` contract.                                                                                               | —                                                                               |
| `description` | `string \| undefined`                                                                               | No       | The `description` member uses the `string \| undefined` contract.                                                                            | —                                                                               |
| `metadata`    | `Readonly<Record<string, unknown>> \| undefined`                                                    | No       | The `metadata` member uses the `Readonly<Record<string, unknown>> \| undefined` contract.                                                    | —                                                                               |
| `retries`     | `number \| undefined`                                                                               | No       | The `retries` member uses the `number \| undefined` contract.                                                                                | —                                                                               |
| `retryDelay`  | `number \| undefined`                                                                               | No       | The `retryDelay` member uses the `number \| undefined` contract.                                                                             | —                                                                               |
| `timeout`     | `number \| undefined`                                                                               | No       | The `timeout` member uses the `number \| undefined` contract.                                                                                | —                                                                               |
| `run`         | `(context: OperationContext) => TResult \| Promise<TResult>`                                        | Yes      | The `run` member uses the `(context: OperationContext) => TResult \| Promise<TResult>` contract.                                             | [`OperationContext`](/tuil/docs/reference/packages/operations/api/operation-context) |
| `rollback`    | `((result: TResult \| undefined, context: OperationContext) => void \| Promise<void>) \| undefined` | No       | The `rollback` member uses the `((result: TResult \| undefined, context: OperationContext) => void \| Promise<void>) \| undefined` contract. | [`OperationContext`](/tuil/docs/reference/packages/operations/api/operation-context) |

## Parameters [#parameters]

This declaration has no public members.

## Returns [#returns]

This declaration does not return a value.

## Throws [#throws]

No thrown errors are documented for this declaration.

## Related types [#related-types]

* [`OperationContext`](/tuil/docs/reference/packages/operations/api/operation-context)

## Source [#source]

[View the secondary source reference](https://github.com/mwillbanks/tuil/blob/main/packages/operations/src/index.ts)

## Package [#package]

[@mwillbanks/tuil-operations](/tuil/docs/reference/packages/operations)
