PDFCLOUD-6254: Convert structured documents to PDF - #47
datalogics-kam wants to merge 30 commits into
Conversation
- Add a skill for forward-compatible typed client API changes. - Require documented API contracts, model-first serialization, and sync/async unit and live coverage. Assisted-by: Codex
- Specify discriminator, boundary, and resource validation coverage - Require timeout and metadata-dependency checks per transport Assisted-by: Codex
- Define the public color input and internal wire-field routing pattern - Require RGB, CMYK, and invalid-channel coverage Assisted-by: Codex
- Require minor releases for new public SDK APIs - Use uv version commands instead of manual version edits Assisted-by: Codex
- Normalize Jira-based feature branch names - Define upstream tracking and detached-HEAD behavior Assisted-by: Codex
- Show the required skill invocation and Jira key - Describe the PDFCloud-API checkout prerequisite Assisted-by: Codex
- Require source docstrings for public structured input contracts - Verify generated union references and rendered field details Assisted-by: Codex
- Define PEP 723 metadata, layout, resource, and docstring conventions - Document local and matrix validation for live examples Assisted-by: Codex
- Require endpoint examples and explicit sample input discovery - Define script structure and local validation expectations Assisted-by: Codex
- Guide examples toward public keyword constructors and union aliases - Preserve dictionary literals for dynamic, invalid, and wire-format data Assisted-by: Codex
- Define an applicability matrix for choosing focused helpers or a coherent discriminated contract. - Allow commit scopes to name the primary file, directory, or domain object they affect. Assisted-by: Codex
Require rendered Literal value meanings and exhaustive payload, client, and live coverage that PR audits can verify. Assisted-by: Codex
- Add sync and async shape helpers with typed line and rectangle inputs - Validate shape coordinates, colors, tagging, and PDF resources - Cover JSON serialization, live service behavior, and API guide discovery Assisted-by: Codex
- Resolve MkDocs cross-references for added shape object types - Restore strict documentation build validation Assisted-by: Codex
- Assert async timeout propagation and PDF MIME validation - Reject multiple input PDFs through both client transports - Cover shape geometry, opacity, and color range boundaries Assisted-by: Codex
- Accept one RGB or CMYK color field for each shape color - Route colors to pdfRest's RGB or CMYK wire fields by channel count - Update unit and live endpoint coverage Assisted-by: Codex
Assisted-by: Codex
- Describe line and rectangle shape fields for generated API reference - Mark the shape union as a type alias so its union renders correctly Assisted-by: Codex
- Prefer PDFREST_LIVE_BASE_URL before the standard endpoint candidates - Document live-test configuration and fallback behavior for contributors Assisted-by: Codex
- Demonstrate typed rectangle and line construction - Exercise tagging and report output metadata against a bundled PDF Assisted-by: Codex
- Export public structured document types for page, style, table, and format-specific options. - Add format-specific payload validation and nested wire serialization. - Deduplicate uploaded Markdown images into ordered resource IDs. Assisted-by: Codex
- Add synchronous and asynchronous helpers for Markdown, plain text, JSON, XML, and CSV inputs. - Cover exact request serialization, validation boundaries, transport behavior, and request customization. Assisted-by: Codex
- Exercise all five structured formats through synchronous and asynchronous clients. - Verify Markdown image resources, response metadata, and server-side invalid-option handling against deterministic fixtures. Assisted-by: Codex
- Add a runnable upload-first example covering Markdown, plain text, JSON, XML, and CSV helpers. - Add deterministic source documents and register the example in the inventory. Assisted-by: Codex
- Add all five format-specific conversion helpers to the Into PDF API guide. - Link generated method signatures to their public structured option types. Assisted-by: Codex
- Release the structured document conversion helpers as a minor feature update. - Keep the project metadata and lockfile package version synchronized. Assisted-by: Codex
- Explain data presentation, page orientation, image alt-text policy, line handling, and CSV alignment values. - Keep value documentation on public aliases for generated API reference reuse. Assisted-by: Codex
Exercise every structured-document literal through both client transports against the live service, including shared page orientation. Assisted-by: Codex
Verify every helper rejects every other structured source before transport, and covers sync and async request customization timeouts. Assisted-by: Codex
Reject below-minimum page, style, table, color, and CSV values so structured conversion constraints are tested on both boundaries. Assisted-by: Codex
ce87afd to
8a5b039
Compare
aad4964 to
4ef4925
Compare
datalogics-kam
left a comment
There was a problem hiding this comment.
Blocking dependency: PDFCLOUD-6287 blocks this work because the client
currently reproduces the upstream structured-text contract's open-ended
strings instead of preventing invalid requests.
In this PR, PdfStructuredTextPageSetup.size is str; the five font selectors
in PdfStructuredTextStyle are str/Sequence[str]; and the internal
Pydantic models enforce only min_length=1. language is likewise only a
non-empty string even though the OpenAPI description merely says it is
"typically" BCP 47. Consequently, values such as arialbold and Executive
pass client-side validation even though they are not valid structured-text font
and page-size identifiers.
This matters because the public font page documents watermark/add-text-style
names and API tokens, while the structured-text converter uses a different
APDFL catalog. See the upstream contract work and complete discrepancy list:
https://datalogics-jira.atlassian.net/browse/PDFCLOUD-6287
Please keep this PR blocked until PDFCLOUD-6287 publishes the authoritative
OpenAPI enums and validation. Then consume those contracts here as public
Literal aliases with accepted-values documentation, validate them in the
payload models, and add exhaustive accepted-value plus representative rejection
tests for sync and async callers.
GitHub does not permit the PR author to submit a Request changes review, so this
is recorded as a review comment; PDFCLOUD-6287 is formally linked as blocking
PDFCLOUD-6254 in Jira.
PDFCLOUD-6254
Why this change
The SDK could not convert structured Markdown, plain text, JSON, XML, or CSV documents through the documented
POST /pdfcapability. Callers had to construct untyped requests and could accidentally combine options that the service accepts only for particular source formats.What changed (high level)
The synchronous and asynchronous clients now provide five format-specific helpers backed by Pydantic payload models and public structured-document types. Format-specific signatures keep incompatible options separate while shared page, typography, table, color, and output settings serialize to the API's
structured_text_optionsobject. Markdown image mappings accept uploaded resources and internally deduplicate their IDs.Behavior changes
Callers upload a source document and pass its
PdfRestFiletoconvert_markdown_to_pdf,convert_plain_text_to_pdf,convert_json_to_pdf,convert_xml_to_pdf, orconvert_csv_to_pdf. Local validation rejects the wrong source format, multiple source files, unsupported Markdown image MIME types, and invalid literal or numeric options before transport. The SDK adds a runnable combined example, fixtures, generated API-guide links, and documented Literal value meanings. This is a feature release from 1.1.0 to 1.2.0; no existing public APIs change.Validation
uv run pytest -n auto --maxschedchunk 2 tests/test_convert_structured_documents_to_pdf.py— 121 passed, 10 expected matching-format skips.PDFREST_LIVE_BASE_URL=http://sleipnir:3000 uvx nox -s tests-3.11 -- tests/live/test_live_convert_structured_documents_to_pdf.py— 32 passed.Risks and follow-ups
This is a stacked draft PR on #45: merge #45 first, then this PR. The base is
pdfcloud-6243-pdf-with-added-shapes, so reviewers see only the structured-document conversion layer. The live coverage depends on the suppliedsleipnir:3000service. No breaking changes are intended.