diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2f8909f..d1328ca 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.6.1" + ".": "2.7.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 00bcaad..b617f28 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 27 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-422330754281be38d7919f08a9d1e7862cbdc6921602473cb07a8f2022635832.yml -openapi_spec_hash: 7e6fa61ced995dc03e0ccd3e11fb121c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-67a3fe4439c3aa74fb2c18b207b43c790d42bab7bfd7e5e16f3e1046765ec959.yml +openapi_spec_hash: c87b33c2c72a172da02ed75d4e79eb70 config_hash: 6a52f6ae7d55cf3b4e91538cc7752aeb diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a74c18..742e3e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 2.7.0 (2026-02-20) + +Full Changelog: [v2.6.1...v2.7.0](https://github.com/moderation-api/sdk-ruby/compare/v2.6.1...v2.7.0) + +### Features + +* **api:** api update ([4779766](https://github.com/moderation-api/sdk-ruby/commit/477976687b0d43cf7cfc3fd1c69d2327d9ddd1e4)) + + +### Chores + +* **internal:** remove mock server code ([6fff870](https://github.com/moderation-api/sdk-ruby/commit/6fff870033a043b5d08560715a1a4bd9c7b3d9ce)) + ## 2.6.1 (2026-02-07) Full Changelog: [v2.6.0...v2.6.1](https://github.com/moderation-api/sdk-ruby/compare/v2.6.0...v2.6.1) diff --git a/Gemfile.lock b/Gemfile.lock index 968e41a..58fb884 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - moderation_api (2.6.1) + moderation_api (2.7.0) cgi connection_pool diff --git a/README.md b/README.md index aa920b7..c532919 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "moderation_api", "~> 2.6.1" +gem "moderation_api", "~> 2.7.0" ``` diff --git a/lib/moderation_api/models/content_submit_params.rb b/lib/moderation_api/models/content_submit_params.rb index 1ca6bc5..e43fe01 100644 --- a/lib/moderation_api/models/content_submit_params.rb +++ b/lib/moderation_api/models/content_submit_params.rb @@ -141,15 +141,23 @@ class Image < ModerationAPI::Internal::Type::BaseModel # @return [Symbol, :image] required :type, const: :image + # @!attribute data + # Base64-encoded image data + # + # @return [String, nil] + optional :data, String + # @!attribute url # A public URL of the image content # - # @return [String] - required :url, String + # @return [String, nil] + optional :url, String - # @!method initialize(url:, type: :image) + # @!method initialize(data: nil, url: nil, type: :image) # Image # + # @param data [String] Base64-encoded image data + # # @param url [String] A public URL of the image content # # @param type [Symbol, :image] @@ -257,15 +265,23 @@ class Image < ModerationAPI::Internal::Type::BaseModel # @return [Symbol, :image] required :type, const: :image + # @!attribute data + # Base64-encoded image data + # + # @return [String, nil] + optional :data, String + # @!attribute url # A public URL of the image content # - # @return [String] - required :url, String + # @return [String, nil] + optional :url, String - # @!method initialize(url:, type: :image) + # @!method initialize(data: nil, url: nil, type: :image) # Image # + # @param data [String] Base64-encoded image data + # # @param url [String] A public URL of the image content # # @param type [Symbol, :image] diff --git a/lib/moderation_api/models/content_submit_response.rb b/lib/moderation_api/models/content_submit_response.rb index 4363b31..6462a0f 100644 --- a/lib/moderation_api/models/content_submit_response.rb +++ b/lib/moderation_api/models/content_submit_response.rb @@ -267,15 +267,23 @@ class Image < ModerationAPI::Internal::Type::BaseModel # @return [Symbol, :image] required :type, const: :image + # @!attribute data + # Base64-encoded image data + # + # @return [String, nil] + optional :data, String + # @!attribute url # A public URL of the image content # - # @return [String] - required :url, String + # @return [String, nil] + optional :url, String - # @!method initialize(url:, type: :image) + # @!method initialize(data: nil, url: nil, type: :image) # Image # + # @param data [String] Base64-encoded image data + # # @param url [String] A public URL of the image content # # @param type [Symbol, :image] diff --git a/lib/moderation_api/version.rb b/lib/moderation_api/version.rb index 6d0d952..7b71ff9 100644 --- a/lib/moderation_api/version.rb +++ b/lib/moderation_api/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ModerationAPI - VERSION = "2.6.1" + VERSION = "2.7.0" end diff --git a/rbi/moderation_api/models/content_submit_params.rbi b/rbi/moderation_api/models/content_submit_params.rbi index 644d94a..6c3fe96 100644 --- a/rbi/moderation_api/models/content_submit_params.rbi +++ b/rbi/moderation_api/models/content_submit_params.rbi @@ -363,20 +363,36 @@ module ModerationAPI sig { returns(Symbol) } attr_accessor :type + # Base64-encoded image data + sig { returns(T.nilable(String)) } + attr_reader :data + + sig { params(data: String).void } + attr_writer :data + # A public URL of the image content - sig { returns(String) } - attr_accessor :url + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url # Image - sig { params(url: String, type: Symbol).returns(T.attached_class) } + sig do + params(data: String, url: String, type: Symbol).returns( + T.attached_class + ) + end def self.new( + # Base64-encoded image data + data: nil, # A public URL of the image content - url:, + url: nil, type: :image ) end - sig { override.returns({ type: Symbol, url: String }) } + sig { override.returns({ type: Symbol, data: String, url: String }) } def to_hash end end @@ -570,22 +586,38 @@ module ModerationAPI sig { returns(Symbol) } attr_accessor :type + # Base64-encoded image data + sig { returns(T.nilable(String)) } + attr_reader :data + + sig { params(data: String).void } + attr_writer :data + # A public URL of the image content - sig { returns(String) } - attr_accessor :url + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url # Image sig do - params(url: String, type: Symbol).returns(T.attached_class) + params(data: String, url: String, type: Symbol).returns( + T.attached_class + ) end def self.new( + # Base64-encoded image data + data: nil, # A public URL of the image content - url:, + url: nil, type: :image ) end - sig { override.returns({ type: Symbol, url: String }) } + sig do + override.returns({ type: Symbol, data: String, url: String }) + end def to_hash end end diff --git a/rbi/moderation_api/models/content_submit_response.rbi b/rbi/moderation_api/models/content_submit_response.rbi index f975a29..056e89a 100644 --- a/rbi/moderation_api/models/content_submit_response.rbi +++ b/rbi/moderation_api/models/content_submit_response.rbi @@ -558,22 +558,38 @@ module ModerationAPI sig { returns(Symbol) } attr_accessor :type + # Base64-encoded image data + sig { returns(T.nilable(String)) } + attr_reader :data + + sig { params(data: String).void } + attr_writer :data + # A public URL of the image content - sig { returns(String) } - attr_accessor :url + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url # Image sig do - params(url: String, type: Symbol).returns(T.attached_class) + params(data: String, url: String, type: Symbol).returns( + T.attached_class + ) end def self.new( + # Base64-encoded image data + data: nil, # A public URL of the image content - url:, + url: nil, type: :image ) end - sig { override.returns({ type: Symbol, url: String }) } + sig do + override.returns({ type: Symbol, data: String, url: String }) + end def to_hash end end 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/moderation_api/models/content_submit_params.rbs b/sig/moderation_api/models/content_submit_params.rbs index 1f1386a..99e76e8 100644 --- a/sig/moderation_api/models/content_submit_params.rbs +++ b/sig/moderation_api/models/content_submit_params.rbs @@ -111,16 +111,22 @@ module ModerationAPI def to_hash: -> { text: String, type: :text } end - type image = { type: :image, url: String } + type image = { type: :image, data: String, url: String } class Image < ModerationAPI::Internal::Type::BaseModel attr_accessor type: :image - attr_accessor url: String + attr_reader data: String? + + def data=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String - def initialize: (url: String, ?type: :image) -> void + def initialize: (?data: String, ?url: String, ?type: :image) -> void - def to_hash: -> { type: :image, url: String } + def to_hash: -> { type: :image, data: String, url: String } end type video = { type: :video, url: String } @@ -189,16 +195,26 @@ module ModerationAPI def to_hash: -> { text: String, type: :text } end - type image = { type: :image, url: String } + type image = { type: :image, data: String, url: String } class Image < ModerationAPI::Internal::Type::BaseModel attr_accessor type: :image - attr_accessor url: String + attr_reader data: String? + + def data=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String - def initialize: (url: String, ?type: :image) -> void + def initialize: ( + ?data: String, + ?url: String, + ?type: :image + ) -> void - def to_hash: -> { type: :image, url: String } + def to_hash: -> { type: :image, data: String, url: String } end type video = { type: :video, url: String } diff --git a/sig/moderation_api/models/content_submit_response.rbs b/sig/moderation_api/models/content_submit_response.rbs index 89a5767..581264d 100644 --- a/sig/moderation_api/models/content_submit_response.rbs +++ b/sig/moderation_api/models/content_submit_response.rbs @@ -183,16 +183,26 @@ module ModerationAPI def to_hash: -> { text: String, type: :text } end - type image = { type: :image, url: String } + type image = { type: :image, data: String, url: String } class Image < ModerationAPI::Internal::Type::BaseModel attr_accessor type: :image - attr_accessor url: String + attr_reader data: String? + + def data=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String - def initialize: (url: String, ?type: :image) -> void + def initialize: ( + ?data: String, + ?url: String, + ?type: :image + ) -> void - def to_hash: -> { type: :image, url: String } + def to_hash: -> { type: :image, data: String, url: String } end type video = { type: :video, url: String }