DocumentCreationService.cs
Creates a document from a source file, start to finish. This is what the backoffice does when an editor clicks Create, expressed as one server-side operation.
Why it exists
Section titled “Why it exists”Until this service, creating a document from a source existed only as browser TypeScript. That meant a browser was the only way to run an import — no scheduled job, no deployment step, no AI assistant, no other site.
Having it here is what lets the API offer create-from-source, and what lets the MCP server wrap it.
What it does
Section titled “What it does”Five steps, in order:
- Resolve the workflow from the blueprint id. A workflow folder exists per blueprint per source type, so the blueprint is enough to say how to read the source and where its content belongs.
- Extract and transform the source, producing the same sections the backoffice shows on its Transformed tab.
- Scaffold from the blueprint via
IContentBlueprintEditingService.GetScaffoldedAsync. The scaffold carries the blueprint’s own content, so any field the mappings do not touch keeps its default. - Apply the mappings through
MappingApplicationService. - Create the document via
IContentEditingService.CreateAsync.
Interface
Section titled “Interface”public interface IDocumentCreationService{ Task<CreateFromSourceResult> CreateAsync(CreateFromSourceRequest request, Guid userKey);}The document is created as a draft. Publishing is the caller’s decision, deliberately. An import that publishes itself gives nobody a chance to check it.
The workflow alias comes from the folder name. DocumentTypeConfig has no alias property — the folder on disk is the identifier, and Path.GetFileName(config.FolderPath) is how it is read.
PDF only, currently. Markdown and web sources return a message pointing at the backoffice rather than failing silently.
mappedValueCount is returned so the caller can compare it against the workflow’s mapping count without reading the created document. A lower number means a section did not resolve.
Related
Section titled “Related”- MappingApplicationService.cs — applies map.json
- SectionLookupBuilder.cs — flattens transform output into the keys mappings address
- CreateFromSourceController.cs — the endpoint