mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
Add bidirectional API types to frontend (#6867)
# Description of Changes Fix https://github.com/Stirling-Tools/Stirling-PDF-SaaS/issues/281. Add generated backend API mappings to the frontend code, and the logic to convert from a backend API to frontend parameters objects. Previously, it was impossible to tell if changing the backend API would require a change to the frontend to support it because the frontend had no static type information about the backend API. This PR adds autogenerated tool API types to the frontend (in `toolApiTypes.ts`) and adds explicit typed mappings between the frontend parameter types and the backend API types, so theoretically the type checker should be able to catch issues when changing one puts us in an invalid state with the other. During development, it pointed out several inconsistencies that we have between the frontend and backend types, some of which were genuine bugs, and others were only happening to work because the backend is more permissive than its API claims to be. This also unlocks the ability for us to render the frontend settings on saved backend API structures, which we've previously had to avoid doing because we had no reverse mapping.
This commit is contained in:
@@ -107,7 +107,7 @@ class KeyLength(IntEnum):
|
||||
|
||||
|
||||
class AddPasswordParams(ApiModel):
|
||||
key_length: KeyLength = Field(..., description="The length of the encryption key")
|
||||
key_length: KeyLength = Field(KeyLength.integer_256, description="The length of the encryption key")
|
||||
owner_password: SecretStr | None = Field(
|
||||
None,
|
||||
description="The owner password to be added to the PDF file (Restricts what can be done with the document once it is opened)",
|
||||
@@ -1283,8 +1283,8 @@ class PageSize1(StrEnum):
|
||||
class SplitForPosterPrintParams(ApiModel):
|
||||
page_size: PageSize1 = Field(..., description="Target page size for output chunks (e.g., 'A4', 'Letter', 'A3')")
|
||||
right_to_left: bool = Field(False, description="Split right-to-left instead of left-to-right")
|
||||
xfactor: int | None = None
|
||||
yfactor: int | None = None
|
||||
x_factor: int = Field(2, description="Horizontal decimation factor (how many columns to split into)", ge=1, le=10)
|
||||
y_factor: int = Field(2, description="Vertical decimation factor (how many rows to split into)", ge=1, le=10)
|
||||
|
||||
|
||||
class SplitPagesParams(ApiModel):
|
||||
|
||||
Reference in New Issue
Block a user