# `Electric.Shapes`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/shapes.ex#L1)

# `shape_handle`

```elixir
@type shape_handle() :: Electric.shape_handle()
```

# `stack_id`

```elixir
@type stack_id() :: Electric.stack_id()
```

# `clean_shape`

```elixir
@spec clean_shape(stack_id(), shape_handle()) :: :ok
```

Remove and clean up all data (meta data and shape log + snapshot) associated with
the given shape handle

# `clean_shapes`

```elixir
@spec clean_shapes(stack_id(), [shape_handle()]) :: :ok
```

# `fetch_handle_by_shape`

```elixir
@spec fetch_handle_by_shape(stack_id(), Electric.Shapes.Shape.t()) ::
  {:ok, shape_handle()} | :error
```

Get the shape handle that corresponds to this shape definition and return it

# `fetch_shape_by_handle`

```elixir
@spec fetch_shape_by_handle(stack_id(), shape_handle()) ::
  Electric.Shapes.Shape.t() | :error
```

# `get_chunk_end_log_offset`

```elixir
@spec get_chunk_end_log_offset(
  stack_id(),
  shape_handle(),
  Electric.Replication.LogOffset.t(),
  keyword()
) :: Electric.Replication.LogOffset.t() | nil
```

Get the last exclusive offset of the chunk starting from the given offset

If `nil` is returned, chunk is not complete and the shape's latest offset should be used

# `get_merged_log_stream`

Get the snapshot followed by the log.

# `get_or_create_shape_handle`

```elixir
@spec get_or_create_shape_handle(stack_id(), Electric.Shapes.Shape.t()) ::
  {shape_handle(), Electric.Replication.LogOffset.t()} | {:error, term()}
```

Get or create a shape handle and return it along with the latest offset of the shape

# `has_shape?`

```elixir
@spec has_shape?(stack_id(), shape_handle()) :: boolean()
```

Check whether the log has an entry for a given shape handle

# `make_new_snapshot!`

```elixir
@spec make_new_snapshot!(
  Electric.Shapes.Querying.json_result_stream(),
  Electric.ShapeCache.Storage.shape_storage(),
  stack_id(),
  shape_handle()
) :: :ok | {:error, term()}
```

Wrap the writing of a snapshot to some Storage backend with the required
ShapeStatus update calls.

# `mark_snapshot_started`

```elixir
@spec mark_snapshot_started(
  Electric.ShapeCache.Storage.shape_storage(),
  stack_id(),
  shape_handle()
) ::
  :ok | {:error, term()}
```

# `query_subset`

# `resolve_shape_handle`

Cheaply validate that a shape handle matches the shape definition.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
