morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
service.hpp File Reference

The server side of the UI service (spec 5 §12, §12b, §13): UiRegistry collects an application's screens and files and builds a ServedBundle; UiService answers ui-hello, ui-catalog and ui-fetch from it as a RemoteServer envelope service. More...

#include <algorithm>
#include <compare>
#include <cstddef>
#include <expected>
#include <format>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "../core/logger.hpp"
#include "../core/remote.hpp"
#include "../core/wire.hpp"
#include "../session/session.hpp"
#include "bundle.hpp"
#include "catalogue.hpp"
#include "document.hpp"
#include "file_store.hpp"
#include "theme.hpp"
#include "value.hpp"

Go to the source code of this file.

Classes

struct  morph::ui::ApplicationInfo
 The application a bundle belongs to, as ui-hello names it. More...
struct  morph::ui::ActionRef
 An action a document names, with the model type it runs on: what the authoriser is asked about. More...
struct  morph::ui::ServedFile
 One file a bundle serves, with every manifest entry whose bytes it is. More...
struct  morph::ui::ServedFile::Holder
 One manifest entry that names the file. More...
struct  morph::ui::ServedScreen
 A screen as the bundle serves it. More...
struct  morph::ui::ServedBundle
 An application's bundle, built and immutable: what UiService serves. More...
class  morph::ui::detail::DocumentActions
 Collects the actions and model types a loaded document names, resolving each query's, mutation's and model-bound node's alias through the enclosing scopes. More...
struct  morph::ui::BundleFile
 A file of the bundle that is not a screen, as UiRegistry::addFile takes it. More...
class  morph::ui::UiRegistry
 Collects an application's screens and files and builds the bundle the UI service serves. More...
class  morph::ui::UiService
 The UI service: answers ui-hello, ui-catalog and ui-fetch from one ServedBundle, and ui-evaluate through the server's ActionDispatcher, as an envelope service of a RemoteServer (ServerConfig::services). More...

Functions

std::optional< std::string > morph::ui::detail::checkServable (std::string const &bytes)
 Whether bytes can be served: within kMaxFileBytes, and within the envelope bound once escaped into an ok reply.
std::optional< std::string > morph::ui::detail::checkEntry (CatalogEntry const &entry)
 Checks a catalog entry's own fields.
bool morph::ui::detail::permitsAll (::morph::session::IAuthorizer const &authorizer, ::morph::session::Context const &session, std::vector< ActionRef > const &refs)
 Whether the principal of session may run every action of refs.
constexpr bool morph::ui::isUiServiceRead (std::string_view modelType, std::string_view actionType) noexcept
 Whether an authoriser is asked about one of the UI service's reads: ui's hello, catalog or fetch.

Detailed Description

The server side of the UI service (spec 5 §12, §12b, §13): UiRegistry collects an application's screens and files and builds a ServedBundle; UiService answers ui-hello, ui-catalog and ui-fetch from it as a RemoteServer envelope service.

Specified in docs/spec/ui/service.md.

Definition in file service.hpp.

Function Documentation

◆ checkServable()

std::optional< std::string > morph::ui::detail::checkServable ( std::string const & bytes)
inlinenodiscard

Whether bytes can be served: within kMaxFileBytes, and within the envelope bound once escaped into an ok reply.

Parameters
bytesThe file.
Returns
Why it cannot, or nothing.

Definition at line 135 of file service.hpp.

◆ checkEntry()

std::optional< std::string > morph::ui::detail::checkEntry ( CatalogEntry const & entry)
inlinenodiscard

Checks a catalog entry's own fields.

Parameters
entryThe entry.
Returns
Why it is refused, or nothing.

Definition at line 148 of file service.hpp.

◆ permitsAll()

bool morph::ui::detail::permitsAll ( ::morph::session::IAuthorizer const & authorizer,
::morph::session::Context const & session,
std::vector< ActionRef > const & refs )
inlinenodiscard

Whether the principal of session may run every action of refs.

Parameters
authorizerThe authoriser.
sessionThe session, its principal verified.
refsThe actions.
Returns
Whether it may run all of them; true for none.

Definition at line 260 of file service.hpp.

◆ isUiServiceRead()

bool morph::ui::isUiServiceRead ( std::string_view modelType,
std::string_view actionType )
nodiscardconstexprnoexcept

Whether an authoriser is asked about one of the UI service's reads: ui's hello, catalog or fetch.

An application that serves a login screen admits these for a session with no principal yet, so a client can greet the service, read the catalog and fetch the login screen. Admitting them discloses no other screen: ui-catalog lists, and ui-fetch serves, a non-public screen only to a principal who may run its queries, which the authoriser still decides.

Parameters
modelTypeThe model type asked about.
actionTypeThe action asked about.
Returns
Whether it is one of those reads.

Definition at line 763 of file service.hpp.