ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.ServedDocument

Description

Shared outbound document assembly, paired with inbound Ecluse.Core.Registry.WireSupport. Ecosystem adapters own their wire shapes and reuse these name and location gates.

Synopsis

The cached-document boundary

assembleAcross :: (Value -> CachedDoc, CachedDoc -> Maybe Value) -> (Text -> Map SourceId (Snapshot Value) -> MergePlan -> Value -> Value) -> Text -> Map SourceId (Snapshot CachedDoc) -> MergePlan -> Maybe CachedDoc -> CachedDoc Source #

Run an ecosystem's plain-Value assembly across its own cached-document boundary. A source or base that another ecosystem injected contributes nothing.

serialiseAcross :: (CachedDoc -> Maybe Encoding) -> CachedDoc -> LByteString Source #

Encode a served document to its compact wire bytes, an empty object for a foreign one.

data RenderRefused Source #

A served document whose render refused its plan, because the plan names a table or string it lacks or the render does not fill its buffer exactly. The pipeline answers it as a render fault.

Constructors

RenderRefused 

Replaying a merge plan

overlaySurvivors :: (src -> [(EntryKey, entry)]) -> Map SourceId (Snapshot src) -> MergePlan -> [(Text, entry)] Source #

Select exact admitted entries from the winning source snapshot, preserving each source's order. Missing keys, ambiguous keys, and mismatched snapshots contribute nothing.

overlayObjectSurvivors :: (src -> KeyMap entry) -> Map SourceId (Snapshot src) -> MergePlan -> [(Text, entry)] Source #

Select exact admitted entries by lookup in each winning source's key map, in source and key order. Only object coordinates are served. Missing keys, ambiguous keys, and mismatched snapshots contribute nothing.

overlayObjectSources :: (src -> KeyMap entry) -> Map SourceId (Snapshot src) -> MergePlan -> [(Text, SourceId, entry)] Source #

overlayObjectSurvivors with the source each entry came from.

The interpolated-name gate

safeDocumentName :: (Text -> Maybe a) -> KeyMap Value -> Maybe a Source #

Gate the document's claimed name before it enters a rewritten artifact URL.

Rebasing an artifact location

rebaseArtifactUrl :: (Text -> Maybe Text) -> Text -> Maybe Text Source #

Rebase an artifact under this mount, checking filenames before and after URL whitespace trimming. Idempotent while the renderer keeps the filename in the terminal path segment.

Reading and editing a raw document

documentObject :: Value -> KeyMap Value Source #

A raw document's own object, empty for a document that is not one.

stringField :: Key -> KeyMap Value -> Maybe Text Source #

The Text at key in a raw document object, if present and a JSON string.

objectField :: Key -> KeyMap Value -> Maybe (KeyMap Value) Source #

The object at key in a raw document object, if present and a JSON object.

adjustField :: Key -> (Value -> Value) -> KeyMap Value -> KeyMap Value Source #

Edit the value an object carries at key. A missing field stays absent.