feat: add Format constants for convert media types, including JXL - #19
Open
Sreini wants to merge 1 commit into
Open
feat: add Format constants for convert media types, including JXL#19Sreini wants to merge 1 commit into
Sreini wants to merge 1 commit into
Conversation
Adds a Format namespace of media-type string constants so the types accepted by convert() are discoverable via autocomplete, including JPEG XL (image/jxl), which the API already accepts. String constants rather than a language-level enum: the JSON body must carry the media type verbatim, and an enum would serialize as its name. Existing callers passing raw strings are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
Formatnamespace of media-type constants so the types accepted byconvertare discoverable via autocomplete — including JPEG XL(
image/jxl), which the API already accepts but no client surfaced.image/jxlis already in the API allowlist (apps/api/src/schemas/optimizations.tsand
apps/opt-api/src/constants/content-types.ts), so this is a client-sidediscoverability change only. There is no API-side work outstanding.
Members
WEBP,PNG,JPEG,JPG,AVIF,JXL,ANY(*/*) — mirroring theAPI allowlist exactly.
Why string constants and not an enum
The JSON body has to carry the media type verbatim. A language-level enum
serializes as its name or ordinal, not
image/jxl. String constants also keepthis fully backward compatible: callers passing raw strings are unaffected.
Verification
Syntax verified (
ruby -con both changed files). The test suite could not be run locally — the repo targets Ruby 4.0.1 (.ruby-version) and only system Ruby 2.6.10 is available here with no version manager, sobundlefails on a bundler version mismatch. The two newtinify_format_test.rbcases rely on CI. Please confirm CI is green before merging.Part of a coordinated change across all six Tinify client libraries, so the
same
FormatAPI is available in each.