Add standalone Automators for file to formatted text and JSON outputs
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3573331. --> Reported by: [marcus_johansson](https://www.drupal.org/user/385947) Related to !21 >>> <p>[Tracker]<br> <strong>Update Summary: </strong>[One-line status update for stakeholders]<br> <strong>Short Description: </strong>Add standalone Automators for file &rarr; formatted text and JSON outputs<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The existing AI Automators in the AI module demonstrate how file&#8208;based content can be transformed into structured formats such as JSON or binary representations. For example, the AI module includes JSON native/binary Automators such as <em>LlmJsonNativeBinary</em> and base classes like <em>TextToJsonField</em> that target JSON output formats. These work by sending prompt/context to an AI provider and mapping results back into fields. </p> <p>For non-AI and deterministic workflows, we need a new set of Automators that use the <code>document_loader</code> module to extract/normalize file content into useful field/value formats without requiring any AI provider. The functionality must not depend on the AI module at runtime; the AI module can be placed in <code>require-dev</code> for tests, but the Automators should function without it.</p> <p>We want Automators that read file input and convert it into:</p> <ul> <li>Formatted text (HTML output)</li> <li>Formatted text with summary (HTML output)</li> <li>Long text output (any supported output type)</li> <li>JSON native output (JSON output) &mdash; JSON field module required</li> <li>JSON field output (JSON output) &mdash; JSON field module required</li> <li>JSON native binary output &mdash; JSON field module required</li> </ul> <p>The last three (JSON ones) are optional and can be split into a separate follow-up issue. Callers should be able to configure what input types are accepted (e.g., PDF, DOCX, URL) and what output types they support, especially for the long text Automator.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <ul> <li>Create new Automator plugin types under a suitable namespace (e.g., <code>Plugin/DocumentAutomatorType</code>).</li> <li>Define a base class for file-to-text transformation that accepts document loader input types and drives html output.</li> <li>For &ldquo;File to Formatted Text (HTML)&rdquo; and &ldquo;File to Formatted Text with Summary (HTML)&rdquo;, pull normalized content using document_loader and ensure output is valid HTML.</li> <li>Define a &ldquo;File to Long Text&rdquo; Automator that accepts any output type supported by document_loader and delegates to the transformation manager to produce final text output.</li> <li>For JSON based Automators (native, field, binary), define a shared base class similar in pattern to AI module&rsquo;s <em>TextToJsonField</em>, since the conversion code will be largely identical except for output target.</li> <li>Ensure the JSON Automators depend on the JSON module and gracefully degrade (disabled/not available) when JSON module is not installed.</li> <li>Design configuration settings on each Automator so site builders can specify accepted input types and output types.</li> <li>Ensure the Automators do NOT require the AI module for runtime operation &mdash; AI should only be included in <code>require-dev</code> for tests that may reference examples from the AI module.</li> <li>Add tests covering valid file inputs, invalid inputs, missing dependencies (JSON module), and expected output format handling.</li> <li>Document how to configure these Automators on fields in content types and how they integrate with document_loader normalization.</li> <li>Optionally split JSON Automators into a follow-up issue if complexity warrants it.</li> </ul> <h3 id="summary-ai-usage">AI usage (if applicable)</h3> <p>[x] AI Assisted Issue<br> This issue was generated with AI assistance, but was reviewed and refined by the creator.</p> <p>[ ] AI Assisted Code<br> This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p> <p>[ ] AI Generated Code<br> This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p> <p>[ ] Vibe Coded<br> This code was generated by an AI and has only been functionally tes<br> ::contentReference[oaicite:1]{index=1}</p> > Related issue: [Issue #3575412](https://www.drupal.org/node/3575412)
issue