> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# InboxJournal

> Interface exported by @botmesh/core/spi.

Defined in: [durability/types.ts:137](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L137)

Persistence contract of the inbound journal.

## Methods

### append()

```ts theme={null}
append(
   record, 
   now, 
   lease?
): Promise<{
  status: "appended" | "duplicate";
  record: InboxRecord;
}>;
```

Defined in: [durability/types.ts:144](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L144)

Insert-if-absent by `id`. `'duplicate'` means the id is already known (any state);
the existing record is returned unchanged. With `lease`, a new record is created
already claimed (`processing`, token 1, 1 attempt), so no other claimer can take it
between the append and the claim.

#### Parameters

| Parameter | Type |
| - | - |
| `record` | [`InboxAppend`](https://botmesh.afaya.com.co/api/core/spi/type-aliases/InboxAppend) |
| `now` | `number` |
| `lease?` | [`LeaseOptions`](https://botmesh.afaya.com.co/api/core/spi/interfaces/LeaseOptions) |

#### Returns

`Promise`\<\{
`status`: `"appended"` | `"duplicate"`;
`record`: [`InboxRecord`](https://botmesh.afaya.com.co/api/core/spi/interfaces/InboxRecord);
}>

***

### claim()

```ts theme={null}
claim(options): Promise<InboxRecord[]>;
```

Defined in: [durability/types.ts:150](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L150)

Lease due records: `pending`/`failed` whose `nextAttemptAt <= now`, plus `processing`
records whose lease expired. Oldest `receivedAt` first. Each claimed record comes back
`processing` with a fresh `fencingToken` and `attempts + 1`.

#### Parameters

| Parameter | Type |
| - | - |
| `options` | [`ClaimOptions`](https://botmesh.afaya.com.co/api/core/spi/interfaces/ClaimOptions) |

#### Returns

`Promise`\<[`InboxRecord`](https://botmesh.afaya.com.co/api/core/spi/interfaces/InboxRecord)\[]>

***

### claimOne()

```ts theme={null}
claimOne(id, options): Promise<InboxRecord | null>;
```

Defined in: [durability/types.ts:152](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L152)

Lease one specific record when it is claimable (as [claim](#claim)); `null` when it is not.

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |
| `options` | [`LeaseOptions`](https://botmesh.afaya.com.co/api/core/spi/interfaces/LeaseOptions) |

#### Returns

`Promise`\<[`InboxRecord`](https://botmesh.afaya.com.co/api/core/spi/interfaces/InboxRecord) | `null`>

***

### ack()

```ts theme={null}
ack(
   id, 
   token, 
   now
): Promise<void>;
```

Defined in: [durability/types.ts:154](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L154)

`processing` → `done`.

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |
| `token` | `number` |
| `now` | `number` |

#### Returns

`Promise`\<`void`>

#### Throws

when `token` is not the current claim.

***

### fail()

```ts theme={null}
fail(
   id, 
   token, 
   error, 
   options
): Promise<void>;
```

Defined in: [durability/types.ts:159](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L159)

`processing` → `failed` (due at `retryAt`, default now) or `dead` (`dead: true`).

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |
| `token` | `number` |
| `error` | `string` |
| `options` | \{ `now`: `number`; `retryAt?`: `number`; `dead?`: `boolean`; } |
| `options.now` | `number` |
| `options.retryAt?` | `number` |
| `options.dead?` | `boolean` |

#### Returns

`Promise`\<`void`>

#### Throws

***

### release()

```ts theme={null}
release(
   id, 
   token, 
   now
): Promise<void>;
```

Defined in: [durability/types.ts:161](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L161)

`processing` → `pending`, due now; the claim's attempt is not charged.

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |
| `token` | `number` |
| `now` | `number` |

#### Returns

`Promise`\<`void`>

#### Throws

***

### extend()

```ts theme={null}
extend(
   id, 
   token, 
   leaseUntil
): Promise<void>;
```

Defined in: [durability/types.ts:163](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L163)

Extend the current lease (heartbeat).

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |
| `token` | `number` |
| `leaseUntil` | `number` |

#### Returns

`Promise`\<`void`>

#### Throws

***

### replay()

```ts theme={null}
replay(id, now): Promise<void>;
```

Defined in: [durability/types.ts:165](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L165)

Operator replay: any record → `pending`, due now, attempts reset. No-op for an unknown id.

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |
| `now` | `number` |

#### Returns

`Promise`\<`void`>

***

### get()

```ts theme={null}
get(id): Promise<InboxRecord | undefined>;
```

Defined in: [durability/types.ts:166](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L166)

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |

#### Returns

`Promise`\<[`InboxRecord`](https://botmesh.afaya.com.co/api/core/spi/interfaces/InboxRecord) | `undefined`>

***

### list()

```ts theme={null}
list(filter?): Promise<InboxRecord[]>;
```

Defined in: [durability/types.ts:168](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L168)

Records, optionally by state, oldest `receivedAt` first.

#### Parameters

| Parameter | Type |
| - | - |
| `filter?` | \{ `state?`: [`InboxState`](https://botmesh.afaya.com.co/api/core/spi/type-aliases/InboxState); `limit?`: `number`; } |
| `filter.state?` | [`InboxState`](https://botmesh.afaya.com.co/api/core/spi/type-aliases/InboxState) |
| `filter.limit?` | `number` |

#### Returns

`Promise`\<[`InboxRecord`](https://botmesh.afaya.com.co/api/core/spi/interfaces/InboxRecord)\[]>

***

### purge()

```ts theme={null}
purge(options): Promise<number>;
```

Defined in: [durability/types.ts:170](https://github.com/andresayac/botmesh/blob/main/packages/core/src/durability/types.ts#L170)

Delete `done` records completed before `doneBefore` (and `dead` ones when `includeDead`). Returns the count.

#### Parameters

| Parameter | Type |
| - | - |
| `options` | \{ `doneBefore`: `number`; `includeDead?`: `boolean`; } |
| `options.doneBefore` | `number` |
| `options.includeDead?` | `boolean` |

#### Returns

`Promise`\<`number`>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.