# `PhoenixKitKnowledgeBase.Schemas.Vault`
[🔗](https://github.com/BeamLabEU/phoenix_kit_knowledge_base/blob/v0.1.0/lib/phoenix_kit_knowledge_base/schemas/vault.ex#L1)

A vault — one self-contained space of notes, folders and links.

Two scopes:

  * `"system"` — created and owned by the organisation. `owner_uuid` is nil;
    admins holding `knowledge_base.manage_system_vaults` administer them.
  * `"user"` — someone's personal vault. `owner_uuid` is the creator, and
    nobody else sees it unless they are added as a member.

Membership (`PhoenixKitKnowledgeBase.Schemas.VaultMember`) applies to both
scopes: it is what grants a specific person `viewer` / `editor` / `owner`
access to a specific vault.

`[[wiki-links]]` never cross a vault boundary — a vault is the resolution
namespace, exactly as an Obsidian vault is.

# `t`

```elixir
@type t() :: %PhoenixKitKnowledgeBase.Schemas.Vault{
  __meta__: term(),
  created_by: term(),
  description: term(),
  directory: term(),
  folders: term(),
  icon: term(),
  inserted_at: term(),
  last_scanned_at: term(),
  members: term(),
  name: term(),
  notes: term(),
  owner_uuid: term(),
  path_key: term(),
  scope: term(),
  slug: term(),
  updated_at: term(),
  uuid: term()
}
```

# `changeset`

Changeset for creating or renaming a vault.

`:slug` is derived from the name when absent. `:scope` and `:owner_uuid` are
castable but the context — not the form — decides them, because "may this
person create a system vault?" is a permission question.

# `put_path_key`

Marks a vault as the one a notes panel's path names (`Places`). Never cast:
the key is derived from the path, not taken from a form.

Both partial unique indexes are declared, so two people creating the same
place's vault at once get a changeset error to recover from — not a raise.

# `scopes`

```elixir
@spec scopes() :: [String.t()]
```

The scopes a vault may have.

# `slugify`

```elixir
@spec slugify(String.t() | nil) :: String.t() | nil
```

Turns free text into a URL-safe slug.

Returns `nil` for input that has no slug-able characters at all (e.g. a
name written entirely in a script this naive transliteration drops), so the
caller's `validate_required(:slug)` reports a real error instead of the
changeset quietly persisting `""`.

---

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