# config


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sortable-queue/blob/main/cjm_fasthtml_sortable_queue/config.py#L14"
target="_blank" style="float:right; font-size:smaller">source</a>

### SortableQueueConfig

``` python

def SortableQueueConfig(
    prefix:str, key_field:str='id', key_fn:Optional=None, item_class:str='queue-item',
    handle_class:str='drag-handle', animation_ms:int=150, queue_title:str='Selected'
)->None:

```

*Configuration for a sortable queue instance.*

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sortable-queue/blob/main/cjm_fasthtml_sortable_queue/config.py#L25"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_item_key

``` python

def get_item_key(
    config:SortableQueueConfig, # Queue configuration
    item:dict, # Queue item dict
)->str: # Unique key string for the item

```

*Extract the unique key from a queue item using the config’s key_fn or
key_field.*

## Tests

``` python
# Default config
cfg = SortableQueueConfig(prefix="sq")
assert cfg.prefix == "sq"
assert cfg.key_field == "id"
assert cfg.key_fn is None
assert cfg.item_class == "queue-item"
assert cfg.handle_class == "drag-handle"
assert cfg.animation_ms == 150
assert cfg.queue_title == "Selected"

# Simple key extraction
item = {"id": "abc123", "name": "Test"}
assert get_item_key(cfg, item) == "abc123"

# Custom key_fn overrides key_field
cfg2 = SortableQueueConfig(prefix="sd", key_fn=lambda i: f"{i['provider']}:{i['record']}")
item2 = {"provider": "whisper", "record": "job_1"}
assert get_item_key(cfg2, item2) == "whisper:job_1"

# Missing key_field returns empty string
assert get_item_key(cfg, {"name": "no id"}) == ""

print("All config tests passed")
```
