# `MishkaCmsCore.Runtime.LayoutDraft`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/runtime/resources/layout_draft.ex#L5)

An unpublished working copy of a runtime `MishkaCmsCore.Runtime.Layout` — the Layout analogue of
`MishkaCmsCore.Runtime.PageDraft`.

A draft holds the same editable fields as a Layout plus:

  * `source_layout_id` — the live Layout it edits, or `nil` for a brand-new draft-only layout.
  * `preview_token` — an unguessable token for the shareable `/_preview/layout/:token` URL.
  * `status` (`:draft` / `:published`) and `applied_at` — set when the draft is published.

Publishing is explicit (`:publish` / `:master_publish`): it writes the draft's fields to the live
Layout (creating it when `source_layout_id` is `nil`, otherwise updating all but its `helpers`),
then marks the draft published. See `MishkaCmsCore.Runtime.Resources.Changes.PublishLayoutDraft`.

Layouts can be **global** (`site_id` nil, master-managed), so — unlike `PageDraft` — this resource
is `global? true` and its `site_id` is nullable; a draft inherits the source layout's site (nil for
a global layout). The preview-modal UI only exposes drafts/editing to users who may edit the
layout (master, or a tenant on its own non-global layout).

# `t`

```elixir
@type t() :: %MishkaCmsCore.Runtime.LayoutDraft{
  __lateral_join_source__: term(),
  __meta__: term(),
  __metadata__: term(),
  __order__: term(),
  active: term(),
  aggregates: term(),
  applied_at: term(),
  calculations: term(),
  content: term(),
  description: term(),
  example: term(),
  extra: term(),
  format: term(),
  helpers: term(),
  id: term(),
  inserted_at: term(),
  label: term(),
  name: term(),
  path: term(),
  permissions: term(),
  precompile: term(),
  preview_token: term(),
  priority: term(),
  resource_links: term(),
  seo_tags: term(),
  site: term(),
  site_id: term(),
  source_hash: term(),
  source_layout: term(),
  source_layout_id: term(),
  status: term(),
  template: term(),
  updated_at: term()
}
```

# `default_short_name`

# `generate_token`

Generate an unguessable URL-safe preview token.

# `input`

```elixir
@spec input(values :: map() | Keyword.t()) :: map() | no_return()
```

Validates that the keys in the provided input are valid for at least one action on the resource.

Raises a KeyError error at compile time if not. This exists because generally a struct should only ever
be created by Ash as a result of a successful action. You should not be creating records manually in code,
e.g `%MyResource{value: 1, value: 2}`. Generally that is fine, but often with embedded resources it is nice
to be able to validate the keys that are being provided, e.g

```elixir
Resource
|> Ash.Changeset.for_create(:create, %{embedded: EmbeddedResource.input(foo: 1, bar: 2)})
|> Ash.create()
```

# `input`

```elixir
@spec input(values :: map() | Keyword.t(), action :: atom()) :: map() | no_return()
```

Same as `input/1`, except restricts the keys to values accepted by the action provided.

# `primary_key_matches?`

---

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