diff --git a/.release-please-manifest.json b/.release-please-manifest.json index bd7f384..29102ae 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.2.0" + ".": "4.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index dbc39e1..7401c19 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-13fc3d7cafdea492f62eef7c1d63424d6d9d8adbff74b9f6ca6fd3fc12a36840.yml -openapi_spec_hash: a1fe6fa48207791657a1ea2d60a6dfcc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e5b5a158784fff63311ceef956e8d5ce9e87c6b557d23ab737270040eb39adcd.yml +openapi_spec_hash: b0293985a8806f367319af573d1b418c config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/CHANGELOG.md b/CHANGELOG.md index b37e93d..ef50677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 4.3.0 (2026-02-27) + +Full Changelog: [v4.2.0...v4.3.0](https://github.com/imagekit-developer/imagekit-ruby/compare/v4.2.0...v4.3.0) + +### Features + +* **api:** dpr type update ([650aa0f](https://github.com/imagekit-developer/imagekit-ruby/commit/650aa0f905b4a586c036ae2f019bd7cfb7775d40)) + + +### Bug Fixes + +* **client:** always add content-length to post body, even when empty ([e156b70](https://github.com/imagekit-developer/imagekit-ruby/commit/e156b70c82c9b38de49307218fb3f687f651aa5b)) +* **client:** loosen json header parsing ([9fc1fc6](https://github.com/imagekit-developer/imagekit-ruby/commit/9fc1fc60c60173f92f1f99fabe38f9ec826d940d)) +* **client:** serialize query parameters properly ([bbfc6e0](https://github.com/imagekit-developer/imagekit-ruby/commit/bbfc6e0d80da5661600a888e8c915d336919fe36)) +* properly mock time in ruby ci tests ([8f0a0a9](https://github.com/imagekit-developer/imagekit-ruby/commit/8f0a0a93ebc66d8d56d5e47950607f8d67f37514)) + + +### Chores + +* **docs:** remove www prefix ([a4b9610](https://github.com/imagekit-developer/imagekit-ruby/commit/a4b961058ac8967dcfef109421dbca9ee3eedf0b)) +* **internal:** remove mock server code ([c8aa3b8](https://github.com/imagekit-developer/imagekit-ruby/commit/c8aa3b8c2320102d8e29941f78f1f1ade06cab00)) +* update mock server docs ([1e5ed9e](https://github.com/imagekit-developer/imagekit-ruby/commit/1e5ed9ea31388b76995c292fc22f9ed773ad6f40)) + ## 4.2.0 (2026-02-02) Full Changelog: [v4.1.2...v4.2.0](https://github.com/imagekit-developer/imagekit-ruby/compare/v4.1.2...v4.2.0) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a225d78..021d116 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,13 +43,13 @@ If you’d like to use the repository from source, you can either install from g To install via git in your `Gemfile`: ```ruby -gem "imagekitio", git: "https://www.github.com/imagekit-developer/imagekit-ruby" +gem "imagekitio", git: "https://github.com/imagekit-developer/imagekit-ruby" ``` Alternatively, reference local copy of the repo: ```bash -$ git clone -- 'https://www.github.com/imagekit-developer/imagekit-ruby' '' +$ git clone -- 'https://github.com/imagekit-developer/imagekit-ruby' '' ``` ```ruby @@ -66,12 +66,6 @@ $ bundle exec rake ## Running tests -Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. - -```bash -$ npx prism mock path/to/your/openapi.yml -``` - ```bash $ bundle exec rake test ``` diff --git a/Gemfile.lock b/Gemfile.lock index f0715a9..7d5f9a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - imagekitio (4.2.0) + imagekitio (4.3.0) cgi connection_pool diff --git a/README.md b/README.md index 390b3d7..eb891d0 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "imagekitio", "~> 4.2.0" +gem "imagekitio", "~> 4.3.0" ``` diff --git a/lib/imagekitio/internal/transport/pooled_net_requester.rb b/lib/imagekitio/internal/transport/pooled_net_requester.rb index fa32384..dfed0d7 100644 --- a/lib/imagekitio/internal/transport/pooled_net_requester.rb +++ b/lib/imagekitio/internal/transport/pooled_net_requester.rb @@ -75,7 +75,7 @@ def build_request(request, &blk) case body in nil - nil + req["content-length"] ||= 0 unless req["transfer-encoding"] in String req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"] req.body_stream = Imagekitio::Internal::Util::ReadIOAdapter.new(body, &blk) diff --git a/lib/imagekitio/internal/util.rb b/lib/imagekitio/internal/util.rb index 1dd7d34..c6ffdf2 100644 --- a/lib/imagekitio/internal/util.rb +++ b/lib/imagekitio/internal/util.rb @@ -485,11 +485,42 @@ def writable_enum(&blk) end # @type [Regexp] - JSON_CONTENT = %r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)} + JSON_CONTENT = %r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)} # @type [Regexp] JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)} class << self + # @api private + # + # @param query [Hash{Symbol=>Object}] + # + # @return [Hash{Symbol=>Object}] + def encode_query_params(query) + out = {} + query.each { write_query_param_element!(out, _1, _2) } + out + end + + # @api private + # + # @param collection [Hash{Symbol=>Object}] + # @param key [String] + # @param element [Object] + # + # @return [nil] + private def write_query_param_element!(collection, key, element) + case element + in Hash + element.each do |name, value| + write_query_param_element!(collection, "#{key}[#{name}]", value) + end + in Array + collection[key] = element.map(&:to_s).join(",") + else + collection[key] = element.to_s + end + end + # @api private # # @param y [Enumerator::Yielder] diff --git a/lib/imagekitio/models/transformation.rb b/lib/imagekitio/models/transformation.rb index 160d809..63e6b76 100644 --- a/lib/imagekitio/models/transformation.rb +++ b/lib/imagekitio/models/transformation.rb @@ -209,8 +209,8 @@ class Transformation < Imagekitio::Internal::Type::BaseModel # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). # - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). # - # @return [Float, nil] - optional :dpr, Float + # @return [Float, String, nil] + optional :dpr, union: -> { Imagekitio::Transformation::Dpr } # @!attribute duration # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. @@ -549,7 +549,7 @@ class Transformation < Imagekitio::Internal::Type::BaseModel # # @param distort [String] Distorts the shape of an image. Supports two modes: # - # @param dpr [Float] Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DP + # @param dpr [Float, String] Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DP # # @param duration [Float, String] Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. # @@ -785,6 +785,25 @@ module CropMode # @return [Array] end + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. Also accepts arithmetic expressions. + # + # - Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + # + # @see Imagekitio::Models::Transformation#dpr + module Dpr + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. # Typically used with startOffset to indicate the length from the start offset. # Arithmetic expressions are supported. See diff --git a/lib/imagekitio/resources/accounts/usage.rb b/lib/imagekitio/resources/accounts/usage.rb index adcdbc9..bbb3fc3 100644 --- a/lib/imagekitio/resources/accounts/usage.rb +++ b/lib/imagekitio/resources/accounts/usage.rb @@ -25,10 +25,11 @@ class Usage # @see Imagekitio::Models::Accounts::UsageGetParams def get(params) parsed, options = Imagekitio::Accounts::UsageGetParams.dump_request(params) + query = Imagekitio::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/accounts/usage", - query: parsed.transform_keys(end_date: "endDate", start_date: "startDate"), + query: query.transform_keys(end_date: "endDate", start_date: "startDate"), model: Imagekitio::Models::Accounts::UsageGetResponse, options: options ) diff --git a/lib/imagekitio/resources/assets.rb b/lib/imagekitio/resources/assets.rb index f9d64ff..bcc98aa 100644 --- a/lib/imagekitio/resources/assets.rb +++ b/lib/imagekitio/resources/assets.rb @@ -34,10 +34,11 @@ class Assets # @see Imagekitio::Models::AssetListParams def list(params = {}) parsed, options = Imagekitio::AssetListParams.dump_request(params) + query = Imagekitio::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/files", - query: parsed.transform_keys(file_type: "fileType", search_query: "searchQuery"), + query: query.transform_keys(file_type: "fileType", search_query: "searchQuery"), model: Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Models::AssetListResponseItem], options: options ) diff --git a/lib/imagekitio/resources/beta/v2/files.rb b/lib/imagekitio/resources/beta/v2/files.rb index 678ca31..78b2061 100644 --- a/lib/imagekitio/resources/beta/v2/files.rb +++ b/lib/imagekitio/resources/beta/v2/files.rb @@ -19,10 +19,11 @@ class Files # about how to implement secure client-side file upload. # # **File size limit** \ - # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw - # files, and 100MB for videos. On the paid plan, these limits increase to 40MB for - # images, audio, and raw files, and 2GB for videos. These limits can be further increased - # with higher-tier plans. + # On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw + # files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB + # for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + # these limits increase to 50MB for images, audio, and raw files and 2GB for videos. + # These limits can be further increased with enterprise plans. # # **Version limit** \ # A file can have a maximum of 100 versions. diff --git a/lib/imagekitio/resources/custom_metadata_fields.rb b/lib/imagekitio/resources/custom_metadata_fields.rb index 7a81171..73971d2 100644 --- a/lib/imagekitio/resources/custom_metadata_fields.rb +++ b/lib/imagekitio/resources/custom_metadata_fields.rb @@ -89,10 +89,11 @@ def update(id, params = {}) # @see Imagekitio::Models::CustomMetadataFieldListParams def list(params = {}) parsed, options = Imagekitio::CustomMetadataFieldListParams.dump_request(params) + query = Imagekitio::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/customMetadataFields", - query: parsed.transform_keys(folder_path: "folderPath", include_deleted: "includeDeleted"), + query: query.transform_keys(folder_path: "folderPath", include_deleted: "includeDeleted"), model: Imagekitio::Internal::Type::ArrayOf[Imagekitio::CustomMetadataField], options: options ) diff --git a/lib/imagekitio/resources/files.rb b/lib/imagekitio/resources/files.rb index 7e961f4..31b8d2d 100644 --- a/lib/imagekitio/resources/files.rb +++ b/lib/imagekitio/resources/files.rb @@ -207,10 +207,11 @@ def rename(params) # by verifying the entire payload using JWT. # # **File size limit** \ - # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw - # files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, - # audio, and raw files and 2GB for videos. These limits can be further increased with - # higher-tier plans. + # On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw + # files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB + # for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + # these limits increase to 50MB for images, audio, and raw files and 2GB for videos. + # These limits can be further increased with enterprise plans. # # **Version limit** \ # A file can have a maximum of 100 versions. diff --git a/lib/imagekitio/resources/files/metadata.rb b/lib/imagekitio/resources/files/metadata.rb index f732ab3..dadbea2 100644 --- a/lib/imagekitio/resources/files/metadata.rb +++ b/lib/imagekitio/resources/files/metadata.rb @@ -48,10 +48,11 @@ def get(file_id, params = {}) # @see Imagekitio::Models::Files::MetadataGetFromURLParams def get_from_url(params) parsed, options = Imagekitio::Files::MetadataGetFromURLParams.dump_request(params) + query = Imagekitio::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/metadata", - query: parsed, + query: query, model: Imagekitio::Metadata, options: options ) diff --git a/lib/imagekitio/version.rb b/lib/imagekitio/version.rb index abbbfc1..5d680d0 100644 --- a/lib/imagekitio/version.rb +++ b/lib/imagekitio/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Imagekitio - VERSION = "4.2.0" + VERSION = "4.3.0" end diff --git a/rbi/imagekitio/internal/util.rbi b/rbi/imagekitio/internal/util.rbi index 9fbebf9..f4aceb3 100644 --- a/rbi/imagekitio/internal/util.rbi +++ b/rbi/imagekitio/internal/util.rbi @@ -296,11 +296,31 @@ module Imagekitio end JSON_CONTENT = - T.let(%r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}, Regexp) + T.let(%r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)}, Regexp) JSONL_CONTENT = T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp) class << self + # @api private + sig do + params(query: Imagekitio::Internal::AnyHash).returns( + Imagekitio::Internal::AnyHash + ) + end + def encode_query_params(query) + end + + # @api private + sig do + params( + collection: Imagekitio::Internal::AnyHash, + key: String, + element: T.anything + ).void + end + private def write_query_param_element!(collection, key, element) + end + # @api private sig do params( diff --git a/rbi/imagekitio/models/transformation.rbi b/rbi/imagekitio/models/transformation.rbi index 607451a..18d01f0 100644 --- a/rbi/imagekitio/models/transformation.rbi +++ b/rbi/imagekitio/models/transformation.rbi @@ -283,10 +283,10 @@ module Imagekitio # - Learn about # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). # - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). - sig { returns(T.nilable(Float)) } + sig { returns(T.nilable(Imagekitio::Transformation::Dpr::Variants)) } attr_reader :dpr - sig { params(dpr: Float).void } + sig { params(dpr: Imagekitio::Transformation::Dpr::Variants).void } attr_writer :dpr # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. @@ -672,7 +672,7 @@ module Imagekitio crop_mode: Imagekitio::Transformation::CropMode::OrSymbol, default_image: String, distort: String, - dpr: Float, + dpr: Imagekitio::Transformation::Dpr::Variants, duration: Imagekitio::Transformation::Duration::Variants, end_offset: Imagekitio::Transformation::EndOffset::Variants, flip: Imagekitio::Transformation::Flip::OrSymbol, @@ -1006,7 +1006,7 @@ module Imagekitio crop_mode: Imagekitio::Transformation::CropMode::OrSymbol, default_image: String, distort: String, - dpr: Float, + dpr: Imagekitio::Transformation::Dpr::Variants, duration: Imagekitio::Transformation::Duration::Variants, end_offset: Imagekitio::Transformation::EndOffset::Variants, flip: Imagekitio::Transformation::Flip::OrSymbol, @@ -1323,6 +1323,24 @@ module Imagekitio end end + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. Also accepts arithmetic expressions. + # + # - Learn about + # [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + # - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + module Dpr + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::Transformation::Dpr::Variants]) + end + def self.variants + end + end + # Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. # Typically used with startOffset to indicate the length from the start offset. # Arithmetic expressions are supported. See diff --git a/rbi/imagekitio/resources/beta/v2/files.rbi b/rbi/imagekitio/resources/beta/v2/files.rbi index 1a8bba3..6ec4fd2 100644 --- a/rbi/imagekitio/resources/beta/v2/files.rbi +++ b/rbi/imagekitio/resources/beta/v2/files.rbi @@ -16,10 +16,11 @@ module Imagekitio # about how to implement secure client-side file upload. # # **File size limit** \ - # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw - # files, and 100MB for videos. On the paid plan, these limits increase to 40MB for - # images, audio, and raw files, and 2GB for videos. These limits can be further increased - # with higher-tier plans. + # On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw + # files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB + # for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + # these limits increase to 50MB for images, audio, and raw files and 2GB for videos. + # These limits can be further increased with enterprise plans. # # **Version limit** \ # A file can have a maximum of 100 versions. diff --git a/rbi/imagekitio/resources/files.rbi b/rbi/imagekitio/resources/files.rbi index d8a7ec4..85d1eee 100644 --- a/rbi/imagekitio/resources/files.rbi +++ b/rbi/imagekitio/resources/files.rbi @@ -168,10 +168,11 @@ module Imagekitio # by verifying the entire payload using JWT. # # **File size limit** \ - # On the free plan, the maximum upload file sizes are 20MB for images, audio, and raw - # files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, - # audio, and raw files and 2GB for videos. These limits can be further increased with - # higher-tier plans. + # On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw + # files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB + # for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + # these limits increase to 50MB for images, audio, and raw files and 2GB for videos. + # These limits can be further increased with enterprise plans. # # **Version limit** \ # A file can have a maximum of 100 versions. diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6e..0000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index e0dc137..df8caf9 100755 --- a/scripts/test +++ b/scripts/test @@ -4,53 +4,7 @@ set -e cd -- "$(dirname -- "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi echo "==> Running tests" bundle exec rake test "$@" diff --git a/sig/imagekitio/internal/util.rbs b/sig/imagekitio/internal/util.rbs index 73bf10f..62eba05 100644 --- a/sig/imagekitio/internal/util.rbs +++ b/sig/imagekitio/internal/util.rbs @@ -106,6 +106,16 @@ module Imagekitio JSON_CONTENT: Regexp JSONL_CONTENT: Regexp + def encode_query_params: ( + ::Hash[Symbol, top] query + ) -> ::Hash[Symbol, top] + + private def write_query_param_element!: ( + ::Hash[Symbol, top] collection, + String key, + top element + ) -> nil + def self?.write_multipart_content: ( Enumerator::Yielder y, val: top, diff --git a/sig/imagekitio/models/transformation.rbs b/sig/imagekitio/models/transformation.rbs index 80be008..ab5fdb4 100644 --- a/sig/imagekitio/models/transformation.rbs +++ b/sig/imagekitio/models/transformation.rbs @@ -22,7 +22,7 @@ module Imagekitio crop_mode: Imagekitio::Models::Transformation::crop_mode, default_image: String, distort: String, - dpr: Float, + dpr: Imagekitio::Models::Transformation::dpr, duration: Imagekitio::Models::Transformation::duration, end_offset: Imagekitio::Models::Transformation::end_offset, flip: Imagekitio::Models::Transformation::flip, @@ -161,9 +161,11 @@ module Imagekitio def distort=: (String) -> String - attr_reader dpr: Float? + attr_reader dpr: Imagekitio::Models::Transformation::dpr? - def dpr=: (Float) -> Float + def dpr=: ( + Imagekitio::Models::Transformation::dpr + ) -> Imagekitio::Models::Transformation::dpr attr_reader duration: Imagekitio::Models::Transformation::duration? @@ -362,7 +364,7 @@ module Imagekitio ?crop_mode: Imagekitio::Models::Transformation::crop_mode, ?default_image: String, ?distort: String, - ?dpr: Float, + ?dpr: Imagekitio::Models::Transformation::dpr, ?duration: Imagekitio::Models::Transformation::duration, ?end_offset: Imagekitio::Models::Transformation::end_offset, ?flip: Imagekitio::Models::Transformation::flip, @@ -419,7 +421,7 @@ module Imagekitio crop_mode: Imagekitio::Models::Transformation::crop_mode, default_image: String, distort: String, - dpr: Float, + dpr: Imagekitio::Models::Transformation::dpr, duration: Imagekitio::Models::Transformation::duration, end_offset: Imagekitio::Models::Transformation::end_offset, flip: Imagekitio::Models::Transformation::flip, @@ -570,6 +572,14 @@ module Imagekitio def self?.values: -> ::Array[Imagekitio::Models::Transformation::crop_mode] end + type dpr = Float | String + + module Dpr + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::dpr] + end + type duration = Float | String module Duration diff --git a/test/imagekitio/client_test.rb b/test/imagekitio/client_test.rb index c58cec4..ac64c1d 100644 --- a/test/imagekitio/client_test.rb +++ b/test/imagekitio/client_test.rb @@ -136,9 +136,11 @@ def test_client_retry_after_seconds end def test_client_retry_after_date + time_now = Time.now + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( status: 500, - headers: {"retry-after" => (Time.now + 10).httpdate}, + headers: {"retry-after" => (time_now + 10).httpdate}, body: {} ) @@ -150,11 +152,11 @@ def test_client_retry_after_date max_retries: 1 ) + Thread.current.thread_variable_set(:time_now, time_now) assert_raises(Imagekitio::Errors::InternalServerError) do - Thread.current.thread_variable_set(:time_now, Time.now) image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") - Thread.current.thread_variable_set(:time_now, nil) end + Thread.current.thread_variable_set(:time_now, nil) assert_requested(:any, /./, times: 2) assert_in_delta(10, Thread.current.thread_variable_get(:mock_sleep).last, 1.0) diff --git a/test/imagekitio/internal/util_test.rb b/test/imagekitio/internal/util_test.rb index 976d5b0..1b29975 100644 --- a/test/imagekitio/internal/util_test.rb +++ b/test/imagekitio/internal/util_test.rb @@ -171,6 +171,8 @@ def test_json_content cases = { "application/json" => true, "application/jsonl" => false, + "application/arbitrary+json" => true, + "application/ARBITRARY+json" => true, "application/vnd.github.v3+json" => true, "application/vnd.api+json" => true } diff --git a/test/imagekitio/resources/accounts/origins_test.rb b/test/imagekitio/resources/accounts/origins_test.rb index 49f7a48..78285d1 100644 --- a/test/imagekitio/resources/accounts/origins_test.rb +++ b/test/imagekitio/resources/accounts/origins_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Accounts::OriginsTest < Imagekitio::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.origins.create( @@ -114,7 +114,7 @@ def test_create_required_params end def test_update_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.origins.update( @@ -225,7 +225,7 @@ def test_update_required_params end def test_list - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.origins.list @@ -235,7 +235,7 @@ def test_list end def test_delete - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.origins.delete("id") @@ -245,7 +245,7 @@ def test_delete end def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.origins.get("id") diff --git a/test/imagekitio/resources/accounts/url_endpoints_test.rb b/test/imagekitio/resources/accounts/url_endpoints_test.rb index fa91264..966e30b 100644 --- a/test/imagekitio/resources/accounts/url_endpoints_test.rb +++ b/test/imagekitio/resources/accounts/url_endpoints_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Accounts::URLEndpointsTest < Imagekitio::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.url_endpoints.create(description: "My custom URL endpoint") @@ -24,7 +24,7 @@ def test_create_required_params end def test_update_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.url_endpoints.update("id", description: "My custom URL endpoint") @@ -44,7 +44,7 @@ def test_update_required_params end def test_list - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.url_endpoints.list @@ -54,7 +54,7 @@ def test_list end def test_delete - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.url_endpoints.delete("id") @@ -64,7 +64,7 @@ def test_delete end def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.url_endpoints.get("id") diff --git a/test/imagekitio/resources/accounts/usage_test.rb b/test/imagekitio/resources/accounts/usage_test.rb index f928f45..64346dd 100644 --- a/test/imagekitio/resources/accounts/usage_test.rb +++ b/test/imagekitio/resources/accounts/usage_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Accounts::UsageTest < Imagekitio::Test::ResourceTest def test_get_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.accounts.usage.get(end_date: "2019-12-27", start_date: "2019-12-27") diff --git a/test/imagekitio/resources/assets_test.rb b/test/imagekitio/resources/assets_test.rb index f4b2148..882e51f 100644 --- a/test/imagekitio/resources/assets_test.rb +++ b/test/imagekitio/resources/assets_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::AssetsTest < Imagekitio::Test::ResourceTest def test_list - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.assets.list diff --git a/test/imagekitio/resources/beta/v2/files_test.rb b/test/imagekitio/resources/beta/v2/files_test.rb index 640bff4..c2f5728 100644 --- a/test/imagekitio/resources/beta/v2/files_test.rb +++ b/test/imagekitio/resources/beta/v2/files_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Beta::V2::FilesTest < Imagekitio::Test::ResourceTest def test_upload_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.beta.v2.files.upload(file: Pathname(__FILE__), file_name: "fileName") diff --git a/test/imagekitio/resources/cache/invalidation_test.rb b/test/imagekitio/resources/cache/invalidation_test.rb index 2d29a04..dec4bfc 100644 --- a/test/imagekitio/resources/cache/invalidation_test.rb +++ b/test/imagekitio/resources/cache/invalidation_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Cache::InvalidationTest < Imagekitio::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.cache.invalidation.create(url: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg") @@ -21,7 +21,7 @@ def test_create_required_params end def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.cache.invalidation.get("requestId") diff --git a/test/imagekitio/resources/custom_metadata_fields_test.rb b/test/imagekitio/resources/custom_metadata_fields_test.rb index fcddba8..1d455ad 100644 --- a/test/imagekitio/resources/custom_metadata_fields_test.rb +++ b/test/imagekitio/resources/custom_metadata_fields_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::CustomMetadataFieldsTest < Imagekitio::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number}) @@ -24,7 +24,7 @@ def test_create_required_params end def test_update - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.custom_metadata_fields.update("id") @@ -43,7 +43,7 @@ def test_update end def test_list - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.custom_metadata_fields.list @@ -53,7 +53,7 @@ def test_list end def test_delete - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.custom_metadata_fields.delete("id") diff --git a/test/imagekitio/resources/files/bulk_test.rb b/test/imagekitio/resources/files/bulk_test.rb index 56991d8..6699988 100644 --- a/test/imagekitio/resources/files/bulk_test.rb +++ b/test/imagekitio/resources/files/bulk_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Files::BulkTest < Imagekitio::Test::ResourceTest def test_delete_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.bulk.delete(file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be]) @@ -21,7 +21,7 @@ def test_delete_required_params end def test_add_tags_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.bulk.add_tags( @@ -41,7 +41,7 @@ def test_add_tags_required_params end def test_remove_ai_tags_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.bulk.remove_ai_tags( @@ -61,7 +61,7 @@ def test_remove_ai_tags_required_params end def test_remove_tags_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.bulk.remove_tags( diff --git a/test/imagekitio/resources/files/metadata_test.rb b/test/imagekitio/resources/files/metadata_test.rb index ce2626c..2c48eb2 100644 --- a/test/imagekitio/resources/files/metadata_test.rb +++ b/test/imagekitio/resources/files/metadata_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Files::MetadataTest < Imagekitio::Test::ResourceTest def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.metadata.get("fileId") @@ -33,7 +33,7 @@ def test_get end def test_get_from_url_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.metadata.get_from_url(url: "https://example.com") diff --git a/test/imagekitio/resources/files/versions_test.rb b/test/imagekitio/resources/files/versions_test.rb index b1d3dc4..3abf45a 100644 --- a/test/imagekitio/resources/files/versions_test.rb +++ b/test/imagekitio/resources/files/versions_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Files::VersionsTest < Imagekitio::Test::ResourceTest def test_list - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.versions.list("fileId") @@ -14,7 +14,7 @@ def test_list end def test_delete_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.versions.delete("versionId", file_id: "fileId") @@ -30,7 +30,7 @@ def test_delete_required_params end def test_get_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.versions.get("versionId", file_id: "fileId") @@ -73,7 +73,7 @@ def test_get_required_params end def test_restore_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.versions.restore("versionId", file_id: "fileId") diff --git a/test/imagekitio/resources/files_test.rb b/test/imagekitio/resources/files_test.rb index 314183f..aedd4b4 100644 --- a/test/imagekitio/resources/files_test.rb +++ b/test/imagekitio/resources/files_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::FilesTest < Imagekitio::Test::ResourceTest def test_update - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.update("fileId") @@ -14,7 +14,7 @@ def test_update end def test_delete - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.delete("fileId") @@ -24,7 +24,7 @@ def test_delete end def test_copy_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.copy(destination_path: "/folder/to/copy/into/", source_file_path: "/path/to/file.jpg") @@ -41,7 +41,7 @@ def test_copy_required_params end def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.get("fileId") @@ -84,7 +84,7 @@ def test_get end def test_move_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.move(destination_path: "/folder/to/move/into/", source_file_path: "/path/to/file.jpg") @@ -101,7 +101,7 @@ def test_move_required_params end def test_rename_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.rename(file_path: "/path/to/file.jpg", new_file_name: "newFileName.jpg") @@ -117,7 +117,7 @@ def test_rename_required_params end def test_upload_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") diff --git a/test/imagekitio/resources/folders/job_test.rb b/test/imagekitio/resources/folders/job_test.rb index 810a3c2..02f4606 100644 --- a/test/imagekitio/resources/folders/job_test.rb +++ b/test/imagekitio/resources/folders/job_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::Folders::JobTest < Imagekitio::Test::ResourceTest def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.folders.job.get("jobId") diff --git a/test/imagekitio/resources/folders_test.rb b/test/imagekitio/resources/folders_test.rb index eb4097a..ec2ee28 100644 --- a/test/imagekitio/resources/folders_test.rb +++ b/test/imagekitio/resources/folders_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::FoldersTest < Imagekitio::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.folders.create(folder_name: "summer", parent_folder_path: "/product/images/") @@ -20,7 +20,7 @@ def test_create_required_params end def test_delete_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.folders.delete(folder_path: "/folder/to/delete/") @@ -36,7 +36,7 @@ def test_delete_required_params end def test_copy_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.folders.copy( @@ -56,7 +56,7 @@ def test_copy_required_params end def test_move_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.folders.move( @@ -76,7 +76,7 @@ def test_move_required_params end def test_rename_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name") diff --git a/test/imagekitio/resources/saved_extensions_test.rb b/test/imagekitio/resources/saved_extensions_test.rb index 9ce1a47..9102206 100644 --- a/test/imagekitio/resources/saved_extensions_test.rb +++ b/test/imagekitio/resources/saved_extensions_test.rb @@ -4,7 +4,7 @@ class Imagekitio::Test::Resources::SavedExtensionsTest < Imagekitio::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.saved_extensions.create( @@ -30,7 +30,7 @@ def test_create_required_params end def test_update - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.saved_extensions.update("id") @@ -51,7 +51,7 @@ def test_update end def test_list - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.saved_extensions.list @@ -61,7 +61,7 @@ def test_list end def test_delete - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.saved_extensions.delete("id") @@ -71,7 +71,7 @@ def test_delete end def test_get - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @image_kit.saved_extensions.get("id")