From 9094f0e52026d4aa743bb95cf16c20fc247dc861 Mon Sep 17 00:00:00 2001 From: chrisdengso <8185683+chrisdengso@users.noreply.github.com> Date: Thu, 22 Oct 2026 12:15:01 +0000 Subject: [PATCH] feat: regenerate from the OpenAPI spec --- .github/release-notes/v3.0.0.md | 32 ++++++++++++++++++++++ .github/workflows/publish-gem.yml | 44 +++++++++++++++++++++++-------- .speakeasy/gen.lock | 2 +- 3 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 .github/release-notes/v3.0.0.md diff --git a/.github/release-notes/v3.0.0.md b/.github/release-notes/v3.0.0.md new file mode 100644 index 00000000..ff7a5fd1 --- /dev/null +++ b/.github/release-notes/v3.0.0.md @@ -0,0 +1,32 @@ +## moderation_api 3.0.0 + +A new major version of the Ruby SDK. Read the breaking changes before you upgrade. + +```bash +gem install moderation_api -v "~> 3.0" +``` + +### Ruby-specific changes + +- The module is `ModerationApi` (was `ModerationAPI`). Create the client with `ModerationApi::ModerationApi.new(secret_key: ENV.fetch("MODAPI_SECRET_KEY"))`. +- Requests are typed objects, for example `Operations::SubmitContentRequest.new(content: Operations::TextRequest.new(text: "..."))`, and responses carry the result in `.object`. Sorbet type signatures are included. +- Verify webhooks with `require "moderation_api/webhook_signature"` and `ModerationApi::WebhookSignature.construct_event(payload, signature)`. +### What's new + +- **Covers the whole API**, including the management API (`projects`, `channels`), wordlists and the review queue. +- **Automatic pagination.** List methods return an iterator that fetches the next page for you. +- **Clear errors.** One error class per HTTP status (`BadRequestError`, `NotFoundError`, `RateLimitError`, ...). Every error has a specific `code` (for example `invalid_api_key`, `quota_exceeded` or `author_not_found`), a `request_id` and a `doc_url`. See [Errors](https://docs.moderationapi.com/api-reference/errors). +- **Retries** with exponential backoff on `429` and `5xx`, and timeouts per client or per request. +- **Webhook verification** that reads the secret from `MODAPI_WEBHOOK_SECRET`. + +### Breaking changes + +The SDK is now generated from our OpenAPI spec with a new generator. Most calls keep their names, but check these: + +- **List responses** are `{ data, pagination }` instead of a plain array or a resource-specific shape, and list methods take `page` and `pageSize`. +- **Errors** have a new body: `code` is the specific error code, not the HTTP category. The old `data` field is gone. +- **Renamed:** `account.list` is now `account.retrieve`, and `actions.execute.execute` is now `actions.execute`. +- **Removed:** `actions.execute.executeByID` (use `actions.execute` with `actionId` or `actionKey`), `auth.*`, and `content.stream` (see [Real-time voice](https://docs.moderationapi.com/content-moderation/real-time-voice)). +- **Organization keys** work only with `projects` and `channels`; project keys work with everything else. Use one client per key. See the README. + +The license is unchanged: Apache-2.0. diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml index 746c410b..820455f7 100644 --- a/.github/workflows/publish-gem.yml +++ b/.github/workflows/publish-gem.yml @@ -1,12 +1,17 @@ # Maintained in moderation-api/sdk-generator (custom/ruby). Edits here are overwritten. +# Every push to main whose package version has no release tag yet publishes +# that version and creates the GitHub release (notes: .github/release-notes/vX.Y.Z.md +# if present, otherwise generated from the merged pull requests). name: Publish Gem on: - release: - types: [published] + push: + branches: [main] workflow_dispatch: +concurrency: release + permissions: - contents: read + contents: write jobs: publish: @@ -16,15 +21,32 @@ jobs: - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 with: ruby-version: "3.2" - - name: Check the release tag matches the gem version - if: github.event_name == 'release' + - name: Read the version + run: echo "VERSION=$(ruby -e 'puts Gem::Specification.load("moderation_api.gemspec").version')" >> "$GITHUB_ENV" + - name: Check for an unreleased version + id: version run: | - version=$(ruby -e 'puts Gem::Specification.load("moderation_api.gemspec").version') - if [ "${GITHUB_REF_NAME#v}" != "$version" ]; then - echo "::error::Release tag $GITHUB_REF_NAME does not match gem version $version" - exit 1 + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" + if git ls-remote --exit-code --tags origin "refs/tags/v${VERSION}" >/dev/null; then + echo "v${VERSION} is already released." + echo "release=false" >> "$GITHUB_OUTPUT" + else + echo "release=true" >> "$GITHUB_OUTPUT" fi - - run: gem build moderation_api.gemspec - - run: gem push moderation_api-*.gem + - if: steps.version.outputs.release == 'true' + run: gem build moderation_api.gemspec + - if: steps.version.outputs.release == 'true' + run: gem push moderation_api-${VERSION}.gem env: GEM_HOST_API_KEY: ${{ secrets.MODERATION_API_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }} + - name: Create the GitHub release + if: steps.version.outputs.release == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + notes=".github/release-notes/v${VERSION}.md" + if [ -f "$notes" ]; then + gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "v${VERSION}" --notes-file "$notes" + else + gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "v${VERSION}" --generate-notes + fi diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index b102f3bd..54564933 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,7 +1,7 @@ lockVersion: 2.0.0 id: a78f35a2-6d8d-4b9f-8962-89b8103f2924 management: - docChecksum: 3320e8867e978fb3c091936a85b4b990 + docChecksum: 9e61a5512adcd4b1e0a74112ed775731 docVersion: 1.1.0 speakeasyVersion: internal generationVersion: internal