Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: Conformance
working-directory: .
run: node stand-in/conformance.mjs -- node sdk/typescript/examples/conformance.mjs
- name: Conformance (API v2)
working-directory: .
run: node stand-in/conformance.mjs --v2 -- node sdk/typescript/examples/conformance-v2.mjs
- run: npm pack --dry-run

php:
Expand Down Expand Up @@ -72,6 +75,8 @@ jobs:
node-version: "26"
- name: Conformance
run: node stand-in/conformance.mjs -- php sdk/php/examples/conformance.php
- name: Conformance (API v2)
run: node stand-in/conformance.mjs --v2 -- php sdk/php/examples/conformance-v2.php

php-without-curl:
# ext-curl is optional (only the built-in CurlTransport needs it): the SDK must
Expand Down Expand Up @@ -124,6 +129,9 @@ jobs:
- name: Conformance
working-directory: .
run: node stand-in/conformance.mjs -- python sdk/python/examples/conformance.py
- name: Conformance (API v2)
working-directory: .
run: node stand-in/conformance.mjs --v2 -- python sdk/python/examples/conformance_v2.py

dotnet:
name: .NET 10 and 11
Expand All @@ -140,11 +148,14 @@ jobs:
- run: dotnet build sdk/dotnet -warnaserror
- run: dotnet test sdk/dotnet --no-build
- run: dotnet build sdk/dotnet/examples/Conformance -c Release -warnaserror
- run: dotnet build sdk/dotnet/examples/ConformanceV2 -c Release -warnaserror
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "26"
- name: Conformance
run: node stand-in/conformance.mjs -- dotnet sdk/dotnet/examples/Conformance/bin/Release/net10.0/Conformance.dll
- name: Conformance (API v2)
run: node stand-in/conformance.mjs --v2 -- dotnet sdk/dotnet/examples/ConformanceV2/bin/Release/net10.0/ConformanceV2.dll
- run: dotnet pack sdk/dotnet/src/Supertext.Sdk -c Release -o sdk/dotnet/artifacts -warnaserror

java:
Expand Down Expand Up @@ -172,6 +183,8 @@ jobs:
node-version: "26"
- name: Conformance
run: node ../../stand-in/conformance.mjs -- java -cp target/classes examples/Conformance.java
- name: Conformance (API v2)
run: node ../../stand-in/conformance.mjs --v2 -- java -cp target/classes examples/ConformanceV2.java

kotlin:
name: Kotlin (Java ${{ matrix.java }})
Expand All @@ -198,3 +211,5 @@ jobs:
node-version: "26"
- name: Conformance
run: node ../../stand-in/conformance.mjs -- java -cp 'target/classes:target/test-classes:target/lib/*' ConformanceKt
- name: Conformance (API v2)
run: node ../../stand-in/conformance.mjs --v2 -- java -cp 'target/classes:target/test-classes:target/lib/*' ConformanceV2Kt
55 changes: 55 additions & 0 deletions .github/workflows/live-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Live API v2

# Runs scripts/live-v2.mjs against Supertext's platform API with the TypeScript v2 client: key check,
# account, features, a quote and one small translation (a few characters of credit). Weekly, by hand,
# and on changes to the v2 client or the check. Needs the secret SUPERTEXT_API_KEY_V2. Then
# scripts/compare-links.mjs prints how API v1 and v2 keep links in sample sentences (diagnostic).
# See docs/DEVELOPER.md → Tests and CI.
on:
pull_request:
paths: ["sdk/typescript/src/v2/**", "scripts/live-v2.mjs", "scripts/compare-links.mjs", ".github/workflows/live-v2.yml"]
push:
branches: [main]
paths: ["sdk/typescript/src/v2/**", "scripts/live-v2.mjs", "scripts/compare-links.mjs", ".github/workflows/live-v2.yml"]
schedule:
- cron: "41 5 * * 2"
workflow_dispatch:

permissions:
contents: read

jobs:
live:
name: Live API v2
runs-on: ubuntu-latest
defaults:
run:
working-directory: sdk/typescript
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
package-manager-cache: false
- run: npm ci
- run: npm run build
- name: Check against the live API
working-directory: .
env:
SUPERTEXT_API_KEY_V2: ${{ secrets.SUPERTEXT_API_KEY_V2 }}
run: |
if [ -z "$SUPERTEXT_API_KEY_V2" ]; then
echo "::warning::Secret SUPERTEXT_API_KEY_V2 is not set: API v2 can't be checked live."
exit 0
fi
node scripts/live-v2.mjs

- name: Compare links and formatting (API v1 and v2)
if: success() || failure()
working-directory: .
env:
SUPERTEXT_API_KEY: ${{ secrets.SUPERTEXT_API_KEY }}
SUPERTEXT_API_KEY_V2: ${{ secrets.SUPERTEXT_API_KEY_V2 }}
run: node scripts/compare-links.mjs
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ All SDKs in this repository share one version. Format: one section per release,

### Added

- **API v2: Supertext's platform API** (`https://api-platform.supertext.com/v1/`, workspace keys sent as `Authorization: Bearer st_live_…`) in a `v2` namespace next to `v1` in all six SDKs (TypeScript `supertext-sdk/v2`, PHP `Supertext\Sdk\V2`, Python `supertext.v2`, .NET `Supertext.Sdk.V2`, Java and Kotlin `com.supertext.sdk.v2`), with vectors in `spec/v2/` (`auth-header`, `errors`, `batching`, `webhooks`, `api-key-check`, `conformance`, and Supertext's `openapi.json`), a stand-in (`stand-in/stand-in-v2.mjs`) and conformance programs (`node stand-in/conformance.mjs --v2 -- <program>`, in CI for every SDK). `translateTexts` takes the same keyed segments as v1 and sends them as direct text requests (up to 10,000 characters each; HTML segments with `tag_handling: html`; a longer segment through the file endpoint, blanks unchanged). Also: `translateText`/`quoteText`, AI translation of any supported document (`translateFile`, `translateHtml`, the single steps, `quoteFile`; glossary, OCR), language detection, human review (`orderFusedText`/`orderFusedFile` with status, result and quotes; idempotency key for text orders), `getAccount`, `getFeatures`, `validateApiKey`, `checkApiKey` (the v1 `ApiKeyCheck`, on `GET account`), webhooks (create, list, get, update, delete, test) and `verifyWebhook` / `Webhooks.verify` (Standard Webhooks signatures, 5-minute tolerance, `invalid_webhook`). One error type with the v2 codes (`insufficient_credit`, `invalid_request`, `conflict`, …) and Supertext's problem fields (`detail`, `apiErrorCode`, `errorId`, `reason`). v1 is unchanged. Integration guide → *API v2*, API reference → *API v2*. The *Live API v2* workflow checks the TypeScript v2 client against the live API weekly (secret `SUPERTEXT_API_KEY_V2`).

- **Publishing to npm and Maven Central** in `release.yml` (jobs *Publish to npm* and *Publish to Maven Central*, a `release` profile in the Java and Kotlin poms), and *Run workflow* with a version publishes an existing release to the registries that don't have it yet. They start working once the accounts and secrets are set up (`docs/DEVELOPER.md` → *Releasing*).

### Changed

- Java: `Transport.Response` keeps the body as bytes (new constructor `Response(int, Map, byte[])` and `getBodyBytes()`; `getBody()` still decodes UTF-8), so binary documents download intact; `JdkHttpTransport` reads bytes. `HtmlDocument.content(Segment)` is public. Kotlin: `HttpResponseData` gets `bodyBytes` and `HttpResponseData.ofBytes(status, headers, bytes)` for the same reason. Existing transports keep working.

## 0.7.0 — 2026-11-26

### Added
Expand Down
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Wherever the docs or a README mention the API key, show both links: "No Supertex
- **Rich text:** each `data-st-id` element is translated on its own: one per paragraph with inline tags, never one per formatted run.
- **Languages:** only the codes `GET features` lists (`spec/languages.json`): 32 bare sources; 41 targets, regional only for de/en/fr/it/pt (`de-CH`, `en-US`), script for zh/sr (`zh-Hans`, `sr-Latn`), `gsw-u-sd-chzh`/`chbe`, bare for the rest (`es`, `nl`, `sl`). Anything else: HTTP 404 `INVALID_LANGUAGE_PAIR`. Politeness on a target without it (en, gsw, rm, sq, sr): HTTP 400 `FEATURE_ERROR`. **Defaults only where obvious:** the SDK resolves a CMS target by the plugin's mapping (a combo box per CMS language, `suggestTarget` preselected), else an exact match (case, `_`/`-`), else a default (`defaultTargets`: bare de/en/fr/it/pt → `de-DE`/`en-US`/`fr-FR`/`it-IT`/`pt-PT`, zh → `zh-Hans`, sr → `sr-Latn`, zh-TW/HK/MO → `zh-Hant`, zh-CN/SG → `zh-Hans`, a region of a bare target → the bare target: `es-ES` → `es`), else `unsupported_language`. Nothing else is guessed (`en-IE`, `de-LI`, `gsw`, `sr-RS` need a mapping). The client sends codes as given.
- **Translation files:** Supertext's web app keeps an uploaded HTML file's `<head>` (the `supertext:*` metas) and the `data-st-id` attributes, so `TranslationFiles` HTML exports import back unchanged (confirmed October 2026).
- **Versioned API:** everything API-bound is in the `v1` namespace of each SDK; a later API version gets `v2` next to it (and `spec/v2/`).
- **Versioned API:** everything API-bound is in the `v1` namespace of each SDK; Supertext's platform API is `v2` next to it (`spec/v2/`, `stand-in/stand-in-v2.mjs`, `conformance.mjs --v2`). A behaviour change to v2 also touches all six SDKs.
- **API v2 (platform API, November 2026):** base `https://api-platform.supertext.com/v1/`, `Authorization: Bearer st_live_…` (strip a pasted `Bearer `). Errors are problem+json (`code`, `detail`, `error_id`; 402 `reason`), e.g. 401 `api_key_invalid`. `translate/ai/text` takes ≤ 10,000 characters (`tag_handling: html` for HTML segments); longer segments go through `translate/ai/file` as HTML. Key check: `GET account`. Webhooks: Standard Webhooks (HMAC-SHA256, `whsec_` base64 secret, 300 s).

**Commando Center:** the SDK only provides the API key check (`checkApiKey()`, `apiKeyFingerprint`, `ApiKeyCheck`; `spec/api-key-check.json`) and `SDK_VERSION`. Version reports and the ping endpoint live in **Supertext Plugin Health** (Commando-Center-Supertext-Translation → `plugin-health/`), which calls exactly these: never rename them or the check's fields (`status`, `checkedAt`, `httpStatus`, `errorCode`, `fingerprint`). There is no `spec/commando/` here any more.

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You need a Supertext API key. No Supertext account yet? Create one at [supertext

PHP is on Packagist, Python on PyPI and .NET on NuGet (from 0.6.0). npm and Maven Central (Java, Kotlin) aren't set up yet; until they are, use the files attached to a [release](https://github.com/Supertext/Supertext-API-SDK-Guide/releases) or build from this repository.

All six offer the same things, named the way each language expects, in a **`v1` namespace** for the API version (TypeScript `supertext-sdk/v1`, PHP `Supertext\Sdk\V1`, Python `supertext.v1`, .NET `Supertext.Sdk.V1`, Java and Kotlin `com.supertext.sdk.v1`), so a later API version can sit next to it:
All six offer the same things, named the way each language expects, in a **`v1` namespace** for the API version (TypeScript `supertext-sdk/v1`, PHP `Supertext\Sdk\V1`, Python `supertext.v1`, .NET `Supertext.Sdk.V1`, Java and Kotlin `com.supertext.sdk.v1`), with API v2 next to it (below):

- `translateTexts(segments, target, source?, politeness?)`: many keyed texts (plain or HTML) in one go, split into documents under the size limit, translated one after the other, read back by key.
- `translateHtml(html, target, source?, politeness?)`: one HTML document, the full round trip.
Expand All @@ -35,6 +35,8 @@ All six offer the same things, named the way each language expects, in a **`v1`
- One error type with stable codes (`authentication_failure`, `invalid_language_pair`, `quota_exceeded`, …) to show users a message in their language.
- Built in: the `Supertext-Auth-Key` header (pasted prefixes stripped), the exact multipart upload the API accepts, HTTP 429 retries with `Retry-After`, polling with a timeout, and deleting the file afterwards, also after errors.

**API v2** (Supertext's platform API, `https://api-platform.supertext.com/v1/`, workspace keys `st_live_…`) is in a **`v2` namespace** next to it (TypeScript `supertext-sdk/v2`, PHP `Supertext\Sdk\V2`, Python `supertext.v2`, .NET `Supertext.Sdk.V2`, Java and Kotlin `com.supertext.sdk.v2`): `translateTexts` with the same keyed segments, now as direct text requests (10,000 characters each, HTML with `tag_handling`); `translateText`, AI translation of DOCX, PPTX, XLSX, PDF and other documents (`translateFile`), language detection, quotes, human review (`orderFusedText`, `orderFusedFile`), the account, webhooks with a signature check (`verifyWebhook`), and errors from Supertext's problem answers (`insufficient_credit`, `invalid_request`, …). See the [guide](docs/integration-guide.md#16-api-v2-the-supertext-platform-api).

Quick look (TypeScript; the others are in their READMEs):

```ts
Expand Down
Loading
Loading