diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6833b492..6781258c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: lint: timeout-minutes: 15 name: lint - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: @@ -45,7 +45,7 @@ jobs: permissions: contents: read id-token: write - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: @@ -66,6 +66,44 @@ jobs: - name: Build SDK run: ./scripts/build + - name: Get GitHub OIDC Token + if: |- + github.repository == 'stainless-sdks/imagekit-java' && + !startsWith(github.ref, 'refs/heads/stl/') + id: github-oidc + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: core.setOutput('github_token', await core.getIDToken()); + - name: Build and upload Maven artifacts + if: |- + github.repository == 'stainless-sdks/imagekit-java' && + !startsWith(github.ref, 'refs/heads/stl/') + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + PROJECT: imagekit-java + run: ./scripts/upload-artifacts + test: + timeout-minutes: 15 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Java + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + - name: Set up Gradle + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index ffa6f597..a15b81ab 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -18,7 +18,6 @@ jobs: run: | bash ./bin/check-release-environment env: - RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }} SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index 32fae7eb..00000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Release Please -on: - push: - branches: - - master - -permissions: - contents: write - pull-requests: write - -jobs: - release-please: - if: github.repository == 'imagekit-developer/imagekit-java' - runs-on: ubuntu-latest - - steps: - - uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1 - id: release - with: - token: ${{ secrets.RELEASE_PLEASE_TOKEN }} diff --git a/.github/workflows/stlc-promote.yml b/.github/workflows/stlc-promote.yml deleted file mode 100644 index 6da8cb46..00000000 --- a/.github/workflows/stlc-promote.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Promote SDKs - -on: - push: - branches: [main] - -permissions: - contents: read - -jobs: - promote: - runs-on: ubuntu-latest - env: - PRODUCTION_REPO: imagekit-developer/imagekit-java - PRODUCTION_BRANCH: master - GH_TOKEN: ${{ secrets.SDK_WRITE_TOKEN }} - steps: - - name: Check out staging - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Fetch production main - run: | - git remote add production \ - "https://x-access-token:${GH_TOKEN}@github.com/${PRODUCTION_REPO}.git" - git fetch production "${PRODUCTION_BRANCH}" - - - name: Check if production is already in sync - id: diff - run: | - STAGING_SHA=$(git rev-parse origin/main) - PRODUCTION_SHA=$(git rev-parse production/${PRODUCTION_BRANCH}) - if [ "$STAGING_SHA" = "$PRODUCTION_SHA" ]; then - echo "Production is already at $STAGING_SHA. Nothing to release." - echo "synced=true" >> "$GITHUB_OUTPUT" - else - echo "synced=false" >> "$GITHUB_OUTPUT" - fi - - - name: Push staging main to the release branch on production - if: steps.diff.outputs.synced == 'false' - run: | - git push production origin/main:refs/heads/stainless/release --force - - - name: Open or update the release PR on production - if: steps.diff.outputs.synced == 'false' - run: | - EXISTING_PR=$(gh pr list \ - --repo "${PRODUCTION_REPO}" \ - --head stainless/release \ - --state open \ - --json number \ - --jq '.[0].number') - if [ -z "${EXISTING_PR}" ]; then - gh pr create \ - --repo "${PRODUCTION_REPO}" \ - --base "${PRODUCTION_BRANCH}" \ - --head stainless/release \ - --title "Release SDK updates" \ - --body "$(git log --oneline production/${PRODUCTION_BRANCH}..origin/main)" - else - echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it." - fi diff --git a/.github/workflows/sync-release-as.yml b/.github/workflows/sync-release-as.yml deleted file mode 100644 index 99150044..00000000 --- a/.github/workflows/sync-release-as.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Sync Release-As from release PR title - -on: - pull_request: - types: [edited] - -permissions: - contents: write - -jobs: - sync: - if: >- - github.event.pull_request.base.ref == 'master' && - startsWith(github.event.pull_request.head.ref, 'release-please--') && - github.event.changes.title != null - runs-on: ubuntu-latest - steps: - - name: Extract versions from old and new title - id: parse - env: - NEW_TITLE: ${{ github.event.pull_request.title }} - OLD_TITLE: ${{ github.event.changes.title.from }} - run: | - # Anchored on pull-request-title-pattern "release: ${version}" from release-please-config.json. - extract() { - echo "$1" | grep -oE '^release:[[:space:]]+v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' \ - | sed -E 's/^release:[[:space:]]+v?//' - } - NEW_VERSION=$(extract "$NEW_TITLE") - OLD_VERSION=$(extract "$OLD_TITLE") - echo "old=$OLD_VERSION" - echo "new=$NEW_VERSION" - if [ -z "$NEW_VERSION" ]; then - echo "::notice::No semver in new title; nothing to do." - echo "skip=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then - echo "::notice::Version unchanged ($NEW_VERSION); not pushing." - echo "skip=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" - - - name: Check out master - if: steps.parse.outputs.skip != 'true' - uses: actions/checkout@v6 - with: - ref: master - token: ${{ secrets.RELEASE_PLEASE_TOKEN }} - fetch-depth: 1 - - - name: Push empty Release-As commit - if: steps.parse.outputs.skip != 'true' - env: - VERSION: ${{ steps.parse.outputs.version }} - run: | - git config user.name "release-as-bot" - git config user.email "release-as-bot@users.noreply.github.com" - git commit --allow-empty -m "chore: pin next release - - Release-As: ${VERSION}" - git push origin master diff --git a/.gitignore b/.gitignore index 3f9641c6..90b85e94 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,3 @@ build/ codegen.log kls_database.db - - -image-kit-java-example/resources -image-kit-java-example/src/main/resources/ -temp \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 006b15f4..c1c7ec9d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1,4 @@ configured_endpoints: 47 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-5280e65473c0c42b7f41216fd22aeb469acb5f54b6ee1a3181f3ec9b7a19dc17.yml +openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d +config_hash: 7960882e624d385c4d9aecca2132adad diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 6dd6f7c1..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,210 +0,0 @@ -# Changelog - -## [3.2.0](https://github.com/imagekit-developer/imagekit-java/compare/v3.1.2...v3.2.0) (2026-06-03) - - -### Bug Fixes - -* metadata response shape ([2064e1a](https://github.com/imagekit-developer/imagekit-java/commit/2064e1a12d6d20d71d0921bf1bb4b3e40be9f520)) - - -### Chores - -* pin next release ([4c20da0](https://github.com/imagekit-developer/imagekit-java/commit/4c20da05e894b647b8e4cb81f5613dd1d7b916a0)) - -## [3.1.2](https://github.com/imagekit-developer/imagekit-java/compare/v3.1.1...v3.1.2) (2026-05-25) - - -### Features - -* initial stlc build ([9418324](https://github.com/imagekit-developer/imagekit-java/commit/941832443279b45ffdab0ff5a440fc19b1904aa4)) - - -### Chores - -* pin next release ([537e748](https://github.com/imagekit-developer/imagekit-java/commit/537e7488b778bfdfc543b9b876dd5faf6bfea53c)) -* Update webhook description ([9e5cc4b](https://github.com/imagekit-developer/imagekit-java/commit/9e5cc4bc6da2ffe1ecfc8993465a502c2716451e)) -* Update webhook description ([3859bd4](https://github.com/imagekit-developer/imagekit-java/commit/3859bd4f87124025eb99bcc19fbaaacc78713852)) - -## 3.1.1 (2026-05-17) - -Full Changelog: [v3.1.0...v3.1.1](https://github.com/imagekit-developer/imagekit-java/compare/v3.1.0...v3.1.1) - -### Build System - -* **dotnet:** adding variant name for build warnings cannot infer union variant name ([ede45e2](https://github.com/imagekit-developer/imagekit-java/commit/ede45e238c23ec07bd5c9209d81645636b9e1892)) -* revert dotnet specific changes ([a2059aa](https://github.com/imagekit-developer/imagekit-java/commit/a2059aad80d79249bd66492a063c0358421c391b)) - -## 3.1.0 (2026-05-13) - -Full Changelog: [v3.0.0...v3.1.0](https://github.com/imagekit-developer/imagekit-java/compare/v3.0.0...v3.1.0) - -### Features - -* **api:** add no-enlarge crop modes and colorize transformation ([183b131](https://github.com/imagekit-developer/imagekit-java/commit/183b131e263f5d3958317b867011349ebd0820ae)) -* **client:** improve logging ([a62b5e3](https://github.com/imagekit-developer/imagekit-java/commit/a62b5e30077bab50d3a9764daa7c520df18914bb)) -* **client:** more robust error parsing ([8e42517](https://github.com/imagekit-developer/imagekit-java/commit/8e4251712d721a17b9caa4f1ad04e9c2c06822a0)) -* **client:** support proxy authentication ([60effd3](https://github.com/imagekit-developer/imagekit-java/commit/60effd33a60b70e3f44e9180927e3a63a93ee00d)) -* **helper:** add colorize transformation support in URL generation ([209a37c](https://github.com/imagekit-developer/imagekit-java/commit/209a37cb5547b1875b8b0b39b54c674d527a3e87)) -* support setting headers via env ([c31a472](https://github.com/imagekit-developer/imagekit-java/commit/c31a472fd2674c2e339d16024cb47bf246994a38)) - - -### Performance Improvements - -* **client:** create one json mapper ([92128db](https://github.com/imagekit-developer/imagekit-java/commit/92128db5fbd82870290b9c1b5003115dd7c04469)) - - -### Chores - -* redact api-key headers in debug logs ([8db78f2](https://github.com/imagekit-developer/imagekit-java/commit/8db78f2751eb396a6f418e63631c22ecddbafb8c)) -* remove duplicated dokka setup ([a1a0ece](https://github.com/imagekit-developer/imagekit-java/commit/a1a0ece2a2e02b2dc10b6bee8d043170e3cd9681)) - - -### Documentation - -* clarify forwards compat behavior ([d5ec8cf](https://github.com/imagekit-developer/imagekit-java/commit/d5ec8cffa3ebac99d70f70f7b6c4fadbe042a5be)) - -## 3.0.0 (2026-04-21) - -Full Changelog: [v0.0.1...v3.0.0](https://github.com/imagekit-developer/imagekit-java/compare/v0.0.1...v3.0.0) - -### Features - -* add helper utilities and lib module with tests ([92fb768](https://github.com/imagekit-developer/imagekit-java/commit/92fb768157a6630a3770f5ad99596b6c3ed184f3)) -* **api:** add BaseWebhookEvent ([4ab06b0](https://github.com/imagekit-developer/imagekit-java/commit/4ab06b01316b114e526159de348b9d52fdd57567)) -* **api:** add customMetadata property to folder schema ([0413e64](https://github.com/imagekit-developer/imagekit-java/commit/0413e64aa737500a42764fb2613f94cf582cb2b8)) -* **api:** add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint ([70d2551](https://github.com/imagekit-developer/imagekit-java/commit/70d2551ec48038eb1deb0459a0b4dc2b6506c837)) -* **api:** add path policy related non-breaking changes ([6e2eac3](https://github.com/imagekit-developer/imagekit-java/commit/6e2eac363b8f707a58009f6812350f45d4856da2)) -* **api:** Add saved extensions API and enhance transformation options ([1bca614](https://github.com/imagekit-developer/imagekit-java/commit/1bca6144095239ef2892cd989f89136e4af1a953)) -* **api:** add selectedFieldsSchema in upload and list API response ([34289ae](https://github.com/imagekit-developer/imagekit-java/commit/34289ae2c42a258e56ad87133c9eff209b248163)) -* **api:** add webhook signature verification ([ff73a7a](https://github.com/imagekit-developer/imagekit-java/commit/ff73a7abfc250eb2558c073684d328a48b9df29e)) -* **api:** dam related webhook events ([8352cba](https://github.com/imagekit-developer/imagekit-java/commit/8352cbaa2184947c142175d475c2cc06c9e9f57f)) -* **api:** dpr type update ([6a528ff](https://github.com/imagekit-developer/imagekit-java/commit/6a528ff9db3c2123c79997bd48b503be731cca65)) -* **api:** extract UpdateFileDetailsRequest to model ([c75a767](https://github.com/imagekit-developer/imagekit-java/commit/c75a767180e2d032fc0ab1d2fe74e41795bd957d)) -* **api:** fix spec indentation ([26eba98](https://github.com/imagekit-developer/imagekit-java/commit/26eba981e412103f0293fafd8888e3d075deec0d)) -* **api:** fix upload API request params ([7abe230](https://github.com/imagekit-developer/imagekit-java/commit/7abe23093ccf53fcf4b0829cc7d4b792cf8c4406)) -* **api:** indentation fix ([0caeef8](https://github.com/imagekit-developer/imagekit-java/commit/0caeef861804c31031de369a40e0ac755ff26396)) -* **api:** Introduce lxc, lyc, lap parameters in overlays. ([e3b34fb](https://github.com/imagekit-developer/imagekit-java/commit/e3b34fb41f580c5bd557c99cc7c26af6d5583b20)) -* **api:** manual updates ([afb90e6](https://github.com/imagekit-developer/imagekit-java/commit/afb90e655bbe37ba25e2cb3f02577414483c3488)) -* **api:** manual updates ([b586d51](https://github.com/imagekit-developer/imagekit-java/commit/b586d513361b7ed938fb9a4c29a44a9e47e1cca2)) -* **api:** manual updates ([75ff27c](https://github.com/imagekit-developer/imagekit-java/commit/75ff27c3c8a2c90d7bf5d14e75b1e3de05733781)) -* **api:** manual updates ([646022d](https://github.com/imagekit-developer/imagekit-java/commit/646022de6d3820653968a99867c60b3df998f9d3)) -* **api:** manual updates ([f5206be](https://github.com/imagekit-developer/imagekit-java/commit/f5206beb4c997de9c2ff47a70d36795557fae7c5)) -* **api:** manual updates ([e474ef2](https://github.com/imagekit-developer/imagekit-java/commit/e474ef2004c784def6eba33158337511c073d178)) -* **api:** manual updates ([09a68d6](https://github.com/imagekit-developer/imagekit-java/commit/09a68d6fb594866ed049c11cba27d797ef553908)) -* **api:** manual updates ([e01a75a](https://github.com/imagekit-developer/imagekit-java/commit/e01a75a9df1f6f49754095c9b61159236b5658b5)) -* **api:** manual updates ([2d41187](https://github.com/imagekit-developer/imagekit-java/commit/2d41187dea1edca9d0f941690244b4c50874d9cc)) -* **api:** manual updates ([2ef93ad](https://github.com/imagekit-developer/imagekit-java/commit/2ef93ad3db97af5fef99687a4438c76e2220b384)) -* **api:** manual updates ([c6e61f8](https://github.com/imagekit-developer/imagekit-java/commit/c6e61f8ca6b3a9485ab15d0221842ef76b6cae32)) -* **api:** manual updates ([1c76234](https://github.com/imagekit-developer/imagekit-java/commit/1c762344ee41aa7099febdca72f368943ee8428b)) -* **api:** manual updates ([cd2b64e](https://github.com/imagekit-developer/imagekit-java/commit/cd2b64ef8d6324264a71321bb11a7849260d98fc)) -* **api:** manual updates ([1341b62](https://github.com/imagekit-developer/imagekit-java/commit/1341b6282b4a32013cb60f11ee0ec9aaef8acac4)) -* **api:** manual updates ([83ce070](https://github.com/imagekit-developer/imagekit-java/commit/83ce0707ff45a9daa97e12daa9ad050dcbab53f9)) -* **api:** manual updates ([d57885b](https://github.com/imagekit-developer/imagekit-java/commit/d57885b731de1837a7edcd3f6eab303db855475a)) -* **api:** manual updates ([74027ef](https://github.com/imagekit-developer/imagekit-java/commit/74027efe9095a5e650addddf064d6e3773413894)) -* **api:** manual updates ([76c5b5e](https://github.com/imagekit-developer/imagekit-java/commit/76c5b5e1fbc0ac3415d5e35febce642dd47cd0ab)) -* **api:** manual updates ([b462410](https://github.com/imagekit-developer/imagekit-java/commit/b46241040326016adf4ad220178ccf3221323f90)) -* **api:** manual updates ([cbbd424](https://github.com/imagekit-developer/imagekit-java/commit/cbbd424da5ebd388dd6e3d8af7e38b7633ed0604)) -* **api:** merge with main to bring back missing parameters ([fb7f512](https://github.com/imagekit-developer/imagekit-java/commit/fb7f512d8932eb43656a89fdce6ccc8f59b3ebb6)) -* **api:** remove Stainless attribution from readme ([065125f](https://github.com/imagekit-developer/imagekit-java/commit/065125f9c510b69c6ec41ddb811f9cebcdd37c1b)) -* **api:** revert dpr breaking change ([997ab63](https://github.com/imagekit-developer/imagekit-java/commit/997ab6353eeb46a8b97cad9f9688a11b9d700fc3)) -* **api:** update api docs link ([0b273a9](https://github.com/imagekit-developer/imagekit-java/commit/0b273a981219fbf9083fcb2559d81f3e472ca9e1)) -* **api:** Update env var name ([1b520d1](https://github.com/imagekit-developer/imagekit-java/commit/1b520d13de7c42693d3acc4a364fdec55eb341ce)) -* **api:** update webhook event names and remove DAM prefix ([0cbbc63](https://github.com/imagekit-developer/imagekit-java/commit/0cbbc63ad53db27fae27e4b0f470b3242d8bdaeb)) -* **client:** add `HttpRequest#url()` method ([fa1b9b7](https://github.com/imagekit-developer/imagekit-java/commit/fa1b9b7159b51b86831440ba956082f3d2619c37)) -* **client:** add connection pooling option ([c7a7295](https://github.com/imagekit-developer/imagekit-java/commit/c7a72959cf29e796657dea8d7590f4b96d5fb542)) -* **client:** add more convenience service method overloads ([f462bff](https://github.com/imagekit-developer/imagekit-java/commit/f462bfff56865ae16dadb5a404c696d3d5ff1ff9)) -* **client:** allow configuring dispatcher executor service ([a7be5ce](https://github.com/imagekit-developer/imagekit-java/commit/a7be5cec994774da7ba3c6129e63d13686d065c9)) -* **client:** send `X-Stainless-Kotlin-Version` header ([2224a12](https://github.com/imagekit-developer/imagekit-java/commit/2224a1264e0fd8772808873c4978b7930f0acb4b)) - - -### Bug Fixes - -* add ai-tasks property to response schemas with enum values ([b0bfdf6](https://github.com/imagekit-developer/imagekit-java/commit/b0bfdf6c142e23170be4051a985d7206c74f5958)) -* add one more method in multipartbuilder to build from json ([9dc2f89](https://github.com/imagekit-developer/imagekit-java/commit/9dc2f897ec7b9a1998d283359472b882cfb9ee68)) -* **api:** add missing embeddedMetadata and video properties to FileDetails ([ceb43dd](https://github.com/imagekit-developer/imagekit-java/commit/ceb43ddf46ac19fc90fb28e716d6f5490630bc30)) -* **api:** extract shared schemas to prevent Go webhook union breaking changes ([f5fdf8f](https://github.com/imagekit-developer/imagekit-java/commit/f5fdf8fd7cc5a0f70fef28fd8b1fc23ebda05c8c)) -* **api:** rename DamFile events to File for consistency ([f18e22b](https://github.com/imagekit-developer/imagekit-java/commit/f18e22be52528874c7adb453bc360b0e511001c3)) -* **ci:** use java-version 21 for publish step ([181fbe5](https://github.com/imagekit-developer/imagekit-java/commit/181fbe5360fbc5820cb9df684d242896ec146049)) -* **client:** allow updating header/query affecting fields in `toBuilder()` ([91e327e](https://github.com/imagekit-developer/imagekit-java/commit/91e327e82db972ae6e5a50f9fb14e52ead007621)) -* **client:** cancel okhttp call when future cancelled ([d4b8c84](https://github.com/imagekit-developer/imagekit-java/commit/d4b8c848066b410e35a95c555bc238f8e5228b83)) -* **client:** deserialization of empty objects ([8ccff9b](https://github.com/imagekit-developer/imagekit-java/commit/8ccff9bc6b39dbd306eb5325a830bbadc0053585)) -* **client:** disallow coercion from float to int ([a6dc3e2](https://github.com/imagekit-developer/imagekit-java/commit/a6dc3e26f63b2b3c2d5a8185c329f5140f84076d)) -* **client:** fully respect max retries ([87d2ad3](https://github.com/imagekit-developer/imagekit-java/commit/87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0)) -* **client:** incorrect `getPackageVersion` impl ([078eab8](https://github.com/imagekit-developer/imagekit-java/commit/078eab8cf903109aaead3f0e90a2ee0b14c9c9ce)) -* **client:** incorrect `Retry-After` parsing ([15b04f7](https://github.com/imagekit-developer/imagekit-java/commit/15b04f7bfb7677c941dda5db230b273115551600)) -* **client:** multi-value header serialization ([ccb0ffb](https://github.com/imagekit-developer/imagekit-java/commit/ccb0ffb22b5a6ce7789110fa3d83e42a279fcb22)) -* **client:** preserve time zone in lenient date-time parsing ([3c1ce69](https://github.com/imagekit-developer/imagekit-java/commit/3c1ce699ab55a45358fc78b2437ca1971c6918ea)) -* **client:** send retry count header for max retries 0 ([87d2ad3](https://github.com/imagekit-developer/imagekit-java/commit/87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0)) -* date time deserialization leniency ([7f3e0d6](https://github.com/imagekit-developer/imagekit-java/commit/7f3e0d6f67a4e7b598ef2763d81faff8e00b9959)) -* deserialization order ([a7d3f1e](https://github.com/imagekit-developer/imagekit-java/commit/a7d3f1e74b0cd489ed67458efe462996b2706e50)) -* **docs:** fix mcp installation instructions for remote servers ([2a727d4](https://github.com/imagekit-developer/imagekit-java/commit/2a727d401b4dff5441414b565ba081822a737926)) -* fix request delays for retrying to be more respectful of high requested delays ([eb80ae5](https://github.com/imagekit-developer/imagekit-java/commit/eb80ae59186571723c253602ebf87e31bc52b988)) -* vocab field is required ([ea9bfc3](https://github.com/imagekit-developer/imagekit-java/commit/ea9bfc30c34316aca3f1536e366b920e7e9c8bb7)) - - -### Chores - -* **ci:** skip lint on metadata-only changes ([f43fd3a](https://github.com/imagekit-developer/imagekit-java/commit/f43fd3ae0642cc33b727775e62eb58a6fb3f0123)) -* **ci:** skip uploading artifacts on stainless-internal branches ([19e8f78](https://github.com/imagekit-developer/imagekit-java/commit/19e8f78f7ee6e65ad0943dcccc7e17af31cf074c)) -* **ci:** upgrade `actions/github-script` ([940ebfc](https://github.com/imagekit-developer/imagekit-java/commit/940ebfcf3a2153e86b2292f2ca6077874d9fb170)) -* **ci:** upgrade `actions/setup-java` ([e60fd58](https://github.com/imagekit-developer/imagekit-java/commit/e60fd58b5a303ea126c427f046fc30c0c63bfa79)) -* configure new SDK language ([4c0fdb3](https://github.com/imagekit-developer/imagekit-java/commit/4c0fdb3884cf537b504527a651790546eb645210)) -* drop apache dependency ([48e02f7](https://github.com/imagekit-developer/imagekit-java/commit/48e02f702dea5f4c0553740e48bd670c63477f51)) -* improve formatter performance ([daaa7f3](https://github.com/imagekit-developer/imagekit-java/commit/daaa7f33c20310093952bd4396d305bef42c81b8)) -* **internal:** allow passing args to `./scripts/test` ([1d14a59](https://github.com/imagekit-developer/imagekit-java/commit/1d14a5930b16ce47c2f85e2e5e8b2507dec9a61f)) -* **internal:** bump palantir-java-format ([87b5f18](https://github.com/imagekit-developer/imagekit-java/commit/87b5f1817dda7429a6b4a154f71d4196198df0c0)) -* **internal:** change some comment formatting ([86ca3d7](https://github.com/imagekit-developer/imagekit-java/commit/86ca3d7d9676b6a07f1930195a8dd5dacf12714a)) -* **internal:** clean up maven repo artifact script and add html documentation to repo root ([8e34e08](https://github.com/imagekit-developer/imagekit-java/commit/8e34e08c8aa939a06b933c0c29c0df46b175b8c2)) -* **internal:** codegen related update ([e970882](https://github.com/imagekit-developer/imagekit-java/commit/e970882efd7aa0f4770edce814c9b837e8ae247c)) -* **internal:** codegen related update ([da02221](https://github.com/imagekit-developer/imagekit-java/commit/da0222197fca08583b2096effa2bd18a9f9f615b)) -* **internal:** codegen related update ([814caf9](https://github.com/imagekit-developer/imagekit-java/commit/814caf9f6454c4b32af76f3a5b68d6af54d631b3)) -* **internal:** codegen related update ([cd82f98](https://github.com/imagekit-developer/imagekit-java/commit/cd82f981b54a9131ed8195f62de0bb65bb436b6d)) -* **internal:** codegen related update ([da788af](https://github.com/imagekit-developer/imagekit-java/commit/da788af79c52a70075f39b26776b203cd958ceb0)) -* **internal:** codegen related update ([f25c3c4](https://github.com/imagekit-developer/imagekit-java/commit/f25c3c46f4104091a5e8e376c22727eb3aaa4611)) -* **internal:** correct cache invalidation for `SKIP_MOCK_TESTS` ([1f6f1dc](https://github.com/imagekit-developer/imagekit-java/commit/1f6f1dcfb312298c1cbb524512d0a8aa7e05560e)) -* **internal:** depend on packages directly in example ([87d2ad3](https://github.com/imagekit-developer/imagekit-java/commit/87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0)) -* **internal:** expand imports ([f10c1b0](https://github.com/imagekit-developer/imagekit-java/commit/f10c1b040943402094e0f75669b0eb61503d9875)) -* **internal:** improve examples ([998d126](https://github.com/imagekit-developer/imagekit-java/commit/998d126b14aebc0a454a15d9169049888395ec35)) -* **internal:** improve maven repo docs ([b92f5f0](https://github.com/imagekit-developer/imagekit-java/commit/b92f5f0ea9c1defd19ed0224471dc6cd2bed2e2e)) -* **internal:** make `OkHttp` constructor internal ([534feb3](https://github.com/imagekit-developer/imagekit-java/commit/534feb30f3c327e09d1e13423e447224e2da90d7)) -* **internal:** remove mock server code ([3f1d1c6](https://github.com/imagekit-developer/imagekit-java/commit/3f1d1c67caa0d9824d3c03bef1c8b58a5d58c76e)) -* **internal:** remove redundant deserializer symbols ([2d52469](https://github.com/imagekit-developer/imagekit-java/commit/2d52469a65c898504a76adb6ab4826aa3febbbdc)) -* **internal:** remove unnecessary base URL ([98d50fa](https://github.com/imagekit-developer/imagekit-java/commit/98d50fa72841ab2a4fe4baf62861f4c2e911a23b)) -* **internal:** support uploading Maven repo artifacts to stainless package server ([83de2bf](https://github.com/imagekit-developer/imagekit-java/commit/83de2bfb62facd417c3cd626c0f3a7ed7e989165)) -* **internal:** tweak CI branches ([3e76397](https://github.com/imagekit-developer/imagekit-java/commit/3e76397ba5582f39d56aeb243d2fa81564814604)) -* **internal:** update `actions/checkout` version ([7115c38](https://github.com/imagekit-developer/imagekit-java/commit/7115c3879f8983659e87b369a23600d4c2ae9646)) -* **internal:** update `TestServerExtension` comment ([89b8598](https://github.com/imagekit-developer/imagekit-java/commit/89b85982f5be8ac9de8b4ea05a6ca0490951f21b)) -* **internal:** update gitignore ([4c944e0](https://github.com/imagekit-developer/imagekit-java/commit/4c944e0804b949085602a5d724120ab40acba53d)) -* **internal:** update maven repo doc to include authentication ([7156f6f](https://github.com/imagekit-developer/imagekit-java/commit/7156f6fa1a10aa4d4cd1655d2a3612239fc25422)) -* **internal:** update multipart form array serialization ([11184c7](https://github.com/imagekit-developer/imagekit-java/commit/11184c77fbc86d278f2791bdbbfcaa1cb542eaae)) -* **internal:** update retry delay tests ([51a3135](https://github.com/imagekit-developer/imagekit-java/commit/51a3135751d0ff2bdc2c741e714061615d232b7b)) -* **internal:** upgrade AssertJ ([99a48d6](https://github.com/imagekit-developer/imagekit-java/commit/99a48d6896e90c14b96e182b85692a7f1b6aece7)) -* make `Properties` more resilient to `null` ([34b930a](https://github.com/imagekit-developer/imagekit-java/commit/34b930ad491dafb8e94442ef07864d47d1f54137)) -* remove custom code ([ec944a0](https://github.com/imagekit-developer/imagekit-java/commit/ec944a0fafc93f26bc277530738901258e787bb1)) -* sync repo ([05af7d5](https://github.com/imagekit-developer/imagekit-java/commit/05af7d57aab0174c720f1dd71e87d39f1197bfa1)) -* test on Jackson 2.14.0 to avoid encountering FasterXML/jackson-databind[#3240](https://github.com/imagekit-developer/imagekit-java/issues/3240) in tests ([7f3e0d6](https://github.com/imagekit-developer/imagekit-java/commit/7f3e0d6f67a4e7b598ef2763d81faff8e00b9959)) -* **tests:** bump steady to v0.19.4 ([3b0fc2e](https://github.com/imagekit-developer/imagekit-java/commit/3b0fc2efe92fcf1733f4bbdefe779cd2203e585a)) -* **tests:** update webhook tests ([2f221f7](https://github.com/imagekit-developer/imagekit-java/commit/2f221f7678f232232a18d3b533bbeb93a7758599)) -* update mock server docs ([6fb3f0c](https://github.com/imagekit-developer/imagekit-java/commit/6fb3f0cfd3a1f8bb17c9c632c56db7f5a7240948)) -* update placeholder string ([6b3d9f5](https://github.com/imagekit-developer/imagekit-java/commit/6b3d9f5c59f9e416ea67380045bf54ef9f48f135)) -* update SDK settings ([b39e9dc](https://github.com/imagekit-developer/imagekit-java/commit/b39e9dc8e9af7806353b5f9276f023fec45c5905)) -* update SDK settings ([00f7055](https://github.com/imagekit-developer/imagekit-java/commit/00f705596f585c9020a4620a9675e733f28b8b1b)) - - -### Documentation - -* correct typo in default value description for custom metadata field ([fc00907](https://github.com/imagekit-developer/imagekit-java/commit/fc00907646fa9bfb333ac303783d58956cc262c2)) -* improve examples ([f9a78b0](https://github.com/imagekit-developer/imagekit-java/commit/f9a78b0fd65f309da64d400d91665696ebfb67eb)) -* prominently feature MCP server setup in root SDK readmes ([41bf700](https://github.com/imagekit-developer/imagekit-java/commit/41bf7009b03948c41ffd933a80ee0ffea1a7a00b)) -* remove `$` for better copy-pasteabality ([2273b04](https://github.com/imagekit-developer/imagekit-java/commit/2273b04035285050a65b6703e523789905d71387)) - - -### Refactors - -* AITags to singular AITag schema with array items pattern ([e71dfe1](https://github.com/imagekit-developer/imagekit-java/commit/e71dfe138309b105b1eb38d5622e21f147446571)) - - -### Build System - -* updating CI ([a14b7cc](https://github.com/imagekit-developer/imagekit-java/commit/a14b7cc70204cd8af648e3c3ac7664f3916850b1)) diff --git a/README.md b/README.md index 977f147f..63ee938b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,22 @@ -# ImageKit.io Java SDK +# Image Kit Java API Library [![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/3.2.0) -[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/3.2.0/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/3.1.1) +[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/3.2.0/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/3.2.0) -The ImageKit Java SDK is a comprehensive library designed to simplify the integration of ImageKit into your server-side applications. It provides powerful tools for working with the ImageKit REST API, including building and transforming URLs, generating signed URLs for secure content delivery, verifying webhooks, and handling file uploads. +The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. + +## MCP Server + +Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) + +> Note: You may need to set environment variables in your MCP client. @@ -15,30 +24,6 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc -## Table of Contents - -- [Installation](#installation) -- [Requirements](#requirements) -- [Usage](#usage) -- [URL generation](#url-generation) - - [Basic URL generation](#basic-url-generation) - - [URL generation with transformations](#url-generation-with-transformations) - - [URL generation with image overlay](#url-generation-with-image-overlay) - - [URL generation with text overlay](#url-generation-with-text-overlay) - - [URL generation with multiple overlays](#url-generation-with-multiple-overlays) - - [Signed URLs for secure delivery](#signed-urls-for-secure-delivery) -- [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads) -- [Webhook verification](#webhook-verification) -- [Advanced Usage](#advanced-usage) - - [Client configuration](#client-configuration) - - [File uploads](#file-uploads) - - [Error handling](#error-handling) - - [Retries](#retries) - - [Timeouts](#timeouts) - - [Proxies](#proxies) - - [Logging](#logging) -- [Semantic versioning](#semantic-versioning) - ## Installation @@ -74,298 +59,17 @@ import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); -System.out.println(response); -``` - -## URL generation - -The ImageKit SDK provides a powerful `client.helper().buildUrl()` method for generating optimized image and video URLs with transformations. - -### Basic URL generation - -Generate a simple URL without any transformations: - -```java -import io.imagekit.client.ImageKitClient; -import io.imagekit.client.okhttp.ImageKitOkHttpClient; -import io.imagekit.models.SrcOptions; - -ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") - .build(); - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/image.jpg") - .build() -); -System.out.println(url); -// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg -``` - -### URL generation with transformations - -Apply common transformations like resizing, quality, and format conversion: - -```java -import io.imagekit.models.SrcOptions; -import io.imagekit.models.Transformation; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/image.jpg") - .addTransformation( - Transformation.builder() - .width(400.0) - .height(300.0) - .crop(Transformation.Crop.MAINTAIN_RATIO) - .quality(80.0) - .format(Transformation.Format.WEBP) - .build() - ) - .build() -); -System.out.println(url); -// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp -``` - -### URL generation with image overlay - -Add image overlays to your base image: - -```java -import io.imagekit.models.ImageOverlay; -import io.imagekit.models.Overlay; -import io.imagekit.models.OverlayPosition; -import io.imagekit.models.SrcOptions; -import io.imagekit.models.Transformation; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/base-image.jpg") - .addTransformation( - Transformation.builder() - .width(500.0) - .height(400.0) - .overlay(Overlay.ofImage( - ImageOverlay.builder() - .input("/path/to/overlay-logo.png") - .position(OverlayPosition.builder() - .x(10.0) - .y(10.0) - .build()) - .addTransformation( - Transformation.builder() - .width(100.0) - .height(50.0) - .build() - ) - .build() - )) - .build() - ) - .build() -); -System.out.println(url); -// Result: URL with image overlay positioned at x:10, y:10 -``` - -### URL generation with text overlay - -Add customized text overlays: - -```java -import io.imagekit.models.Overlay; -import io.imagekit.models.OverlayPosition; -import io.imagekit.models.SrcOptions; -import io.imagekit.models.TextOverlay; -import io.imagekit.models.TextOverlayTransformation; -import io.imagekit.models.Transformation; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/base-image.jpg") - .addTransformation( - Transformation.builder() - .width(600.0) - .height(400.0) - .overlay(Overlay.ofText( - TextOverlay.builder() - .text("Sample Text Overlay") - .position(OverlayPosition.builder() - .x(50.0) - .y(50.0) - .focus(OverlayPosition.Focus.CENTER) - .build()) - .addTransformation( - TextOverlayTransformation.builder() - .fontSize(40.0) - .fontFamily("Arial") - .fontColor("FFFFFF") - .build() - ) - .build() - )) - .build() - ) - .build() -); -System.out.println(url); -// Result: URL with white Arial text overlay at center position -``` - -### URL generation with multiple overlays - -Combine multiple overlays for complex compositions: - -```java -import io.imagekit.models.ImageOverlay; -import io.imagekit.models.Overlay; -import io.imagekit.models.OverlayPosition; -import io.imagekit.models.SrcOptions; -import io.imagekit.models.TextOverlay; -import io.imagekit.models.TextOverlayTransformation; -import io.imagekit.models.Transformation; -import java.util.Arrays; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/base-image.jpg") - .addTransformation( - // First transformation step: text overlay - Transformation.builder() - .width(800.0) - .height(600.0) - .overlay(Overlay.ofText( - TextOverlay.builder() - .text("Header Text") - .position(OverlayPosition.builder() - .x(20.0) - .y(20.0) - .build()) - .addTransformation( - TextOverlayTransformation.builder() - .fontSize(30.0) - .fontColor("000000") - .build() - ) - .build() - )) - .build() - ) - .addTransformation( - // Second transformation step: image watermark overlay - Transformation.builder() - .overlay(Overlay.ofImage( - ImageOverlay.builder() - .input("/watermark.png") - .position(OverlayPosition.builder() - .focus(OverlayPosition.Focus.BOTTOM_RIGHT) - .build()) - .addTransformation( - Transformation.builder() - .width(100.0) - .opacity(70.0) - .build() - ) - .build() - )) - .build() - ) - .build() -); -System.out.println(url); -// Result: URL with text overlay at top-left and semi-transparent watermark at bottom-right -``` - -### Signed URLs for secure delivery - -Generate signed URLs that expire after a specified time for secure content delivery: - -```java -import io.imagekit.models.SrcOptions; -import io.imagekit.models.Transformation; - -// Generate a signed URL that expires in 1 hour (3600 seconds) -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/private/secure-image.jpg") - .addTransformation( - Transformation.builder() - .width(400.0) - .height(300.0) - .quality(90.0) - .build() - ) - .signed(true) - .expiresIn(3600.0) // URL expires in 1 hour - .build() -); -System.out.println(url); -// Result: URL with signature parameters (?ik-t=timestamp&ik-s=signature) - -// Generate a signed URL that doesn't expire -String permanentSignedUrl = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/private/secure-image.jpg") - .signed(true) - // No expiresIn means the URL won't expire - .build() -); -System.out.println(permanentSignedUrl); -// Result: URL with signature parameter (?ik-s=signature) -``` - -## Authentication parameters for client-side uploads - -Generate authentication parameters for secure client-side file uploads: - -```java -import io.imagekit.client.ImageKitClient; -import io.imagekit.client.okhttp.ImageKitOkHttpClient; -import java.util.Map; - -ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") - .build(); - -// Generate authentication parameters with auto-generated token and default expiry -Map authParams = client.helper().getAuthenticationParameters(null, null); -System.out.println(authParams); -// Result: {token=, expire=, signature=} - -// Generate with custom token and expiry -Map customAuthParams = client.helper().getAuthenticationParameters("my-custom-token", 1800L); -System.out.println(customAuthParams); -// Result: {token=my-custom-token, expire=1800, signature=} ``` -These authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key. - -## Webhook verification - -The ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with. - -For detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature). - -# Advanced Usage - ## Client configuration Configure the client using system properties or environment variables: @@ -374,8 +78,8 @@ Configure the client using system properties or environment variables: import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); ``` @@ -386,7 +90,8 @@ import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") + .privateKey("My Private Key") + .password("My Password") .build(); ``` @@ -397,20 +102,23 @@ import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties - // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables + // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() - .privateKey("private_key_xxx") + .privateKey("My Private Key") .build(); ``` See this table for the available options: -| Setter | Environment variable | Required | Default value | -| --------------- | -------------------------------- | -------- | --------------------------- | -| `privateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | -| `webhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | -| `baseUrl` | `IMAGE_KIT_BASE_URL` | false | `"https://api.imagekit.io"` | +| Setter | System property | Environment variable | Required | Default value | +| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | +| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | +| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | +| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | + +System properties take precedence over environment variables. > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -454,16 +162,16 @@ import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.FileInputStream; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -475,16 +183,16 @@ import io.imagekit.client.ImageKitClientAsync; import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.FileInputStream; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -503,8 +211,8 @@ import io.imagekit.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() - .fileName("uploaded-image.jpg") - .file(Paths.get("/path/to/your/image.jpg")) + .fileName("fileName") + .file(Paths.get("/path/to/file")) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -514,11 +222,11 @@ Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/i ```java import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.FileInputStream; +import java.net.URL; FileUploadParams params = FileUploadParams.builder() - .fileName("uploaded-image.jpg") - .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("fileName") + .file(new URL("https://example.com//path/to/file").openStream()) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -529,10 +237,9 @@ Or a `byte[]` array: import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -byte[] imageData = /* your binary data */; FileUploadParams params = FileUploadParams.builder() - .fileName("binary-upload.jpg") - .file(imageData) + .fileName("fileName") + .file("content".getBytes()) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -543,15 +250,14 @@ Note that when passing a non-`Path` its filename is unknown so it will not be in import io.imagekit.core.MultipartField; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.FileInputStream; import java.io.InputStream; +import java.net.URL; FileUploadParams params = FileUploadParams.builder() - .fileName("custom-upload.jpg") + .fileName("fileName") .file(MultipartField.builder() - .value(new FileInputStream("/path/to/your/image.jpg")) - .filename("image.jpg") - .contentType("image/jpeg") + .value(new URL("https://example.com//path/to/file").openStream()) + .filename("/path/to/file") .build()) .build(); FileUploadResponse response = client.files().upload(params); @@ -568,11 +274,11 @@ import io.imagekit.core.http.Headers; import io.imagekit.core.http.HttpResponseFor; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.FileInputStream; +import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); diff --git a/bin/check-release-environment b/bin/check-release-environment index 273c639d..3a6a7b4a 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -2,10 +2,6 @@ errors=() -if [ -z "${RELEASE_PLEASE_TOKEN}" ]; then - errors+=("The RELEASE_PLEASE_TOKEN secret has not been set. Create a fine-grained GitHub PAT and add it as a repository secret.") -fi - if [ -z "${SONATYPE_USERNAME}" ]; then errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts index 0f1f0c0e..8f4f902a 100644 --- a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -10,7 +10,7 @@ repositories { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts index ffb5e8d6..dd476783 100644 --- a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -12,7 +12,7 @@ repositories { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } compilerOptions { diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt index 27fccef1..8b8caae8 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt @@ -308,7 +308,7 @@ class ImageKitOkHttpClient private constructor() { * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You * can find this in the * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only required if - * you are using webhooks. + * you're using webhooks. */ fun webhookSecret(webhookSecret: String?) = apply { clientOptions.webhookSecret(webhookSecret) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt index 56e9cfdc..575c8dca 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -308,7 +308,7 @@ class ImageKitOkHttpClientAsync private constructor() { * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You * can find this in the * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only required if - * you are using webhooks. + * you're using webhooks. */ fun webhookSecret(webhookSecret: String?) = apply { clientOptions.webhookSecret(webhookSecret) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt index 9a3a74ca..a1946c26 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt @@ -3,7 +3,6 @@ package io.imagekit.client import io.imagekit.core.ClientOptions -import io.imagekit.lib.HelperService import io.imagekit.services.blocking.AccountService import io.imagekit.services.blocking.AssetService import io.imagekit.services.blocking.BetaService @@ -69,8 +68,6 @@ interface ImageKitClient { fun webhooks(): WebhookService - fun helper(): HelperService - /** * Closes this client, relinquishing any underlying resources. * diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt index cba5ce63..1dd949c6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt @@ -3,7 +3,6 @@ package io.imagekit.client import io.imagekit.core.ClientOptions -import io.imagekit.lib.HelperService import io.imagekit.services.async.AccountServiceAsync import io.imagekit.services.async.AssetServiceAsync import io.imagekit.services.async.BetaServiceAsync @@ -69,8 +68,6 @@ interface ImageKitClientAsync { fun webhooks(): WebhookServiceAsync - fun helper(): HelperService - /** * Closes this client, relinquishing any underlying resources. * diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt index ef9cab34..7acd014c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt @@ -4,8 +4,6 @@ package io.imagekit.client import io.imagekit.core.ClientOptions import io.imagekit.core.getPackageVersion -import io.imagekit.lib.Helper -import io.imagekit.lib.HelperService import io.imagekit.services.async.AccountServiceAsync import io.imagekit.services.async.AccountServiceAsyncImpl import io.imagekit.services.async.AssetServiceAsync @@ -75,8 +73,6 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK WebhookServiceAsyncImpl(clientOptionsWithUserAgent) } - private val helper: Helper by lazy { Helper.create(clientOptions) } - override fun sync(): ImageKitClient = sync override fun withRawResponse(): ImageKitClientAsync.WithRawResponse = withRawResponse @@ -102,8 +98,6 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun webhooks(): WebhookServiceAsync = webhooks - override fun helper(): HelperService = helper - override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt index b8deaa48..18683fc3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt @@ -4,8 +4,6 @@ package io.imagekit.client import io.imagekit.core.ClientOptions import io.imagekit.core.getPackageVersion -import io.imagekit.lib.Helper -import io.imagekit.lib.HelperService import io.imagekit.services.blocking.AccountService import io.imagekit.services.blocking.AccountServiceImpl import io.imagekit.services.blocking.AssetService @@ -65,8 +63,6 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } - private val helper: Helper by lazy { Helper.create(clientOptions) } - override fun async(): ImageKitClientAsync = async override fun withRawResponse(): ImageKitClient.WithRawResponse = withRawResponse @@ -92,8 +88,6 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun webhooks(): WebhookService = webhooks - override fun helper(): HelperService = helper - override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt index 48c0a5ed..2897284d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt @@ -24,39 +24,45 @@ internal fun checkKnown(name: String, value: MultipartField): T = } @JvmSynthetic -internal fun checkLength(name: String, value: String, length: Int): String = value.also { - check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } -} +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } @JvmSynthetic -internal fun checkMinLength(name: String, value: String, minLength: Int): String = value.also { - check(it.length >= minLength) { - if (minLength == 1) "`$name` must be non-empty, but was empty" - else "`$name` must have at least length $minLength, but was ${it.length}" +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } } -} @JvmSynthetic -internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = value.also { - check(it.length <= maxLength) { - "`$name` must have at most length $maxLength, but was ${it.length}" +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } } -} @JvmSynthetic internal fun checkJacksonVersionCompatibility() { - val incompatibleJacksonVersions = RUNTIME_JACKSON_VERSIONS.mapNotNull { - val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] - when { - it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> - it to "incompatible major version" - it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> it to "minor version too low" - it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && - it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> it to "patch version too low" - badVersionReason != null -> it to badVersionReason - else -> null + val incompatibleJacksonVersions = + RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] + when { + it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> + it to "incompatible major version" + it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> + it to "minor version too low" + it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && + it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> + it to "patch version too low" + badVersionReason != null -> it to badVersionReason + else -> null + } } - } check(incompatibleJacksonVersions.isEmpty()) { """ This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt index 047b8564..ec7df69e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt @@ -141,7 +141,7 @@ private constructor( /** * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You can * find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only - * required if you are using webhooks. + * required if you're using webhooks. */ fun webhookSecret(): Optional = Optional.ofNullable(webhookSecret) @@ -345,7 +345,7 @@ private constructor( * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You * can find this in the * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only required if - * you are using webhooks. + * you're using webhooks. */ fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt deleted file mode 100644 index 796243ad..00000000 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt +++ /dev/null @@ -1,972 +0,0 @@ -// Package lib provides helper utilities for ImageKit SDK -// This file contains custom helper functions - not generated - -package io.imagekit.lib - -import io.imagekit.core.ClientOptions -import io.imagekit.models.SrcOptions -import io.imagekit.models.Transformation -import io.imagekit.models.TransformationPosition -import java.security.SecureRandom -import java.time.Instant -import javax.crypto.Mac -import javax.crypto.spec.SecretKeySpec - -/** - * Helper service containing utility methods for ImageKit SDK operations like URL building, - * transformation string generation, and authentication parameter generation. - */ -class Helper(private val privateKey: String) : HelperService { - - companion object { - private const val DEFAULT_TIMESTAMP = 9999999999L - - /** - * Creates a new Helper instance with the given private key. - * - * @param privateKey The private API key from ImageKit dashboard - * @return A new Helper instance - */ - @JvmStatic fun create(privateKey: String): Helper = Helper(privateKey) - - /** - * Creates a new Helper instance from ClientOptions. - * - * @param options The client options containing the private key - * @return A new Helper instance - */ - @JvmStatic fun create(options: ClientOptions): Helper = Helper(options.privateKey) - } - - /** - * Builds a URL with the given options including transformations. - * - * @param options The source options for URL generation - * @return The generated URL string - */ - override fun buildUrl(options: SrcOptions): String { - val urlEndpoint = options.urlEndpoint() - val src = options.src() - - if (src.isEmpty()) { - return "" - } - - val transformationPosition = - options.transformationPosition().orElse(TransformationPosition.QUERY) - - val isAbsoluteURL = src.startsWith("http://") || src.startsWith("https://") - - val urlObj: java.net.URL - val isSrcParameterUsedForURL: Boolean - - try { - if (!isAbsoluteURL) { - urlObj = java.net.URL(urlEndpoint) - isSrcParameterUsedForURL = false - } else { - urlObj = java.net.URL(src) - isSrcParameterUsedForURL = true - } - } catch (e: Exception) { - return "" - } - - // Extract existing query parameters from URL if present - val existingQuery = - if (isSrcParameterUsedForURL && urlObj.query != null) { - urlObj.query - } else { - "" - } - - // Build query parameters - val queryParts = mutableListOf() - - // Add existing query parameters first - if (existingQuery.isNotEmpty()) { - queryParts.add(existingQuery) - } - - // Add new query parameters (sorted alphabetically for consistent signing) - options.queryParameters().ifPresent { queryParams -> - val params = queryParams._additionalProperties() - if (params.isNotEmpty()) { - val newQuery = - params.entries - .sortedBy { it.key } // Sort alphabetically by key - .joinToString("&") { (key, value) -> - val valueStr = - value.asString().orElseGet { - value - .asNumber() - .map { it.toString() } - .orElseGet { - value - .asBoolean() - .map { it.toString() } - .orElse(value.toString()) - } - } - "${java.net.URLEncoder.encode(key, "UTF-8")}=${java.net.URLEncoder.encode(valueStr, "UTF-8")}" - } - queryParts.add(newQuery) - } - } - - val query = queryParts.joinToString("&") - - // Build transformation string - val transformationString = - options.transformation().map { buildTransformationString(it) }.orElse("") - - // Determine if transformation will be in query params - val addAsQuery = - transformationPosition == TransformationPosition.QUERY || isSrcParameterUsedForURL - - // Transformation placeholder to avoid URL encoding issues - val transformationPlaceholder = "PLEASEREPLACEJUSTBEFORESIGN" - - // Build the URL path - var path = "" - if (!isAbsoluteURL) { - // For non-absolute URLs, construct: endpoint_path + transformations + src - val endpointPath = urlObj.path.ifEmpty { "/" } - val pathParts = mutableListOf() - pathParts.add(endpointPath) - - if (transformationString.isNotEmpty() && !addAsQuery) { - pathParts.add("tr:$transformationPlaceholder") - } - pathParts.add(src) - - path = pathParts.joinToString("/") { it.trim('/') }.replace(Regex("/+"), "/") - if (!path.startsWith("/")) { - path = "/$path" - } - } else { - path = urlObj.path - } - - // Build the complete URL using URI to properly encode the path - val uriString = - try { - java.net - .URI( - urlObj.protocol, - null, // user info - urlObj.host, - if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) urlObj.port - else -1, - path, - null, // query will be added later - null, // fragment - ) - .toASCIIString() - } catch (e: Exception) { - // Fallback to manual construction - "${urlObj.protocol}://${urlObj.host}${if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) ":${urlObj.port}" else ""}$path" - } - - var finalURL = uriString - - // Add query parameters - if (query.isNotEmpty()) { - finalURL += "?$query" - } - - // Add transformation parameter to query if needed - if (transformationString.isNotEmpty() && addAsQuery) { - val separator = if (query.isEmpty()) "?" else "&" - finalURL += "${separator}tr=$transformationPlaceholder" - } - - // Replace the placeholder with actual transformation string - if (transformationString.isNotEmpty()) { - finalURL = finalURL.replace(transformationPlaceholder, transformationString) - } - - // Sign the URL if needed - val shouldSign = options.signed().orElse(false) || (options.expiresIn().orElse(0.0) > 0) - if (shouldSign) { - val expiryTimestamp = getSignatureTimestamp(options.expiresIn().orElse(0.0)) - val urlSignature = getSignature(finalURL, urlEndpoint, expiryTimestamp) - - val hasExistingParams = finalURL.contains("?") - val separator = if (hasExistingParams) "&" else "?" - - if (expiryTimestamp != DEFAULT_TIMESTAMP) { - finalURL += "${separator}ik-t=$expiryTimestamp&ik-s=$urlSignature" - } else { - finalURL += "${separator}ik-s=$urlSignature" - } - } - - return finalURL - } - - private fun getSignatureTimestamp(expiresIn: Double): Long { - return if (expiresIn > 0) { - Instant.now().epochSecond + expiresIn.toLong() - } else { - DEFAULT_TIMESTAMP - } - } - - private fun getSignature(finalURL: String, urlEndpoint: String, expiryTimestamp: Long): String { - if (privateKey.isEmpty() || finalURL.isEmpty() || urlEndpoint.isEmpty()) { - return "" - } - - // Create the string to sign: relative path + expiry timestamp - val urlEndpointWithSlash = if (urlEndpoint.endsWith("/")) urlEndpoint else "$urlEndpoint/" - val stringToSign = - finalURL.replaceFirst(urlEndpointWithSlash, "") + expiryTimestamp.toString() - - val mac = Mac.getInstance("HmacSHA1") - val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") - mac.init(secretKey) - val hash = mac.doFinal(stringToSign.toByteArray()) - - return hash.joinToString("") { "%02x".format(it) } - } - - /** - * Builds a transformation string from the given transformations. - * - * @param transformations The list of transformations - * @return The transformation string - */ - override fun buildTransformationString(transformations: List?): String { - if (transformations.isNullOrEmpty()) { - return "" - } - - val parsedTransforms = mutableListOf() - - for (transform in transformations) { - val parts = mutableListOf() - - // Basic transformations (in order from Go SDK) - - // Width - transform.width().ifPresent { w -> - when { - w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") - w.isString() -> parts.add("w-${w.asString()}") - } - } - - // Height - transform.height().ifPresent { h -> - when { - h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") - h.isString() -> parts.add("h-${h.asString()}") - } - } - - // Quality - transform.quality().ifPresent { q -> parts.add("q-${formatNumber(q)}") } - - // Aspect Ratio - transform.aspectRatio().ifPresent { ar -> - when { - ar.isNumber() -> parts.add("ar-${formatNumber(ar.asNumber())}") - ar.isString() -> parts.add("ar-${ar.asString()}") - } - } - - // Crop - transform.crop().ifPresent { c -> if (c.toString().isNotEmpty()) parts.add("c-$c") } - - // Crop Mode - transform.cropMode().ifPresent { cm -> - if (cm.toString().isNotEmpty()) parts.add("cm-$cm") - } - - // Focus - transform.focus().ifPresent { fo -> parts.add("fo-$fo") } - - // Format - transform.format().ifPresent { f -> if (f.toString().isNotEmpty()) parts.add("f-$f") } - - // Radius - transform.radius().ifPresent { r -> - when { - r.isMax() -> parts.add("r-max") - r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") - r.isString() -> parts.add("r-${r.asString()}") - } - } - - // Background - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - - // Border - transform.border().ifPresent { b -> parts.add("b-$b") } - - // Color Replace - transform.colorReplace().ifPresent { cr -> parts.add("cr-$cr") } - - // Default Image - transform.defaultImage().ifPresent { di -> - if (di.isNotEmpty()) { - val value = di.removePrefix("/").removeSuffix("/").replace("/", "@@") - parts.add("di-$value") - } - } - - // DPR - transform.dpr().ifPresent { dpr -> parts.add("dpr-${formatNumber(dpr)}") } - - // X position - transform.x().ifPresent { x -> - when { - x.isNumber() -> parts.add("x-${formatNumber(x.asNumber())}") - x.isString() -> parts.add("x-${x.asString()}") - } - } - - // Y position - transform.y().ifPresent { y -> - when { - y.isNumber() -> parts.add("y-${formatNumber(y.asNumber())}") - y.isString() -> parts.add("y-${y.asString()}") - } - } - - // X Center - transform.xCenter().ifPresent { xc -> - when { - xc.isNumber() -> parts.add("xc-${formatNumber(xc.asNumber())}") - xc.isString() -> parts.add("xc-${xc.asString()}") - } - } - - // Y Center - transform.yCenter().ifPresent { yc -> - when { - yc.isNumber() -> parts.add("yc-${formatNumber(yc.asNumber())}") - yc.isString() -> parts.add("yc-${yc.asString()}") - } - } - - // Opacity - transform.opacity().ifPresent { o -> parts.add("o-${formatNumber(o)}") } - - // Zoom - transform.zoom().ifPresent { z -> parts.add("z-${formatNumber(z)}") } - - // Rotation - transform.rotation().ifPresent { rt -> - when { - rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") - rt.isString() -> parts.add("rt-${rt.asString()}") - } - } - - // Blur - transform.blur().ifPresent { bl -> parts.add("bl-${formatNumber(bl)}") } - - // Named - transform.named().ifPresent { n -> parts.add("n-$n") } - - // Progressive - transform.progressive().ifPresent { pr -> parts.add("pr-$pr") } - - // Lossless - transform.lossless().ifPresent { lo -> parts.add("lo-$lo") } - - // Flip - transform.flip().ifPresent { fl -> if (fl.toString().isNotEmpty()) parts.add("fl-$fl") } - - // Trim - transform.trim().ifPresent { t -> - when { - t.isTrue() -> parts.add("t-true") - t.isNumber() -> parts.add("t-${formatNumber(t.asNumber())}") - } - } - - // Metadata - transform.metadata().ifPresent { md -> parts.add("md-$md") } - - // Color Profile - transform.colorProfile().ifPresent { cp -> parts.add("cp-$cp") } - - // Video Codec - transform.videoCodec().ifPresent { vc -> - if (vc.toString().isNotEmpty()) parts.add("vc-$vc") - } - - // Audio Codec - transform.audioCodec().ifPresent { ac -> - if (ac.toString().isNotEmpty()) parts.add("ac-$ac") - } - - // Start Offset - transform.startOffset().ifPresent { so -> - when { - so.isNumber() -> parts.add("so-${formatNumber(so.asNumber())}") - so.isString() -> parts.add("so-${so.asString()}") - } - } - - // End Offset - transform.endOffset().ifPresent { eo -> - when { - eo.isNumber() -> parts.add("eo-${formatNumber(eo.asNumber())}") - eo.isString() -> parts.add("eo-${eo.asString()}") - } - } - - // Duration - transform.duration().ifPresent { du -> - when { - du.isNumber() -> parts.add("du-${formatNumber(du.asNumber())}") - du.isString() -> parts.add("du-${du.asString()}") - } - } - - // Streaming Resolutions - transform.streamingResolutions().ifPresent { resolutions -> - if (resolutions.isNotEmpty()) { - val sr = resolutions.joinToString("_") - parts.add("sr-$sr") - } - } - - // AI transformations (boolean flags) - transform.grayscale().ifPresent { gs -> if (gs.asBoolean()) parts.add("e-grayscale") } - transform.aiUpscale().ifPresent { au -> if (au.asBoolean()) parts.add("e-upscale") } - transform.aiRetouch().ifPresent { ar -> if (ar.asBoolean()) parts.add("e-retouch") } - transform.aiVariation().ifPresent { av -> if (av.asBoolean()) parts.add("e-genvar") } - transform.aiRemoveBackground().ifPresent { rb -> - if (rb.asBoolean()) parts.add("e-bgremove") - } - transform.aiRemoveBackgroundExternal().ifPresent { re -> - if (re.asBoolean()) parts.add("e-removedotbg") - } - transform.contrastStretch().ifPresent { cs -> - if (cs.asBoolean()) parts.add("e-contrast") - } - - // AI Drop Shadow - transform.aiDropShadow().ifPresent { ds -> - when { - ds.isTrue() -> parts.add("e-dropshadow") - ds.isString() -> parts.add("e-dropshadow-${ds.asString()}") - } - } - - // AI Change Background - transform.aiChangeBackground().ifPresent { bg -> parts.add("e-changebg-$bg") } - - // AI Edit - transform.aiEdit().ifPresent { edit -> parts.add("e-edit-$edit") } - - // Effects - transform.shadow().ifPresent { s -> - when { - s.isTrue() -> parts.add("e-shadow") - s.isString() -> parts.add("e-shadow-${s.asString()}") - } - } - - transform.sharpen().ifPresent { sh -> - when { - sh.isTrue() -> parts.add("e-sharpen") - sh.isNumber() -> parts.add("e-sharpen-${formatNumber(sh.asNumber())}") - } - } - - transform.unsharpMask().ifPresent { usm -> - when { - usm.isTrue() -> parts.add("e-usm") - usm.isString() -> parts.add("e-usm-${usm.asString()}") - } - } - - transform.gradient().ifPresent { gr -> - when { - gr.isTrue() -> parts.add("e-gradient") - gr.isString() -> parts.add("e-gradient-${gr.asString()}") - } - } - - transform.colorize().ifPresent { co -> parts.add("e-colorize-$co") } - - transform.distort().ifPresent { d -> parts.add("e-distort-$d") } - - // Original - transform.original().ifPresent { orig -> if (orig) parts.add("orig-true") } - - // Page - transform.page().ifPresent { pg -> - when { - pg.isNumber() -> parts.add("pg-${formatNumber(pg.asNumber())}") - pg.isString() -> parts.add("pg-${pg.asString()}") - } - } - - // Overlay - transform.overlay().ifPresent { overlay -> - val overlayStr = processOverlay(overlay) - if (overlayStr.isNotEmpty()) { - parts.add(overlayStr) - } - } - - // Raw parameter (added last) - transform.raw().ifPresent { raw -> - if (raw.isNotEmpty()) { - parts.add(raw) - } - } - - if (parts.isNotEmpty()) { - parsedTransforms.add(parts.joinToString(",")) - } - } - - return parsedTransforms.joinToString(":") - } - - private fun formatNumber(value: Double): String { - return if (value == value.toLong().toDouble()) { - value.toLong().toString() - } else { - value.toString() - } - } - - private val simpleOverlayPathRegex = Regex("^[a-zA-Z0-9\\-._/ ]*$") - private val simpleOverlayTextRegex = Regex("^[a-zA-Z0-9\\-._ ]*$") - - private fun processOverlay(overlay: io.imagekit.models.Overlay): String { - val entries = mutableListOf() - var transformationString = "" - - // Each branch: add layer type + input, extract base overlay fields, build transformation - // string - var layerMode: String? = null - var position: io.imagekit.models.OverlayPosition? = null - var timing: io.imagekit.models.OverlayTiming? = null - - when { - overlay.isText() -> { - val textOverlay = overlay.asText() - if (textOverlay.text().isEmpty()) return "" - - val encoding = - textOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-text") - entries.add(processText(textOverlay.text(), encoding)) - - textOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - textOverlay.position().ifPresent { position = it } - textOverlay.timing().ifPresent { timing = it } - - textOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildTextOverlayTransformation(transformations) - } - } - } - - overlay.isImage() -> { - val imageOverlay = overlay.asImage() - if (imageOverlay.input().isEmpty()) return "" - - val encoding = - imageOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-image") - entries.add(processInputPath(imageOverlay.input(), encoding)) - - imageOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - imageOverlay.position().ifPresent { position = it } - imageOverlay.timing().ifPresent { timing = it } - - imageOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildTransformationString(transformations) - } - } - } - - overlay.isVideo() -> { - val videoOverlay = overlay.asVideo() - if (videoOverlay.input().isEmpty()) return "" - - val encoding = - videoOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-video") - entries.add(processInputPath(videoOverlay.input(), encoding)) - - videoOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - videoOverlay.position().ifPresent { position = it } - videoOverlay.timing().ifPresent { timing = it } - - videoOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildTransformationString(transformations) - } - } - } - - overlay.isSubtitle() -> { - val subtitleOverlay = overlay.asSubtitle() - if (subtitleOverlay.input().isEmpty()) return "" - - val encoding = - subtitleOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-subtitles") - entries.add(processInputPath(subtitleOverlay.input(), encoding)) - - subtitleOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - subtitleOverlay.position().ifPresent { position = it } - subtitleOverlay.timing().ifPresent { timing = it } - - subtitleOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildSubtitleOverlayTransformation(transformations) - } - } - } - - overlay.isSolidColor() -> { - val solidColorOverlay = overlay.asSolidColor() - if (solidColorOverlay.color().isEmpty()) return "" - - entries.add("l-image") - entries.add("i-ik_canvas") - entries.add("bg-${solidColorOverlay.color()}") - - solidColorOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - solidColorOverlay.position().ifPresent { position = it } - solidColorOverlay.timing().ifPresent { timing = it } - - solidColorOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildSolidColorOverlayTransformation(transformations) - } - } - } - } - - if (entries.isEmpty()) return "" - - // Shared base overlay processing (matches Go's order) - // LayerMode - if (!layerMode.isNullOrEmpty()) { - entries.add("lm-$layerMode") - } - - // Position - if (position != null) { - processOverlayPosition(position!!, entries) - } - - // Timing - if (timing != null) { - processOverlayTiming(timing!!, entries) - } - - // Transformation string - if (transformationString.isNotEmpty()) { - entries.add(transformationString) - } - - // Close layer - entries.add("l-end") - return entries.joinToString(",") - } - - private fun processInputPath(str: String, encoding: String): String { - val cleaned = str.removePrefix("/").removeSuffix("/") - - if (encoding == "plain") { - return "i-${cleaned.replace("/", "@@")}" - } - - if (encoding == "base64") { - val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - // Auto-detect - if (simpleOverlayPathRegex.matches(cleaned)) { - return "i-${cleaned.replace("/", "@@")}" - } - - val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - private fun processText(str: String, encoding: String): String { - if (encoding == "plain") { - return "i-${pathEscape(str)}" - } - - if (encoding == "base64") { - val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - // Auto-detect - if (simpleOverlayTextRegex.matches(str)) { - return "i-${pathEscape(str)}" - } - - val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - /** Equivalent to Go's url.PathEscape — encodes for use in URL path segments */ - private fun pathEscape(str: String): String { - return java.net.URI(null, null, "/$str", null).toASCIIString().removePrefix("/") - } - - private fun buildTextOverlayTransformation( - transformations: List - ): String { - val entries = mutableListOf() - for (transform in transformations) { - processTextOverlayTransformation(transform, entries) - } - return entries.joinToString(",") - } - - private fun buildSubtitleOverlayTransformation( - transformations: List - ): String { - val entries = mutableListOf() - for (transform in transformations) { - processSubtitleOverlayTransformation(transform, entries) - } - return entries.joinToString(",") - } - - private fun buildSolidColorOverlayTransformation( - transformations: List - ): String { - val entries = mutableListOf() - for (transform in transformations) { - processSolidColorOverlayTransformation(transform, entries) - } - return entries.joinToString(",") - } - - private fun processTextOverlayTransformation( - transform: io.imagekit.models.TextOverlayTransformation, - parts: MutableList, - ) { - transform.width().ifPresent { w -> - when { - w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") - w.isString() -> parts.add("w-${w.asString()}") - } - } - transform.fontSize().ifPresent { fs -> - when { - fs.isNumber() -> parts.add("fs-${formatNumber(fs.asNumber())}") - fs.isString() -> parts.add("fs-${fs.asString()}") - } - } - transform.fontFamily().ifPresent { ff -> - val cleaned = ff.removePrefix("/").removeSuffix("/").replace("/", "@@") - parts.add("ff-$cleaned") - } - transform.fontColor().ifPresent { fc -> parts.add("co-$fc") } - transform.innerAlignment().ifPresent { ia -> parts.add("ia-${ia.toString().lowercase()}") } - transform.padding().ifPresent { p -> - when { - p.isNumber() -> parts.add("pa-${formatNumber(p.asNumber())}") - p.isString() -> parts.add("pa-${p.asString()}") - } - } - transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } - transform.typography().ifPresent { t -> parts.add("tg-$t") } - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - transform.radius().ifPresent { r -> - when { - r.isMax() -> parts.add("r-max") - r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") - r.isString() -> parts.add("r-${r.asString()}") - } - } - transform.rotation().ifPresent { rt -> - when { - rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") - rt.isString() -> parts.add("rt-${rt.asString()}") - } - } - transform.flip().ifPresent { fl -> parts.add("fl-${fl.toString().lowercase()}") } - transform.lineHeight().ifPresent { lh -> - when { - lh.isNumber() -> parts.add("lh-${formatNumber(lh.asNumber())}") - lh.isString() -> parts.add("lh-${lh.asString()}") - } - } - } - - private fun processSolidColorOverlayTransformation( - transform: io.imagekit.models.SolidColorOverlayTransformation, - parts: MutableList, - ) { - transform.width().ifPresent { w -> - when { - w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") - w.isString() -> parts.add("w-${w.asString()}") - } - } - transform.height().ifPresent { h -> - when { - h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") - h.isString() -> parts.add("h-${h.asString()}") - } - } - transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - transform.gradient().ifPresent { g -> - when { - g.isTrue() -> parts.add("e-gradient") - g.isString() -> parts.add("e-gradient-${g.asString()}") - } - } - transform.radius().ifPresent { r -> - when { - r.isMax() -> parts.add("r-max") - r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") - r.isString() -> parts.add("r-${r.asString()}") - } - } - } - - private fun processSubtitleOverlayTransformation( - transform: io.imagekit.models.SubtitleOverlayTransformation, - parts: MutableList, - ) { - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - transform.color().ifPresent { c -> parts.add("co-$c") } - transform.fontSize().ifPresent { fs -> parts.add("fs-${formatNumber(fs)}") } - transform.fontFamily().ifPresent { ff -> parts.add("ff-$ff") } - transform.fontOutline().ifPresent { fo -> parts.add("fol-$fo") } - transform.fontShadow().ifPresent { fs -> parts.add("fsh-$fs") } - transform.typography().ifPresent { tg -> parts.add("tg-$tg") } - } - - private fun processOverlayPosition( - position: io.imagekit.models.OverlayPosition, - parts: MutableList, - ) { - position.x().ifPresent { x -> - when { - x.isNumber() -> parts.add("lx-${formatNumber(x.asNumber())}") - x.isString() -> parts.add("lx-${x.asString()}") - } - } - position.y().ifPresent { y -> - when { - y.isNumber() -> parts.add("ly-${formatNumber(y.asNumber())}") - y.isString() -> parts.add("ly-${y.asString()}") - } - } - position.xCenter().ifPresent { xc -> - when { - xc.isNumber() -> parts.add("lxc-${formatNumber(xc.asNumber())}") - xc.isString() -> parts.add("lxc-${xc.asString()}") - } - } - position.yCenter().ifPresent { yc -> - when { - yc.isNumber() -> parts.add("lyc-${formatNumber(yc.asNumber())}") - yc.isString() -> parts.add("lyc-${yc.asString()}") - } - } - position.anchorPoint().ifPresent { ap -> parts.add("lap-${ap.toString().lowercase()}") } - position.focus().ifPresent { f -> parts.add("lfo-${f.toString().lowercase()}") } - } - - private fun processOverlayTiming( - timing: io.imagekit.models.OverlayTiming, - parts: MutableList, - ) { - timing.start().ifPresent { s -> - when { - s.isNumber() -> parts.add("lso-${formatNumber(s.asNumber())}") - s.isString() -> parts.add("lso-${s.asString()}") - } - } - timing.end().ifPresent { e -> - when { - e.isNumber() -> parts.add("leo-${formatNumber(e.asNumber())}") - e.isString() -> parts.add("leo-${e.asString()}") - } - } - timing.duration().ifPresent { d -> - when { - d.isNumber() -> parts.add("ldu-${formatNumber(d.asNumber())}") - d.isString() -> parts.add("ldu-${d.asString()}") - } - } - } - - /** - * Generates authentication parameters for client-side file uploads. - * - * @param token Optional custom token. If null or empty, a random token will be generated. - * @param expire Optional expiration timestamp in seconds. If 0 or null, defaults to 30 minutes - * from now. - * @return Map containing token, expire, and signature - */ - override fun getAuthenticationParameters(token: String?, expire: Long?): Map { - if (privateKey.isEmpty()) { - throw IllegalStateException( - "private API key is required for authentication parameters generation" - ) - } - - val defaultExpire = Instant.now().epochSecond + (60 * 30) // 30 minutes - val finalToken = - if (token.isNullOrEmpty()) { - generateToken() - } else { - token - } - - val finalExpire = - if (expire == null || expire == 0L) { - defaultExpire - } else { - expire - } - - val signature = getAuthenticationSignature(finalToken, finalExpire, privateKey) - - return mapOf("token" to finalToken, "expire" to finalExpire, "signature" to signature) - } - - // Private helper methods - - private fun getAuthenticationSignature( - token: String, - expire: Long, - privateKey: String, - ): String { - val signatureString = "$token$expire" - val mac = Mac.getInstance("HmacSHA1") - val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") - mac.init(secretKey) - val hash = mac.doFinal(signatureString.toByteArray()) - - return hash.joinToString("") { "%02x".format(it) } - } - - private fun generateToken(): String { - val random = SecureRandom() - val bytes = ByteArray(16) - random.nextBytes(bytes) - return bytes.joinToString("") { "%02x".format(it) } - } -} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt deleted file mode 100644 index 57cfb063..00000000 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.models.SrcOptions -import io.imagekit.models.Transformation - -/** - * Helper service interface for ImageKit SDK operations like URL building, transformation string - * generation, and authentication parameter generation. - * - * You should not instantiate this service directly, and instead use it via the client: - * ```java - * ImageKitClient client = ImageKitOkHttpClient.builder() - * .privateKey("private_key_xxx") - * .build(); - * - * String url = client.helper().buildUrl(srcOptions); - * ``` - */ -interface HelperService { - - fun buildUrl(options: SrcOptions): String - - fun buildTransformationString(transformations: List?): String - - fun getAuthenticationParameters(token: String? = null, expire: Long? = null): Map -} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt index 9b98b065..851e9de2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt @@ -315,11 +315,9 @@ private constructor( * An enum containing [LayerMode]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LayerMode] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt index f445553d..0198066b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt @@ -99,9 +99,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt index 6111757e..9257c90e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt @@ -101,9 +101,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt index d8ab909c..41001c11 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt @@ -1063,11 +1063,9 @@ private constructor( * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Name] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3741,9 +3739,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 override fun visitMixed(mixed: List) = - mixed.sumOf { - it.validity().toInt() - } + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -5080,9 +5076,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 override fun visitMixed(mixed: List) = - mixed.sumOf { - it.validity().toInt() - } + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -6417,9 +6411,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 override fun visitMixed(mixed: List) = - mixed.sumOf { - it.validity().toInt() - } + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt index 705e37fb..aa138b3a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt @@ -1089,11 +1089,9 @@ private constructor( * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Name] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3767,9 +3765,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 override fun visitMixed(mixed: List) = - mixed.sumOf { - it.validity().toInt() - } + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -5106,9 +5102,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 override fun visitMixed(mixed: List) = - mixed.sumOf { - it.validity().toInt() - } + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -6443,9 +6437,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 override fun visitMixed(mixed: List) = - mixed.sumOf { - it.validity().toInt() - } + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt index e7e70737..790c058f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt @@ -202,7 +202,6 @@ private constructor( /** * The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) 50vw, * 100vw"`). - * * - If it includes one or more `vw` units, breakpoints smaller than the corresponding * percentage of the smallest device width are excluded. * - If it contains no `vw` units, the full breakpoint list is used. @@ -586,7 +585,6 @@ private constructor( /** * The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) 50vw, * 100vw"`). - * * - If it includes one or more `vw` units, breakpoints smaller than the corresponding * percentage of the smallest device width are excluded. * - If it contains no `vw` units, the full breakpoint list is used. diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt index be16aaac..a06b2211 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt @@ -517,11 +517,9 @@ private constructor( * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Encoding] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt index 09db8abf..9c76769d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt @@ -463,11 +463,9 @@ private constructor( * An enum containing [AnchorPoint]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AnchorPoint] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -650,11 +648,9 @@ private constructor( * An enum containing [Focus]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Focus] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt index b80af2c9..cd10e154 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt @@ -106,9 +106,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt index ddc738d0..d97593a0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt @@ -517,9 +517,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -962,9 +961,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitMax(max: JsonValue) = max.let { - if (it == JsonValue.from("max")) 1 else 0 - } + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } override fun visitString(string: String) = 1 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt index 392b72e5..afe64575 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt @@ -582,9 +582,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt index 5b2a0202..ca27cd57 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt @@ -57,11 +57,9 @@ class StreamingResolution @JsonCreator private constructor(private val value: Js * An enum containing [StreamingResolution]'s known values, as well as an [_UNKNOWN] member. * * An instance of [StreamingResolution] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the SDK * is on an older version than the API, then the API may respond with new members that the SDK * is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt index 21e45f07..cc1fb9f5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt @@ -511,11 +511,9 @@ private constructor( * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Encoding] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt index 0cc3d0e0..fce2b9d9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt @@ -501,11 +501,9 @@ private constructor( * An enum containing [Typography]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Typography] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt index 4e3c8d00..34bad4f7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt @@ -512,11 +512,9 @@ private constructor( * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Encoding] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt index ab4292e6..9b8f019a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt @@ -751,11 +751,9 @@ private constructor( * An enum containing [Flip]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Flip] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1111,11 +1109,9 @@ private constructor( * An enum containing [InnerAlignment]'s known values, as well as an [_UNKNOWN] member. * * An instance of [InnerAlignment] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1776,9 +1772,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitMax(max: JsonValue) = max.let { - if (it == JsonValue.from("max")) 1 else 0 - } + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } override fun visitString(string: String) = 1 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt index 5232c39e..5bc3343c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt @@ -2857,9 +2857,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -2998,11 +2997,9 @@ private constructor( * An enum containing [AiRemoveBackground]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiRemoveBackground] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3139,11 +3136,9 @@ private constructor( * * An instance of [AiRemoveBackgroundExternal] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3276,11 +3271,9 @@ private constructor( * An enum containing [AiRetouch]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiRetouch] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3411,11 +3404,9 @@ private constructor( * An enum containing [AiUpscale]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiUpscale] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3549,11 +3540,9 @@ private constructor( * An enum containing [AiVariation]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiVariation] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -3904,11 +3893,9 @@ private constructor( * An enum containing [AudioCodec]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AudioCodec] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -4049,11 +4036,9 @@ private constructor( * An enum containing [ContrastStretch]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ContrastStretch] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -4200,11 +4185,9 @@ private constructor( * An enum containing [Crop]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Crop] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -4363,11 +4346,9 @@ private constructor( * An enum containing [CropMode]'s known values, as well as an [_UNKNOWN] member. * * An instance of [CropMode] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -4945,11 +4926,9 @@ private constructor( * An enum containing [Flip]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Flip] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -5124,11 +5103,9 @@ private constructor( * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Format] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -5374,9 +5351,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -5512,11 +5488,9 @@ private constructor( * An enum containing [Grayscale]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Grayscale] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -6166,9 +6140,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitMax(max: JsonValue) = max.let { - if (it == JsonValue.from("max")) 1 else 0 - } + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } override fun visitString(string: String) = 1 @@ -6613,9 +6586,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -6833,9 +6805,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitNumber(number: Double) = 1 @@ -7268,9 +7239,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitNumber(number: Double) = 1 @@ -7487,9 +7457,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitTrue(true_: JsonValue) = true_.let { - if (it == JsonValue.from(true)) 1 else 0 - } + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -7635,11 +7604,9 @@ private constructor( * An enum containing [VideoCodec]'s known values, as well as an [_UNKNOWN] member. * * An instance of [VideoCodec] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt index 15dbcbc0..83704298 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt @@ -44,11 +44,9 @@ private constructor(private val value: JsonField) : Enum { * An enum containing [TransformationPosition]'s known values, as well as an [_UNKNOWN] member. * * An instance of [TransformationPosition] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the SDK * is on an older version than the API, then the API may respond with new members that the SDK * is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt index 3cb7bc9f..1184c502 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt @@ -513,11 +513,9 @@ private constructor( * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Encoding] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt index 48b42555..6dd926dd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -460,13 +460,11 @@ private constructor( object : Visitor { override fun visitCloudinary(cloudinary: Cloudinary) = cloudinary.validity() - override fun visitImgix(imgix: JsonValue) = imgix.let { - if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 - } + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: JsonValue) = akamai.let { - if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 - } + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt index 32cd4ba6..0750882e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -518,13 +518,11 @@ private constructor( object : Visitor { override fun visitCloudinary(cloudinary: Cloudinary) = cloudinary.validity() - override fun visitImgix(imgix: JsonValue) = imgix.let { - if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 - } + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: JsonValue) = akamai.let { - if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 - } + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt index aefa188d..aa2572ca 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt @@ -33,7 +33,6 @@ private constructor( /** * Filter results by file type. - * * - `all` — include all file types * - `image` — include only image files * - `non-image` — include only non-image files (e.g., JS, CSS, video) @@ -59,7 +58,6 @@ private constructor( * * Note : When the searchQuery parameter is present, the following query parameters will have no * effect on the result: - * * 1. `tags` * 2. `type` * 3. `name` @@ -78,7 +76,6 @@ private constructor( /** * Filter results by asset type. - * * - `file` — returns only files * - `file-version` — returns specific file versions * - `folder` — returns only folders @@ -130,7 +127,6 @@ private constructor( /** * Filter results by file type. - * * - `all` — include all file types * - `image` — include only image files * - `non-image` — include only non-image files (e.g., JS, CSS, video) @@ -172,7 +168,6 @@ private constructor( * * Note : When the searchQuery parameter is present, the following query parameters will * have no effect on the result: - * * 1. `tags` * 2. `type` * 3. `name` @@ -207,7 +202,6 @@ private constructor( /** * Filter results by asset type. - * * - `file` — returns only files * - `file-version` — returns specific file versions * - `folder` — returns only folders @@ -353,7 +347,6 @@ private constructor( /** * Filter results by file type. - * * - `all` — include all file types * - `image` — include only image files * - `non-image` — include only non-image files (e.g., JS, CSS, video) @@ -392,11 +385,9 @@ private constructor( * An enum containing [FileType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FileType] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -570,11 +561,9 @@ private constructor( * An enum containing [Sort]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Sort] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -715,7 +704,6 @@ private constructor( /** * Filter results by asset type. - * * - `file` — returns only files * - `file-version` — returns specific file versions * - `folder` — returns only folders @@ -758,11 +746,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt index 780e8629..a2572b32 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt @@ -7,7 +7,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize import io.imagekit.core.BaseSerializer @@ -22,7 +21,6 @@ import io.imagekit.core.checkRequired import io.imagekit.core.getOrThrow import io.imagekit.core.http.Headers import io.imagekit.core.http.QueryParams -import io.imagekit.core.jsonMapper import io.imagekit.core.toImmutable import io.imagekit.errors.ImageKitInvalidDataException import io.imagekit.models.ExtensionItem @@ -52,7 +50,6 @@ import kotlin.io.path.name * **Version limit** \ A file can have a maximum of 100 versions. * * **Demo applications** - * * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), * supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. @@ -66,7 +63,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -116,7 +112,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and width and * height of the area of interest in the format `x,y,width,height`. For example - * `10,10,100,100` @@ -246,10 +241,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file * size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions (like * video encodes or thumbnails) in advance, so they're ready for delivery without delay. * @@ -491,7 +484,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -512,7 +504,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -524,7 +515,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -584,7 +574,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and width * and height of the area of interest in the format `x,y,width,height`. For example - * `10,10,100,100` @@ -888,10 +877,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing * file size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions * (like video encodes or thumbnails) in advance, so they're ready for delivery without * delay. @@ -1095,9 +1082,9 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _toJsonString(_customMetadata()), + "customMetadata" to _customMetadata(), "description" to _description(), - "extensions" to _toJsonString(_extensions()), + "extensions" to _extensions(), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1105,44 +1092,14 @@ private constructor( "overwriteCustomMetadata" to _overwriteCustomMetadata(), "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), - "responseFields" to _toCommaSeparated(_responseFields()), - "tags" to _toCommaSeparated(_tags()), - "transformation" to _toJsonString(_transformation()), + "responseFields" to _responseFields(), + "tags" to _tags(), + "transformation" to _transformation(), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() - private fun _toJsonString(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val jsonString = jsonMapper().writeValueAsString(field.value) - return MultipartField.of(jsonString) - } - - private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val mapper = jsonMapper() - val node = mapper.valueToTree(field.value) - if (!node.isArray) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val csv = - node - .elements() - .asSequence() - .filter { !it.isNull && !it.isMissingNode } - .map { it.asText() } - .joinToString(",") - return MultipartField.of(csv) - } - override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @@ -1174,7 +1131,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1224,7 +1180,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and width * and height of the area of interest in the format `x,y,width,height`. For example - * `10,10,100,100` @@ -1359,10 +1314,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing * file size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions * (like video encodes or thumbnails) in advance, so they're ready for delivery without * delay. @@ -1663,7 +1616,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1684,7 +1636,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1696,7 +1647,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1767,7 +1717,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and * width and height of the area of interest in the format `x,y,width,height`. For * example - `10,10,100,100` @@ -2088,11 +2037,9 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for * reducing file size or applying basic optimizations upfront (e.g., resize, * compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed * versions (like video encodes or thumbnails) in advance, so they're ready for * delivery without delay. @@ -2472,11 +2419,9 @@ private constructor( * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2602,10 +2547,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file * size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions (like * video encodes or thumbnails) in advance, so they're ready for delivery without delay. * @@ -3839,11 +3782,9 @@ private constructor( * member. * * An instance of [Protocol] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt index 2e7a0826..9a6a0d35 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt @@ -1521,11 +1521,9 @@ private constructor( * member. * * An instance of [AiAutoDescription] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1670,11 +1668,9 @@ private constructor( * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiTasks] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1819,11 +1815,9 @@ private constructor( * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AwsAutoTagging] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1970,11 +1964,9 @@ private constructor( * member. * * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2119,11 +2111,9 @@ private constructor( * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. * * An instance of [RemoveBg] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt index 3bd5a4fc..6a3e4e52 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt @@ -179,11 +179,9 @@ private constructor( * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt index f223a6dc..cbda2b69 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt @@ -836,11 +836,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1104,9 +1102,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = mixed.sumOf { - it.validity().toInt() - } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index 891cc997..aa69f84a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -1144,11 +1144,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1413,9 +1411,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = mixed.sumOf { - it.validity().toInt() - } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index 6c6668c8..2854e1df 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -1123,9 +1123,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = mixed.sumOf { - it.validity().toInt() - } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt index 7a3ea5d3..78ac2a34 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt @@ -1266,11 +1266,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt index 22e1b373..9934cf97 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt @@ -1640,11 +1640,9 @@ private constructor( * member. * * An instance of [AiAutoDescription] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1789,11 +1787,9 @@ private constructor( * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiTasks] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1938,11 +1934,9 @@ private constructor( * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AwsAutoTagging] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2089,11 +2083,9 @@ private constructor( * member. * * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2238,11 +2230,9 @@ private constructor( * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. * * An instance of [RemoveBg] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt index 71618af7..7067c777 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt @@ -7,7 +7,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize import io.imagekit.core.BaseSerializer @@ -22,7 +21,6 @@ import io.imagekit.core.checkRequired import io.imagekit.core.getOrThrow import io.imagekit.core.http.Headers import io.imagekit.core.http.QueryParams -import io.imagekit.core.jsonMapper import io.imagekit.core.toImmutable import io.imagekit.errors.ImageKitInvalidDataException import io.imagekit.models.ExtensionItem @@ -53,7 +51,6 @@ import kotlin.io.path.name * **Version limit** \ A file can have a maximum of 100 versions. * * **Demo applications** - * * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), * supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. @@ -67,7 +64,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -82,7 +78,6 @@ private constructor( /** * The name with which the file has to be uploaded. The file name can contain: - * * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. * - Special Characters: `.`, `-` * @@ -119,7 +114,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and width and * height of the area of interest in the format `x,y,width,height`. For example - * `10,10,100,100` @@ -174,7 +168,6 @@ private constructor( * a new folder(s) is created. * * The folder name can contain: - * * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` * - Special Characters: `/` , `_` , `-` * @@ -288,10 +281,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file * size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions (like * video encodes or thumbnails) in advance, so they're ready for delivery without delay. * @@ -554,7 +545,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -575,7 +565,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -587,7 +576,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -599,7 +587,6 @@ private constructor( /** * The name with which the file has to be uploaded. The file name can contain: - * * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. * - Special Characters: `.`, `-` * @@ -651,7 +638,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and width * and height of the area of interest in the format `x,y,width,height`. For example - * `10,10,100,100` @@ -798,7 +784,6 @@ private constructor( * before, a new folder(s) is created. * * The folder name can contain: - * * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` * - Special Characters: `/` , `_` , `-` * @@ -1011,10 +996,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing * file size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions * (like video encodes or thumbnails) in advance, so they're ready for delivery without * delay. @@ -1218,10 +1201,10 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _toJsonString(_customMetadata()), + "customMetadata" to _customMetadata(), "description" to _description(), "expire" to _expire(), - "extensions" to _toJsonString(_extensions()), + "extensions" to _extensions(), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1230,45 +1213,15 @@ private constructor( "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), "publicKey" to _publicKey(), - "responseFields" to _toCommaSeparated(_responseFields()), + "responseFields" to _responseFields(), "signature" to _signature(), - "tags" to _toCommaSeparated(_tags()), - "transformation" to _toJsonString(_transformation()), + "tags" to _tags(), + "transformation" to _transformation(), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() - private fun _toJsonString(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val jsonString = jsonMapper().writeValueAsString(field.value) - return MultipartField.of(jsonString) - } - - private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val mapper = jsonMapper() - val node = mapper.valueToTree(field.value) - if (!node.isArray) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val csv = - node - .elements() - .asSequence() - .filter { !it.isNull && !it.isMissingNode } - .map { it.asText() } - .joinToString(",") - return MultipartField.of(csv) - } - override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @@ -1303,7 +1256,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1318,7 +1270,6 @@ private constructor( /** * The name with which the file has to be uploaded. The file name can contain: - * * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. * - Special Characters: `.`, `-` * @@ -1355,7 +1306,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and width * and height of the area of interest in the format `x,y,width,height`. For example - * `10,10,100,100` @@ -1412,7 +1362,6 @@ private constructor( * before, a new folder(s) is created. * * The folder name can contain: - * * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` * - Special Characters: `/` , `_` , `-` * @@ -1529,10 +1478,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing * file size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions * (like video encodes or thumbnails) in advance, so they're ready for delivery without * delay. @@ -1866,7 +1813,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1887,7 +1833,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1899,7 +1844,6 @@ private constructor( /** * The API accepts any of the following: - * * - **Binary data** – send the raw bytes as `multipart/form-data`. * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. @@ -1917,7 +1861,6 @@ private constructor( /** * The name with which the file has to be uploaded. The file name can contain: - * * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. * - Special Characters: `.`, `-` * @@ -1972,7 +1915,6 @@ private constructor( /** * Define an important area in the image. This is only relevant for image type files. - * * - To be passed as a string with the x and y coordinates of the top-left corner, and * width and height of the area of interest in the format `x,y,width,height`. For * example - `10,10,100,100` @@ -2125,7 +2067,6 @@ private constructor( * before, a new folder(s) is created. * * The folder name can contain: - * * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` * - Special Characters: `/` , `_` , `-` * @@ -2350,11 +2291,9 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for * reducing file size or applying basic optimizations upfront (e.g., resize, * compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed * versions (like video encodes or thumbnails) in advance, so they're ready for * delivery without delay. @@ -2746,11 +2685,9 @@ private constructor( * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. * * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2876,10 +2813,8 @@ private constructor( /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file * size or applying basic optimizations upfront (e.g., resize, compress). - * * - `post` — applied immediately after upload. Ideal for generating transformed versions (like * video encodes or thumbnails) in advance, so they're ready for delivery without delay. * @@ -4113,11 +4048,9 @@ private constructor( * member. * * An instance of [Protocol] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt index dadd8634..5f16e01c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt @@ -1520,11 +1520,9 @@ private constructor( * member. * * An instance of [AiAutoDescription] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1669,11 +1667,9 @@ private constructor( * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiTasks] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1818,11 +1814,9 @@ private constructor( * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AwsAutoTagging] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1969,11 +1963,9 @@ private constructor( * member. * * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2118,11 +2110,9 @@ private constructor( * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. * * An instance of [RemoveBg] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt index 8f3987f6..e03767c1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt @@ -479,9 +479,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { @@ -527,11 +526,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt index 03db715a..ddc2bda8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt @@ -945,7 +945,6 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apertureValue: JsonField, - private val brightnessValue: JsonField, private val colorSpace: JsonField, private val createDate: JsonField, private val customRendered: JsonField, @@ -960,23 +959,16 @@ private constructor( private val flash: JsonField, private val flashpixVersion: JsonField, private val fNumber: JsonField, - private val focalLength: JsonField, - private val focalLengthIn35mmFormat: JsonField, + private val focalLength: JsonField, private val focalPlaneResolutionUnit: JsonField, private val focalPlaneXResolution: JsonField, private val focalPlaneYResolution: JsonField, private val interopOffset: JsonField, private val iso: JsonField, - private val lensModel: JsonField, - private val lightSource: JsonField, - private val maxApertureValue: JsonField, private val meteringMode: JsonField, private val sceneCaptureType: JsonField, - private val sceneType: JsonField, - private val sensingMethod: JsonField, private val shutterSpeedValue: JsonField, private val subSecTime: JsonField, - private val userComment: JsonField, private val whiteBalance: JsonField, private val additionalProperties: MutableMap, ) { @@ -986,9 +978,6 @@ private constructor( @JsonProperty("ApertureValue") @ExcludeMissing apertureValue: JsonField = JsonMissing.of(), - @JsonProperty("BrightnessValue") - @ExcludeMissing - brightnessValue: JsonField = JsonMissing.of(), @JsonProperty("ColorSpace") @ExcludeMissing colorSpace: JsonField = JsonMissing.of(), @@ -1031,10 +1020,7 @@ private constructor( fNumber: JsonField = JsonMissing.of(), @JsonProperty("FocalLength") @ExcludeMissing - focalLength: JsonField = JsonMissing.of(), - @JsonProperty("FocalLengthIn35mmFormat") - @ExcludeMissing - focalLengthIn35mmFormat: JsonField = JsonMissing.of(), + focalLength: JsonField = JsonMissing.of(), @JsonProperty("FocalPlaneResolutionUnit") @ExcludeMissing focalPlaneResolutionUnit: JsonField = JsonMissing.of(), @@ -1048,42 +1034,23 @@ private constructor( @ExcludeMissing interopOffset: JsonField = JsonMissing.of(), @JsonProperty("ISO") @ExcludeMissing iso: JsonField = JsonMissing.of(), - @JsonProperty("LensModel") - @ExcludeMissing - lensModel: JsonField = JsonMissing.of(), - @JsonProperty("LightSource") - @ExcludeMissing - lightSource: JsonField = JsonMissing.of(), - @JsonProperty("MaxApertureValue") - @ExcludeMissing - maxApertureValue: JsonField = JsonMissing.of(), @JsonProperty("MeteringMode") @ExcludeMissing meteringMode: JsonField = JsonMissing.of(), @JsonProperty("SceneCaptureType") @ExcludeMissing sceneCaptureType: JsonField = JsonMissing.of(), - @JsonProperty("SceneType") - @ExcludeMissing - sceneType: JsonField = JsonMissing.of(), - @JsonProperty("SensingMethod") - @ExcludeMissing - sensingMethod: JsonField = JsonMissing.of(), @JsonProperty("ShutterSpeedValue") @ExcludeMissing shutterSpeedValue: JsonField = JsonMissing.of(), @JsonProperty("SubSecTime") @ExcludeMissing subSecTime: JsonField = JsonMissing.of(), - @JsonProperty("UserComment") - @ExcludeMissing - userComment: JsonField = JsonMissing.of(), @JsonProperty("WhiteBalance") @ExcludeMissing whiteBalance: JsonField = JsonMissing.of(), ) : this( apertureValue, - brightnessValue, colorSpace, createDate, customRendered, @@ -1099,22 +1066,15 @@ private constructor( flashpixVersion, fNumber, focalLength, - focalLengthIn35mmFormat, focalPlaneResolutionUnit, focalPlaneXResolution, focalPlaneYResolution, interopOffset, iso, - lensModel, - lightSource, - maxApertureValue, meteringMode, sceneCaptureType, - sceneType, - sensingMethod, shutterSpeedValue, subSecTime, - userComment, whiteBalance, mutableMapOf(), ) @@ -1125,12 +1085,6 @@ private constructor( */ fun apertureValue(): Optional = apertureValue.getOptional("ApertureValue") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun brightnessValue(): Optional = brightnessValue.getOptional("BrightnessValue") - /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -1221,14 +1175,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun focalLength(): Optional = focalLength.getOptional("FocalLength") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun focalLengthIn35mmFormat(): Optional = - focalLengthIn35mmFormat.getOptional("FocalLengthIn35mmFormat") + fun focalLength(): Optional = focalLength.getOptional("FocalLength") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. @@ -1263,25 +1210,6 @@ private constructor( */ fun iso(): Optional = iso.getOptional("ISO") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun lensModel(): Optional = lensModel.getOptional("LensModel") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun lightSource(): Optional = lightSource.getOptional("LightSource") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun maxApertureValue(): Optional = - maxApertureValue.getOptional("MaxApertureValue") - /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -1295,18 +1223,6 @@ private constructor( fun sceneCaptureType(): Optional = sceneCaptureType.getOptional("SceneCaptureType") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun sceneType(): Optional = sceneType.getOptional("SceneType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun sensingMethod(): Optional = sensingMethod.getOptional("SensingMethod") - /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -1320,12 +1236,6 @@ private constructor( */ fun subSecTime(): Optional = subSecTime.getOptional("SubSecTime") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun userComment(): Optional = userComment.getOptional("UserComment") - /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -1342,16 +1252,6 @@ private constructor( @ExcludeMissing fun _apertureValue(): JsonField = apertureValue - /** - * Returns the raw JSON value of [brightnessValue]. - * - * Unlike [brightnessValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("BrightnessValue") - @ExcludeMissing - fun _brightnessValue(): JsonField = brightnessValue - /** * Returns the raw JSON value of [colorSpace]. * @@ -1494,17 +1394,7 @@ private constructor( */ @JsonProperty("FocalLength") @ExcludeMissing - fun _focalLength(): JsonField = focalLength - - /** - * Returns the raw JSON value of [focalLengthIn35mmFormat]. - * - * Unlike [focalLengthIn35mmFormat], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("FocalLengthIn35mmFormat") - @ExcludeMissing - fun _focalLengthIn35mmFormat(): JsonField = focalLengthIn35mmFormat + fun _focalLength(): JsonField = focalLength /** * Returns the raw JSON value of [focalPlaneResolutionUnit]. @@ -1553,36 +1443,6 @@ private constructor( */ @JsonProperty("ISO") @ExcludeMissing fun _iso(): JsonField = iso - /** - * Returns the raw JSON value of [lensModel]. - * - * Unlike [lensModel], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LensModel") - @ExcludeMissing - fun _lensModel(): JsonField = lensModel - - /** - * Returns the raw JSON value of [lightSource]. - * - * Unlike [lightSource], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LightSource") - @ExcludeMissing - fun _lightSource(): JsonField = lightSource - - /** - * Returns the raw JSON value of [maxApertureValue]. - * - * Unlike [maxApertureValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("MaxApertureValue") - @ExcludeMissing - fun _maxApertureValue(): JsonField = maxApertureValue - /** * Returns the raw JSON value of [meteringMode]. * @@ -1603,26 +1463,6 @@ private constructor( @ExcludeMissing fun _sceneCaptureType(): JsonField = sceneCaptureType - /** - * Returns the raw JSON value of [sceneType]. - * - * Unlike [sceneType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("SceneType") - @ExcludeMissing - fun _sceneType(): JsonField = sceneType - - /** - * Returns the raw JSON value of [sensingMethod]. - * - * Unlike [sensingMethod], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("SensingMethod") - @ExcludeMissing - fun _sensingMethod(): JsonField = sensingMethod - /** * Returns the raw JSON value of [shutterSpeedValue]. * @@ -1643,16 +1483,6 @@ private constructor( @ExcludeMissing fun _subSecTime(): JsonField = subSecTime - /** - * Returns the raw JSON value of [userComment]. - * - * Unlike [userComment], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("UserComment") - @ExcludeMissing - fun _userComment(): JsonField = userComment - /** * Returns the raw JSON value of [whiteBalance]. * @@ -1685,7 +1515,6 @@ private constructor( class Builder internal constructor() { private var apertureValue: JsonField = JsonMissing.of() - private var brightnessValue: JsonField = JsonMissing.of() private var colorSpace: JsonField = JsonMissing.of() private var createDate: JsonField = JsonMissing.of() private var customRendered: JsonField = JsonMissing.of() @@ -1700,30 +1529,22 @@ private constructor( private var flash: JsonField = JsonMissing.of() private var flashpixVersion: JsonField = JsonMissing.of() private var fNumber: JsonField = JsonMissing.of() - private var focalLength: JsonField = JsonMissing.of() - private var focalLengthIn35mmFormat: JsonField = JsonMissing.of() + private var focalLength: JsonField = JsonMissing.of() private var focalPlaneResolutionUnit: JsonField = JsonMissing.of() private var focalPlaneXResolution: JsonField = JsonMissing.of() private var focalPlaneYResolution: JsonField = JsonMissing.of() private var interopOffset: JsonField = JsonMissing.of() private var iso: JsonField = JsonMissing.of() - private var lensModel: JsonField = JsonMissing.of() - private var lightSource: JsonField = JsonMissing.of() - private var maxApertureValue: JsonField = JsonMissing.of() private var meteringMode: JsonField = JsonMissing.of() private var sceneCaptureType: JsonField = JsonMissing.of() - private var sceneType: JsonField = JsonMissing.of() - private var sensingMethod: JsonField = JsonMissing.of() private var shutterSpeedValue: JsonField = JsonMissing.of() private var subSecTime: JsonField = JsonMissing.of() - private var userComment: JsonField = JsonMissing.of() private var whiteBalance: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(exifDetails: ExifDetails) = apply { apertureValue = exifDetails.apertureValue - brightnessValue = exifDetails.brightnessValue colorSpace = exifDetails.colorSpace createDate = exifDetails.createDate customRendered = exifDetails.customRendered @@ -1739,22 +1560,15 @@ private constructor( flashpixVersion = exifDetails.flashpixVersion fNumber = exifDetails.fNumber focalLength = exifDetails.focalLength - focalLengthIn35mmFormat = exifDetails.focalLengthIn35mmFormat focalPlaneResolutionUnit = exifDetails.focalPlaneResolutionUnit focalPlaneXResolution = exifDetails.focalPlaneXResolution focalPlaneYResolution = exifDetails.focalPlaneYResolution interopOffset = exifDetails.interopOffset iso = exifDetails.iso - lensModel = exifDetails.lensModel - lightSource = exifDetails.lightSource - maxApertureValue = exifDetails.maxApertureValue meteringMode = exifDetails.meteringMode sceneCaptureType = exifDetails.sceneCaptureType - sceneType = exifDetails.sceneType - sensingMethod = exifDetails.sensingMethod shutterSpeedValue = exifDetails.shutterSpeedValue subSecTime = exifDetails.subSecTime - userComment = exifDetails.userComment whiteBalance = exifDetails.whiteBalance additionalProperties = exifDetails.additionalProperties.toMutableMap() } @@ -1773,20 +1587,6 @@ private constructor( this.apertureValue = apertureValue } - fun brightnessValue(brightnessValue: Double) = - brightnessValue(JsonField.of(brightnessValue)) - - /** - * Sets [Builder.brightnessValue] to an arbitrary JSON value. - * - * You should usually call [Builder.brightnessValue] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun brightnessValue(brightnessValue: JsonField) = apply { - this.brightnessValue = brightnessValue - } - fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) /** @@ -1970,33 +1770,19 @@ private constructor( */ fun fNumber(fNumber: JsonField) = apply { this.fNumber = fNumber } - fun focalLength(focalLength: Double) = focalLength(JsonField.of(focalLength)) + fun focalLength(focalLength: Long) = focalLength(JsonField.of(focalLength)) /** * Sets [Builder.focalLength] to an arbitrary JSON value. * - * You should usually call [Builder.focalLength] with a well-typed [Double] value + * You should usually call [Builder.focalLength] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun focalLength(focalLength: JsonField) = apply { + fun focalLength(focalLength: JsonField) = apply { this.focalLength = focalLength } - fun focalLengthIn35mmFormat(focalLengthIn35mmFormat: Long) = - focalLengthIn35mmFormat(JsonField.of(focalLengthIn35mmFormat)) - - /** - * Sets [Builder.focalLengthIn35mmFormat] to an arbitrary JSON value. - * - * You should usually call [Builder.focalLengthIn35mmFormat] with a well-typed - * [Long] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun focalLengthIn35mmFormat(focalLengthIn35mmFormat: JsonField) = apply { - this.focalLengthIn35mmFormat = focalLengthIn35mmFormat - } - fun focalPlaneResolutionUnit(focalPlaneResolutionUnit: Long) = focalPlaneResolutionUnit(JsonField.of(focalPlaneResolutionUnit)) @@ -2063,44 +1849,6 @@ private constructor( */ fun iso(iso: JsonField) = apply { this.iso = iso } - fun lensModel(lensModel: String) = lensModel(JsonField.of(lensModel)) - - /** - * Sets [Builder.lensModel] to an arbitrary JSON value. - * - * You should usually call [Builder.lensModel] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun lensModel(lensModel: JsonField) = apply { this.lensModel = lensModel } - - fun lightSource(lightSource: Long) = lightSource(JsonField.of(lightSource)) - - /** - * Sets [Builder.lightSource] to an arbitrary JSON value. - * - * You should usually call [Builder.lightSource] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun lightSource(lightSource: JsonField) = apply { - this.lightSource = lightSource - } - - fun maxApertureValue(maxApertureValue: Double) = - maxApertureValue(JsonField.of(maxApertureValue)) - - /** - * Sets [Builder.maxApertureValue] to an arbitrary JSON value. - * - * You should usually call [Builder.maxApertureValue] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun maxApertureValue(maxApertureValue: JsonField) = apply { - this.maxApertureValue = maxApertureValue - } - fun meteringMode(meteringMode: Long) = meteringMode(JsonField.of(meteringMode)) /** @@ -2128,30 +1876,6 @@ private constructor( this.sceneCaptureType = sceneCaptureType } - fun sceneType(sceneType: String) = sceneType(JsonField.of(sceneType)) - - /** - * Sets [Builder.sceneType] to an arbitrary JSON value. - * - * You should usually call [Builder.sceneType] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun sceneType(sceneType: JsonField) = apply { this.sceneType = sceneType } - - fun sensingMethod(sensingMethod: Long) = sensingMethod(JsonField.of(sensingMethod)) - - /** - * Sets [Builder.sensingMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.sensingMethod] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun sensingMethod(sensingMethod: JsonField) = apply { - this.sensingMethod = sensingMethod - } - fun shutterSpeedValue(shutterSpeedValue: Double) = shutterSpeedValue(JsonField.of(shutterSpeedValue)) @@ -2179,19 +1903,6 @@ private constructor( this.subSecTime = subSecTime } - fun userComment(userComment: String) = userComment(JsonField.of(userComment)) - - /** - * Sets [Builder.userComment] to an arbitrary JSON value. - * - * You should usually call [Builder.userComment] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun userComment(userComment: JsonField) = apply { - this.userComment = userComment - } - fun whiteBalance(whiteBalance: Long) = whiteBalance(JsonField.of(whiteBalance)) /** @@ -2235,7 +1946,6 @@ private constructor( fun build(): ExifDetails = ExifDetails( apertureValue, - brightnessValue, colorSpace, createDate, customRendered, @@ -2251,22 +1961,15 @@ private constructor( flashpixVersion, fNumber, focalLength, - focalLengthIn35mmFormat, focalPlaneResolutionUnit, focalPlaneXResolution, focalPlaneYResolution, interopOffset, iso, - lensModel, - lightSource, - maxApertureValue, meteringMode, sceneCaptureType, - sceneType, - sensingMethod, shutterSpeedValue, subSecTime, - userComment, whiteBalance, additionalProperties.toMutableMap(), ) @@ -2290,7 +1993,6 @@ private constructor( } apertureValue() - brightnessValue() colorSpace() createDate() customRendered() @@ -2306,22 +2008,15 @@ private constructor( flashpixVersion() fNumber() focalLength() - focalLengthIn35mmFormat() focalPlaneResolutionUnit() focalPlaneXResolution() focalPlaneYResolution() interopOffset() iso() - lensModel() - lightSource() - maxApertureValue() meteringMode() sceneCaptureType() - sceneType() - sensingMethod() shutterSpeedValue() subSecTime() - userComment() whiteBalance() validated = true } @@ -2343,7 +2038,6 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (apertureValue.asKnown().isPresent) 1 else 0) + - (if (brightnessValue.asKnown().isPresent) 1 else 0) + (if (colorSpace.asKnown().isPresent) 1 else 0) + (if (createDate.asKnown().isPresent) 1 else 0) + (if (customRendered.asKnown().isPresent) 1 else 0) + @@ -2359,22 +2053,15 @@ private constructor( (if (flashpixVersion.asKnown().isPresent) 1 else 0) + (if (fNumber.asKnown().isPresent) 1 else 0) + (if (focalLength.asKnown().isPresent) 1 else 0) + - (if (focalLengthIn35mmFormat.asKnown().isPresent) 1 else 0) + (if (focalPlaneResolutionUnit.asKnown().isPresent) 1 else 0) + (if (focalPlaneXResolution.asKnown().isPresent) 1 else 0) + (if (focalPlaneYResolution.asKnown().isPresent) 1 else 0) + (if (interopOffset.asKnown().isPresent) 1 else 0) + (if (iso.asKnown().isPresent) 1 else 0) + - (if (lensModel.asKnown().isPresent) 1 else 0) + - (if (lightSource.asKnown().isPresent) 1 else 0) + - (if (maxApertureValue.asKnown().isPresent) 1 else 0) + (if (meteringMode.asKnown().isPresent) 1 else 0) + (if (sceneCaptureType.asKnown().isPresent) 1 else 0) + - (if (sceneType.asKnown().isPresent) 1 else 0) + - (if (sensingMethod.asKnown().isPresent) 1 else 0) + (if (shutterSpeedValue.asKnown().isPresent) 1 else 0) + (if (subSecTime.asKnown().isPresent) 1 else 0) + - (if (userComment.asKnown().isPresent) 1 else 0) + (if (whiteBalance.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2384,7 +2071,6 @@ private constructor( return other is ExifDetails && apertureValue == other.apertureValue && - brightnessValue == other.brightnessValue && colorSpace == other.colorSpace && createDate == other.createDate && customRendered == other.customRendered && @@ -2400,22 +2086,15 @@ private constructor( flashpixVersion == other.flashpixVersion && fNumber == other.fNumber && focalLength == other.focalLength && - focalLengthIn35mmFormat == other.focalLengthIn35mmFormat && focalPlaneResolutionUnit == other.focalPlaneResolutionUnit && focalPlaneXResolution == other.focalPlaneXResolution && focalPlaneYResolution == other.focalPlaneYResolution && interopOffset == other.interopOffset && iso == other.iso && - lensModel == other.lensModel && - lightSource == other.lightSource && - maxApertureValue == other.maxApertureValue && meteringMode == other.meteringMode && sceneCaptureType == other.sceneCaptureType && - sceneType == other.sceneType && - sensingMethod == other.sensingMethod && shutterSpeedValue == other.shutterSpeedValue && subSecTime == other.subSecTime && - userComment == other.userComment && whiteBalance == other.whiteBalance && additionalProperties == other.additionalProperties } @@ -2423,7 +2102,6 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( apertureValue, - brightnessValue, colorSpace, createDate, customRendered, @@ -2439,22 +2117,15 @@ private constructor( flashpixVersion, fNumber, focalLength, - focalLengthIn35mmFormat, focalPlaneResolutionUnit, focalPlaneXResolution, focalPlaneYResolution, interopOffset, iso, - lensModel, - lightSource, - maxApertureValue, meteringMode, sceneCaptureType, - sceneType, - sensingMethod, shutterSpeedValue, subSecTime, - userComment, whiteBalance, additionalProperties, ) @@ -2463,137 +2134,23 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExifDetails{apertureValue=$apertureValue, brightnessValue=$brightnessValue, colorSpace=$colorSpace, createDate=$createDate, customRendered=$customRendered, dateTimeOriginal=$dateTimeOriginal, exifImageHeight=$exifImageHeight, exifImageWidth=$exifImageWidth, exifVersion=$exifVersion, exposureCompensation=$exposureCompensation, exposureMode=$exposureMode, exposureProgram=$exposureProgram, exposureTime=$exposureTime, flash=$flash, flashpixVersion=$flashpixVersion, fNumber=$fNumber, focalLength=$focalLength, focalLengthIn35mmFormat=$focalLengthIn35mmFormat, focalPlaneResolutionUnit=$focalPlaneResolutionUnit, focalPlaneXResolution=$focalPlaneXResolution, focalPlaneYResolution=$focalPlaneYResolution, interopOffset=$interopOffset, iso=$iso, lensModel=$lensModel, lightSource=$lightSource, maxApertureValue=$maxApertureValue, meteringMode=$meteringMode, sceneCaptureType=$sceneCaptureType, sceneType=$sceneType, sensingMethod=$sensingMethod, shutterSpeedValue=$shutterSpeedValue, subSecTime=$subSecTime, userComment=$userComment, whiteBalance=$whiteBalance, additionalProperties=$additionalProperties}" + "ExifDetails{apertureValue=$apertureValue, colorSpace=$colorSpace, createDate=$createDate, customRendered=$customRendered, dateTimeOriginal=$dateTimeOriginal, exifImageHeight=$exifImageHeight, exifImageWidth=$exifImageWidth, exifVersion=$exifVersion, exposureCompensation=$exposureCompensation, exposureMode=$exposureMode, exposureProgram=$exposureProgram, exposureTime=$exposureTime, flash=$flash, flashpixVersion=$flashpixVersion, fNumber=$fNumber, focalLength=$focalLength, focalPlaneResolutionUnit=$focalPlaneResolutionUnit, focalPlaneXResolution=$focalPlaneXResolution, focalPlaneYResolution=$focalPlaneYResolution, interopOffset=$interopOffset, iso=$iso, meteringMode=$meteringMode, sceneCaptureType=$sceneCaptureType, shutterSpeedValue=$shutterSpeedValue, subSecTime=$subSecTime, whiteBalance=$whiteBalance, additionalProperties=$additionalProperties}" } /** Object containing GPS information. */ class Gps @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val gpsAltitude: JsonField, - private val gpsAltitudeRef: JsonField, - private val gpsDateStamp: JsonField, - private val gpsImgDirection: JsonField, - private val gpsImgDirectionRef: JsonField, - private val gpsLatitude: JsonField>, - private val gpsLatitudeRef: JsonField, - private val gpsLongitude: JsonField>, - private val gpsLongitudeRef: JsonField, - private val gpsTimeStamp: JsonField>, private val gpsVersionId: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("GPSAltitude") - @ExcludeMissing - gpsAltitude: JsonField = JsonMissing.of(), - @JsonProperty("GPSAltitudeRef") - @ExcludeMissing - gpsAltitudeRef: JsonField = JsonMissing.of(), - @JsonProperty("GPSDateStamp") - @ExcludeMissing - gpsDateStamp: JsonField = JsonMissing.of(), - @JsonProperty("GPSImgDirection") - @ExcludeMissing - gpsImgDirection: JsonField = JsonMissing.of(), - @JsonProperty("GPSImgDirectionRef") - @ExcludeMissing - gpsImgDirectionRef: JsonField = JsonMissing.of(), - @JsonProperty("GPSLatitude") - @ExcludeMissing - gpsLatitude: JsonField> = JsonMissing.of(), - @JsonProperty("GPSLatitudeRef") - @ExcludeMissing - gpsLatitudeRef: JsonField = JsonMissing.of(), - @JsonProperty("GPSLongitude") - @ExcludeMissing - gpsLongitude: JsonField> = JsonMissing.of(), - @JsonProperty("GPSLongitudeRef") - @ExcludeMissing - gpsLongitudeRef: JsonField = JsonMissing.of(), - @JsonProperty("GPSTimeStamp") - @ExcludeMissing - gpsTimeStamp: JsonField> = JsonMissing.of(), @JsonProperty("GPSVersionID") @ExcludeMissing - gpsVersionId: JsonField> = JsonMissing.of(), - ) : this( - gpsAltitude, - gpsAltitudeRef, - gpsDateStamp, - gpsImgDirection, - gpsImgDirectionRef, - gpsLatitude, - gpsLatitudeRef, - gpsLongitude, - gpsLongitudeRef, - gpsTimeStamp, - gpsVersionId, - mutableMapOf(), - ) - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsAltitude(): Optional = gpsAltitude.getOptional("GPSAltitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsAltitudeRef(): Optional = gpsAltitudeRef.getOptional("GPSAltitudeRef") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsDateStamp(): Optional = gpsDateStamp.getOptional("GPSDateStamp") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsImgDirection(): Optional = gpsImgDirection.getOptional("GPSImgDirection") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsImgDirectionRef(): Optional = - gpsImgDirectionRef.getOptional("GPSImgDirectionRef") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsLatitude(): Optional> = gpsLatitude.getOptional("GPSLatitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsLatitudeRef(): Optional = gpsLatitudeRef.getOptional("GPSLatitudeRef") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsLongitude(): Optional> = gpsLongitude.getOptional("GPSLongitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsLongitudeRef(): Optional = gpsLongitudeRef.getOptional("GPSLongitudeRef") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gpsTimeStamp(): Optional> = gpsTimeStamp.getOptional("GPSTimeStamp") + gpsVersionId: JsonField> = JsonMissing.of() + ) : this(gpsVersionId, mutableMapOf()) /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. @@ -2601,106 +2158,6 @@ private constructor( */ fun gpsVersionId(): Optional> = gpsVersionId.getOptional("GPSVersionID") - /** - * Returns the raw JSON value of [gpsAltitude]. - * - * Unlike [gpsAltitude], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GPSAltitude") - @ExcludeMissing - fun _gpsAltitude(): JsonField = gpsAltitude - - /** - * Returns the raw JSON value of [gpsAltitudeRef]. - * - * Unlike [gpsAltitudeRef], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GPSAltitudeRef") - @ExcludeMissing - fun _gpsAltitudeRef(): JsonField = gpsAltitudeRef - - /** - * Returns the raw JSON value of [gpsDateStamp]. - * - * Unlike [gpsDateStamp], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GPSDateStamp") - @ExcludeMissing - fun _gpsDateStamp(): JsonField = gpsDateStamp - - /** - * Returns the raw JSON value of [gpsImgDirection]. - * - * Unlike [gpsImgDirection], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GPSImgDirection") - @ExcludeMissing - fun _gpsImgDirection(): JsonField = gpsImgDirection - - /** - * Returns the raw JSON value of [gpsImgDirectionRef]. - * - * Unlike [gpsImgDirectionRef], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GPSImgDirectionRef") - @ExcludeMissing - fun _gpsImgDirectionRef(): JsonField = gpsImgDirectionRef - - /** - * Returns the raw JSON value of [gpsLatitude]. - * - * Unlike [gpsLatitude], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GPSLatitude") - @ExcludeMissing - fun _gpsLatitude(): JsonField> = gpsLatitude - - /** - * Returns the raw JSON value of [gpsLatitudeRef]. - * - * Unlike [gpsLatitudeRef], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GPSLatitudeRef") - @ExcludeMissing - fun _gpsLatitudeRef(): JsonField = gpsLatitudeRef - - /** - * Returns the raw JSON value of [gpsLongitude]. - * - * Unlike [gpsLongitude], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GPSLongitude") - @ExcludeMissing - fun _gpsLongitude(): JsonField> = gpsLongitude - - /** - * Returns the raw JSON value of [gpsLongitudeRef]. - * - * Unlike [gpsLongitudeRef], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GPSLongitudeRef") - @ExcludeMissing - fun _gpsLongitudeRef(): JsonField = gpsLongitudeRef - - /** - * Returns the raw JSON value of [gpsTimeStamp]. - * - * Unlike [gpsTimeStamp], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GPSTimeStamp") - @ExcludeMissing - fun _gpsTimeStamp(): JsonField> = gpsTimeStamp - /** * Returns the raw JSON value of [gpsVersionId]. * @@ -2732,208 +2189,15 @@ private constructor( /** A builder for [Gps]. */ class Builder internal constructor() { - private var gpsAltitude: JsonField = JsonMissing.of() - private var gpsAltitudeRef: JsonField = JsonMissing.of() - private var gpsDateStamp: JsonField = JsonMissing.of() - private var gpsImgDirection: JsonField = JsonMissing.of() - private var gpsImgDirectionRef: JsonField = JsonMissing.of() - private var gpsLatitude: JsonField>? = null - private var gpsLatitudeRef: JsonField = JsonMissing.of() - private var gpsLongitude: JsonField>? = null - private var gpsLongitudeRef: JsonField = JsonMissing.of() - private var gpsTimeStamp: JsonField>? = null private var gpsVersionId: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(gps: Gps) = apply { - gpsAltitude = gps.gpsAltitude - gpsAltitudeRef = gps.gpsAltitudeRef - gpsDateStamp = gps.gpsDateStamp - gpsImgDirection = gps.gpsImgDirection - gpsImgDirectionRef = gps.gpsImgDirectionRef - gpsLatitude = gps.gpsLatitude.map { it.toMutableList() } - gpsLatitudeRef = gps.gpsLatitudeRef - gpsLongitude = gps.gpsLongitude.map { it.toMutableList() } - gpsLongitudeRef = gps.gpsLongitudeRef - gpsTimeStamp = gps.gpsTimeStamp.map { it.toMutableList() } gpsVersionId = gps.gpsVersionId.map { it.toMutableList() } additionalProperties = gps.additionalProperties.toMutableMap() } - fun gpsAltitude(gpsAltitude: Double) = gpsAltitude(JsonField.of(gpsAltitude)) - - /** - * Sets [Builder.gpsAltitude] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsAltitude] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun gpsAltitude(gpsAltitude: JsonField) = apply { - this.gpsAltitude = gpsAltitude - } - - fun gpsAltitudeRef(gpsAltitudeRef: Long) = - gpsAltitudeRef(JsonField.of(gpsAltitudeRef)) - - /** - * Sets [Builder.gpsAltitudeRef] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsAltitudeRef] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun gpsAltitudeRef(gpsAltitudeRef: JsonField) = apply { - this.gpsAltitudeRef = gpsAltitudeRef - } - - fun gpsDateStamp(gpsDateStamp: String) = gpsDateStamp(JsonField.of(gpsDateStamp)) - - /** - * Sets [Builder.gpsDateStamp] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsDateStamp] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun gpsDateStamp(gpsDateStamp: JsonField) = apply { - this.gpsDateStamp = gpsDateStamp - } - - fun gpsImgDirection(gpsImgDirection: Double) = - gpsImgDirection(JsonField.of(gpsImgDirection)) - - /** - * Sets [Builder.gpsImgDirection] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsImgDirection] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun gpsImgDirection(gpsImgDirection: JsonField) = apply { - this.gpsImgDirection = gpsImgDirection - } - - fun gpsImgDirectionRef(gpsImgDirectionRef: String) = - gpsImgDirectionRef(JsonField.of(gpsImgDirectionRef)) - - /** - * Sets [Builder.gpsImgDirectionRef] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsImgDirectionRef] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun gpsImgDirectionRef(gpsImgDirectionRef: JsonField) = apply { - this.gpsImgDirectionRef = gpsImgDirectionRef - } - - fun gpsLatitude(gpsLatitude: List) = gpsLatitude(JsonField.of(gpsLatitude)) - - /** - * Sets [Builder.gpsLatitude] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsLatitude] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun gpsLatitude(gpsLatitude: JsonField>) = apply { - this.gpsLatitude = gpsLatitude.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.gpsLatitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addGpsLatitude(gpsLatitude: Double) = apply { - this.gpsLatitude = - (this.gpsLatitude ?: JsonField.of(mutableListOf())).also { - checkKnown("gpsLatitude", it).add(gpsLatitude) - } - } - - fun gpsLatitudeRef(gpsLatitudeRef: String) = - gpsLatitudeRef(JsonField.of(gpsLatitudeRef)) - - /** - * Sets [Builder.gpsLatitudeRef] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsLatitudeRef] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun gpsLatitudeRef(gpsLatitudeRef: JsonField) = apply { - this.gpsLatitudeRef = gpsLatitudeRef - } - - fun gpsLongitude(gpsLongitude: List) = - gpsLongitude(JsonField.of(gpsLongitude)) - - /** - * Sets [Builder.gpsLongitude] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsLongitude] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun gpsLongitude(gpsLongitude: JsonField>) = apply { - this.gpsLongitude = gpsLongitude.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.gpsLongitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addGpsLongitude(gpsLongitude: Double) = apply { - this.gpsLongitude = - (this.gpsLongitude ?: JsonField.of(mutableListOf())).also { - checkKnown("gpsLongitude", it).add(gpsLongitude) - } - } - - fun gpsLongitudeRef(gpsLongitudeRef: String) = - gpsLongitudeRef(JsonField.of(gpsLongitudeRef)) - - /** - * Sets [Builder.gpsLongitudeRef] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsLongitudeRef] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun gpsLongitudeRef(gpsLongitudeRef: JsonField) = apply { - this.gpsLongitudeRef = gpsLongitudeRef - } - - fun gpsTimeStamp(gpsTimeStamp: List) = - gpsTimeStamp(JsonField.of(gpsTimeStamp)) - - /** - * Sets [Builder.gpsTimeStamp] to an arbitrary JSON value. - * - * You should usually call [Builder.gpsTimeStamp] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun gpsTimeStamp(gpsTimeStamp: JsonField>) = apply { - this.gpsTimeStamp = gpsTimeStamp.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.gpsTimeStamp]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addGpsTimeStamp(gpsTimeStamp: Double) = apply { - this.gpsTimeStamp = - (this.gpsTimeStamp ?: JsonField.of(mutableListOf())).also { - checkKnown("gpsTimeStamp", it).add(gpsTimeStamp) - } - } - fun gpsVersionId(gpsVersionId: List) = gpsVersionId(JsonField.of(gpsVersionId)) @@ -2989,16 +2253,6 @@ private constructor( */ fun build(): Gps = Gps( - gpsAltitude, - gpsAltitudeRef, - gpsDateStamp, - gpsImgDirection, - gpsImgDirectionRef, - (gpsLatitude ?: JsonMissing.of()).map { it.toImmutable() }, - gpsLatitudeRef, - (gpsLongitude ?: JsonMissing.of()).map { it.toImmutable() }, - gpsLongitudeRef, - (gpsTimeStamp ?: JsonMissing.of()).map { it.toImmutable() }, (gpsVersionId ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3021,16 +2275,6 @@ private constructor( return@apply } - gpsAltitude() - gpsAltitudeRef() - gpsDateStamp() - gpsImgDirection() - gpsImgDirectionRef() - gpsLatitude() - gpsLatitudeRef() - gpsLongitude() - gpsLongitudeRef() - gpsTimeStamp() gpsVersionId() validated = true } @@ -3050,18 +2294,7 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (gpsAltitude.asKnown().isPresent) 1 else 0) + - (if (gpsAltitudeRef.asKnown().isPresent) 1 else 0) + - (if (gpsDateStamp.asKnown().isPresent) 1 else 0) + - (if (gpsImgDirection.asKnown().isPresent) 1 else 0) + - (if (gpsImgDirectionRef.asKnown().isPresent) 1 else 0) + - (gpsLatitude.asKnown().getOrNull()?.size ?: 0) + - (if (gpsLatitudeRef.asKnown().isPresent) 1 else 0) + - (gpsLongitude.asKnown().getOrNull()?.size ?: 0) + - (if (gpsLongitudeRef.asKnown().isPresent) 1 else 0) + - (gpsTimeStamp.asKnown().getOrNull()?.size ?: 0) + - (gpsVersionId.asKnown().getOrNull()?.size ?: 0) + internal fun validity(): Int = (gpsVersionId.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3069,81 +2302,44 @@ private constructor( } return other is Gps && - gpsAltitude == other.gpsAltitude && - gpsAltitudeRef == other.gpsAltitudeRef && - gpsDateStamp == other.gpsDateStamp && - gpsImgDirection == other.gpsImgDirection && - gpsImgDirectionRef == other.gpsImgDirectionRef && - gpsLatitude == other.gpsLatitude && - gpsLatitudeRef == other.gpsLatitudeRef && - gpsLongitude == other.gpsLongitude && - gpsLongitudeRef == other.gpsLongitudeRef && - gpsTimeStamp == other.gpsTimeStamp && gpsVersionId == other.gpsVersionId && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - gpsAltitude, - gpsAltitudeRef, - gpsDateStamp, - gpsImgDirection, - gpsImgDirectionRef, - gpsLatitude, - gpsLatitudeRef, - gpsLongitude, - gpsLongitudeRef, - gpsTimeStamp, - gpsVersionId, - additionalProperties, - ) - } + private val hashCode: Int by lazy { Objects.hash(gpsVersionId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Gps{gpsAltitude=$gpsAltitude, gpsAltitudeRef=$gpsAltitudeRef, gpsDateStamp=$gpsDateStamp, gpsImgDirection=$gpsImgDirection, gpsImgDirectionRef=$gpsImgDirectionRef, gpsLatitude=$gpsLatitude, gpsLatitudeRef=$gpsLatitudeRef, gpsLongitude=$gpsLongitude, gpsLongitudeRef=$gpsLongitudeRef, gpsTimeStamp=$gpsTimeStamp, gpsVersionId=$gpsVersionId, additionalProperties=$additionalProperties}" + "Gps{gpsVersionId=$gpsVersionId, additionalProperties=$additionalProperties}" } /** Object containing EXIF image information. */ class Image @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val artist: JsonField, - private val copyright: JsonField, private val exifOffset: JsonField, private val gpsInfo: JsonField, - private val imageDescription: JsonField, private val make: JsonField, private val model: JsonField, private val modifyDate: JsonField, private val orientation: JsonField, private val resolutionUnit: JsonField, private val software: JsonField, - private val xResolution: JsonField, + private val xResolution: JsonField, private val yCbCrPositioning: JsonField, - private val yResolution: JsonField, + private val yResolution: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("Artist") - @ExcludeMissing - artist: JsonField = JsonMissing.of(), - @JsonProperty("Copyright") - @ExcludeMissing - copyright: JsonField = JsonMissing.of(), @JsonProperty("ExifOffset") @ExcludeMissing exifOffset: JsonField = JsonMissing.of(), @JsonProperty("GPSInfo") @ExcludeMissing gpsInfo: JsonField = JsonMissing.of(), - @JsonProperty("ImageDescription") - @ExcludeMissing - imageDescription: JsonField = JsonMissing.of(), @JsonProperty("Make") @ExcludeMissing make: JsonField = JsonMissing.of(), @JsonProperty("Model") @ExcludeMissing model: JsonField = JsonMissing.of(), @JsonProperty("ModifyDate") @@ -3160,19 +2356,16 @@ private constructor( software: JsonField = JsonMissing.of(), @JsonProperty("XResolution") @ExcludeMissing - xResolution: JsonField = JsonMissing.of(), + xResolution: JsonField = JsonMissing.of(), @JsonProperty("YCbCrPositioning") @ExcludeMissing yCbCrPositioning: JsonField = JsonMissing.of(), @JsonProperty("YResolution") @ExcludeMissing - yResolution: JsonField = JsonMissing.of(), + yResolution: JsonField = JsonMissing.of(), ) : this( - artist, - copyright, exifOffset, gpsInfo, - imageDescription, make, model, modifyDate, @@ -3185,18 +2378,6 @@ private constructor( mutableMapOf(), ) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun artist(): Optional = artist.getOptional("Artist") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun copyright(): Optional = copyright.getOptional("Copyright") - /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -3209,13 +2390,6 @@ private constructor( */ fun gpsInfo(): Optional = gpsInfo.getOptional("GPSInfo") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun imageDescription(): Optional = - imageDescription.getOptional("ImageDescription") - /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -3256,7 +2430,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun xResolution(): Optional = xResolution.getOptional("XResolution") + fun xResolution(): Optional = xResolution.getOptional("XResolution") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. @@ -3269,24 +2443,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun yResolution(): Optional = yResolution.getOptional("YResolution") - - /** - * Returns the raw JSON value of [artist]. - * - * Unlike [artist], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Artist") @ExcludeMissing fun _artist(): JsonField = artist - - /** - * Returns the raw JSON value of [copyright]. - * - * Unlike [copyright], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("Copyright") - @ExcludeMissing - fun _copyright(): JsonField = copyright + fun yResolution(): Optional = yResolution.getOptional("YResolution") /** * Returns the raw JSON value of [exifOffset]. @@ -3305,16 +2462,6 @@ private constructor( */ @JsonProperty("GPSInfo") @ExcludeMissing fun _gpsInfo(): JsonField = gpsInfo - /** - * Returns the raw JSON value of [imageDescription]. - * - * Unlike [imageDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageDescription") - @ExcludeMissing - fun _imageDescription(): JsonField = imageDescription - /** * Returns the raw JSON value of [make]. * @@ -3375,7 +2522,7 @@ private constructor( */ @JsonProperty("XResolution") @ExcludeMissing - fun _xResolution(): JsonField = xResolution + fun _xResolution(): JsonField = xResolution /** * Returns the raw JSON value of [yCbCrPositioning]. @@ -3395,7 +2542,7 @@ private constructor( */ @JsonProperty("YResolution") @ExcludeMissing - fun _yResolution(): JsonField = yResolution + fun _yResolution(): JsonField = yResolution @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3418,29 +2565,23 @@ private constructor( /** A builder for [Image]. */ class Builder internal constructor() { - private var artist: JsonField = JsonMissing.of() - private var copyright: JsonField = JsonMissing.of() private var exifOffset: JsonField = JsonMissing.of() private var gpsInfo: JsonField = JsonMissing.of() - private var imageDescription: JsonField = JsonMissing.of() private var make: JsonField = JsonMissing.of() private var model: JsonField = JsonMissing.of() private var modifyDate: JsonField = JsonMissing.of() private var orientation: JsonField = JsonMissing.of() private var resolutionUnit: JsonField = JsonMissing.of() private var software: JsonField = JsonMissing.of() - private var xResolution: JsonField = JsonMissing.of() + private var xResolution: JsonField = JsonMissing.of() private var yCbCrPositioning: JsonField = JsonMissing.of() - private var yResolution: JsonField = JsonMissing.of() + private var yResolution: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(image: Image) = apply { - artist = image.artist - copyright = image.copyright exifOffset = image.exifOffset gpsInfo = image.gpsInfo - imageDescription = image.imageDescription make = image.make model = image.model modifyDate = image.modifyDate @@ -3453,28 +2594,6 @@ private constructor( additionalProperties = image.additionalProperties.toMutableMap() } - fun artist(artist: String) = artist(JsonField.of(artist)) - - /** - * Sets [Builder.artist] to an arbitrary JSON value. - * - * You should usually call [Builder.artist] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun artist(artist: JsonField) = apply { this.artist = artist } - - fun copyright(copyright: String) = copyright(JsonField.of(copyright)) - - /** - * Sets [Builder.copyright] to an arbitrary JSON value. - * - * You should usually call [Builder.copyright] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun copyright(copyright: JsonField) = apply { this.copyright = copyright } - fun exifOffset(exifOffset: Long) = exifOffset(JsonField.of(exifOffset)) /** @@ -3497,20 +2616,6 @@ private constructor( */ fun gpsInfo(gpsInfo: JsonField) = apply { this.gpsInfo = gpsInfo } - fun imageDescription(imageDescription: String) = - imageDescription(JsonField.of(imageDescription)) - - /** - * Sets [Builder.imageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.imageDescription] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun imageDescription(imageDescription: JsonField) = apply { - this.imageDescription = imageDescription - } - fun make(make: String) = make(JsonField.of(make)) /** @@ -3584,16 +2689,16 @@ private constructor( */ fun software(software: JsonField) = apply { this.software = software } - fun xResolution(xResolution: Double) = xResolution(JsonField.of(xResolution)) + fun xResolution(xResolution: Long) = xResolution(JsonField.of(xResolution)) /** * Sets [Builder.xResolution] to an arbitrary JSON value. * - * You should usually call [Builder.xResolution] with a well-typed [Double] value + * You should usually call [Builder.xResolution] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun xResolution(xResolution: JsonField) = apply { + fun xResolution(xResolution: JsonField) = apply { this.xResolution = xResolution } @@ -3611,16 +2716,16 @@ private constructor( this.yCbCrPositioning = yCbCrPositioning } - fun yResolution(yResolution: Double) = yResolution(JsonField.of(yResolution)) + fun yResolution(yResolution: Long) = yResolution(JsonField.of(yResolution)) /** * Sets [Builder.yResolution] to an arbitrary JSON value. * - * You should usually call [Builder.yResolution] with a well-typed [Double] value + * You should usually call [Builder.yResolution] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun yResolution(yResolution: JsonField) = apply { + fun yResolution(yResolution: JsonField) = apply { this.yResolution = yResolution } @@ -3653,11 +2758,8 @@ private constructor( */ fun build(): Image = Image( - artist, - copyright, exifOffset, gpsInfo, - imageDescription, make, model, modifyDate, @@ -3688,11 +2790,8 @@ private constructor( return@apply } - artist() - copyright() exifOffset() gpsInfo() - imageDescription() make() model() modifyDate() @@ -3721,11 +2820,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (artist.asKnown().isPresent) 1 else 0) + - (if (copyright.asKnown().isPresent) 1 else 0) + - (if (exifOffset.asKnown().isPresent) 1 else 0) + + (if (exifOffset.asKnown().isPresent) 1 else 0) + (if (gpsInfo.asKnown().isPresent) 1 else 0) + - (if (imageDescription.asKnown().isPresent) 1 else 0) + (if (make.asKnown().isPresent) 1 else 0) + (if (model.asKnown().isPresent) 1 else 0) + (if (modifyDate.asKnown().isPresent) 1 else 0) + @@ -3742,11 +2838,8 @@ private constructor( } return other is Image && - artist == other.artist && - copyright == other.copyright && exifOffset == other.exifOffset && gpsInfo == other.gpsInfo && - imageDescription == other.imageDescription && make == other.make && model == other.model && modifyDate == other.modifyDate && @@ -3761,11 +2854,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - artist, - copyright, exifOffset, gpsInfo, - imageDescription, make, model, modifyDate, @@ -3782,7 +2872,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Image{artist=$artist, copyright=$copyright, exifOffset=$exifOffset, gpsInfo=$gpsInfo, imageDescription=$imageDescription, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" + "Image{exifOffset=$exifOffset, gpsInfo=$gpsInfo, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" } /** JSON object. */ @@ -4086,9 +3176,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { @@ -4113,8 +3202,8 @@ private constructor( private val resolutionUnit: JsonField, private val thumbnailLength: JsonField, private val thumbnailOffset: JsonField, - private val xResolution: JsonField, - private val yResolution: JsonField, + private val xResolution: JsonField, + private val yResolution: JsonField, private val additionalProperties: MutableMap, ) { @@ -4134,10 +3223,10 @@ private constructor( thumbnailOffset: JsonField = JsonMissing.of(), @JsonProperty("XResolution") @ExcludeMissing - xResolution: JsonField = JsonMissing.of(), + xResolution: JsonField = JsonMissing.of(), @JsonProperty("YResolution") @ExcludeMissing - yResolution: JsonField = JsonMissing.of(), + yResolution: JsonField = JsonMissing.of(), ) : this( compression, resolutionUnit, @@ -4176,13 +3265,13 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun xResolution(): Optional = xResolution.getOptional("XResolution") + fun xResolution(): Optional = xResolution.getOptional("XResolution") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun yResolution(): Optional = yResolution.getOptional("YResolution") + fun yResolution(): Optional = yResolution.getOptional("YResolution") /** * Returns the raw JSON value of [compression]. @@ -4232,7 +3321,7 @@ private constructor( */ @JsonProperty("XResolution") @ExcludeMissing - fun _xResolution(): JsonField = xResolution + fun _xResolution(): JsonField = xResolution /** * Returns the raw JSON value of [yResolution]. @@ -4242,7 +3331,7 @@ private constructor( */ @JsonProperty("YResolution") @ExcludeMissing - fun _yResolution(): JsonField = yResolution + fun _yResolution(): JsonField = yResolution @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4269,8 +3358,8 @@ private constructor( private var resolutionUnit: JsonField = JsonMissing.of() private var thumbnailLength: JsonField = JsonMissing.of() private var thumbnailOffset: JsonField = JsonMissing.of() - private var xResolution: JsonField = JsonMissing.of() - private var yResolution: JsonField = JsonMissing.of() + private var xResolution: JsonField = JsonMissing.of() + private var yResolution: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4339,29 +3428,29 @@ private constructor( this.thumbnailOffset = thumbnailOffset } - fun xResolution(xResolution: Double) = xResolution(JsonField.of(xResolution)) + fun xResolution(xResolution: Long) = xResolution(JsonField.of(xResolution)) /** * Sets [Builder.xResolution] to an arbitrary JSON value. * - * You should usually call [Builder.xResolution] with a well-typed [Double] value + * You should usually call [Builder.xResolution] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun xResolution(xResolution: JsonField) = apply { + fun xResolution(xResolution: JsonField) = apply { this.xResolution = xResolution } - fun yResolution(yResolution: Double) = yResolution(JsonField.of(yResolution)) + fun yResolution(yResolution: Long) = yResolution(JsonField.of(yResolution)) /** * Sets [Builder.yResolution] to an arbitrary JSON value. * - * You should usually call [Builder.yResolution] with a well-typed [Double] value + * You should usually call [Builder.yResolution] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun yResolution(yResolution: JsonField) = apply { + fun yResolution(yResolution: JsonField) = apply { this.yResolution = yResolution } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt index 88196800..f20cbd08 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt @@ -871,9 +871,8 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { @@ -1014,9 +1013,8 @@ private constructor( object : Visitor { override fun visitStrings(strings: List) = strings.size - override fun visitAll(all: JsonValue) = all.let { - if (it == JsonValue.from("all")) 1 else 0 - } + override fun visitAll(all: JsonValue) = + all.let { if (it == JsonValue.from("all")) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt index ec5e7dbf..b93f0bfc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt @@ -95,9 +95,8 @@ private constructor( */ fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: JsonField>) = apply { - this.successfullyUpdatedFileIds = successfullyUpdatedFileIds.map { - it.toMutableList() - } + this.successfullyUpdatedFileIds = + successfullyUpdatedFileIds.map { it.toMutableList() } } /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt index 06991cdf..482d08bd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt @@ -95,9 +95,8 @@ private constructor( */ fun successfullyDeletedFileIds(successfullyDeletedFileIds: JsonField>) = apply { - this.successfullyDeletedFileIds = successfullyDeletedFileIds.map { - it.toMutableList() - } + this.successfullyDeletedFileIds = + successfullyDeletedFileIds.map { it.toMutableList() } } /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt index d2fbe196..fdf89448 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -95,9 +95,8 @@ private constructor( */ fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: JsonField>) = apply { - this.successfullyUpdatedFileIds = successfullyUpdatedFileIds.map { - it.toMutableList() - } + this.successfullyUpdatedFileIds = + successfullyUpdatedFileIds.map { it.toMutableList() } } /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt index cdfd98b3..1395119e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt @@ -95,9 +95,8 @@ private constructor( */ fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: JsonField>) = apply { - this.successfullyUpdatedFileIds = successfullyUpdatedFileIds.map { - it.toMutableList() - } + this.successfullyUpdatedFileIds = + successfullyUpdatedFileIds.map { it.toMutableList() } } /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt index bf326008..8c8ded52 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt @@ -288,11 +288,9 @@ private constructor( * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -430,11 +428,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, if the * SDK is on an older version than the API, then the API may respond with new members that * the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt index 295dc266..eea9cab4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt @@ -1451,11 +1451,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1600,11 +1598,9 @@ private constructor( * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Protocol] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt index c5d5c55f..c5950733 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -1028,11 +1028,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1177,11 +1175,9 @@ private constructor( * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Protocol] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt index 396cd63d..6d2169f9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -1875,11 +1875,9 @@ private constructor( * * An instance of [AiAutoDescription] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2025,11 +2023,9 @@ private constructor( * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. * * An instance of [AiTasks] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2177,11 +2173,9 @@ private constructor( * * An instance of [AwsAutoTagging] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2329,11 +2323,9 @@ private constructor( * * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2479,11 +2471,9 @@ private constructor( * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. * * An instance of [RemoveBg] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt index ec19ee10..a0d0711c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -933,11 +933,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1494,11 +1492,9 @@ private constructor( * * An instance of [AudioCodec] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1650,11 +1646,9 @@ private constructor( * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Format] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1808,11 +1802,9 @@ private constructor( * * An instance of [StreamProtocol] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1961,11 +1953,9 @@ private constructor( * * An instance of [VideoCodec] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt index 20876918..f14cea7e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt @@ -961,11 +961,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1282,11 +1280,9 @@ private constructor( * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Reason] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1863,11 +1859,9 @@ private constructor( * * An instance of [AudioCodec] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2019,11 +2013,9 @@ private constructor( * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Format] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2177,11 +2169,9 @@ private constructor( * * An instance of [StreamProtocol] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2330,11 +2320,9 @@ private constructor( * * An instance of [VideoCodec] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt index 572bd48a..c20ecd16 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt @@ -994,11 +994,9 @@ private constructor( * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1555,11 +1553,9 @@ private constructor( * * An instance of [AudioCodec] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1711,11 +1707,9 @@ private constructor( * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Format] can contain an unknown value in a couple of cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -1869,11 +1863,9 @@ private constructor( * * An instance of [StreamProtocol] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { @@ -2022,11 +2014,9 @@ private constructor( * * An instance of [VideoCodec] can contain an unknown value in a couple of * cases: - * * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may * respond with new members that the SDK is unaware of. - * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt index 7f555060..5b01b0fc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt @@ -203,7 +203,6 @@ interface FileServiceAsync { * **Version limit** \ A file can have a maximum of 100 versions. * * **Demo applications** - * * - A full-fledged * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt index 39fe358b..1bd07809 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt @@ -42,7 +42,6 @@ interface FileServiceAsync { * **Version limit** \ A file can have a maximum of 100 versions. * * **Demo applications** - * * - A full-fledged * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt index 9fd39e19..f08afc49 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt @@ -189,7 +189,6 @@ interface FileService { * **Version limit** \ A file can have a maximum of 100 versions. * * **Demo applications** - * * - A full-fledged * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt index 26c56f4f..c5152a7c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt @@ -12,7 +12,6 @@ import io.imagekit.errors.ImageKitInvalidDataException import io.imagekit.errors.ImageKitWebhookException import io.imagekit.models.webhooks.UnsafeUnwrapWebhookEvent import io.imagekit.models.webhooks.UnwrapWebhookEvent -import java.util.Base64 import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -56,8 +55,7 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO val headersMap = headers.names().associateWith { name -> headers.values(name) }.toMap() - val encodedKey = Base64.getEncoder().encodeToString(webhookSecret.toByteArray()) - val webhook = Webhook(encodedKey) + val webhook = Webhook(webhookSecret) webhook.verify(unwrapParams.body(), headersMap) } catch (e: WebhookVerificationException) { throw ImageKitWebhookException("Could not verify webhook event signature", e) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt index 8b239b59..499eb3d3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt @@ -42,7 +42,6 @@ interface FileService { * **Version limit** \ A file can have a maximum of 100 versions. * * **Demo applications** - * * - A full-fledged * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt index 9b96e041..b9a37cba 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt @@ -67,7 +67,6 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -82,57 +81,33 @@ internal class FileUploadResponseTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -152,8 +127,8 @@ internal class FileUploadResponseTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -246,7 +221,6 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -261,57 +235,33 @@ internal class FileUploadResponseTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -331,8 +281,8 @@ internal class FileUploadResponseTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -432,7 +382,6 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -447,57 +396,33 @@ internal class FileUploadResponseTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -517,8 +442,8 @@ internal class FileUploadResponseTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt index 6ffad9ef..07f1f69e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt @@ -66,7 +66,6 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -81,57 +80,33 @@ internal class FileUploadResponseTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -151,8 +126,8 @@ internal class FileUploadResponseTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -245,7 +220,6 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -260,57 +234,33 @@ internal class FileUploadResponseTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -330,8 +280,8 @@ internal class FileUploadResponseTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -431,7 +381,6 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -446,57 +395,33 @@ internal class FileUploadResponseTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -516,8 +441,8 @@ internal class FileUploadResponseTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt index 0b773633..ab004c52 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt @@ -23,7 +23,6 @@ internal class MetadataTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -38,57 +37,33 @@ internal class MetadataTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -108,8 +83,8 @@ internal class MetadataTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -135,7 +110,6 @@ internal class MetadataTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -150,57 +124,33 @@ internal class MetadataTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -220,8 +170,8 @@ internal class MetadataTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -251,7 +201,6 @@ internal class MetadataTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -266,57 +215,33 @@ internal class MetadataTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -336,8 +261,8 @@ internal class MetadataTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index fd3c10c9..d7674219 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -639,7 +639,6 @@ internal class UnsafeUnwrapWebhookEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -654,57 +653,35 @@ internal class UnsafeUnwrapWebhookEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() ) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -724,8 +701,8 @@ internal class UnsafeUnwrapWebhookEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -876,7 +853,6 @@ internal class UnsafeUnwrapWebhookEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -891,57 +867,37 @@ internal class UnsafeUnwrapWebhookEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) .gps( Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) .addGpsVersionId(0L) .build() ) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -964,8 +920,8 @@ internal class UnsafeUnwrapWebhookEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt index 23347b93..616ad516 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt @@ -637,7 +637,6 @@ internal class UnwrapWebhookEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -652,57 +651,35 @@ internal class UnwrapWebhookEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() ) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -722,8 +699,8 @@ internal class UnwrapWebhookEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -874,7 +851,6 @@ internal class UnwrapWebhookEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -889,57 +865,37 @@ internal class UnwrapWebhookEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) .gps( Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) .addGpsVersionId(0L) .build() ) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -962,8 +918,8 @@ internal class UnwrapWebhookEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt index 5e839689..4c62f94f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -88,7 +88,6 @@ internal class UploadPreTransformSuccessEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -103,57 +102,35 @@ internal class UploadPreTransformSuccessEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() ) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -173,8 +150,8 @@ internal class UploadPreTransformSuccessEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -294,7 +271,6 @@ internal class UploadPreTransformSuccessEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -309,57 +285,33 @@ internal class UploadPreTransformSuccessEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) - .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -379,8 +331,8 @@ internal class UploadPreTransformSuccessEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() @@ -509,7 +461,6 @@ internal class UploadPreTransformSuccessEventTest { .exif( Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) - .brightnessValue(0.0) .colorSpace(0L) .createDate("CreateDate") .customRendered(0L) @@ -524,57 +475,35 @@ internal class UploadPreTransformSuccessEventTest { .flash(0L) .flashpixVersion("FlashpixVersion") .fNumber(0.0) - .focalLength(0.0) - .focalLengthIn35mmFormat(0L) + .focalLength(0L) .focalPlaneResolutionUnit(0L) .focalPlaneXResolution(0.0) .focalPlaneYResolution(0.0) .interopOffset(0L) .iso(0L) - .lensModel("LensModel") - .lightSource(0L) - .maxApertureValue(0.0) .meteringMode(0L) .sceneCaptureType(0L) - .sceneType("SceneType") - .sensingMethod(0L) .shutterSpeedValue(0.0) .subSecTime("SubSecTime") - .userComment("UserComment") .whiteBalance(0L) .build() ) .gps( - Metadata.Exif.Gps.builder() - .gpsAltitude(0.0) - .gpsAltitudeRef(0L) - .gpsDateStamp("GPSDateStamp") - .gpsImgDirection(0.0) - .gpsImgDirectionRef("GPSImgDirectionRef") - .addGpsLatitude(0.0) - .gpsLatitudeRef("GPSLatitudeRef") - .addGpsLongitude(0.0) - .gpsLongitudeRef("GPSLongitudeRef") - .addGpsTimeStamp(0.0) - .addGpsVersionId(0L) - .build() + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() ) .image( Metadata.Exif.Image.builder() - .artist("Artist") - .copyright("Copyright") .exifOffset(0L) .gpsInfo(0L) - .imageDescription("ImageDescription") .make("Make") .model("Model") .modifyDate("ModifyDate") .orientation(0L) .resolutionUnit(0L) .software("Software") - .xResolution(0.0) + .xResolution(0L) .yCbCrPositioning(0L) - .yResolution(0.0) + .yResolution(0L) .build() ) .interoperability( @@ -594,8 +523,8 @@ internal class UploadPreTransformSuccessEventTest { .resolutionUnit(0L) .thumbnailLength(0L) .thumbnailOffset(0L) - .xResolution(0.0) - .yResolution(0.0) + .xResolution(0L) + .yResolution(0L) .build() ) .build() diff --git a/image-kit-java-example/build.gradle.kts b/image-kit-java-example/build.gradle.kts index 43f09527..f9f4b81b 100644 --- a/image-kit-java-example/build.gradle.kts +++ b/image-kit-java-example/build.gradle.kts @@ -8,8 +8,7 @@ repositories { } dependencies { - implementation(project(":image-kit-java-core")) - implementation(project(":image-kit-java-client-okhttp")) + implementation(project(":image-kit-java")) } tasks.withType().configureEach { @@ -20,7 +19,7 @@ tasks.withType().configureEach { application { // Use `./gradlew :image-kit-java-example:run` to run `Main` // Use `./gradlew :image-kit-java-example:run -Pexample=Something` to run `SomethingExample` - mainClass = "io.imagekit.example.${ + mainClass = "com.imagekit.api.example.${ if (project.hasProperty("example")) "${project.property("example")}Example" else diff --git a/image-kit-java-example/src/main/java/io/imagekit/example/Main.java b/image-kit-java-example/src/main/java/io/imagekit/example/Main.java deleted file mode 100644 index f9881a57..00000000 --- a/image-kit-java-example/src/main/java/io/imagekit/example/Main.java +++ /dev/null @@ -1,117 +0,0 @@ -package io.imagekit.example; - -import io.imagekit.client.ImageKitClient; -import io.imagekit.client.okhttp.ImageKitOkHttpClient; -import io.imagekit.models.ExtensionItem; -import io.imagekit.models.ExtensionItem.AiTasks.Task.YesNo; -import io.imagekit.models.ExtensionItem.AiTasks.Task.YesNo.OnNo; -import io.imagekit.models.ExtensionItem.AiTasks.Task.YesNo.OnYes; -import io.imagekit.models.files.FileUploadParams; -import io.imagekit.models.files.FileUploadResponse; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -public final class Main { - public static void main(String[] args) throws IOException, URISyntaxException { - // Initialize the client using the IMAGEKIT_PRIVATE_KEY environment variable - ImageKitClient client = ImageKitOkHttpClient.builder().fromEnv().build(); - - // Resolve the sample image bundled in src/main/resources/test.png - Path filePath; - if (args.length > 0) { - filePath = Paths.get(args[0]); - } else { - filePath = Paths.get(Main.class.getResource("/test.png").toURI()); - } - System.out.println("Using file: " + filePath); - System.out.println(); - - // --- Example 1: Upload using Path --- - System.out.println("=== Upload using Path ==="); - FileUploadParams pathParams = FileUploadParams.builder() - .fileName("path-upload.jpg") - .file(filePath) - .folder("/java-sdk-testing") - .build(); - FileUploadResponse pathResponse = client.files().upload(pathParams); - System.out.println("Uploaded: " + pathResponse.name()); - System.out.println("URL: " + pathResponse.url()); - System.out.println("File ID: " + pathResponse.fileId()); - System.out.println(); - - // --- Example 2: Upload using InputStream --- - System.out.println("=== Upload using InputStream ==="); - InputStream imageStream = Main.class.getResourceAsStream("/test.png"); - FileUploadParams streamParams = FileUploadParams.builder() - .fileName("stream-upload.jpg") - .file(imageStream) - .folder("/java-sdk-testing") - .build(); - FileUploadResponse streamResponse = client.files().upload(streamParams); - System.out.println("Uploaded: " + streamResponse.name()); - System.out.println("URL: " + streamResponse.url()); - System.out.println("File ID: " + streamResponse.fileId()); - System.out.println(); - - // --- Example 3: Upload using byte[] --- - System.out.println("=== Upload using byte[] ==="); - byte[] fileBytes = Files.readAllBytes(filePath); - FileUploadParams bytesParams = FileUploadParams.builder() - .fileName("bytes-upload.jpg") - .file(fileBytes) - .folder("/java-sdk-testing") - .build(); - FileUploadResponse bytesResponse = client.files().upload(bytesParams); - System.out.println("Uploaded: " + bytesResponse.name()); - System.out.println("URL: " + bytesResponse.url()); - System.out.println("File ID: " + bytesResponse.fileId()); - System.out.println(); - - // --- Example 4: Upload with tags and folder --- - System.out.println("=== Upload with tags and folder ==="); - FileUploadParams taggedParams = FileUploadParams.builder() - .fileName("tagged-upload.jpg") - .file(filePath) - .folder("/java-sdk-testing") - .addTag("example") - .addTag("java-sdk") - .useUniqueFileName(false) - .build(); - FileUploadResponse taggedResponse = client.files().upload(taggedParams); - System.out.println("Uploaded: " + taggedResponse.name()); - System.out.println("URL: " + taggedResponse.url()); - System.out.println("File ID: " + taggedResponse.fileId()); - System.out.println("Tags: " + taggedResponse.tags()); - - System.out.println(); - - // --- Example 5: Upload with AI tasks extension --- - System.out.println("=== Upload with AI tasks extension ==="); - FileUploadParams aiParams = FileUploadParams.builder() - .fileName("ai-task-upload.png") - .file(filePath) - .folder("/java-sdk-testing") - .addExtension(ExtensionItem.AiTasks.builder() - .addTask(YesNo.builder() - .instruction("Does this image contain a person?") - .onYes(OnYes.builder().addAddTag("has-person").build()) - .onNo(OnNo.builder().addAddTag("no-person").build()) - .build()) - .addSelectTagsTask("What objects are visible in this image?") - .build()) - .addTag("ai-processed") - .build(); - FileUploadResponse aiResponse = client.files().upload(aiParams); - System.out.println("Uploaded: " + aiResponse.name()); - System.out.println("URL: " + aiResponse.url()); - System.out.println("File ID: " + aiResponse.fileId()); - System.out.println("Extensions: " + aiResponse.extensionStatus()); - - System.out.println(); - System.out.println("All uploads completed successfully!"); - } -} diff --git a/image-kit-java-lib/build.gradle.kts b/image-kit-java-lib/build.gradle.kts deleted file mode 100644 index dc97c82e..00000000 --- a/image-kit-java-lib/build.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - id("image-kit.kotlin") -} - -dependencies { - api(project(":image-kit-java-core")) - - testImplementation(kotlin("test")) - testImplementation(project(":image-kit-java-client-okhttp")) - testImplementation("org.assertj:assertj-core:3.27.7") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") -} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt deleted file mode 100644 index 4ec0df72..00000000 --- a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt +++ /dev/null @@ -1,517 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.client.okhttp.ImageKitOkHttpClient -import io.imagekit.models.SrcOptions -import io.imagekit.models.StreamingResolution -import io.imagekit.models.Transformation -import io.imagekit.models.TransformationPosition -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperAdvancedTransformationsTest { - - private val privateKey = "My Private API Key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - // AI Transformation Tests - @Test - fun `should generate the correct URL for AI background removal when set to true`() { - val transformation = - listOf( - Transformation.builder() - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove") - } - - @Test - fun `should generate the correct URL for external AI background removal when set to true`() { - val transformation = - listOf( - Transformation.builder() - .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-removedotbg") - } - - @Test - fun `should generate the correct URL when AI drop shadow transformation is set to true`() { - val transformation = listOf(Transformation.builder().aiDropShadowTrue().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow") - } - - @Test - fun `should generate the correct URL when gradient transformation is set to true`() { - val transformation = listOf(Transformation.builder().gradientTrue().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient") - } - - @Test - fun `should not apply AI background removal when value is not true`() { - val transformation = listOf(Transformation.builder().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") - } - - @Test - fun `should not apply external AI background removal when value is not true`() { - val transformation = listOf(Transformation.builder().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") - } - - @Test - fun `should handle AI transformations with parameters`() { - val transformation = - listOf(Transformation.builder().aiDropShadow("custom-shadow-params").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow-custom-shadow-params" - ) - } - - @Test - fun `should handle gradient with parameters`() { - val transformation = - listOf(Transformation.builder().gradient("ld-top_from-green_to-00FF0010_sp-1").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient-ld-top_from-green_to-00FF0010_sp-1" - ) - } - - @Test - fun `should combine AI transformations with regular transformations`() { - val transformation = - listOf( - Transformation.builder() - .width(300.0) - .height(200.0) - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,e-bgremove" - ) - } - - @Test - fun `should handle multiple AI transformations`() { - val transformation = - listOf( - Transformation.builder() - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .aiDropShadowTrue() - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove,e-dropshadow" - ) - } - - // Parameter-specific tests - @Test - fun `should generate the correct URL for width transformation when provided with a number value`() { - val transformation = listOf(Transformation.builder().width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-400") - } - - @Test - fun `should generate the correct URL for height transformation when provided with a string value`() { - val transformation = listOf(Transformation.builder().height("300").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=h-300") - } - - @Test - fun `should generate the correct URL for aspectRatio transformation when provided with colon format`() { - val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=ar-4:3") - } - - @Test - fun `should generate the correct URL for quality transformation when provided with a number value`() { - val transformation = listOf(Transformation.builder().quality(80.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=q-80") - } - - @Test - fun `should skip transformation parameters that are undefined or empty`() { - val transformation = listOf(Transformation.builder().width(300.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300") - } - - @Test - fun `should handle boolean transformation values`() { - val transformation = listOf(Transformation.builder().trimTrue().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=t-true") - } - - @Test - fun `should handle transformation parameter with empty string value`() { - val transformation = listOf(Transformation.builder().defaultImage("").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") - } - - @Test - fun `should handle complex transformation combinations`() { - val transformation = - listOf( - Transformation.builder() - .width(300.0) - .height(200.0) - .quality(85.0) - .border("5_FF0000") - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,q-85,b-5_FF0000" - ) - } - - @Test - fun `should generate the correct URL for radius transformation with string value for per corner radius`() { - val transformation = listOf(Transformation.builder().radius("10_10_max_10").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=r-10_10_max_10") - } - - @Test - fun `should generate the correct URL with many transformations, including video and AI transforms`() { - val transformation = - listOf( - Transformation.builder() - .height(300.0) - .width(400.0) - .aspectRatio("4-3") - .quality(40.0) - .crop(Transformation.Crop.FORCE) - .cropMode(Transformation.CropMode.EXTRACT) - .focus("left") - .format(Transformation.Format.JPEG) - .radius(50.0) - .background("A94D34") - .border("5-A94D34") - .rotation(90.0) - .blur(10.0) - .named("some_name") - .progressive(true) - .lossless(true) - .trim(5.0) - .metadata(true) - .colorProfile(true) - .defaultImage("/folder/file.jpg/") - .dpr(3.0) - .x(10.0) - .y(20.0) - .xCenter(30.0) - .yCenter(40.0) - .flip(Transformation.Flip.H) - .opacity(0.8) - .zoom(2.0) - .videoCodec(Transformation.VideoCodec.H264) - .audioCodec(Transformation.AudioCodec.AAC) - .startOffset(5.0) - .endOffset(15.0) - .duration(10.0) - .streamingResolutions( - listOf(StreamingResolution._1440, StreamingResolution._1080) - ) - .grayscale(Transformation.Grayscale.TRUE) - .aiUpscale(Transformation.AiUpscale.TRUE) - .aiRetouch(Transformation.AiRetouch.TRUE) - .aiVariation(Transformation.AiVariation.TRUE) - .aiDropShadowTrue() - .aiChangeBackground("prompt-car") - .aiEdit("prompt-make it vintage") - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .contrastStretch(Transformation.ContrastStretch.TRUE) - .shadow("bl-15_st-40_x-10_y-N5") - .sharpen(10.0) - .unsharpMask("2-2-0.8-0.024") - .gradient("from-red_to-white") - .colorize("co-FF0000_in-15") - .colorReplace("FF0000_100_0000FF") - .distort("a-45") - .original(true) - .page("2_4") - .raw("h-200,w-300,l-image,i-logo.png,l-end") - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,q-40,ar-4-3,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,cr-FF0000_100_0000FF,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,o-0.8,z-2,rt-90,bl-10,n-some_name,pr-true,lo-true,fl-h,t-5,md-true,cp-true,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-bgremove,e-contrast,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,e-colorize-co-FF0000_in-15,e-distort-a-45,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end" - ) - } -} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt deleted file mode 100644 index b8b361a4..00000000 --- a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt +++ /dev/null @@ -1,101 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.client.okhttp.ImageKitOkHttpClient -import kotlin.test.assertFailsWith -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperAuthenticationTest { - - private val privateKey = "private_key_test" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should return correct authentication parameters with provided token and expire`() { - val token = "your_token" - val expire = 1582269249L - - val params = client.helper().getAuthenticationParameters(token, expire) - - // Expected exact match with Node.js/Go SDK output - val expectedSignature = "e71bcd6031016b060d349d212e23e85c791decdd" - - assertThat(params["token"]).isEqualTo(token) - assertThat(params["expire"]).isEqualTo(expire) - assertThat(params["signature"]).isEqualTo(expectedSignature) - } - - @Test - fun `should return authentication parameters with required properties when no params provided`() { - val params = client.helper().getAuthenticationParameters(null, null) - - // Check that all required properties exist - assertThat(params).containsKeys("token", "expire", "signature") - - // Token should be a 32-character hex string (16 bytes as hex) - val token = params["token"] as String - assertThat(token).matches("^[0-9a-f]{32}$") - - // Expire should be a number greater than current time - val expire = params["expire"] as Long - val currentTime = System.currentTimeMillis() / 1000 - assertThat(expire).isGreaterThan(currentTime) - - // Signature should be a hex string (40 characters for HMAC-SHA1) - val signature = params["signature"] as String - assertThat(signature).matches("^[a-f0-9]{40}$") - } - - @Test - fun `should handle edge case with expire time 0`() { - val token = "test-token" - val expire = 0L - - val params = client.helper().getAuthenticationParameters(token, expire) - - assertThat(params["token"]).isEqualTo(token) - - // When expire is 0 (falsy), it should use default expire time (30 minutes from now) - val expireResult = params["expire"] as Long - val expectedExpire = System.currentTimeMillis() / 1000 + 60 * 30 - - // Allow a 10 second tolerance for test execution time - assertThat(expireResult).isBetween(expectedExpire - 10, expectedExpire + 10) - - // Signature should be a hex string (40 characters for HMAC-SHA1) - val signature = params["signature"] as String - assertThat(signature).matches("^[a-f0-9]{40}$") - } - - @Test - fun `should handle empty string token`() { - val token = "" // Empty string is falsy - val expire = 1582269249L - - val params = client.helper().getAuthenticationParameters(token, expire) - - // Since empty string is falsy, it should generate a hex token - val tokenResult = params["token"] as String - assertThat(tokenResult).isNotEmpty() - assertThat(tokenResult).matches("^[0-9a-f]{32}$") - - assertThat(params["expire"]).isEqualTo(expire) - - // Signature should be a hex string (40 characters for HMAC-SHA1) - val signature = params["signature"] as String - assertThat(signature).matches("^[a-f0-9]{40}$") - } - - @Test - fun `should return error when private key is not provided`() { - val emptyKeyClient = ImageKitOkHttpClient.builder().privateKey("").build() - - val exception = - assertFailsWith { - emptyKeyClient.helper().getAuthenticationParameters("test", 123L) - } - - assertThat(exception.message) - .isEqualTo("private API key is required for authentication parameters generation") - } -} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt deleted file mode 100644 index ced3c2a7..00000000 --- a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt +++ /dev/null @@ -1,433 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.client.okhttp.ImageKitOkHttpClient -import io.imagekit.core.JsonValue -import io.imagekit.models.SrcOptions -import io.imagekit.models.Transformation -import io.imagekit.models.TransformationPosition -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperBuildUrlTest { - - private val privateKey = "My Private API Key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should throw exception when src is not provided`() { - org.junit.jupiter.api.assertThrows { - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .build() - ) - } - } - - @Test - fun `should generate a valid URL when src is slash`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/") - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/") - } - - @Test - fun `should generate a valid URL when src is provided without transformation`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") - } - - @Test - fun `should generate a valid URL when absolute URL is provided without transformation`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - } - - @Test - fun `should generate valid URL when undefined transformation parameters are provided with path`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path_alt.jpg") - .transformationPosition(TransformationPosition.QUERY) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - } - - @Test - fun `by default transformationPosition should be query`() { - val transformation = - listOf( - Transformation.builder().height(300.0).width(400.0).build(), - Transformation.builder().rotation(90.0).build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" - ) - } - - @Test - fun `should generate the URL without sdk version`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path.jpg") - .transformation(transformation) - .transformationPosition(TransformationPosition.PATH) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-400,h-300/test_path.jpg") - } - - @Test - fun `should generate the correct URL with a valid src and transformation`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should add transformation as query when src has absolute url even if transformationPosition is path`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("https://my.custom.domain.com/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://my.custom.domain.com/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `handle non-default url-endpoint case`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/imagekit_id/new-endpoint/") - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?tr=w-400,h-300" - ) - } - - @Test - fun `should generate the correct URL when the provided path contains multiple leading slashes`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("///test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should generate the correct URL when the urlEndpoint is overridden`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint_alt") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint_alt/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should generate the correct URL with transformationPosition as query parameter when src is provided`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path.jpg") - .transformationPosition(TransformationPosition.QUERY) - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should generate the correct URL with a valid src parameter and transformation`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?tr=w-400,h-300") - } - - @Test - fun `should merge query parameters correctly in the generated URL`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("t2", JsonValue.from("v2")) - .putAdditionalProperty("t3", JsonValue.from("v3")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1") - .queryParameters(queryParams) - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1&t2=v2&t3=v3&tr=w-400,h-300" - ) - } - - @Test - fun `should generate the correct URL with chained transformations`() { - val transformation = - listOf( - Transformation.builder().height(300.0).width(400.0).build(), - Transformation.builder().rotation(90.0).build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" - ) - } - - @Test - fun `should generate the correct URL with chained transformations including raw transformation`() { - val transformation = - listOf( - Transformation.builder().height(300.0).width(400.0).build(), - Transformation.builder().raw("rndm_trnsf-abcd").build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rndm_trnsf-abcd" - ) - } - - @Test - fun `should generate the correct URL when border transformation is applied`() { - val transformation = - listOf(Transformation.builder().height(300.0).width(400.0).border("20_FF0000").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,b-20_FF0000" - ) - } - - @Test - fun `should generate the correct URL when transformation has empty key and value`() { - val transformation = listOf(Transformation.builder().raw("").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") - } - - @Test - fun `should generate a valid URL when cname is used`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://custom.domain.com") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://custom.domain.com/test_path.jpg") - } - - @Test - fun `should generate a valid URL when cname is used with a url-pattern`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://custom.domain.com/url-pattern") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://custom.domain.com/url-pattern/test_path.jpg") - } -} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt deleted file mode 100644 index f8be2b29..00000000 --- a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt +++ /dev/null @@ -1,1564 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.client.okhttp.ImageKitOkHttpClient -import io.imagekit.core.JsonValue -import io.imagekit.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperOverlayTest { - - private val privateKey = "My Private API Key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - // ======================================== - // TestOverlayTransformations - 12 tests - // ======================================== - - @Test - fun `should ignore overlay when type property is missing`() { - val transformation = listOf(Transformation.builder().width(300.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-300/base-image.jpg") - } - - @Test - fun `should ignore text overlay when text property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder().text("").type(JsonValue.from("text")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore image overlay when input property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder().input("").type(JsonValue.from("image")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore video overlay when input property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder().input("").type(JsonValue.from("video")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore subtitle overlay when input property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("") - .type(JsonValue.from("subtitle")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore solid color overlay when color property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("") - .type(JsonValue.from("solidColor")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should generate URL with text overlay using URL encoding`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Minimal Text") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Minimal%20Text,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay from input file`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with video overlay from input file`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("play-pause-loop.mp4") - .type(JsonValue.from("video")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-video.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-play-pause-loop.mp4,l-end/base-video.mp4" - ) - } - - @Test - fun `should generate URL with subtitle overlay from input file`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("subtitle.srt") - .type(JsonValue.from("subtitle")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-video.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,l-end/base-video.mp4" - ) - } - - @Test - fun `should generate URL with solid color overlay using background color`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("FF0000") - .type(JsonValue.from("solidColor")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with multiple complex overlays including nested transformations`() { - val transformation = - listOf( - // Text overlay with complex transformations - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Every thing") - .type(JsonValue.from("text")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - TextOverlayTransformation.builder() - .width("bw_mul_0.5") - .fontSize(20.0) - .fontFamily("Arial") - .fontColor("0000ff") - .innerAlignment( - TextOverlayTransformation.InnerAlignment.LEFT - ) - .padding(5.0) - .alpha(7.0) - .typography("b") - .background("red") - .radius(10.0) - .rotation("N45") - .flip(TextOverlayTransformation.Flip.H) - .lineHeight(20.0) - .build() - ) - ) - .build() - ) - ) - .build(), - // Image overlay with nested transformations including nested text overlay - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - Transformation.builder() - .width("bw_mul_0.5") - .height("bh_mul_0.5") - .rotation("N45") - .flip(Transformation.Flip.H) - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Nested text overlay") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - ) - .build() - ) - ) - .build(), - // Video overlay - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("play-pause-loop.mp4") - .type(JsonValue.from("video")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - Transformation.builder() - .width("bw_mul_0.5") - .height("bh_mul_0.5") - .rotation("N45") - .flip(Transformation.Flip.H) - .build() - ) - ) - .build() - ) - ) - .build(), - // Subtitle overlay - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("subtitle.srt") - .type(JsonValue.from("subtitle")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - SubtitleOverlayTransformation.builder() - .background("red") - .color("0000ff") - .fontFamily("Arial") - .fontOutline("2_A1CCDD50") - .fontShadow("A1CCDD_3") - .build() - ) - ) - .build() - ) - ) - .build(), - // Solid color overlay - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("FF0000") - .type(JsonValue.from("solidColor")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - SolidColorOverlayTransformation.builder() - .width("bw_mul_0.5") - .height("bh_mul_0.5") - .alpha(0.5) - .background("red") - .gradientTrue() - .radiusMax() - .build() - ) - ) - .build() - ) - ) - .build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Every%20thing,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,fs-20,ff-Arial,co-0000ff,ia-left,pa-5,al-7,tg-b,bg-red,r-10,rt-N45,fl-h,lh-20,l-end:l-image,i-logo.png,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-text,i-Nested%20text%20overlay,l-end,l-end:l-video,i-play-pause-loop.mp4,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-end:l-subtitles,i-subtitle.srt,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,bg-red,co-0000ff,ff-Arial,fol-2_A1CCDD50,fsh-A1CCDD_3,l-end:l-image,i-ik_canvas,bg-FF0000,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,al-0.5,bg-red,e-gradient,r-max,l-end/base-image.jpg" - ) - } - - // ======================================== - // TestOverlayEncoding - 19 tests - // ======================================== - - @Test - fun `should use plain encoding for simple image paths with slashes converted to @@`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer_logo/nykaa.png") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,i-customer_logo@@nykaa.png,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use base64 encoding for image paths containing special characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer_logo/Ñykaa.png") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXJfbG9nby%2FDkXlrYWEucG5n,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use plain encoding for simple text overlays`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder().text("Manu").type(JsonValue.from("text")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,i-Manu,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should convert slashes to @@ in fontFamily paths for custom fonts`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Manu") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontFamily("nested-path/Poppins-Regular_Q15GrYWmL.ttf") - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,i-Manu,ff-nested-path@@Poppins-Regular_Q15GrYWmL.ttf,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use URL encoding for text overlays with spaces and safe characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("alnum123-._ ") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,i-alnum123-._%20,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use base64 encoding for text overlays with special unicode characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Let's use ©, ®, ™, etc") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,ie-TGV0J3MgdXNlIMKpLCDCriwg4oSiLCBldGM%3D,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use plain encoding when explicitly specified for text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("HelloWorld") - .type(JsonValue.from("text")) - .encoding(TextOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/demo/tr:l-text,i-HelloWorld,l-end/sample.jpg") - } - - @Test - fun `should use base64 encoding when explicitly specified for text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("HelloWorld") - .type(JsonValue.from("text")) - .encoding(TextOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,ie-SGVsbG9Xb3JsZA%3D%3D,l-end/sample.jpg" - ) - } - - @Test - fun `should use plain encoding when explicitly specified for image overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer/logo.png") - .type(JsonValue.from("image")) - .encoding(ImageOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,i-customer@@logo.png,l-end/sample.jpg" - ) - } - - @Test - fun `should use base64 encoding when explicitly specified for image overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer/logo.png") - .type(JsonValue.from("image")) - .encoding(ImageOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXIvbG9nby5wbmc%3D,l-end/sample.jpg" - ) - } - - @Test - fun `should use base64 encoding when explicitly specified for video overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("/path/to/video.mp4") - .type(JsonValue.from("video")) - .encoding(VideoOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-video,ie-cGF0aC90by92aWRlby5tcDQ%3D,l-end/sample.mp4" - ) - } - - @Test - fun `should use plain encoding when explicitly specified for subtitle overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("/sub.srt") - .type(JsonValue.from("subtitle")) - .encoding(SubtitleOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/demo/tr:l-subtitles,i-sub.srt,l-end/sample.mp4") - } - - @Test - fun `should use base64 encoding when explicitly specified for subtitle overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("sub.srt") - .type(JsonValue.from("subtitle")) - .encoding(SubtitleOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-subtitles,ie-c3ViLnNydA%3D%3D,l-end/sample.mp4" - ) - } - - @Test - fun `should properly encode overlay text when transformations are in query parameters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Minimal Text") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.QUERY) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/demo/sample.jpg?tr=l-text,i-Minimal%20Text,l-end") - } - - @Test - fun `should generate URL with image overlay using layerMode multiply`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.MULTIPLY) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lm-multiply,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using layerMode cutter`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("mask.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.CUTTER) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-mask.png,lm-cutter,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using layerMode cutout`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("shape.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.CUTOUT) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-shape.png,lm-cutout,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using layerMode displace`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("displacement.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.DISPLACE) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-displacement.png,lm-displace,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using xCenter yCenter and anchorPoint`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .position( - OverlayPosition.builder() - .xCenter(50.0) - .yCenter("bh_mul_0.5") - .anchorPoint(OverlayPosition.AnchorPoint.TOP_LEFT) - .build() - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lxc-50,lyc-bh_mul_0.5,lap-top_left,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Hello") - .type(JsonValue.from("text")) - .layerMode(BaseOverlay.LayerMode.MULTIPLY) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,lm-multiply,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on video overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("video.mp4") - .type(JsonValue.from("video")) - .layerMode(BaseOverlay.LayerMode.MULTIPLY) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-video.mp4,lm-multiply,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on subtitle overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("subtitle.srt") - .type(JsonValue.from("subtitle")) - .layerMode(BaseOverlay.LayerMode.CUTTER) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,lm-cutter,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on solid color overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("FF0000") - .type(JsonValue.from("solidColor")) - .layerMode(BaseOverlay.LayerMode.CUTOUT) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,lm-cutout,l-end/base-image.jpg" - ) - } - - @Test - fun `should strip leading and trailing slashes from image overlay input path`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/path/to/logo.png/") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-path@@to@@logo.png,l-end/base-image.jpg" - ) - } - - @Test - fun `should strip leading and trailing slashes from fontFamily in text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Hello") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontFamily("/sdk-testing-files/Poppins-Regular.ttf/") - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,ff-sdk-testing-files@@Poppins-Regular.ttf,l-end/base-image.jpg" - ) - } - - @Test - fun `should use processInputPath for subtitle overlay with slashes`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("/path/to/subtitle.srt") - .type(JsonValue.from("subtitle")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-path@@to@@subtitle.srt,l-end/base-image.jpg" - ) - } - - @Test - fun `should order anchorPoint before focus in overlay position`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .position( - OverlayPosition.builder() - .focus(OverlayPosition.Focus.CENTER) - .anchorPoint(OverlayPosition.AnchorPoint.BOTTOM_RIGHT) - .build() - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lap-bottom_right,lfo-center,l-end/base-image.jpg" - ) - } - - @Test - fun `should properly path-escape special characters in plain text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Hello World") - .type(JsonValue.from("text")) - .encoding(TextOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello%20World,l-end/base-image.jpg" - ) - } -} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt deleted file mode 100644 index 8c24cf6e..00000000 --- a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt +++ /dev/null @@ -1,279 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.client.okhttp.ImageKitOkHttpClient -import io.imagekit.core.JsonValue -import io.imagekit.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperSigningTest { - - private val privateKey = "dummy-key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should generate a signed URL when signed is true without expiresIn`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?ik-s=32dbbbfc5f945c0403c71b54c38e76896ef2d6b0" - ) - } - - @Test - fun `should generate a signed URL when signed is true with expiresIn`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(true) - .expiresIn(3600.0) - .build() - ) - - // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. - assertThat(url).contains("ik-t") - } - - @Test - fun `should generate a signed URL when expiresIn is above 0 and even if signed is false`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(false) - .expiresIn(3600.0) - .build() - ) - - // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. - assertThat(url).contains("ik-t") - } - - @Test - fun `should generate signed URL with special characters in filename`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/हिन्दी.png") - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=3fff2f31da1f45e007adcdbe95f88c8c330e743c" - ) - } - - @Test - fun `should generate signed URL with text overlay containing special characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("हिन्दी") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontColor("red") - .fontSize("32") - .fontFamily( - "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" - ) - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/हिन्दी.png") - .transformation(transformation) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?tr=l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end&ik-s=705e41579d368caa6530a4375355325277fcfe5c" - ) - } - - @Test - fun `should generate signed URL with text overlay and special characters using path transformation position`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("हिन्दी") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontColor("red") - .fontSize("32") - .fontFamily( - "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" - ) - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/हिन्दी.png") - .transformationPosition(TransformationPosition.PATH) - .transformation(transformation) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=20958f6126fd67c90653f55a49f2b7bb938d9d1c" - ) - } - - @Test - fun `should generate signed URL with query parameters`() { - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("version", JsonValue.from("1.0")) - .putAdditionalProperty("cache", JsonValue.from("false")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .queryParameters(queryParams) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?cache=false&version=1.0&ik-s=03767bb6f0898c04e42f65714af65d937c696d66" - ) - } - - @Test - fun `should generate signed URL with transformations and query parameters`() { - val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) - - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("version", JsonValue.from("2.0")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .transformation(transformation) - .queryParameters(queryParams) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=2.0&tr=w-300,h-200&ik-s=601d97a7834b7554f4dabf0d3fc3a219ceeb6b31" - ) - } - - @Test - fun `should not sign URL when signed is false`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(false) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/demo/sdk-testing-files/future-search.png") - assertThat(url).doesNotContain("ik-s=") - assertThat(url).doesNotContain("ik-t=") - } - - @Test - fun `should generate signed URL with transformations in path position and query parameters`() { - val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) - - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("version", JsonValue.from("2.0")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .transformation(transformation) - .transformationPosition(TransformationPosition.PATH) - .queryParameters(queryParams) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:w-300,h-200/sdk-testing-files/future-search.png?version=2.0&ik-s=dd1ee8f83d019bc59fd57a5fc4674a11eb8a3496" - ) - } -} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt deleted file mode 100644 index 504f0acd..00000000 --- a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt +++ /dev/null @@ -1,108 +0,0 @@ -package io.imagekit.lib - -import io.imagekit.client.okhttp.ImageKitOkHttpClient -import io.imagekit.core.JsonValue -import io.imagekit.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperTransformationTest { - - private val privateKey = "test-key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should return empty string for empty transformation array`() { - val result = client.helper().buildTransformationString(null) - assertThat(result).isEmpty() - - val result2 = client.helper().buildTransformationString(emptyList()) - assertThat(result2).isEmpty() - } - - @Test - fun `should generate transformation string for width only`() { - val transformation = listOf(Transformation.builder().width(300.0).build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300") - } - - @Test - fun `should generate transformation string for multiple parameters`() { - val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300,h-200") - } - - @Test - fun `should generate transformation string for chained transformations`() { - val transformation = - listOf( - Transformation.builder().width(300.0).build(), - Transformation.builder().height(200.0).build(), - ) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300:h-200") - } - - @Test - fun `should handle empty transformation object`() { - val transformation = listOf(Transformation.builder().build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEmpty() - } - - @Test - fun `should handle transformation with overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder().text("Hello").type(JsonValue.from("text")).build() - ) - ) - .build() - ) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("l-text,i-Hello,l-end") - } - - @Test - fun `should handle raw transformation parameter`() { - val transformation = listOf(Transformation.builder().raw("custom-transform-123").build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("custom-transform-123") - } - - @Test - fun `should handle mixed parameters with raw`() { - val transformation = - listOf(Transformation.builder().width(300.0).raw("custom-param-123").build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300,custom-param-123") - } - - @Test - fun `should handle quality parameter`() { - val transformation = listOf(Transformation.builder().quality(80.0).build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("q-80") - } - - @Test - fun `should handle aspect ratio parameter`() { - val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("ar-4:3") - } -} diff --git a/release-please-config.json b/release-please-config.json index 0a47df51..8f987198 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -2,11 +2,11 @@ "packages": { ".": {} }, - "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", "include-v-in-tag": true, "include-component-in-tag": false, "versioning": "prerelease", - "prerelease": false, + "prerelease": true, "bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false, "pull-request-header": "Automated Release PR",