PhoenixKitKnowledgeBase.Schemas.Vault (PhoenixKitKnowledgeBase v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Changeset for creating or renaming a vault.

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.

The scopes a vault may have.

Turns free text into a URL-safe slug.

Types

t()

@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()
}

Functions

changeset(vault, attrs)

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(changeset, 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()

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

The scopes a vault may have.

slugify(value)

@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 "".