Relatude.DB.CMS 1.1.9.30-alpha

This is a prerelease version of Relatude.DB.CMS.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Relatude.DB.CMS --version 1.1.9.30-alpha
                    
NuGet\Install-Package Relatude.DB.CMS -Version 1.1.9.30-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Relatude.DB.CMS" Version="1.1.9.30-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Relatude.DB.CMS" Version="1.1.9.30-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Relatude.DB.CMS" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Relatude.DB.CMS --version 1.1.9.30-alpha
                    
#r "nuget: Relatude.DB.CMS, 1.1.9.30-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Relatude.DB.CMS@1.1.9.30-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Relatude.DB.CMS&version=1.1.9.30-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Relatude.DB.CMS&version=1.1.9.30-alpha&prerelease
                    
Install as a Cake Tool

Relatude.CMS

A .NET 8 content backend layered on Relatude.DB, an in-process object-oriented graph database (NuGet Relatude.DB.Server). You model your domain as C# interfaces (the engine generates the implementing classes), declare relationships as small marker classes, and read/write through a NodeStore. Provides the base content model (IItem, IPage, ISite, ITemplate), pluggable content rendering (MVC, Razor Pages or any IResult), and DB access plumbing.

Using an AI coding agent? This package ships a Claude Code skill (relatude-cms) with the same guidance below. The commerce layer is documented in Relatude.Ecom (relatude-ecom skill), which builds on this one.

Host setup (Program.cs)

Relatude.DB runs in-process inside an ASP.NET Core app:

var builder = WebApplication.CreateBuilder(args);
builder.AddRelatudeCMS()          // Relatude.DB, CMS settings, analytics and content routing
    .AddMvcRendering()           // MVC views and controllers; AddRazorPagesRendering() adds Razor Pages
    .AddRendering(o => o.RenderRazorView<IArticle>());  // code defaults: what renders a type without a template
builder.AddRelatudeDB(o => o.OnDatamodelInit = (dm, _) => dm.AddCmsContentModel());  // optional, before or after: one ServerOptions

var app = builder.Build();
app.UseRelatudeCMS();             // starts the engine (admin UI at /relatude.db) and the analytics middleware
app.MapRelatudeCMS();         // content URLs to what renders them, see Content rendering
app.Run();

The schema (datamodel) is managed through the admin UI at /relatude.db, where you point a datamodel source at the assembly/types holding your model interfaces, or registered in code: builder.AddRelatudeDB(o => o.OnDatamodelInit = (dm, _) => dm.AddCmsContentModel()).

Getting a NodeStore

NodeStore (namespace Relatude.DB.Nodes) is the entire data API. In a request, inject RelatudeRequest (Relatude.DB.CMS.Web, scoped): each store is named for who it reads as: .VisitorDB is the store as the visitor (the signed-in user's read access, the request's culture, published content only), .AdminDB the same request with access checks off, for trusted code (its culture first, then what is in no culture or only in another, as a store in a culture reads nothing that is in none, such as the users), and beside them User, UserId, CultureCode, Url, Node, Content, Render, GetUrl(node) and Preview (the versions the CMS interface previews in the request, below). The request's culture is the URL's, else, for a URL that names none (such as the root's, /), the page's own (CultureOfPage): the user's preferred culture when the page has a version in it, none when it has one in no culture, else the first culture it has one in, in the store's order; AddRelatudeCMS(o => o.CultureCode = current => …) replaces the rule (it gets the request, whose stores throw until the culture is chosen), and o.UserId = (http, relatude) => … how the visitor is found. Code with no request injects IRelatudeDB (Relatude.DB.NodeServer, a singleton): .AdminDB is the store as the master admin (no access checks, published content, no culture), .AsUser(userId, cultureCode) and .AsAnonymous(cultureCode) read as a visitor, and .IsOpen is false while the database starts; RelatudeDBRuntime.AdminDB is the same store where there is no DI, and a test passes new RelatudeDB(store). Authentication is the host's; the CMS reads the signed-in user's node id from the NameIdentifier claim (which CmsPrincipal.For(user, scheme) writes), else finds the user by the Email claim (a sign-in for a user the store does not have, such as a cookie for a user deleted since, reads as anonymous), and a page the visitor may not read redirects to login, or answers 403 once signed in (AddRelatudeCMS(o => o.LoginRedirect = false) turns that off). Convention: methods that touch data take NodeStore db as a parameter rather than capturing it.

Modeling: interfaces, not classes

An entity is an interface extending IItem (and usually IPage for routable content):

public interface IPage : IItem {
    string MetaTitle { get; set; }
    string MetaDescription { get; set; }
    Reference<ITemplate> Template { get; set; }     // the page's template, or none
}

IItem gives every node Guid Id, string Name, NodeMeta Meta (Meta.Address is the URL slug). IPage adds SEO metadata, a Template reference, and its place in the page tree: Parent and Children, the ends of RTree, which the URL manager (named among its URL parents) and the CMS interface's content tree follow. A page type declares no Parent or Children of its own: the datamodel refuses a property declared twice in a hierarchy. A type's icon, which the CMS interface shows it with, is [Node(Icon = "lucide:house")]: a name of Relatude.DB's icon library or SVG source; the CMS's own types have Fluent colour icons (IPage, ITemplate, ICMSUser, ICMSUserGroup, IDonation), which a site's types inherit unless they set their own. What people call a type and what it is for, [Node(Title = "Article", Description = "A story with a picture.")], name it in the interface and describe it in the create wizard; both are the type's own, not inherited, and a type without a title is named from its code name (IArticlePage, "Article page"). IItem and IPage are abstract ([Node(Abstract = true)], Relatude.DB's IsAbstract): content is of a type inheriting them, never an item or a page as such, and the store refuses a node of either. Mark a site's own bases the same way (an abstract class is abstract by itself), and a type whose nodes only live inside another node, in an embedded list such as a page's blocks, [Node(InnerNode = true)]; both are the type's own, not inherited. The interface never offers an abstract type to create (the create wizard, New beside a link field or an embedded list, the content tree's menus), and offers an inner node type in embedded lists alone; opened with an abstract type, the create wizard offers the types inheriting it. A type an embedded property takes counts as inner too, as a model that marks nothing has it. Other base types: ISite, ITemplate and its kinds (see Content rendering), ICountry, ICMSUser, ICMSUserGroup. A user (ICMSUser) signs in with Username (unique, lower-cased when written) or Email and Password, Relatude.DB's PasswordValue: hashed (Argon2id) when set with SetPassword, at least 8 characters, checked with user.Password.Verify(typed), and never sent out of the server. With AllowCloudSignIn on, the user may also sign in with Relatude Cloud (Microsoft, Google or a passkey at services.relatude.com), as the user whose Email that proves, where the CMS settings allow it (SignIn, see the CMS API).

Relations are declared as classes deriving from OneToMany<,>, ManyToMany<,>, OneToOne<,>, OneOne<>, or ManyMany<>, with nested marker classes naming each end. The CMS's page tree is one:

public class RTree : OneToMany<IPage, IPage> {
    public class Parent : One { }     // exposed on IPage as RTree.Parent Parent
    public class Children : Many { }  // exposed on IPage as RTree.Children Children
}

OneToMany<TOne,TMany> exposes One/Many; ManyToMany<TFrom,TTo> exposes ManyFrom/ManyTo; OneToOne<,> exposes OneFrom/OneTo. Attributes (Relatude.DB.Nodes) tune mapping: [Node(...)] on the interface, [Exclude], and per-type property attributes ([StringProperty], [IntegerProperty(Indexed=true, UniqueValues=true)], [DecimalProperty], [GuidProperty], …). Embedded value maps use [EmbeddedMapProperty(KeyProperty = ...)].

Relation ends are objects, not plain collections:

if (page.Parent.IsSet()) { … }            // One: has value? / Many: Count() > 0
var parent = page.Parent.Get();             // One → T (throws if not set; guard first)
page.Parent.TryGet(out var parent);         // safe variant
foreach (var child in node.Children.Get())  // Many → IEnumerable<T>

In queries prefer Include(...) over lazy .Get() to avoid N+1.

CRUD through NodeStore

var page = db.Create<IPage>();             // in-memory, NOT yet persisted
db.Insert(page);                            // or CreateAndInsert<IPage>(p => { ... })
db.Update(existing);                        // UpdateOrFail / UpdateIfExists / Upsert / ForceUpsert
db.Delete(node);                            // also Delete(Guid id) / Delete(IEnumerable<Guid>)
var p = db.Get<IPage>(id);                  // throws if missing
db.TryGet<IPage>(id, out var page2);        // safe
bool exists = db.Exists<IPage>(id);

Relations are set/cleared as their own operations (property-selector lambda):

db.SetRelation(page, p => p.Template, templateId);  // one-end: replaces
db.AddRelation(template, t => t.Pages, page);        // add to many-end
db.RemoveRelation(template, t => t.Pages, page);     // remove one link
db.ClearAndSetRelation(node, x => x.Many, newSet);   // replace whole set

Write methods accept flushToDisk (default false) and have …Async counterparts. Mutating a property on a loaded node still requires an Update call to persist.

Querying

db.Query<T>() returns IQueryOfNodes<T,T> — fluent and expression-based; nothing runs until a terminal call:

var results = db.Query<IPage>()
    .Where(p => p.MetaTitle != null)
    .Include(p => p.Template)            // eager-load; ThenInclude to go deeper
    .OrderBy(p => p.Name)
    .Page(0, 20)                          // pageIndex0based, pageSize (or Take/Skip)
    .Execute();                           // ResultSet<IPage>; .ToList()/.ToArray() also

var one  = db.Query<IPage>().Where(p => p.Meta.Address == slug).FirstOrDefault();
long n   = db.Query<IPage>().Count();

Also: WhereSearch/Search (BM25 + optional semantic/vector), WhereRelates/WhereNotRelates/WhereRelatesAny, WhereIn, WhereTypes, Facets(), Sum(...), SelectId(), a string-based Where("a => …") overload, and db.TryParseUrl(url, out var keys) for URL → node through the store's URL manager (what content rendering uses; db.TryGetFromAddress<T>(address, out var node) is a raw address lookup that bypasses the manager). Query context controls culture/visibility/revisions: db.Context.Culture("nb-NO").Hidden().Admin().Create(). Default queries exclude hidden nodes.

Transaction plugins (triggers)

Cross-cutting node behavior goes in a plugin. Derive NodeTransactionPlugin<T>, override OnBeforeNodeAction / lifecycle hooks, register with db.RegisterTransactionPlugin(...). Example: a NodeTransactionPlugin<IArticle> that sets each article's address from its name on upsert, with transaction.UpdateAddress(key, RelatudeUrlHelper.ToUrlSlug(name)). Switch on the NodeOperation enum (Upsert, Insert*, Update*, ForceUpsert, Delete*). A write comes as a whole node (OnBeforeNodeAction) or as some of its properties (OnBeforePropertyAction), which is how the CMS API's update and the CMS interface save, so a rule about values checks both. A module registers one with TransactionPlugin<T>() (see Modules).

Content rendering (Relatude.DB.CMS.Web.Rendering)

Rendering a URL takes three steps:

  1. Resolve. ContentResolver finds the node the URL addresses through the store's URL manager (db.TryParseUrl), so base paths, domains, parent-chain URLs and cultures route the way the manager builds them. The result is a ContentMatch: the node, its template or its type's code default, and the culture the URL matched. ContentResolver takes the URL apart once per request, and a file URL is served by the same routes: MapRelatudeCMS() answers files and adjusted files (resized images, converted video) through Relatude.DB's FileHandler, range requests included, read as the visitor, so read access applies to files too. Override ContentResolver.Resolve to find content another way, such as preview links, and call Match(node) to give the node its template or code default.
  2. Select. The first answer wins: selectors added with o.Select(...), in order; for a page with a template, the template's kind; for content without one, the code default for its type, then, with o.ViewPerType(), the view named after its type.
  3. Dispatch. The adapter for the target's rendering system serves it:
Target Adapter Rendered by
RazorViewTarget(view) AddMvcRendering() RelatudeContentController, with the node as the view's model
MvcControllerTarget(controller, action, area) AddMvcRendering() the host's controller action
RazorPageTarget(page, area) AddRazorPagesRendering() the Razor Page
ResultTarget((http, match) => IResult) always mapped any IResult: Blazor SSR's RazorComponentResult, JSON, a template engine

Templates. IPage.Template is a Reference<ITemplate>. A template's kind is its node type:

Kind Renders with
ITemplate only a selector, o.Select(...)
IRazorViewTemplate RazorViewTarget(ViewName)
IMvcControllerTemplate MvcControllerTarget(Controller, Action), a blank action meaning Index
IRazorPageTemplate RazorPageTarget(PagePath)

NodeTypes lists the node type ids the template is for, their subtypes included; an empty list means every type, as the last choice. It is marked [GuidArrayProperty(GuidType = GuidValueType.NodeType)], so the CMS interface offers the types by name. The CMS pins its type ids with [Node(Id = …)]; pin a site's own types too, since an unpinned id comes from the full name.

builder.AddRelatudeDB(options => options.OnDatamodelInit = (dm, _) => {
    dm.AddCmsContentModel();                   // IItem, IPage, ISite, ITemplate and the template kinds, and the engine's own models they build on
    dm.AddNamespace<IArticle>();               // the site's own node types
});
builder.AddRelatudeCMS()                       // after AddRelatudeDB
    .AddMvcRendering().AddRazorPagesRendering()   // MVC + Razor Pages
    .AddRendering(o => o
        .Select((http, m) => http.Request.Query["view"] == "print" ? new RazorViewTarget("Print") : null)
        .Select((http, m) => m.Content is IArticle { Body.Length: > 20_000 } ? new RazorViewTarget("ArticleLong") : null)
        .RenderRazorView<IHomePage>("Home")         // code defaults, for content without a template
        .RenderRazorView<IProduct>(p => p.InStock ? "Product" : "SoldOut")
        .RenderMvcController<ISection>("Section")
        .RenderRazorPage<ILandingPage>("Landing")
        .RenderRazorView<IPage>("Default")          // any other page
        .TemplateKind<IJsonTemplate>(t => new ResultTarget((http, m) => Results.Json(new { m.Content.Name }))));

var app = builder.Build();
app.UseRelatudeDB();
app.UseRelatudeCMS();
app.UseStaticFiles();
app.UseRouting();                             // after the static files, so a file request never looks for content
app.MapRelatudeCMS();                     // pattern "{**url}" by default
  • Code defaults say what renders content of a type and its subtypes that has no template, with no template in the database: RenderRazorView<T>(view) (no name: the type's name without its leading I, so IArticle gives Article), RenderRazorView<T>(node => view), RenderMvcController<T>(controller, action), RenderRazorPage<T>(page) (with or without the leading /), RenderResult<T>((http, node) => IResult), and Render<T>(target) / Render<T>(node => target) for anything else. They work for any IItem. Defining a type again replaces it; a per-node default returning null leaves the content unrendered. o.ViewPerType(), off by default, renders whatever is left with the view named after its type.
  • Templates render by their kind, and a page without a template gets the closest one by type. Templates and code defaults compete by distance from the page's type: the type itself, else its nearest base type. A template as close as a code default wins over it, so editors can take over a type with a template that lists it; a template listing no types is the last choice, after every code default. Two equally close templates are ambiguous, which is the usual case for layout variants (article and article-wide both for IArticle), so pages of such a type choose their template; two equally close code defaults (a type deriving from two interfaces) are ambiguous too, settled by a default for the type itself.
  • Checks. A page whose template is not for its type throws on request, as does content of a type with equally close code defaults, and so do an ambiguous page without a template and a plain template no selector rendered. Saving such pages is refused (on update; CreateAndInsert inserts empty first), through plugins a Relatude.DB IStoreInitializer service registers on every store, whatever order the setup calls come in. A check logged when the store opens, and after templates change, reports views, controller actions and Razor Pages that code defaults name but that do not exist, code defaults for types not in the datamodel, ambiguous types, the names in templates, plain templates when no selector is added, and unknown node types. A default decided per node is not checked up front.
  • Full control. Selectors decide before everything, templates included; to override one template, test m.Template (its Name or Id) in a selector. o.TemplateKind<T>(t => ...) adds a kind of the host's own, asked before the built-in ones. AddMvcRendering() and AddRazorPagesRendering() add the rendering systems a site uses; AddRendering(o => ...) holds the code defaults, selectors and kinds, and every call adds to the same options.
  • Reading the content. Bind it as a parameter, public IActionResult Index([FromContent] IArticle article) (a ContentMatch parameter gets the whole match, including TemplateByType and TypeDefault), or call HttpContext.GetContent<IArticle>() / GetContentMatch() from anywhere. Resolution and selection run once per request, lazily, whoever asks first. [FromContent] skips validation, which would read every related node.
  • Rendering is optional. Without MapRelatudeCMS() nothing is routed, and GetContent<T>() still works.
  • Explicit routes win. The content routes are catch-alls, so every explicit route of the host beats content at the same path. A URL with no content, or a page with nothing to render it, falls through to the host's MapFallback or a 404.
  • Controllers must be conventionally routed. No [Route], no [ApiController]: dynamic routes cannot reach attribute-routed actions.
  • Outbound URLs come from the store. db.GetUrl(page) goes through the same URL manager.
  • Pictures whose box changes shape. @Current.GetDynamicImageHtml(Model.Picture, 1200, 1200) (on RelatudeRequest; Relatude.DB's file.GetDynamicImageHtml(db, …) beneath it, DynamicImageOptions in Relatude.DB.Common) writes a box that fills the element it is in, holding the whole picture fitted inside the two numbers (a limit on the file, not on what is shown). CSS alone crops it to whatever size the box gets as the server would crop it to that size: the picture's crop mode (Fit when none; DefaultCropMode for a template's own), focus point and background. Give the parent its size (aspect-ratio, a height, a grid cell); with none, the box takes the picture's proportions. Adjustment takes format, quality and tone to the server, its crop mode, focus and background overriding the picture's. On a page the interface's preview loads, the box is marked as the picture's field.
  • Composing with another router, such as a legacy CMS: call ContentResolver.GetRender(http) and MvcContentRouteTransformer.TrySetRouteValues(target, values) from your own transformer.

RelatudeUrlHelper.ToUrlSlug(name) (Relatude.DB.CMS.Engine.Web) makes a URL slug from a name (lower case, æ/ø/å and diacritics transliterated). The store makes it unique when it is saved as an address.

The full manual comes with the package, as skill/references/manual.md.

Templates at runtime (Relatude.DB.CMS.Templates)

AddRelatudeCMS() brings the standard templates module: templates evaluated at runtime, kept as text files in the file library. Razor and other compiled templates are not these. One library is the site's design library (TemplatesOptions.Library, Design by default, made with the first template saved); a file is named by its path from the library's top (pages/article.sbn-html, folders by name, in any case), and the extension names the engine that renders it. Engines are modules of their own; Relatude.DB.Scriban is the first (AddModule<ScribanModule>()). Inside a template, include, layout and asset addresses are found from the top of the library the template is in.

builder.AddRelatudeCMS()
    .AddModule<ScribanModule>();
// the files a new database starts with: made where missing, never changed
await TemplateSeed.EnsureAsync(db, TemplateSeed.FromResources(typeof(Program).Assembly, "design"), new LibraryFileKinds([ScribanModule.Kind]));
  • Page templates: a page renders with a template file only through an IFileTemplate : ITemplate node, whose File (Reference<ITextFile>) is the file; editors choose it like any template, and templates.bind makes one.
  • Any text: ITemplateRenderer (RenderAsync(db, path, model) with a path in the design library, or RenderAsync(db, fileId, model) with a file of any library; RenderToAsync with the content type the template asks for; RenderTextAsync(db, text, "sbn-html", model) for a template kept in a property of your own). Data is read with the store given, so as its user. TemplateRenderOptions.Versions reads versions of text files in place of the published ones (a change bundle's, for its preview).
  • Reading the files: TemplateFiles (a service) keeps each library's files in memory, read as published, until a file or folder of any library is written or moved; Sources(db, fileOf?, versions?) is what a render reads layouts and includes from.
  • Assets: a text file no engine renders (a stylesheet, a script) is served to anyone at {TemplatesOptions.AssetsPath}/{hash of its text}/{name} (/-design/…), immutable; a file that is not text at its own address. ITemplateSources.AssetUrl(path) gives the address, Scriban's asset.url. A template's own text is never served.
  • Seeding: TemplateSeed.EnsureAsync(db, files, kinds?, library?) makes the library, folders and files it lacks (text files with their text, other files uploaded) and never changes one it has; files from a folder (FromFolder) or an assembly's resources (FromResources). A module's module.Templates("templates") seeds its embedded files once, the first time it meets a database.
  • An engine: ITemplateEngine (Key, Kinds, Check, RenderAsync, Describe), added with services.AddTemplateEngine<T>(), and its files' kind in the file library with services.AddLibraryFileKind(...). Describe() gives the editor and agents the language: reference, highlighting spec, starter files.
  • Commands (any signed-in user; the store checks each write): templates.engines, .files (the design library's files), .read { path | id }, .save { path, text, version? } (folders and file made where missing; 409 when the text changed since version), .delete { path } (to the wastebin), .check, .preview, .page-templates, .bind, .render-node. Moving, renaming and folders are the file library's commands. The CMS interface's Templates blade (from Settings) lists the page templates and opens the design library; a text file opened in the file library opens in its code editor, with checks and a preview for a template.

CMS settings and analytics (Relatude.CMS.Settings, Relatude.DB.CMS.Web.Analytics)

builder.AddRelatudeCMS() registers the CMS's own settings, CmsSettings, as a Relatude.DB custom settings set: a CMS tab beside each database's settings in the admin UI, read from code as db.Settings.Get<CmsSettings>(). It is layered like every custom setting: relatude.settings/cms.json (SHARED), the admin UI's saves (THIS SERVER), then RelatudeDB:CustomSettings:cms in appsettings. Its groups are Analytics, Modules, Wastebin, SignIn (Relatude Cloud sign-in: AllowRelatudeCloudSignIn, and Microsoft, Google, PassKey) and Interface plugins (see Modules); more CMS settings go in the same class.

builder.AddRelatudeDB();
builder.AddRelatudeCMS();
var app = builder.Build();
app.UseRelatudeDB();
app.UseRelatudeCMS();            // analytics: after UseRelatudeDB, before the site's pages and static files

Analytics is off until turned on: two logs, each with its own switch (CMS > Analytics > Record page views, Record page requests; or the switches of the CMS interface's Analytics blade). Then:

  • The page views of people (LogPageViews) are recorded in the custom log cms-pageviews ("Page views" under Logs in the admin UI): path, host, referrer host, visitor hash, visitor type (human; unknown too with the page check off), country, region, city, position, browser, operating system, device, language and duration. With the page check on (below) only page views it finds a person's are recorded; with it off, a visitor the IP lookup finds to be a bot is left out. A page view is a GET answered 200 with HTML. The admin UI, /-info/, the CMS interface and its API, pages the CMS interface's preview shows (CmsPreviewFinder.Wanted), the paths in ExcludedPaths and prefetches are never page views.
  • Every page served (LogPageRequests) is recorded in the custom log cms-pagerequests ("Page requests"), bots included, with only what the request says: path, host, referrer host, visitor hash and duration. Nothing is looked up for it, so it needs no IP lookup and no bot check.
  • The CMS interface shows them in its Analytics blade, an administrator's (the commands analytics and analytics-settings), laid out after Google Analytics: visitors, page views, views per visitor and time to serve as measures over the period beside the period before; the last 30 minutes by the minute; sources and pages with each row's share and change; a world map by country or by place with the countries' flags, cities and languages; devices, browsers and operating systems with icons; an average day and week; a few sentences on what stands out; and a CSV download. analytics { period, log, from?, to? } takes today, yesterday, 7d, 30d, 90d, 6m, 12m or custom with its first and last day, and answers totals/previous, series/previousSeries, top (each { name, count, before }; countries are ISO codes), realtime, hours, places, icons and botShare. Every number is a statistic the log keeps, so nothing reads the entries; the statistics reach back hours for six days, days for half a year, weeks for three years and months for fifteen.
  • A log is the database's once it is made. It is created when it is missing - the first time it is turned on, and again if it is deleted in the admin UI. After that, changes made in the admin UI (retention, columns taken out, statistics, switches) are kept. The CMS only adds: a version of the CMS that brings new columns, or a new statistic of a column, puts them into the log once, where missing, and the database's storage remembers which version each log has (cms/pageviews-log.json, cms/pagerequests-log.json); a column removed afterwards stays removed.
  • Nothing happens while the visitor waits. The middleware only queues the page view (PageViewQueue). AnalyticsWorker, a hosted service, waits for the pages to have reported (PageCheck.WaitBeforeRecording: LookupDelaySeconds, 5, and with the page check at least EngagedSeconds + 15; not at all while only page requests are recorded), looks the visitors of a batch up at once with db.Services.IPLookup (once per address and user agent; settled verdicts are kept for 10 minutes), and records the entries. A failed lookup records the page views without it and warns once per 10 minutes.
  • The page check is added to every HTML page while page views are recorded, just before its last </body>, as the CMS's HtmlRewriter finds it (InjectBotCheck, InlineBotCheck; PageCheck, the script Web/Analytics/pagecheck.js, about 2 KB). Only an uncompressed UTF-8 HTML 200 of at most 16 MB is held to do it; everything else streams through untouched. Call UseResponseCompression() before UseRelatudeCMS(), if at all. The script reports to POST /-info/pageview for its own page view: whether BotD found a bot, and whether the visitor did anything (a trusted pointer move, touch, key or wheel, or the page in sight for EngagedSeconds, 10); a tab out of sight says so and is waited for, ten minutes at most. PageViewChecks keeps what each page view's page said, in memory: a report counts only for a page view expected, by the id its page carried (PageViewIds), from the same address (an IPv6 address by its /64) and user agent, or with ids off, for the oldest unclaimed page view of its address, user agent and path. PageCheck.Judge decides: a known bot (user agent or network; not the IP lookup's verdict from bot check reports at the address, which would make everyone behind it a bot), headers that contradict the user agent (ClientHints: the fetch metadata a modern browser sends to a secure origin, Chromium's Sec-CH-UA and its version, only for user agents naming that browser alone), a page that never reported or went at once are left out. A run of 200 page views with no report warns that the check may be blocked.
  • No cookie and no address are kept (GDPR). The visitor is the daily visitor hash, SHA-256(IP + User-Agent + Language + daily salt) (DailyVisitorHash). The salt is 32 random bytes per UTC day, held in memory only and never written, so a hash cannot be traced back or linked across days. A process restart starts a new salt, so a visitor seen on both sides of it counts twice that day. The referrer is only its host, and the query string is left out unless LogQueryString is on.
  • IAnalyticsHost is the database side (settings, custom logs, the database's storage, IP lookups, reserved paths). The default is RelatudeAnalyticsHost, the default database's; tests replace it.
  • Behind a proxy, call app.UseForwardedHeaders() first, so the address hashed and looked up is the visitor's.

CMS API (Relatude.DB.CMS.Api)

The NodeStore over HTTP, for a CMS interface and its plugins: the same architecture as the Relatude.DB admin UI, one command endpoint and one event stream, with a bearer token naming the user every request runs as. The TypeScript side is @relatude/sdk (its db export): a typed query builder and a RelatudeStore with the NodeStore's methods. The CMS interface runs on it, signing in through auth/login or the site's cookie (auth/session).

builder.AddRelatudeCMS().AddApi(o => {
    // auth/login checks an ICMSUser's Username or Email and its Password (CmsApiOptions.DefaultVerifyLogin) unless
    // VerifyLogin says otherwise; this one lets administrators alone in, through the same check
    o.VerifyLogin = async (login, current) =>
        await CmsApiOptions.DefaultVerifyLogin(login, current) is { } id && current.AdminDB.Get<ICMSUser>(id).UserType == SystemUserType.Admin ? id : (Guid?)null;
    o.Authorize = (ctx, command) => true;      // the hook for access control per command; false answers 403
});
app.MapRelatudeCmsApi();                       // before MapRelatudeCMS()
app.MapRelatudeCmsUI();                        // the CMS itself at /relatude.cms/ (below)
  • Routes under CmsApiOptions.Path ({UIPath}/api unless set, so /relatude.cms/api): POST command with { type, payload, runId? }, GET stream (SSE), POST upload?id=&property=&name=&context=&keepMeta= (the file as the body, into the revision the read context names, sent as JSON in context; answered with the file as the user now reads it; a new file starts with no metadata, and keepMeta=true, the image editors' for the same picture edited, keeps what the old one said about itself; inner=Property/{id}[/Property/{id}…] puts it in an inner node's file property, the steps down from the node, the inner node saved already), POST upload/start, upload/part?upload=&offset=, upload/finish?upload= and upload/cancel?upload= (a file in parts, over Relatude.DB's multipart upload: start takes upload's query and the file's size, refused at once over CmsApiOptions.MaxFileBytes (no limit by default; MaxUploadBytes, 1 GB, bounds a single request), and answers { upload }, null where the property's file store takes no parts; a part is the bytes from offset and answers { received }, what the server has, checked by its token alone and never waiting on the database (the user is asked for at the start and the finish), a part sent again changing nothing and one that comes before the bytes ahead of it waiting for them a minute, then refused with 409; finish stores the file in the revision the upload was started in and answers it, the same answer when sent again; an upload is its user's, and goes after ten minutes without a part; the SDK's fileUpload sends a file larger than 2 MiB so, three parts under way at once), POST upload/pack?pack=&context= (small files many to a request, each into a node's own file property, stored with one transaction: the body is four bytes giving the length of a list (little endian), the list as UTF-8 JSON { files: [{ id, property, name, size }] }, then the files' bytes one after another in its order, 16 MB of files and 1,000 files at most; answers { files: [{ file } | { error, status }] } in the same order, a file refused (one the user may not write, a text file's own field, one over MaxFileBytes, a second for one field) on its own while the others are stored; pack is an id the client makes, and the answer is kept five minutes, so a pack sent again after its answer was lost is answered without being stored again; the SDK's fileUploadPack sends packs db.packsOf makes, 2 MiB and 500 files at most, and the interface's uploads send small files so, three requests at once), and POST auth/login ({ userName, password }, checked by VerifyLogin, else by CmsApiOptions.DefaultVerifyLogin: an ICMSUser whose Username (in any case) or Email the user name is, and whose Password it is), auth/session (a token for the user the site's own cookie signs in, whatever VerifyLogin says; SessionTokens turns it off), auth/refresh, and auth/logout; GET file-content?id=&property=&context= (a file's bytes as the user reads them, in the revision the context names: for the image editor, which draws with WebGL and so cannot take a picture from another origin) and POST imaging/{operation} (the image AI on an image the editor sends as a multipart form, or create-image, a picture made from instruction with width, height and transparent and no image; image with mask, reference (any number), instruction, factor, top/right/bottom/left, hint, question, language, fresh as the operation takes them: remove-background, upscale, remove-object, manipulate-image, expand-image and shrink-image answer the PNG with X-Relatude-Credits and X-Relatude-Credits-Left, rotate-if-needed { rotation }, image-to-meta and ask-about-image JSON, ask-about-image-bool { answer, certainty } (true for yes, how sure from 0 to 100); 409 with no image AI; Authorize is asked for imaging:{operation}), GET openraster/read?id=&property=&context= and POST openraster/read (a picture of layers, an OpenRaster .ora, unpacked by the server for the image editor: { width, height, stack, entries }, stack the file's stack.xml and entries every other entry, base64 by its path; a stored file in the revision the context names, or one sent as the form's file) and POST openraster/pack (the layers the editor drew packed into an .ora: a form of stack and a file per entry named by its path, mergedimage.png among them; answers the file, a thumbnail made when none is sent), POST video-frame (one frame of the video editor's edit as a JPEG, asked with a JSON body that carries the read context as a command does: { id, property, context, edit, time, height }, at its output time as ffmpeg will render it for the save, but for a GIF's colours), and POST video-thumbnails ({ id, property, context, series }: the frames the editor's timeline and its scrubbing show, a series made by the database's video converter and kept with its converted files, Relatude.DB's FileAdjustmentImage.Frames: quick the keyframes before ten times across the video, made in about a second, all 120 frames; an animated WebP in which each frame is whole and shown until the next one's time, so a frame's time is the sum of the durations before it; answered once made, else 202 { progress, message } with the conversion put first in line, or 422 { error } when it cannot be made; both series are queued when a video is uploaded and when file-info is asked of one, as a video's file field does, so they are usually made before the editor opens). The three sign-in routes also set the HttpOnly cookie relatude.cms.files (CmsFileReaders, as long as the token), which auth/logout deletes: the site serves a file the visitor may not read, or a draft's, as the cookie's user, in the version of the node whose file the URL's hash names, so the interface's pictures of drafts and members-only pages load (a picture's request cannot send the token). It reads files alone. Errors are { error } with 400/401/403 (a write the database refuses too)/404/500; a command stopped with command-cancel (its runId) answers 499.

  • Tokens (ICmsApiTokens, default DataProtectionCmsApiTokens) are sealed with ASP.NET Core data protection and last TokenLifetime (12 h). A token of a user deleted since is refused. Without a persisted key ring every restart signs everyone out. AllowAnonymous serves token-less callers as the anonymous visitor, read-only commands only.

  • Sign-ins by a redirect (CmsSignIn.cs) end on the interface's page with an HttpOnly cookie (relatude.cms.signin, two minutes, path {api}/auth) that auth/session trades for a token once, before it looks at the site's own cookie; one that fails comes back as ?signin-error=, which the login screen shows. GET auth/options tells the login screen, to anyone, what it offers besides a password: { cloud: ["microsoft", "google", "passkey"] } as the CMS settings allow. The database's administrator: the Relatude.DB admin UI has Open CMS above the signed-in user (Relatude.DB's IAdminUILink, which AddApi() registers once MapRelatudeCmsUI() maps the interface), GET auth/db-admin, which hands whoever the admin UI lets in (its session, or localhost while NoLoginRequiredForLocalhost is on) to the interface as CmsApiUsers.DbAdmin, Relatude.DB's master administrator, no ICMSUser: an administrator of the CMS who reads everything (whoami names it DB Admin), and is sent to the admin UI's sign-in when not signed in. The link opens the CMS in a window of its own, named (IAdminUILink.Target, relatude-cms), so the next click comes back to it. The other way, whoami tells an administrator dbAdmin, { url, store } (the admin UI's address and the id it knows the database by): the CMS's menu has Open Relatude.DB, and the form designer a Datamodel link per field to the property in the admin UI's datamodel editor (#datamodel?store=…&type=…&property=…, which the admin UI reads from its address), all in one named window (relatude-db). They sign no one in: the admin UI asks for its own sign-in as ever. Relatude Cloud: with the CMS setting SignIn.AllowRelatudeCloudSignIn on, and SignIn.Microsoft, .Google and .PassKey saying which ways, the login screen has a button for each, GET auth/cloud?method=, which registers a request at services.relatude.com (ICmsCloudSignIn, ServicesCmsCloudSignIn: /api/site-sign-in, with the server's ApiKey and PKCE, the secret kept in a sealed cookie) and sends the browser there to sign in; back at GET auth/cloud/callback the code is traded for the addresses that way proves (a Google or Microsoft account's address, or for a passkey those of the Google and Microsoft accounts linked to the Relatude account), and the ICMSUser with one of them as its Email is signed in if its AllowCloudSignIn is on. The service sends the browser back only to one of the sign-in addresses of the license the API key belongs to (or localhost); the user needs no access to the license.

  • Reads run as the user (CmsApiContext.EditorDB/QueryContext): a payload's context ({ culture, cultureFallback, edit, hidden, deleted, links }) picks the culture and edit view (unpublished nodes too, edit-view access applied), and deleted reads nodes in the wastebin too, each with $status.deleted; links: "stored" reads HTML and Markdown as the store keeps them, their links to the site rdb: link tokens by id rather than URLs, so an editor writing back what it reads keeps every link by id (the CMS interface reads so). get and exists go through a query, since a read by id ignores read access. Writes run as the user too: they are TransactionData run by NodeStore.Execute, so the store's transaction plugins run as for C# writes, and Relatude.DB checks each against the user's groups (a node's edit group, its publish group for what readers see, either node's edit group for a link; DefaultWriteAccess when the node and its type name none, Everyone by default). A refused write answers 403 and writes nothing. Authorize restricts commands besides.

  • Commands: whoami (the user's id, name, email and groups, and admin: a user node of the type Admin, or the database's administrator, who may design the interface's forms; for an administrator dbAdmin, where the Relatude.DB admin UI is), schema (each type's own and inherited properties: kind, string type, enum values, relation targets, how a property holding nodes is shown (display, Relatude.DB's DisplayMode) and whether its nodes may be edited in place (allowInline: always for embedded nodes, for a relation end or a reference only with Relatude.DB's AllowInlineEditing) and an embedded one's innerTypes, what an editor labels each property (title, Relatude.DB's Title, null for one made from its name) and how wide its field is (width, Relatude.DB's Width: a percentage, a share of the form's row, or a CSS length), where an editor puts every property's title (titleLayout, Relatude.DB's TitleLayout: Default, Left, Above or None, null when the model says nothing, which is Default), the unit beside its control (unit), how tall a text area or HTML field is (height, a CSS length) and how many lines a text area shows (textLines), what a Guid or Guid[] property's ids are ids of (guidType, Relatude.DB's GuidType: NodeType, Property or Relation, null for any id, which the editor offers by name in a drop-down), with the string type (SingleLineText a text box, MultiLineText a text area, Code, code in any language, a code editor highlighting it in the language the node names in a string property Language or <Property>Language beside it, and a code type of one language, CSharp, JSON, JavaScript, TypeScript or CSS, the same editor in that language unless the node names another), and defaultValue, what a node of the type gets when the property is given nothing (null for a file and a property holding nodes), which the editor gives a new inner node; the name property (nameProperty: Name for a type with a name, one inheriting Relatude.DB's IName, as every IItem does; null for the rest), which the editor shows at the top of a node's form; the type's form layout when one is designed; and the type's icon as SVG, its own or the closest base type's, made by Relatude.DB's icon library from the model's [Node(Icon = "set:name")] or SVG source; and its title and description, the type's own from the model's [Node(Title = ..., Description = ...)], null when it gives none; and canBeDraft, whether a new node of it can be a draft; isAbstract and isInnerNode, the model's [Node(Abstract = true)] and [Node(InnerNode = true)], whose nodes insert refuses (400), as it does a new inner node of an abstract type, and an embedded property's innerTypes leaves abstract types out; for a password property, password: the ways it may be kept (storages) and what a new one must be like; and beside the types the datamodel's relations, each { id, codeName, fullName, relationType, sourceTypes, targetTypes }), commands, query ({ query, parameters: [{ name, type, value }] }, the query language with typed parameters - decimal, datetime, guid[], …), get, exists, count ({ type } one type's and its descendants', none every node; { types } several at once, answered { counts: { type: n } } with a type not there left out, which the Content blade asks once for every type it lists; with notPublishedIn, a culture's code, also notPublished: { type: n }, those its readers do not read as their own, neither published in it nor in no culture, by Relatude.DB's WherePublishedIn, which query takes too), get-related, get-url, parse-url (the page a URL addresses), parse-urls ({ urls }, at most 300: for each a page's { id, culture }, a stored file's with its property and, in an inner node, inner, or null; the preview's finder asks it), content-link ({ id, property?, adjustment? }: { link, url }, the stored link to a node, or to a file of it resized by the adjustment, to put in HTML; an adjustment the store cannot make, as of an SVG, is left out, and a crop, a width and a height filled, that names no focus point follows the picture's (ImageFileMeta.FocusPoint, which image analysis sets and editors move), so moving the point moves the crop wherever the link is shown, at a new URL), content-link-for-url ({ url }: the stored link to what a path of the site addresses, a page or a file of one, as content-links says what it is, or null; a picture dragged into HTML from a page of the site is linked to its file so rather than uploaded again), content-links ({ links }: what each stored link points at as the user reads it, { link, url, kind, id, type, name, property, width, height, missing, restricted, picture, adjustment, file }, width and height those a picture is resized to, for a file or a variant file, { name, contentType, size } (a variant of a video is a picture of it), and for a file that is a picture picture: { width, height, focus, whole, resizable, name, contentType, cropMode, background }, its own pixels, its focus point, a URL of it whole to crop while a size is dragged, whether it can be resized (not an SVG, nor a GIF), the file's name and type, and the picture's own crop mode and background, which a link naming none is made with; and for a variant adjustment, the image adjustment's settings that are set, by their JSON names, as content-link takes them; a deleted target, or a file field emptied, is missing with the URL #, one the user may not read restricted and unnamed), node-meta ({ id }: what the store keeps beside the values - address and URL, created and changed by, revision, culture, collection, the four access groups with the one that applies and where it comes from and the one that would without the node's own, release and expiry; groups and users named where the user may read them), meta-choices (what a node's access groups and collection can be set to: the engine's groups, then the groups and collections the user reads), tree and tree-path (a one-to-many relation as the content tree: RTree unless the CMS setting Content.Tree names another; when sites (ISite) can be in it, one site's tree, the site root or the first by name, answered with sites and root, and tree-path says which site a node is in; a page with ShowInTree off (indexed) is left out, and what is below it with it, unless hidden asks for them, marked $hidden; $children counts the children shown), tree-move and tree-copy ({ id | ids, parent? | before? | after?, children? }: a node, with its branch or alone, or several (ids, together, each with its branch), into a parent, beside a sibling or to the top, where in a tree of sites only a site goes; one node moved beside itself without its children lifts them out beside it, and a copy may go into its original or beside it; a copy is of one node, has its values, access, files and the links it can share, and runs as a process, answered as its snapshot), tree-count ({ id | ids, children? }: { nodes, warnAt }, how many nodes a copy would make or a delete take), tree-count-below ({ ids }: everything below each node, the ones not shown in the tree included, the tree walked once; a process the user can cancel, answered as its snapshot, its result { counted, below }, below by node and leaving out the nodes with none), tree-delete ({ ids, children? }: with everything below them, or one node alone, its children taking its place; past 200 nodes a process, answered as { process }), tree-create ({ type, name?, parent? | after?, values?, draft? }: a node of a type the tree holds, with the values given, as insert takes them (the interface's draft of a new node, saved), placed, with an address made from its name, the one given or the one among the values; at the top only a site), processes, process-pause, process-resume, process-cancel, process-dismiss ({ id }; the user's processes, below), collab-join, collab-live, collab-leave, collab-send (who has a node open, and the relay of editing it together, below), file-url, file-info ({ id, property }: the file as the user reads it, its pictures asked for ahead of other conversions, what the file field asks again while converting says they are being made, or analysis.queued that the database's task queue is analysing it in the background, as it does after an upload, in the version the file went into), timestamp; maintenance and maintenance-run (below); form-layout ({ type, layout }, an administrator's alone, else 403: a type's form layout, saved in the CMS settings (Forms.Layouts) for every user, or taken away with null; a field names a property by CodeName once, a width is 5 to 100 percent of the row, tabs naming the same strip share a tab strip, and a tab, a heading or a panel may have a color of the CMS interface's palette: gray, red, orange, amber, green, teal, blue, indigo, violet, pink; a field may say its titleLayout (default, left, above, none), unit and height in place of the model's, an empty unit or height for none; a tab or a panel may say its flow, row (the default) or column, and a panel its height; a height is a CSS length, 300px, 20rem or 50%); form-suggest ({ type, mode, instruction?, answers?, layout?, icons? }, an administrator's alone: a layout of the type's form the AI suggests, not saved, the database's AI else the Relatude AI service on the license; mode redesign lays the form out anew from the type's properties by answers ([{ question, answer }]) and anything said in instruction, change changes the layout given as instruction says, keeping the rest; icons are the names a tab's icon may take. Answers { layout, note, dropped }: the layout tidied (a field of a property the type lacks, of the name or placed twice, a width, colour or icon no form has, a panel in a panel, left out and named in dropped) and checked as form-layout checks one, and what the AI says it did; 503 without an AI, 502 for an answer that is no form) and form-suggest-info ({ ai }: who answers it, null for no AI or a user who is no administrator); insert, update (only the given properties; null resets), upsert, delete, reset-property, add-to-property, multiply-property, relate, unrelate, set-relation, clear-relation, move-relation, set-relation-order, change-type, update-meta (null clears a group or collection), update-address, file-delete (takes the file out in the revision the context names: the value is cleared and the stored file left for the sweep of unreferenced files, as another revision, made of its source's values, or a copy may hold it), file-copy ({ id, property, from: { id, property } }: another node's file, read as the user reads it, shared where the store keeps one copy per content and stored again otherwise, no bytes through the client), file-meta ({ id, property, focus?, cropMode?, background?, title?, description?, keywords?, author?, language? }, each changed only when sent and taken away with null: a picture's focus point, { x, y } in its pixels, which crops are made about; and its own defaults, Relatude.DB's ImageFileMeta.CropMode (Fill, Fit, Stretch, Auto) and BackgroundColor (#RRGGBB or #RRGGBBAA), which a link or URL naming none is made with; and what any file says about itself, Relatude.DB's FileValueMeta (Title, Description, Keywords, Author, Language), which the text index reads; answers the file, whose JSON carries focus, cropMode and background), file-meta-read ({ id, property }: all of it, and what analysis found: objects with their boxes, analysis, cropModeAnalysis (graphic, certainty), textExtraction and technical, what the file itself carries; for the interface's metadata dialog), video-info ({ id, property }: what ffprobe says of a node's video in the revision the context names, { duration, width, height, rotation, frameRate, hasVideo, hasAudio, videoCodec, audioCodec, container, formats }, the size as shown, turned as the file says; 503 while ffmpeg cannot be had, which Relatude.DB downloads on first use), file-transcript ({ id, property }: the text the database keeps of the file, as the user reads the node: { name, possible, transcript, cost, urls }, transcript null until text extraction ran, else { text, timed, characters, language, truncated, error, completedUtc, provider }, a recording's or a video's text timed line by line, [00:01:02.500 --> 00:01:05.250] what is said; possible whether the database has a file-to-text service; cost what the service charges, { perPart, cachedPerPart, partMinutes, parts, credits }; urls { txt, vtt, srt } the transcript's addresses on the site, each one file adjustment of the recording (Relatude.DB's FileAdjustmentTranscript), which serves the transcript once it is made and never starts one, null for a file that is no recording), file-transcribe ({ id, property }: makes it, again, now: the database's text extraction as a process of the user's, kind transcribe:{id}:{property id}, telling how far it has come, the transcript a file conversion (FileAdjustmentTranscript): the sound taken out by ffmpeg part by part, each a cached conversion, so taken out once and kept with the file's converted files, sent and transcribed, the service's wait as a share creeping toward where its answer puts it; its result { transcript, file, credits }; charged to the license; 409 while one runs for the file, and without a file-to-text service), video-render ({ id, property, edit }: the video editor's save, a process of the user's (409 while the same video is being saved, two renders at once on a server): ffmpeg encodes the whole video again as the edit says, VideoEdit, the parts kept (segments, in the source's seconds, each an input seeked to and joined by concat), a crop in shares of the picture as shown, rotate, flipH, flipV, speed (0.25 to 4, the sound's pitch kept), filters (brightness, contrast, saturation, hue, grayscale, sepia, blur, sharpen, denoise, vignette, fadeIn, fadeOut), audio (mute, volume, normalize, fades) and output (format mp4, webm, gif or mp3, quality high, good or small, size the shorter side at most, fps, a GIF's loop), and puts the file made into the property in the revision the context names, named for its format and keeping what the old file said about itself; the result is { file, name, format, duration }), file-analyse ({ id, property, kinds?, force? }: the database's analyses of the file run now, in the revision the context names, and kept with it, Relatude.DB's AnalyseFileAsync: meta, a picture's title, description, keywords, focus point and the things in it; cropMode, Fit for a graphic and Fill for a photograph when the image AI is sure, and the picture's edges' colour as its background where it is fitted whole; text, the text of a document or recording. Without force those the file property wants and that are not done yet, the file's analysis.pending, keeping what was set by hand; with it the kinds asked for, a picture's two when none are, again, replacing it. Answers { file, steps: [{ kind, state, summary, credits }] }, 409 when none can be done here. A file read carries analysis: { pending, possible } for a file the database can analyse in some way), imaging-operations ({ available, operations: [{ key, name, available }], maxFileBytes }: the database's image AI, NodeStore.Services.Imaging, kept five minutes); and transaction ({ actions: [{ op, … }] }, all or nothing - an action may use a node an earlier one inserts). Locks, revert windows and the store's own maintenance (the log, the indexes) are left out on purpose.

  • A node on the wire is { "$id", "$type", "$createdUtc", "$changedUtc", <CodeName>: value }, its name the value Name like any other, an included relation end nested as nodes, an embedded list as its inner nodes, { "$id", "$type", <CodeName>: value } (written whole: an inner node keeps a $id it is sent, a value sent as null is reset, one not sent is kept, a file in it included), and a file with pictures made by the store's file conversions, of a picture or of whatever a converter makes one of (a video's frame, a tenth of the way in): a thumbnailUrl, 480 pixels (a picture cropped to a square), and a previewUrl, the whole picture scaled down to fit 1600 by 1200 (a video's frame 1280 wide). A video's frame is made in the background, so its URLs come only once it is made, and until then converting says how far along it is ({ progress, message }). Values are parsed strictly by property type (an enum by number or name; dates ISO 8601, read as UTC), and property names are CodeNames, matched exactly. HTML comes back with its internal links as URLs, a file as { name, size, contentType, url, … }, and a password as { isSet, storage, retrievable }, never the password nor its stored form: { set, storage } sets one (the store hashes or encrypts it and checks the property's rules, answering 400 without quoting it) and { clear: true } removes it, while any other value, such as the shape read, leaves it as it is.

  • The stream sends connected, a ping every 10 s, nodes-changed ({ changes: [{ id, type, kind }] }) after a command changed nodes - filtered per user by a read-access query, deletions always - process (a process's snapshot, to its user only, at most four times a second for progress) and process-dismissed ({ id }), collab-presence and collab (below), and unauthorized when the token runs out. Changes made outside the API are not published.

  • Editing together (CmsCollaboration): every node blade of the CMS interface joins its node's room (collab-join { nodeId, connectionId, participant, live? }, on its own stream), so each knows who else has the node open (collab-presence { nodeId, version, participants: [{ id, userId, name, live }] }, after every change, under a version that rises, which the answers to collab-join/collab-live carry too: a client keeps the higher, as answer and event come in either order). One that edits together goes live (collab-live, answering first for the first live one, which brings the document) and sends its document's changes, cursors and pointer to the room's other live participants (collab-send { messages: [{ data, to? }] } → collab { nodeId, from, messages }). The server keeps no document and passes the messages (Yjs, base64) on as they came, never back to the connection they came from; participants leave with their stream. A user joins only a node they may read.

  • Revisions and cultures: revisions { id } lists a node's versions in every culture ({ id, type, culture, name, … }, id null for a node without revisions), cultures the cultures to write in, and create-revision { id, revision?, type?, culture? }, set-revision-type { id, revision?, type } (published, the culture's published version is archived), set-revision-culture, delete-revision and add-culture { code, site? } (answering the culture's id, code and name) change them. An administrator keeps the cultures as a whole (the interface's Settings › Languages): culture-list (each { id, code, name, nativeName, sites, nodes } in the order a reader falls back in, nodes those with a version in it, drafts and the wastebin's too; beside them the sites, each { id, name, cultures }), culture-choices (every language .NET knows, { code, name, nativeName }), culture-update { id, code?, name?, nativeName?, sites? } (a new code is checked as add-culture checks one and kept unique, and the culture's content goes with it, as versions name their culture by id; an empty name is .NET's for the code; sites are its sites from then on) and culture-delete { id } (409 while any node has a version in it, which the store refuses too). A node's versions are all neutral or all in cultures (Relatude.DB keeps them so): a version in a culture made for a neutral node, or one of its versions moved into a culture, takes its other versions into that culture, and a neutral version beside versions in cultures is refused (409). The payload's context.revisions ({ nodeId: revisionId }) names the revision a command reads and writes; a node read says which it is in $revisionId, $revisionType and $culture; an insert in a context with a culture is that culture's, and one with draft (insert, tree-create) is a draft (Preliminary), which readers do not see until it is published: every type can be one but the engine's own, users, user groups, collections (and so sites) and cultures, which the engine reads itself (400; the schema says which in canBeDraft). The CMS interface saves every new node of such a type as a draft, and its editor offers Publish beside Save. Each version has values of its own, and editing-together rooms are per revision (revision in every collab-* payload and event). preview { instance, revisions: [{ id, revision }], versions?, now? } names the versions the interface's preview shows (CmsPreviews; none of them ends it; each a node the user reads in edit view, else 404): instance is the interface's own random id (16 to 64 letters, digits, -, _; another user's is 403), and a request to the site whose query has relatude-preview=<instance> reads those versions through RelatudeRequest.VisitorDB, published or not (Relatude.DB's QueryContext.SelectedRevisions, which puts a selected revision's node in queries and relation ends too), a page with nothing published found at the version's own URL; read access and culture apply as to any version, the visitor is the site's own, and a file the previewed page asks for is read in its preview (its Referer). versions: [{ id, at, revision?, max? }] are older versions from nodes' histories (below), which RelatudeRequest.Node then is for those nodes' pages (their values as they were, their relations as they are); now (ISO 8601) reads the site at that time (RelatudeRequest.PreviewTime, Relatude.DB's QueryContext.NowUtc), so content released by then shows and content expired by then does not. Kept in memory two hours after its last use; the interface names it again before each load.

  • Finding fields in the preview: UseRelatudeCMS() adds CmsPreviewFinderMiddleware, which puts a script tag before the last </body> (at the end of a page with none) of an HTML page of any status but a redirect's, a 404 or an error page too, loaded in a frame (Sec-Fetch-Dest: iframe) by a browser the CMS interface is signed in on (its relatude.cms.files cookie), with data-page (the page's node id) and data-culture, and answers that page with Cache-Control: no-store; visitors never get it. The script (GET {api}/preview-finder.js, versioned by its hash) talks only to a parent window of the page's own origin, or a loopback one while the site is on loopback too, and does nothing until that parent connects. The interface then tells it what to look for: the fields its form shows of the page's node, of the nodes it relates to, and of the nodes the page's links and pictures are (parse-urls). A text is found as the whole text of the smallest element holding it (white space and case aside), as most of an element's text, or cut short with an ellipsis; an HTML field whole or by its paragraphs; a picture by its URL. A text two nodes share is the linked node's inside a link, else the page's. The page outlines what is found under the pointer with the field's name; a click on it (or on the name, over a link) opens the field in its node's editor, alone (every other blade of the stack closed, pinned ones kept, the preview staying on the page), on its tab, a box flying to it from the page; an inner node's field opens the inner nodes down to it, in place or in their dialogs, one after the other. Beside the field's name are buttons for what can be done from the page, with the editor's own icons (plus, the upload tray, the pencil, x to take a file or an inner node out, the bin to delete the node), which the interface does: on a node's file field, upload a file in its place, edit the picture (the image dialog, or the SVG dialog for a drawing) and remove the file; on an inner node's field, add another after it (its type asked when the list takes more than one, its values in the inner node's form) and remove it from its list (with an Undo); on an embedded list marked whole, add one at its end (mark a list's container even when it is empty, so there is something to point at, as Website2 does on the preview's pages alone with RelatudeField.IsShown); on a list of links marked whole, or a field of a node in one of the page's lists of links, add one at its end or after it: a node made for a list that owns its nodes (the many end of a one-to-many relation, a page's blocks or children, which the schema's relation end says with owns; in the content tree's relation made in its place by tree-create, given an address; types offered without the shapes others inherit, nor a site), else nodes chosen in the node picker, and a node a list only links to is taken out of it (x) rather than deleted; on any other field of a node that can be a draft, delete the node (to the wastebin while there is one). Each writes at once, as the node's editor would, in the preview's culture, and the preview loads again; an inner node's file is not uploaded from the page, as the server uploads into no inner node. The preview bar's Locate field button (a crosshair) turns this on and off, and while the pointer rests on it the page outlines every place a field was found; its Open button opens the page on screen in its editor, alone. A template can mark where it shows a field, which is then found exactly, whatever the element's text: data-relatude-field on the element, Headline for the page's own node, {node}/Name for another, {node}/Specifications/{inner}/Value for an inner node, {node}/Sections/{section}/Paragraphs/{inner}/Title for an inner node's inner node (each step down an embedded property and an inner node in it, up to 8 deep; a mark of an odd number of parts leaves the node out and is the page's own), and {node}/Specifications for the embedded list itself, marked whole. Razor views write it with the tag helper (@addTagHelper *, Relatude.DB.CMS): <h1 relatude-for="() => Model.Headline">, <a relatude-for="() => article.Name"> in a loop (the node is what the property is read from, and a view naming a property that is gone does not compile), relatude-in="Model.Specifications" beside it for an inner node (an inner node's own Embedded<T> for one it holds, relatude-in="section.Paragraphs", which knows the inner nodes down to it), and relatude-node="item.Id" relatude-property="Name" for a view model holding only an id; code writing HTML uses RelatudeField.Attribute(http, () => article.Name) or RelatudeField.Attribute(http, id, "Name"), which give the attribute with a space before it. Both write it only on the pages the preview loads (RelatudeField.IsShown(http)), so visitors' HTML is unchanged; a cache of page parts must vary by that. A marked element is that field and nothing in it is taken for another, a field marked anywhere is looked for nowhere else, and a mark naming a property the form does not show opens the editor, which says so. What is not marked is found by its value, as above, so render values as they are stored for them to be found: a number or a date only in the culture's own forms. A page rendered in the browser (React, Vue, Svelte, Angular, a script of its own) marks the same way, and the script reads the page again as it changes: an app that moves to another page without loading names the node it shows now on any one element, data-relatude-page with its id ("" for a page of no node) and data-relatude-culture, as the script tag's data-page holds only for the address the page was loaded at; a page that names none is taken apart by its address (parse-urls). The npm package @relatude/site (no dependencies) writes them in any framework, only in the preview (inPreview(), which looks for script[data-relatude-finder]): fieldAttributes(node, 'Name') (an inner node's field with its place, { embedded, id }, or the places down to it as a list) and pageAttributes(node, culture) to spread, fieldMark for one bound attribute, setFieldMark/setPageMark on elements, markAlways() for a page hydrated from a server's render, which must match it. Marks in sight are reported first, up to 1000.

  • Publication in lists: every node read (and every tree row) has $status { state, draft, releaseUtc, expireUtc }, whether readers see it now in the culture of the version read: published, scheduled (published, released later), expired, draft (nothing published) or unpublished (archived only), draft true when a draft is beside the published version (CmsApiJson.Status); read in a culture, missing true and shownIn its code when the version read is another culture's, as the node has none in the one asked for (never for a version in no culture, which is every culture's). The CMS interface marks what readers do not see in its lists and the content tree, and what is missing in the blade's language in violet, and says it in words in a list's Status column. Each also has $rights { edit, publish }, what the user may write of it (IDataStore.GetWriteRights), and the schema each type's rights { create, createPublished } and canWrite: false on a property the user may give no value; the interface shows a form the user may not save read only, and leaves out the publishing, deleting, moving and making it would be refused.

  • History: Relatude.DB keeps every write of a node in its transaction log, chained to the one before (FindOlderVersions), as far back as the log reaches. history { id, revision?, max? } lists a revision's writes newest first (none for a node without revisions; writes from before the node had revisions are every revision's), each { at, utc, current, revision, type, culture, name, changedBy, changed, meta }: at names the write (its log timestamp, as text), changed the properties it changed (null for the oldest), meta what of the version (type, culture, release, expiry), changedBy who saved it ({ id, name }, the user the version's meta names, name null for one the reader may not read; null when no user is recorded); more when the log reaches further than the max writes read (50, at most 500). history-version { id, at?, revision?, max? } reads a version as get reads a node (relation ends are not in the history), and history-restore { id, at, revision?, max? } (an action of transaction too) writes its values back as a new write, to the revision the payload's context.revisions names (400 otherwise): not its files, passwords or relations, nor its type, culture or dates. The CMS interface's editor opens a node's History blade from its menu, where a version is compared with any other, shown whole, previewed and restored. Files have a history of their own: file-history { id, property, revision?, max? } lists the files a revision's file property has held, the one it holds first, then the latest replaced first, each { file, name, size, contentType, width, height, current, exists, from, fromBy, until, before } (file its FileId, from when it last went in and fromBy who put it there, until when it was replaced, before that it was there already in the oldest write read, exists that the store still has its bytes, which a replaced file keeps until the sweep of unreferenced files takes them); GET {api}/file-history-content?id=&property=&file=&revision=&max= gives a picture of one, at most 480 pixels on its longest side (an SVG as it is; 415 for a file no picture is made of, 410 for one gone); and file-history-restore { id, property, file, revision?, max? } puts one back into the revision the context names, its bytes stored again with its name and all that was kept beside it (409 for the file held now). The file field's history button opens its File history blade, which lists them with their pictures and restores the one chosen.

  • The site's change history: Relatude.DB can keep an index of its transaction log, off by default (LocalSettings.History: Enabled, TypesByDefault, BuildSpeed; the database's admin UI, Settings › Maintenance › History), which says who changed what and when across the whole database without reading the log for it. A type is in it by TypesByDefault (true) unless its [Node(History = …)] or the datamodel's override says otherwise; the CMS's IWastebinEntry and IChangeBundle are out. Code reads it through db.History (Status, Read(LogChangeQuery), Analyse(LogActivityQuery), VersionAt<T>(id, timestamp), Rebuild()), and the CMS API through three commands, an administrator's alone (403 otherwise). history-reach answers { supported, enabled, source, reachesBackTo, latest, building, percent, problem, changes }. history-changes { from?, to?, types?, who?, actions?, site?, culture?, node?, search?, transaction?, system?, cursor?, take? } answers a page newest first, { items, next }: an item is one save's change to one node, { at, utc, action, node { id, name, type }, revision, versionType, culture, site, who { id, name }, changed, inSave, kept } (changed the properties' CodeNames, kept whether the version is still in the log, so history-version reads it), a save of more than 12 nodes one item with others and types ([{ type, count }]), a move { from, to } (a node given another parent in the content tree in one save), a link { relation, target }. The actions are created, version, updated, published, unpublished, binned, restored, deleted, version-deleted, language, meta, moved, linked and unlinked; types are CodeNames and take the types inheriting them, search matches the names the nodes have now, transaction (an item's at) lists all of that save, system adds the system's own writes (indexing, file analysis), take is 50 (200 at most) and next the next page's cursor. history-activity { from, to, interval?, by?, types?, who?, actions?, site?, culture?, search?, system?, before? } counts them: { interval, from, to, totals { changes, saves, people, nodes, links }, before, groups [{ key, label, changes }], buckets [{ start, counts, groups }] }, interval hour, day, week or month, by action, type or who, before the totals of the period as long before it (before: false leaves it out). The interface's History (the menu's, an administrator's) shows them: the period and the filters in its bar, one card of the measures as tabs over a chart by action, type or person with the period before as a dashed line (asked for as its own history-activity with by none, which answers the buckets alone), the types and people that changed most and the last 26 weeks a day to a square beside it, and the changes by day, each opening the version it made in the node's own History blade. Its toolbar's Demo (and the Analytics blade's) shows content invented in the browser, never read or written, for showing a client the blade on a site in use. history-version finds a version the node's chain of versions no longer reaches (a node deleted for good) through the index (FindVersionAt).

  • Translating a version: translate-info { id?, revision? } answers { engines: { translation, chat }, charsPerCredit, languages, source }: the engines there are (translation, the database's Translation service, NodeStore.Services.Translation, machine translation text by text, quick and cheap; chat, the CMS's text AI, ICmsAI, given the page's texts together, often better, slower and dearer), every language .NET knows ({ code, name, nativeName, translation }, translation whether the Translation service translates into it), and of the version its culture and the texts that would be translated (texts, characters, fields). translate { id, revision?, to, engine, from?, instructions? } starts a process (kind translate:{id}): it reads the version, translates every text a reader reads (string properties of plain text, HTML or Markdown, the node's and its inner nodes', not code, choices from a list or strings named as addresses, slugs, URLs, e-mail addresses, keys, colours or authors; HTML keeps its markup and rdb: links), and only then, as the user, adds the language where the installation lacks it (to the node's site too when the site names its languages), gives a version in no language the language from (and the node's other versions with it), makes a draft in to copied from the version, and writes the translations into it, taking the draft away again if that write fails; its result is { id, revision, culture, from, engine, translated, untranslated, credits }. The chat agent takes the editor's instructions, and is asked again once for a text it left out. Refused before anything is paid for: the version's own language, one the Translation service does not translate, a version with no text (400), a user who may not edit the node (403), an engine the database lacks (503). The draft is no change bundle's. The CMS interface's Translate dialog (culture/TranslateDialog.tsx) is opened from the editor's menu, its Revisions tab and the note of a missing language version.

  • Sites: a site is one of Relatude.DB's collections (ISystemCollection, which the CMS's ISite is), so one database holds several sites' content. A node is in one site or none (its meta's CollectionId), which a read says in $collection and update-meta's CollectionId changes; a site names the cultures its content is written in (CollectionsToCultures), none meaning any. sites answers { supported, types, items }: the collections the user may read, by name in the context's culture, each { id, name, type, cultures }, and the CodeNames whose changes change the answer. The payload's context.collection is the site the user works in: insert (and so tree-create) puts the node in it, a collection itself goes in its own, and an id that is no collection the user reads is refused (400); reads are not limited by it. add-culture { code, site? } also makes the culture one of the site's. The CMS interface has a site selector in every blade's header beside the language one, which offers the site's languages.

  • Skins: the interface's look is its design tokens (tokens.css, the --r-* custom properties every component is drawn with), and a skin is a value for each, one for the light theme and one for the dark (the size of all text too, text-scale, which every font size is multiplied by). It comes with Default (key windows, after Windows 11), Neutral, and a gallery: WCAG, Windows NT, Mac System 1, iOS, Optimizely, WordPress, Terminal, Paper, Forest, Synthwave, Winter, Relatude, Relatude BW and Relatude Classic; a skin has both themes or one alone (the themes token: both, light or dark; Windows NT, Mac System 1, Optimizely, WordPress and Relatude Classic are light alone, Terminal dark alone), and while one with a theme alone is in force the interface is in that theme whatever the user chose and its switch between light and dark is hidden; the top bar has its own ink (bar-ink, bar-muted, the blades' unless the bar is a colour of its own) and the menu its own hover (nav-hover, nav-hover-ink, for a menu of a colour of its own, as WordPress's dark one); an administrator makes more in the skin designer (Settings › Appearance), whose basic mode turns a few dials (accent, tint, wallpaper, moving background, see-through blades, menu and top bar, and how blurred, corners, depth, font, motion, frosted menus) and whose advanced mode edits every token, pictures as SVG, the shader and the skin as JSON, and every user chooses one in their browser (the choice shows Default, WCAG, Relatude and the installation's own first, the rest under More skins, closed until opened; Terminal not offered, though whoever chose it keeps it). A picture (a token whose name ends in -image: the wallpaper, a blade texture, the menu's illustration) is SVG source, or none, put into the stylesheet as a data: URL, drawn as an image that runs and loads nothing. A logo (the tokens logo-login, logo-bar and logo-bar-collapsed, uploaded in the designer's Logo section) is the name of a picture the installation keeps, its SHA-256 and its type (<64 hex digits>.png, .jpg, .webp, .gif or .svg), or none for Relatude's, one per theme: the login screen shows logo-login atop its card, else logo-bar; the top bar logo-bar over the menu, else logo-login, and logo-bar-collapsed while the menu is collapsed, else the top bar's made to fit; where a skin shows its own, a small Relatude logo goes at the foot of the menu and of the login screen. The AI never sets a logo, and a skin naming a picture the installation does not keep is refused. A moving background is a scene the interface draws with WebGL behind the blades, which a skin chooses (scene: peaks, relatude.com's flight over faceted mountains; snow; aurora; grid; stars; forest, a forest against the light, layer on layer of trees fading into the glow, with shafts of light, mist and falling leaves, and now and then a rabbit hopping by, a moose walking through a little after it, in front or deep among the trees, and an owl flying in as the moose leaves, to perch on bare twigs; winter, a picture book's frozen lake under snowy peaks stood up in 3D, opening as the picture and then moving slowly about the lake, the moon and the stars by night; synthwave, a drive down a neon road through wireframe hills toward a striped sun, palms going by and now and then a car overtaking; or shader) and colours (scene-sky, -horizon, -land, -shade, -snow, -accent, -veil, -speed, -work-speed, the share of the speed it moves at once signed in, eased to and from at sign-in and sign-out, its particles (dust, the graph's links, snowflakes) keeping the square root of the share, so Relatude's flight all but stops past the login screen while its dust still drifts by; slowed so, Peaks leaves out its graph; and -amount); the scenes are the interface's own code, so a skin still carries only values, except scene-shader: a GLSL fragment shader after Shadertoy (mainImage), which runs on the graphics card alone and can read nothing. A scene always moves at its skin's speed. skins answers { default, skins: [{ key, name, description, base, light, dark }], canEdit, ai } (a skin's values over its built-in base's, token names without --r-; ai says what makes a skin from a prompt, to an administrator, or null); an administrator's skin-save { skin } (saved over the skin of its key), skin-delete { key }, skin-default { key } (a built-in or saved skin; null for Default, the skin windows), skin-logo { data } (a picture for a logo, PNG, JPEG, WebP, GIF or SVG by its bytes, as base64 or a data: URL, at most 1 MB, an SVG without scripts or event attributes: kept in the database's storage under cms/skins/logos/ by its SHA-256, answered as { logo }, the value a logo token takes, served to anyone, as the login screen needs it, at GET {api}/skin-logos/{logo}, immutable and sandboxed; a picture no skin names goes a day after it was kept, when skins are saved or deleted) and skin-generate { prompt, tokens, current }, which asks the database's AI (store.Services.AI, else the Relatude AI service on the installation's license, ICmsAI) for a skin, telling it the tokens the interface sent (name, group, kind, what each is for) and the skin as it is, and answers { name, description, light, dark, dropped } unsaved. Every value is checked (CmsSkinJson.IsSafeFor, the interface's isSafeFor): a CSS value has no ; { } < > \ ! @, no url(), quotes in pairs, one line; a picture is one <svg> of at most 16000 characters without scripts, event attributes, styles, embedded or linked files, links only to its own #ids; a shader is at most 12000 characters of plain ASCII with a mainImage and no #version or #extension; so a skin writes values into the interface's stylesheet and nothing else, and a shader draws on its canvas and nothing else. Kept in CmsSettings.Skins, the database's.

  • The AI: everything in the CMS that asks an AI for text goes through one service, ICmsAI (Relatude.DB.CMS.Api). Describe(store) says what answers and whether it takes pictures and tools, null when nothing does; ChatAsync(store, request, cancellation) answers an AIChatRequest with an AIChatResult (the text, the tools the model asks for, what it cost); StreamAsync gives the answer as it is made. It is the database's own AI (store.Services.AI), else the Relatude AI service on the installation's license. A model key the database's AI settings lack is left out, so the configured model answers. Spent credits are a CmsApiException 402 in the service's own words, and no AI at all a 503. Register your own ICmsAI before AddApi() to answer otherwise; ScriptedCmsAI answers from a script (Relatude.DB's ScriptedAIProvider), for tests.

  • Modules add commands with Command(…) (see Modules); other code injects CmsApiCommands and calls Register("my-command", ctx => …, readOnly: true); ctx.Payload<T>(), ctx.EditorDB, ctx.Changed(id, typeId, kind). CmsApiEvents.Broadcast pushes events of its own.

  • Processes: work that goes on after its command. ctx.StartProcess(new CmsProcessStart(kind, title) { Description, Status, CanPause, CanCancel }, async (c, process) => { …; process.Report(done, total, status); await process.CheckpointAsync(); …; return result; }), answered as process.Snapshot(); check the payload first, so a mistake is the command's answer. A process belongs to the user, not to the token: it runs on while they are signed out, processes lists it at the next sign-in, and no other user sees or touches it. CheckpointAsync is where a pause holds the work and a cancel stops it (an OperationCanceledException; any other exception fails it, with the message). The work gets a context of its own, c: the same user, store and payload, no request (c.Http throws), cancelled with the process, its Changed nodes published at each checkpoint. CmsProcesses keeps them in memory, so a restart loses them; a finished one stays until dismissed, for a day at most. tree-copy is one: 25 nodes per transaction, a checkpoint after each batch and its files; cancelled or failing half-way, it removes the nodes it copied.

  • Maintenance (the CMS interface's Settings menu, an entry for each task under Maintenance): checks of the content an administrator runs, each able to put right what it finds. maintenance lists the tasks ({ canRun, tasks: [{ id, title, description, asks, warning }] }, canRun for an administrator, asks what a run needs chosen first, in order: site, then culture, warning what the interface says before a fix); maintenance-run { task, fix?, site?, culture? } (an administrator's alone, else 403; one run of a task at a time per user, else 409; for a task that asks for them, site a collection the user reads and culture a code the store has, one of the site's when it names any, else 400) runs one as a process of kind maintenance:{task}, checking only or, with fix, repairing too, 500 nodes between two checkpoints, so it can be paused and cancelled and what a cancelled fix wrote stays. Its result: { task, fix, site, culture, checked, found, fixed, failed, summary, note, items }, items the first 100 found as node references with problem, and fixed or error in a fix. A batch the store rejects is written again one node at a time, so one refused node leaves the others fixed. The tasks: site-collections (Ensure matching system collection and site) puts each node of a site's content tree in that site's collection and each site in its own, walking the tree as it is (past read access, the nodes not shown in it included), a site below another being its own, as tree-path answers; a node in no site's tree keeps its collection, as an insert in a site puts any node there. A copy or a move in the tree keeps the node's collection, which is how they come apart. neutral-culture (Add a language to neutral content, asking for a site and a language) moves every node in the site's collection whose versions are all neutral into the language, every version with it (ChangeRevisionCulture without a revision id), as a node's versions are all neutral or all in cultures; the nodes with a version in a culture are told apart by the store's meta index (a query context with the site's Collections and RequireCulture()) without being read, the rest read by their revisions a batch at a time, so a node given a culture meanwhile is left alone. A site with nothing in its collection answers a note that points to site-collections. The interface asks for the site, then the language, offering the site's languages (all when it names none).

  • Users and groups (the CMS interface's Users and groups, an administrator's): who there is, who is in which group, and who has what access to what. access-overview answers { database: { read, write }, builtIn, groups, types, userTypes, groupTypes }: the groups, each with its users counted, the groups it is a member of (memberOf) and those in it (members); and each type's rules, read, editView, edit and publish, each { group, from: "type" | "database" }, with fields, the properties one group alone may give a value. access-users { search?, group?, id? } lists the users (300 at most) with groups, the ones they are members of, and effective, those and the groups they are members of in turn, as the store resolves them. access-of { user } (a user's id, or "anonymous" for a visitor who is not signed in) counts per type the published nodes there are and those the user reads, and access-hidden { user, type } names the ones kept from them, each with the group that reads it. Users and groups are nodes, made and changed with the store's own commands: insert, update (UserType 1 a user, 2 an administrator, written by an administrator alone; Password: { set }), relate/unrelate (Memberships of a user; UserMembers, GroupMemberships and GroupMembers of a group) and delete.

  • Limits: MaxPageSize (10 000) for Page/Take/SetRowPaging, MaxQueryLength (20 000), MaxUploadBytes (1 GB). A tree copy has no limit: past TreeCopyWarnAt (10 000 nodes; 0 never) the CMS interface warns and asks whether to go ahead.

CMS interface (MapRelatudeCmsUI)

The interface editors sign in to is not in the package. app.MapRelatudeCmsUI() gets it from services.relatude.com, keeps a copy, and serves it from the site's own address.

  • GET {ui}/ (/relatude.cms/; without the slash it redirects there, the query kept) asks services.relatude.com which release to serve, server to server, each time the CMS is opened: POST {services}/api/cmsui/latest with { apiKey, cmsVersion, installationKey, uiVersion, channel, version, licensePage }, uiVersion being the release it holds and channel/version the installation's choice (below). Only a release it does not hold is downloaded (POST {services}/api/cmsui/release, naming the version the check gave, a zip checked against the SHA-256 the service named). It answers the release's index.html (no-store) with <base href="{ui}/r/{version}/"> and window.__RELATUDE_CMS__ = { api, uiPath, version, cmsVersion } (with unlicensed, below, when the license lacks the CMS) put first in its head. GET {ui}/r/{version}/… serves the release's files, cached as immutable. GET {ui}/?dev serves the release's development build instead (its dev/ folder: React's development build, with its warnings and errors in full, and the interface unminified), its base at {ui}/r/{version}/dev/ and dev: true in the page (false for a release with none, served as it is): for developing interface plugins, which a CMS loads for one page from this computer with ?plugin=<address> while relatude-plugin dev (@relatude/plugin-kit) serves and rebuilds them; npm create @relatude/plugin starts one.
  • The copy it keeps. CmsUiServer holds the release it serves unpacked in memory, with the two before it for pages still open on them, and keeps its zip in the database's storage (cms/ui/release.zip, with release.json naming its version and hash), so a restart does not download it again. While the service cannot be reached the copy is served; a refusal, or no release published, is never answered with it.
  • It takes a license with the feature cms. The server's ApiKey setting (the admin UI's Settings, or RelatudeDB:ApiKey) goes with every request, to the ServicesServerUrl setting (https://services.relatude.com) unless CmsApiOptions.ServicesUrl is set. With no key the page answers 503, with a refused one 403 and the service's reason, with no release published 404, with the service unreachable and no copy kept 502, each as a short HTML page. A license in force that lacks the feature is not refused: the request says licensePage: true, so the service names the release all the same with unlicensed, its reason, which the page carries as window.__RELATUDE_CMS__.unlicensed, and the interface shows, in place of its login and in the login's card and skin, that the CMS is missing from the license, with Check again (the page loaded again, which asks again). The API then signs no one in: auth/login, auth/session and auth/refresh answer 403 while ICmsLicense knows the license to be in force without cms (CmsLicenseState.CmsFeature); a license it does not know (no key, the license server not answering) changes nothing, as for the modules.
  • The path is configurable, as /relatude.db is: the server setting CMS > Hosting > CMS path (CmsServerSettings.UIUrlPath, file key cms-server, applied at a restart) wins over CmsApiOptions.UIPath. The API moves with it ({ui}/api) unless CmsApiOptions.Path is set.
  • From source, for working on the CMS itself. In a Debug build of the CMS made in its repository (never the package's), a site running in Development serves GET {ui}/ from the interface's Vite dev server, CmsApiOptions.UIDevServer (http://localhost:5173, npm run dev in Relatude.CMS.UI; null turns it off): its page with the modules loaded from there and hot reload, the API and sign-in the site's own as with a release, window.__RELATUDE_CMS__.devServer its address. While it does not answer the release is served as ever, and ?release asks for the release while it does.
  • A release has a version of its own, apart from the package's, a channel (release, beta or alpha) and the oldest CMS it runs on (the Relatude.DB.CMS package version, or any). Relatude publishes the releases, and a release's channel can change later, which is how a beta becomes a release. The service counts each opening and download, per release and per installation. Releases come from ICmsUiSource (default ServicesCmsUiSource); register another to serve them from elsewhere.
  • Which release an installation serves is the newest of its channel and the steadier ones that runs on its CMS (release takes releases, beta betas and releases, alpha everything), or the one version it holds to: the server settings CMS › Interface releases (CmsServerSettings.UIChannel, UIVersion; read at every opening), which an administrator also sets in the CMS under Settings › Updates. A version held to that cannot be had (withdrawn, or needing a newer CMS) gives way to the newest of the channel, and the tab says why; a newer release the CMS is too old for is named there too. The API's commands: ui-release (the choice, what was served, newer, problem), ui-releases (every release published, with runs on this CMS), ui-release-set { channel, version } (administrators; saves and asks the service at once).
  • Interface plugins are built with four npm packages on npmjs.com, MIT licensed and released together under one version, the SDK's (prereleases such as 1.0.0-alpha.1 under the dist-tag alpha, so npm create @relatude/plugin@alpha my-plugin): @relatude/create-plugin (the starter, run by npm create @relatude/plugin <folder>), @relatude/plugin-kit (relatudePlugin(), the Vite build, and relatude-plugin dev, which rebuilds and serves the plugin for ?plugin=), @relatude/sdk (definePlugin, useCms, the services' types and the db client) and @relatude/ui (the interface's components and design tokens). A plugin installs them, React and @types/react as dev dependencies, for its types and its build: relatudePlugin() leaves react, react-dom, @relatude/sdk and @relatude/ui out of the bundle, the interface's import map gives the plugin its own copies, and definePlugin's sdk range is checked against the interface's SDK version. Keep the three at one version and upgrade them together (npm install -D @relatude/sdk@alpha @relatude/ui@alpha @relatude/plugin-kit@alpha). The SDK and the components need React 19, the kit Vite 5 or newer.

Relatude Assistance (the help button)

When the installation's license includes the feature assistance, the CMS interface shows Help in its top bar: the assistant, Relatude's ring spanner, through which a user reaches Relatude's people with a question, a problem or feedback, as a message answered later or to talk now. The assistant is one shell with channels; Relatude's people are its first channel. Two commands carry it:

Command Payload Answer
assistance-status none { available, reason }: whether this user gets the button
assistance-start { language?, uiVersion?, interfaceUrl? } the assistance site's session: { token, expiresUtc, url, protocol, status }

assistance-start asks the assistance site over the back channel with the server's API key (ApiKey in the server's settings), naming the installation and the user, so the browser never holds the key; the browser then talks to the assistance site with the token. The CMS settings' Relatude Assistance group (CmsSettings.Assistance) turns the button off (Enabled), keeps it for administrators (Who), or points it at another assistance site (ServerUrl; one on localhost is used without checking the license or needing a key, for developing it). Replace ICmsAssistanceServer to reach it some other way. When an assistant has the conversation, the user can talk with them and show their screen, and see the assistant's: one WebRTC connection between the browsers, its messages relayed by the assistance site. The browser asks before the microphone or a screen is used, every time, and the assistant's pointer is drawn on the user's screen when what they show is the CMS's own tab. When the assistance site writes calls down, the user is told before the call starts, sees what is said as captions, and finds each line in the conversation; the sound is not kept.

Modules (Relatude.DB.CMS.Modules)

A module is everything one feature adds to a site, described in one class and shipped in one assembly, usually a NuGet package: model types, transaction plugins, jobs, settings per database and per server, seed data, CMS API commands, routes, rendering, views, an interface plugin, custom logs and user groups, and what it needs of other modules and of the license. The module is the package; the plugins it brings are the parts that hook into something else: transaction plugins into the store's writes, the interface plugin into the CMS interface. The example is an events module, built on a venues module:

public sealed class EventsModule : CmsModule {
    public override string Name => "events";                       // letters, digits and '-': names its commands, files and switch
    public static readonly Guid Managers = new("6549f757-c808-4c73-bac2-ea96b826ef49");
    public Guid? ParentPageId { get; init; }                       // an option the host sets: AddModule(new EventsModule { … })

    public override void Configure(CmsModuleBuilder module) => module
        .DependsOn<VenuesModule>()                                 // ordered after it, and only active while it is
        .Datamodel(dm => dm.AddNamespace<IEventPage>())
        .TransactionPlugin<EventPagePlugin>()
        .Job("events.close-past", "Marks the events that have ended.", (c, job) => …)
        .Settings<EventSettingsDefinition>()                       // per database or per server, as its Scope says
        .Seed(1, "Three events", c => …)
        .Seed(2, "A first registration", c => …)
        .UserGroup(Managers, "Event managers")
        .Log(EventActivity.Definition())
        .OnStoreOpened(c => …)
        .Command("events.upcoming", ctx => …, readOnly: true)
        .Endpoints(e => e.MapGet("/events.ics", …))
        .Rendering(o => o.RenderRazorView<IEventPage>("EventPage"))
        .Views()                                                   // the views compiled into the module (a Razor class library)
        .InterfacePlugin();                                        // ui/index.js, embedded in the assembly
}

builder.AddRelatudeCMS().AddApi()
    .AddModule<VenuesModule>()
    .AddModule(new EventsModule { ParentPageId = homeId });     // homeId: the page the events go under
  • Added in code, explicitly. AddModule<T>() runs Configure at once: its services and settings are added then, and the rest waits for each database's start. A module added twice is added once. Two with one name, a dependency not added, or modules building on each other in a circle stop the start (UseRelatudeCMS()). Modules run dependencies first, otherwise in the order added.
  • Each database's start goes through Relatude.DB's start-up services, so no setup call of the host's can lose it. IDatamodelInitializer adds the model types of every module that applies, after the host's OnDatamodelInit (AppliesTo; by default every database whose datamodel has the CMS content model, and never one without a module it builds on). IStoreInitializer registers its transaction plugins, runners and jobs. IStoreOpenHandler, once the store is open and on a background thread, makes missing user groups and custom logs, runs the seed steps not run yet, then the start-up work.
  • Seed data is numbered steps, each run once per database, in order. The database's storage keeps the last step run (cms/modules/{name}.json). A step that throws stops the steps after it until the next start. Change data later with a new step, and never renumber a released one. Steps run as the master admin through the store's synchronous writes, so transaction plugins see them, and should find what an earlier run made (fixed ids).
  • Commands and jobs are named after their module (events.upcoming), so a module cannot replace another's or the API's own. A command runs as the user like the API's own (ctx.EditorDB, ctx.IsInGroup(groupId)); the CMS interface sends it with cms.store.send("events.upcoming", payload).
  • The interface plugin is an ES module whose default export is definePlugin(…), embedded in the module's assembly with the files it imports: <EmbeddedResource Include="ui\**" LogicalName="cms-ui/%(RecursiveDir)%(Filename)%(Extension)" />. The API serves them at {api}/modules/{name}/{version}/…, cached as immutable (the version is the assembly's informational version unless Version is overridden). As it starts, the CMS interface asks cms-modules and imports the interface plugins of the active modules; their bare imports resolve through its import map. A plugin can be plain JavaScript, with no build, or built with @relatude/plugin-kit.
  • Interface plugins without a module are listed in the CMS settings (CMS › Interface plugins: name, address, on or off) and loaded from the site or from another site that allows CORS. They run with the editor's access, so add only plugins you trust.
  • Turning a module off (CMS › Modules › Modules turned off: names separated by commas, applied at once) keeps its model types, transaction plugins, settings, rendering and data, so nothing stored is lost or left unguarded. Its interface plugin, its commands (403 with the reason), its routes (left out of routing) and its jobs (a run says why) go at once; its seed steps and start-up work wait for a start where it is on. A module that builds on one turned off is off too.
  • The license. RequiresLicense("feature") keeps a module inactive while the installation's license is known not to carry the feature: no API key, an invalid one, a license disabled or run out, or one without it. It is asked through ICmsLicense (Relatude Services, with the server's API key, at most every ten minutes); while the license server cannot be reached, the module is given the benefit of the doubt.
  • Where a module stands: CmsModules.StatusOf(name, store) answers Active, Disabled, Unlicensed, DependencyInactive or NotInDatabase, with the reason, and SeedVersionOf(name, store) the last seed step run. The CMS interface lists the modules under Settings › Modules, and every interface plugin under Settings › Plugins: built in, the modules', the settings' and this browser's own.
  • Pin the ids of a module's node types and relations ([Node(Id = …)], [Relation(Id = …)]) from its first release, so a rename keeps the data.

The wastebin (Relatude.DB.CMS.Modules.Wastebin)

WastebinModule (wastebin) is the CMS's own module, and every site has it: AddRelatudeCMS() adds it, and adding it again changes nothing. What the CMS interface deletes goes to a wastebin first, with everything below it in the content tree, and comes back where it was when restored. It is turned off like any module, in the CMS settings (Modules.Disabled: wastebin), and the interface then deletes for good again.

  • It is Relatude.DB's own deleted mark. A node in the bin has Deleted set in its meta (db.UpdateMeta(id, nameof(IInnerNodeMeta.Deleted), true)), for every version. Every query, relation end, count and search of a context without QueryContext.Deleted() leaves it out, so the tree, the lists, the site and the search no longer have it. Its values, versions, files and relations stay, so a restore only takes the mark away and its links come back with it.
  • A read by id still finds it (Get, TryGet, TryGetNodeMeta), as it finds a node the reader may not read, and so does the URL manager. The CMS treats a page or file marked deleted as not there: its URL answers 404. It keeps its address meanwhile, so a new page with the same name gets -2.
  • What went in together is an IWastebinEntry node (pinned id; an administrator's to read): the node chosen, its name, type, tree, parent and path, who put it in and when, and how many nodes went with it. Below its node it holds the nodes in the bin down to the node of another entry, which went in before and stays: restoring a page leaves a child deleted on its own before it in the bin.
  • Restoring takes the marks away; when the parent is in the bin too, or gone, it answers 409 until a parent is given. Deleting for good deletes the nodes, those below first.
  • Not everything goes in: the database's own users, user groups, collections (sites) and languages, which the engine reads whatever their meta says, are deleted for good. So is a branch with a node the user may not read (403).
  • Showing what is in it: a context with deleted: true reads the nodes in the bin too, in their places, each with $status.deleted on; wastebin.check says a node in the bin already cannot go in again, so deleting it deletes it for good. The CMS interface's wastebin blade has a switch, Show deleted content, that reads so wherever the interface reads (the store's shared context), each marked with a red bin, until it is turned off or the tab is closed.
  • Kept days: the CMS settings (CmsSettings.Wastebin.KeepDays, 30; 0 keeps until emptied). Older entries are deleted for good when the store opens, every hour while it is open, and by the job wastebin.empty-old.
  • Commands: wastebin.check { ids } → { canBin, reason, keepDays }, wastebin.bin { ids, children?, relation? } → { entries, binned }, wastebin.list { search? } → { items, keepDays, canEmpty }, wastebin.restore { id, parent? } → { id, restored }, wastebin.delete { ids } → { deleted, entries }, wastebin.empty (an administrator's). Past two batches each runs as a process and answers { process }. The CMS interface lists the bin in its menu while the module is active (NavContribution.module), and its tree and editor delete to it, with Undo and Delete for good beside it. Rows of the tree and the content lists, and the file library's files and folders, can also be dragged onto the menu's Wastebin or into its open blade, which puts them in with an Undo; inner nodes, nodes dragged out of a link field and the database's own users, groups, sites and languages are not taken. The file library's toolbar has Delete for what is picked.

The file library (Relatude.DB.CMS.Modules.FileLibrary)

FileLibraryModule (file-library) is the CMS's own module too: AddRelatudeCMS() adds it, and it is turned off like any module. A library holds folders of files that pages use, uploaded once: copied into file fields, or linked from text.

  • The model is part of AddCmsContentModel() (ids pinned): IFileLibrary : IFolder (Sites), IFolder : IItem (Description, FileLibrary, ParentFolder/SubFolders of RFolder, Files of RFileFolder), and the abstract IFile : IItem (File, Description, FileLibrary, Folder, FileType, FileSize) with its kinds IImage (Width, Height), IVideo (Width, Height, Duration), IAudio (Duration), IDocument, ITextFile (Text) and IFileOther. A site's libraries are ISite.FileLibraries, the other end of IFileLibrary.Sites (RSiteFileLibraries, many to many): a library may serve several sites.
  • Kinds come from a file's name when its node is made: LibraryFileKinds (a service), the CMS's own (image, video, audio, document, text, other) and those modules add with services.AddLibraryFileKind(new LibraryFileKind(key, title, nodeType, icon) { Extensions = [...] }); the longest extension a kind takes wins, then a binary file's type. A file keeps its kind: a rename to another kind's name is refused for a text file.
  • Text files (ITextFile : IFile, kind text: css, js, mjs, json, txt, md, xml, csv, html; Scriban's IScribanFile is one too) keep their content in Text, a code property, written with update like any value; their stored file stays empty, and an upload or copy into it is refused. new-files takes each text file's text, so it is made whole with no upload (the interface reads a dropped .css in the browser and sends it so), and replace writes the text of the one there. A transaction plugin keeps FileSize (the text's UTF-8 bytes) and FileType. No thumbnails, and no copying into a file field or linking from text as a stored file.
  • Kept by the module, never written by hand: the kind (chosen from the file's name when its node is made), FileLibrary (from the folders above it, moves included), FileType and FileSize (written after every upload into File, and with a text file's text), and Width, Height and Duration (measured by the store in the background; file-library.measure again).
  • Files are published as they are made: no drafts (the schema's canBeDraft is false), no languages. They are in the text index whatever the database's default, so the search finds words of their names, descriptions and extracted text; a part of a name is found in any case too.
  • Copying into a file field is file-copy with the library file as the source ({ node, property: "File" }): the field holds the same stored file, and later changes in the library do not reach it. Linking from text is content-link(libraryFileId, { property: "File" }): the text shows the library's file as it is, replaced or edited.
  • Deleting goes to the wastebin when it is active: a folder with relation: "RFolder", which takes the folders and files below it along (the bin follows a folder's RFileFolder too), a file with relation: "RFileFolder". Without the bin, file-library.delete deletes for good.
  • Commands (file-library.*): libraries { site? } → { libraries, canCreate }; folder { id, sort?, descending?, page?, pageSize?, kinds? } → { folder, library, path, folders, files, total, counts }; folders { id }; path { id }; files { ids }; search { library?, folder?, site?, text?, kinds?, sort?, … } (a folder and everything below it, a library, or every library of a site); create-library { name, site? }; create-folder { parent, name }; ensure-folders { parent, paths } ("Photos/2024", existing folders used, by name in any case); clashes { folder, names }; new-files { folder, files: [{ name, size, text? }], clash: keep|replace|skip } (a node for each file to upload into, a text file made with its text: replace answers the file of that name, keep names the new one photo-2.jpg); discard { ids } (file nodes no upload filled); move { ids, folder }; rename { id, name?, description? } (a file keeps its extension, and its stored file takes the name); delete { ids }; measure { ids }; kinds (the kinds the datamodel has, with their icons and extensions). A file read answers its kind and text (whether it is kept as text).
  • In the CMS interface: the menu's File library (folders and files together, or a folder tree beside them when the blade is wide or chosen, or every file of the library in one list, paged, its folders left aside: search with the library and no text; uploads of files and whole folders, dropped or chosen, in the upload dialog with its speed graph; a question when names are there already; search across folders; kinds; drag to move; rename with F2; a file's own blade with the file field's editors). File fields have From the file library, the text editor's Picture and File tools a File library tab, and an upload from the text can go into the library or a file field of the page. The page builder's Files tab: a file dragged from it, from a blade's file field or from the computer onto the page goes into the file field it is dropped on (copied, or uploaded), every place a field that takes one is shown outlined as the drag begins; with a file field chosen on the page, a click puts a file there.

Change bundles (Relatude.DB.CMS.Modules.Bundles)

BundlesModule (bundles) is a standard module too. A change bundle (IChangeBundle: a name, a description, a status Open, Published or Discarded, and its members, each a node, its draft revision and whether it was made in the bundle) is a piece of work: drafts of several pages, page templates and template files, previewed together and published as one.

  • Working in a bundle is the payload context's bundle (CmsApiRequestContext.Bundle, the SDK's ReadContext.bundle): its members' drafts are read (a revision named in revisions wins for its reads), and every write runs through CmsApiContext.Execute, which routes it: a value written to a node a bundle can hold goes into the node's draft in the bundle, the node's loose draft adopted or a draft made from the version the context reads, never the published one; a node made is made a draft and a member; a node in another open bundle is not taken in: it is written as the context names it. Uploads and other writes that are no transaction call CmsApiContext.EnsureInBundle(id) first. Without a bundle, a write to a node a bundle holds goes to the version the context names, and publishing the bundle replaces it. A context with refuseHeld (what agents' tools send) is refused (409, naming the bundle) instead, as an agent's content write goes into the node's draft, which may be the bundle's (ChangeBundles.RefuseHeld, before an upload too). A node is in one open bundle at most.
  • Not in a bundle (they take effect at once): deletes, tree moves, links, the file library's folders and binary files, the engine's users, groups, sites and cultures, datamodel changes and settings. A text file saved outside a bundle is live at once.
  • Commands (any signed-in user; the store checks each node written): bundles.list { status? }, bundles.get { id } (members with name, type, culture, made or changed, when, and what stands in the way of publishing), bundles.create { name, description? }, bundles.update, bundles.add { bundle, id, culture? }, bundles.remove { bundle, id, discard? }, bundles.set-dates { id, releaseUtc?, expireUtc? } (every member's draft given the same release and expiry, in one transaction; null clears, left out keeps each draft's own; a member that is no draft any more is skipped and named), bundles.publish { id } (every member in one transaction, each draft taking its culture's published version's place, refused naming them while a draft is no draft any more or a template has errors; at most BundlesModule.MaxMembers), bundles.discard { id } (drafts deleted, nodes made in it deleted). set-revision-type refuses a member. A node read says $bundle { id, name, draft } when an open bundle holds the node, whichever version is read (draft: it is the bundle's draft).
  • Previews: preview { bundle } shows the bundle's drafts on the site, its page templates (RelatudeRequest.PreviewTemplates) and template files (PreviewVersions, read by TemplateFiles over the published ones), and its stylesheets by their hash. A link followed in it stays in it: CmsBundlePreviewLinks (in UseRelatudeCMS()) sends a page navigation from a bundle's preview to the same address with the preview's id. A link followed in the preview of a single draft leaves it.
  • In the CMS interface: the selector right of the search box, and in the preview's bar too while the preview is open (builtins/bundles.tsx, BundleSelector: an icon alone for Published, the bundle's name while one is chosen; the tab's choice in sessionStorage, sent as the store's shared context part bundle). A switch (switchBundle, asking first while a blade has unsaved changes) has the data client read everything again: an editor reads its node anew (the bundle is part of its identity, so a revision it pinned before is let go), the preview shows its page again without the version it named, the page builder lets go of its field, and the Templates plugin's blades read and render again (bundleOf). The menu has Bundles (bundles.home, bundles.bundle: members, take one out, Rename, Publish, Discard), and the editor marks a node a bundle holds and leaves out Publish for it. A node another bundle holds, working in the published site too, can be edited, under a warning that publishing that bundle replaces what is saved, with Work in “…” (switchBundle); it has no Unpublish or Delete.
  • Agents: bundles_list, bundles_create, bundles_get, bundles_set_dates, bundles_publish (area publish), bundles_discard; content_write, content_get, content_set_file, templates_save and templates_preview take bundle.

Design profiles (Relatude.DB.CMS.Modules.Design)

DesignModule (design) is the CMS's own module too: AddRelatudeCMS() adds it. A design profile says how a site should look and sound, for the people and AI agents who design its templates and pages.

  • The model is part of AddCmsContentModel() (ids pinned): IDesignProfile : IItem with Key (how templates and agents name it: lower case, digits and dashes, made from the name when left empty, another profile's never, kept when the profile is renamed), Summary, Description (the brief, Markdown), Logo, LogoOnDark, Mark (files), Files (Embedded<DesignProfileFile>: Title, File, Notes, what it shows and how to use it), Websites (Embedded<DesignProfileWebsite>: Url, Notes), Css (design tokens as custom properties on :root, fonts, base rules) and SourceUrl. A site names its own: ISite.DesignProfile, the other end of IDesignProfile.Sites (RSiteDesignProfile, one profile to many sites). With one profile in the database, that one is every site's.
  • Published as made: no drafts (the schema's canBeDraft is false) and never in a change bundle.
  • Commands: design.profiles (each in brief: name, key, summary, the logo's thumbnail, the colours its CSS names, the sites); design.profile { id? | key? | site? } (one whole, with its files' addresses; with nothing named, the only one); design.from-url { url, name?, site?, wait? } (a process unless wait): the website's home page and up to six stylesheets are read for names, colours, fonts and custom properties, its logo (the header's first, a drawing before a picture), its largest icon (as Mark) and its social picture (into Files) are fetched, through AgentWeb, so only public addresses are reached, and the CMS's text AI (ICmsAI) writes Summary, Description and Css from those facts. A site that turns the server away (401, 403, 429 or a Cloudflare challenge: bot protection) is loaded by Relatude's snapshot service instead (IDesignPageSnapshots, ServicesDesignPageSnapshots: services.relatude.com's POST /api/site-page with the server's ApiKey, a headless Chrome there, 30 pages a license a day): the page as its browser built it, the stylesheets and pictures it loaded, used before anything is fetched, and its screenshot, kept in Files as "The site as it is now"; without an AI, or when it fails, they are written plainly from the colours and fonts, and the answer's notes say so.
  • Templates: Scriban's design.profile is the site's own (or the only one), design.profile "key" a named one: {{ brand = design.profile }}<img src="{{ brand.Logo | image.url { height: 48 } }}">.
  • Agents: design_profiles, design_profile { key? | site? } (file addresses made whole), design_profile_from_url (area content; it holds at once), the guide design, and site_overview lists the profiles. A profile is changed with the content tools like any node.
  • The AI's page: design.showcase { id } answers { html, stale, madeUtc }, a home page the CMS's text AI designed for the profile (design.showcase-make { id }, one completion of AI credits): the brand's voice from its brief, drawn with its CSS's custom properties, its logos and pictures named by placeholder ({{logo}}, {{logo-on-dark}}, {{mark}}, {{picture-1}}…). It is kept in the database's storage with a fingerprint of the profile, stale once the profile changes; scripts, frames, links and event attributes are taken out of it.
  • In the CMS interface: Settings › Design profiles lists them, with New and From a website…. A profile opens as a style guide: its cover, its logos on light, dark and brand grounds and its mark as an app icon and a favicon, its colours by custom property with their WCAG contrast on each ground, its type as its own rules set it (measured), an example page in its CSS at desktop, tablet and phone width (or the AI's page), its brief with Do and Don't apart, its files, websites and CSS. Edit opens the node editor; Make a skin opens the skin designer with a new skin in the profile's look (accent, paper, ink, corners, fonts the computer has, and its logos as the skin's), which Settings › Appearance also offers (From a design profile).

Agent tools, runtime types and design files

What an AI agent does on a site goes through agent tools (Relatude.DB.CMS.Agents): a registry (AgentTools, added by AddApi()) of tools described for a language model, each a name, a description, the JSON Schema of its arguments, an area (AgentAreas: read, content, publish, templates, datamodel) and a handler. A handler runs CMS API commands as the agent's user (AgentToolContext.Command), so the rights are the user's, and adds what an agent needs: drafts by default, deletes into the wastebin, short answers. AgentTools.List(caller) and CallAsync(name, arguments, caller) are all a carrier needs; the MCP server (Relatude.DB.MCP, AddModule<McpModule>()) is the first, at {api}/mcp. The CMS's own tools are site_overview, guide (Markdown guides, Agents/Guides), content_query, content_get, content_tree, content_url, content_write, content_set_file and content_publish; the templates module brings templates_* and the datamodel module datamodel_*. A module adds its own with module.AgentTool(new AgentTool { … }) (named after the module, events_upcoming) and module.AgentGuide(topic, title, text).

  • Commands without a request: CmsApiCommands.InvokeAsync(type, payload, userId, http?) runs a command in-process as a user and answers its JSON; a refusal is a CmsApiException with the status the endpoint would answer. CmsApiContext.Services is the request's services, else the application's, so a command needs no Http for them.
  • file-put ({ id, property, name, data }): a small file (8 MB) sent inside a command as base64, written into the revision the context names as an upload is.
  • The datamodel module (DatamodelModule, datamodel, a standard module): datamodel.types, datamodel.type { type } and datamodel.status read the model; datamodel.change { change, validateOnly?, acceptWarnings?, discardDraft?, note? }, an administrator's, makes and changes runtime types, the types of Relatude.DB's runtime types sources: model files the database reads when it opens, with no class in the site's code, so nothing is rebuilt. A change (ModelChange) names types (kind page, content or block, inherits, title, description, icon, abstract), their properties (type text, html, markdown, code, integer, long, decimal, double, boolean, datetime, guid, textList, file, reference, references, blocks, with lines, maxLength, legalValues, default, min, max, indexed, unit, to, of), removeProperties and removeTypes. It is applied to the model in force as model objects, validated by the database's model editor (DatamodelValidator, with a dry run that compiles it when validateOnly), and made the model in force by DatamodelActivator: the files written, the model replaced kept in the history, the database reopened, which takes some seconds during which pages answer "not found". Errors apply nothing; warnings the change itself brings need acceptWarnings; a type compiled into the site is refused; so is a change while a draft of the model is saved in the admin UI (discardDraft) or a process is at work. A runtime page type inherits IPage and is rendered by a page template bound to it.
  • Design files: stylesheets, scripts and other text files of the design library, saved with templates_save as templates are and served by the hash of their text at {TemplatesOptions.AssetsPath}/{hash}/{name} (/-design/…), immutable. ITemplateSources.AssetUrl(path) gives the address, Scriban's asset.url. A template's own text is never served.
  • templates.bind ({ types, path, name? } or { remove }) makes the page template (IFileTemplate) that renders page types with a template file, or points the one for exactly those types at the file; another template listing one of the types is refused, as two are a tie. templates.render-node ({ id, path?, text?, culture? }) renders a node with the template file that renders its pages, or with the file or text given, read in the payload's context, so a draft renders.

The AI agent of the interface (Relatude.DB.CMS.Modules.Agent)

AgentModule (agent) is a standard module too. It is the agent editors talk with in the CMS interface, called Rela unless the settings say otherwise: it answers questions about the site and works on it, through the site's agent tools, as the editor it talks with. What it writes is a draft in the conversation's change bundle; a call that would hold at once (publishing, deleting, moving, linking, the datamodel) is shown to the editor first and runs only on a yes.

  • When it is there: the CMS settings' AI agent group (CmsSettings.Agent: Enabled, Who everyone or administrators, Name, Model the AI's model by its key, fast unless set, Effort how hard a reasoning model thinks at each step, the model's own default when empty, MaxStepsPerTurn, MaxCreditsPerTurn), and an AI that can call tools (ICmsAI.Describe(store).Tools): the Relatude AI service on the installation's license, or the database's own Relatude Services, OpenAI or Azure provider. agent.info answers { available, reason, name }.
  • Rights: every tool runs as the signed-in user (AgentCaller), held to the effect it said it would have (MaxEffect), in the conversation's bundle: the one the editor works in, else one made at the first change if the editor says yes to the question asked then (a waiting question on that call; without a bundle each node changed is a draft of its own). What the agent is told it may do (site_overview) is what it may do in all (AgentCaller.HeldTo), not what one call is held to. The datamodel tools are an administrator's.
  • The bundle: the one the editor works in when the conversation begins, else one the agent makes the first time it changes something, named after the conversation. The editor previews, publishes or discards it as any bundle; the agent publishes it only on a yes.
  • Commands (the user's own conversations): agent.send { conversation?, text, ui?, attachments? } says something (a new conversation without conversation; ui is what is on the editor's screen) and answers { header }; agent.answer { conversation, call, approve } or { conversation, call, text } allows or refuses a waiting call, or answers a question; agent.stop { conversation }; agent.conversation { conversation, after? } gives { header, entries }; agent.conversations; agent.forget { conversation }.
  • Events (agent, to the user alone): { conversation, kind: "entry", entry } for each thing said, each tool call and its result; { kind: "delta", text } as an answer is written; { kind: "state", header } when the conversation changes between idle, working and awaiting, the header's pending holding the question or the calls that wait for a yes; { kind: "ui", open } when the agent shows something in the interface. The stream replays nothing, so read agent.conversation with after after a reconnect.
  • Files: agent.attach { name, data } keeps a file (base64, 8 MB at most) the editor is about to send and answers { file: { id, name, type, size, kind, width?, height? } }; its id goes in agent.send's attachments (8 a message, with or without text), and the entry carries them as files. A file's kind goes by its bytes: a picture (PNG, JPEG, GIF, WebP) the model sees, the latest six of a conversation, a large one made smaller for it (1568 pixels at most); a text file's text it reads, the first 20,000 characters; a document (a PDF, a Word, Excel or PowerPoint file, RTF, OpenDocument) is read for it once by the database's file-to-text service, which charges the license for it, and given the same way, with the agent's tool attachment_read for more of a long one; any other file, and a document where nothing reads documents, it is only told of. agent.attachment { id, whole? } gives one back as base64, a picture as it is shown. They are kept with the conversation in the database's storage, their user's alone, and go when it is forgotten; a file is on the site only once the agent puts it there, with content_set_file and the file's id as attachment.
  • A field pointed at: agent.send's ui may carry field { node, property, name, kind, value }, the field the editor points at with its content as it stands in their editor. The agent answers with its tool ui_set_field { node, property, value }, which writes nothing: the event { kind: "ui", field: { node, property, value, call } } has the editor's browser put the value in the open editor as an unsaved change, theirs to save. In the interface a text field's title has the button for it, the field is named over the message box until let go, and the change has an Undo in the conversation.
  • The agent's own tools beside the site's: ask_user (one question, with answers to choose from), ui_open (a node's editor, its page in the preview, a type's list or the bundle, opened in the editor's browser), ui_set_field, attachment_read, with an image AI image_create (a picture made at once when asked for, kept in the conversation to be dragged into a file field or the file library; nothing on the site changes), and while CmsSettings.Agent.AllowWeb is on (the default) web_fetch (a public page as its text, links and pictures; a picture or other file downloaded into the conversation, 8 MB at most) and web_crawl (a site's pages from an address, same host, robots.txt kept, 40 pages and two minutes at most, find putting the pages with the words first). AgentWeb fetches them from the server and connects only to public addresses, checked where the connection is made, so redirects and names resolving inward reach nothing of the server's network.
  • Conversations are kept in the database's storage (cms/agent/…), not as nodes, and are their user's alone. A call left waiting survives a restart.
  • What it costs: each answer of the AI is an entry with its credits and usage { in, cached, out, thinking, ms, model, effort }: the tokens the model read (cached of them from its prompt cache) and wrote (thinking of them a reasoning model's thinking), and the time. A step is asked with the whole conversation so far, so what the agent has read is paid for again, at the cached price, at every step after. The header's credits is the conversation's sum, and MaxCreditsPerTurn bounds one request.
  • In the CMS interface: the top bar's button with the agent's name opens its blade; the search box asks it with Tab. The message box is Support's: files and pictures are added with the paperclip, dropped or pasted, a screenshot of the CMS is taken with its button, and a picture is marked up (boxes, arrows, a pen, blurring, cropping) before it goes. Pages it names are links that open beside the conversation. In the offline demo (?demo) a script answers in its place.
  • Tests: register ScriptedCmsAI as ICmsAI and the agent answers from a script, with the site's real tools.

Donations (Relatude.CMS.Models.Donations)

A generic donation node model with the list/detail projection behind the WAF.Client Donations admin module (postWebAPI(session, "Donations", "List" | "Get", …)). The model namespace holds only the IDonation interface — a datamodel source scans it, so anything else in that namespace would be registered as a node type. The wire DTOs (DonationRow/DonationListResult/DonationDetail) and the pure DonationAdminProjection live in Relatude.CMS.Models.Donations.Admin. Sites extend the model with their own node interface (public interface IMyDonation : IDonation { … }) — a member may be declared in only one interface of the hierarchy.

Both namespaces are registered as datamodel sources — matching is exact, and an unregistered base interface silently drops all inherited fields from the derived type:

"DatamodelSources": [
  { "Id": "<unique guid>", "Name": "My site",   "Namespace": "MySite.Models",                 "Type": "AssemblyNameReference", "Reference": null },
  { "Id": "<unique guid>", "Name": "Donations", "Namespace": "Relatude.CMS.Models.Donations", "Type": "AssemblyNameReference", "Reference": "Relatude.DB.CMS" }
]

The admin controller stays in the host — it derives from the host framework's admin API base (e.g. WAF's BaseAdminAPIController), which this package does not reference. Routed as wafapi/Donations/{action}, the shape is:

[HttpPost]
public DonationListResult List(int pageSize = 25, int pageIndex = 0, string? sortBy = null, bool sortDesc = true,
    string? categories = null, string? statuses = null, string? paymentMethods = null, string? search = null) {
    _ = Context.Session;                             // WAF's admin gate — throws (→ 403) without a session
    var query = _cx.Database.Query<IMyDonation>()    // WhereIn(d => d.Status/…) for non-empty filters
        .OrderBy(DonationAdminProjection.SortExpression<IMyDonation>(sortBy), sortDesc);
    var page = query.Page(pageIndex, pageSize).Execute();
    return new DonationListResult { Rows = page.Values.Select(d => DonationAdminProjection.ToRow(d)).ToList(), TotalCount = page.TotalCount };
}

Get(id) is TryGet<IMyDonation> → DonationAdminProjection.ToDetail(d, formGuid: …), where the host resolves the originating form's content guid from IDonation.FormId (see DonationDetail.FormGuid — the admin client cannot query by ContentId). The host also snapshots the form's name onto IDonation.FormName when the donation is created — denormalized on purpose, since the list sorts and searches it server-side (AQL orders node properties, not values computed at projection time); a later rename therefore does not retro-rename existing donations. Category (onetime/recurring/business) and free-text search have no AQL form — when active, materialise the ordered set, filter with MatchesCategory/MatchesSearch, then page.

Notes

  • Create<T>() does not persist — follow with Insert/CreateAndInsert; call Update after mutating a loaded node.
  • Relation ends aren't Lists — use .Get() / .IsSet() / .TryGet().
  • Relation changes go through SetRelation/AddRelation/RemoveRelation, not property assignment.
  • This is a library with no entry point; engine start and schema live in the host app and the /relatude.db admin UI.
  • Relatude.DB source/API reference: https://github.com/Relatude/Relatude.DB
  • Donations: every DatamodelSources entry needs its own unique Id — the store refuses to boot without one.
  • Donations: the enum-like string values (PaymentMethod, Status, GiftType, Frequency) are matched case-sensitively by the admin module's filters — store exactly the values documented on IDonation (all lowercase, e.g. vippsrecurring).
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Relatude.DB.CMS:

Package Downloads
Relatude.Core

Relatude .Net 10.0 Headless CMS and E-commerce solution

Relatude.DB.Ecom

Relatude E-commerce backend API for Relatude.DB. Builds on the Relatude.CMS package.

Relatude.DB.MCP

An MCP server for Relatude CMS: AI agents read and change a site's datamodel, content and templates at runtime, with the rights of the user their key is for.

Relatude.DB.Scriban

Scriban templates for Relatude CMS: page templates, emails and any other text, kept in the database or as files, evaluated at runtime.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.11.42-alpha 0 11/24/2026
1.1.11.35-alpha 63 11/22/2026
1.1.10.34-alpha 55 11/22/2026
1.1.10.32-alpha 48 11/22/2026
1.1.9.30-alpha 65 11/20/2026
1.1.8.29-alpha 75 11/18/2026
1.1.8.28-alpha 90 11/17/2026
1.1.7.25-alpha 100 11/16/2026
1.1.6.25-alpha 175 11/13/2026
1.1.2.21-alpha 133 11/9/2026
1.1.2.20-alpha 98 11/9/2026
1.1.2.14-alpha 194 11/5/2026
1.1.1.13-alpha 176 11/2/2026
1.1.1.12-alpha 111 11/1/2026
1.1.1.9-alpha 106 10/30/2026
1.1.1.8-alpha 109 10/29/2026
1.1.1.7-alpha 139 10/23/2026
1.1.1.6-alpha 103 10/21/2026
1.1.1.3-alpha 188 10/17/2026
1.0.43 275 10/5/2026
Loading failed