77 lines
2.8 KiB
C#
77 lines
2.8 KiB
C#
namespace Wiki.Core.Model;
|
|
|
|
/// <summary>Where in the vault a document lives. Kinds are disjoint sets of paths.</summary>
|
|
public enum DocumentKind
|
|
{
|
|
/// <summary>wiki/*.md — the retrieval corpus, embedded.</summary>
|
|
Wiki,
|
|
/// <summary>raw/*.md — sources waiting for distillation.</summary>
|
|
Raw,
|
|
/// <summary>raw/_processed/*.md — sources distillation has finished with; provenance.</summary>
|
|
RawProcessed,
|
|
/// <summary>output/*.md — synthesised answers, audit and consolidation reports.</summary>
|
|
Output,
|
|
}
|
|
|
|
/// <summary>A listing entry: enough to know whether a document changed without reading it.</summary>
|
|
public sealed record DocumentRef(DocumentKind Kind, string Slug, string Path, string ContentHash);
|
|
|
|
/// <summary>A parsed vault document. Frontmatter fields the vault uses are lifted into properties; the rest stay in <see cref="Frontmatter"/>.</summary>
|
|
public sealed record Document(
|
|
DocumentKind Kind,
|
|
string Slug,
|
|
string Path,
|
|
string ContentHash,
|
|
string Title,
|
|
string? Type,
|
|
IReadOnlyList<string> Tags,
|
|
IReadOnlyList<string> Aliases,
|
|
IReadOnlyList<string> Related,
|
|
IReadOnlyList<string> Sources,
|
|
DateOnly? Updated,
|
|
IReadOnlyDictionary<string, FrontmatterValue> Frontmatter,
|
|
string Body,
|
|
int BodyStartLine)
|
|
{
|
|
public DocumentRef Ref => new(Kind, Slug, Path, ContentHash);
|
|
}
|
|
|
|
/// <summary>A frontmatter value: a scalar or a list of scalars. The vault uses nothing deeper.</summary>
|
|
public sealed record FrontmatterValue(string? Scalar, IReadOnlyList<string>? List)
|
|
{
|
|
public static FrontmatterValue Of(string scalar) => new(scalar, null);
|
|
public static FrontmatterValue Of(IReadOnlyList<string> list) => new(null, list);
|
|
public bool IsList => List is not null;
|
|
|
|
/// <summary>The value as a list: a list as is, a scalar as a one-element list, an empty scalar as empty.</summary>
|
|
public IReadOnlyList<string> AsList() =>
|
|
List ?? (string.IsNullOrWhiteSpace(Scalar) ? [] : [Scalar!]);
|
|
}
|
|
|
|
/// <summary>Part of a document body addressable in typed questions: <c>slug#pN</c>.</summary>
|
|
public sealed record Paragraph(string Id, string Slug, string Heading, string Text);
|
|
|
|
/// <summary>An outgoing reference from one document to another, by target slug.</summary>
|
|
public sealed record Link(string FromSlug, string ToSlug, LinkKind Kind, int? Line);
|
|
|
|
public enum LinkKind
|
|
{
|
|
/// <summary>[[target]] in the body.</summary>
|
|
WikiLink,
|
|
/// <summary>An entry in the <c>related:</c> frontmatter list.</summary>
|
|
Related,
|
|
}
|
|
|
|
/// <summary>A caller identity for attribution. Resolved by the host's authentication, carried into use cases.</summary>
|
|
public sealed record Identity(string Name, IdentityKind Kind)
|
|
{
|
|
public static readonly Identity Anonymous = new("anonymous", IdentityKind.Anonymous);
|
|
}
|
|
|
|
public enum IdentityKind
|
|
{
|
|
Anonymous,
|
|
Human,
|
|
Machine,
|
|
}
|