diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 9965c41..34a3350 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.1.1" + ".": "4.2.0" } diff --git a/.stats.yml b/.stats.yml index 7fc4abc..b80b97b 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/moderation-api-e864d762f50e49c0584bbf35eacc43cdb1397f805cca52cb8d4c07781739d0a3.yml -openapi_spec_hash: f511fefb34946e5878ac17f2b3056b1f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-cbf656f40e43acf60d9596f78204f031dc8c7205626df8f05ce8e88bcf49b597.yml +openapi_spec_hash: 23be5a56248a1a575b34833eb7e7fe49 config_hash: 9d144cc6c49d3fd53e5b4472c1e22165 diff --git a/CHANGELOG.md b/CHANGELOG.md index ac753c5..14e7b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 4.2.0 (2026-06-01) + +Full Changelog: [v4.1.1...v4.2.0](https://github.com/moderation-api/sdk-typescript/compare/v4.1.1...v4.2.0) + +### Features + +* **api:** api update ([3e63e9b](https://github.com/moderation-api/sdk-typescript/commit/3e63e9b0cc49dd5c18a47ad1917fd835a9ca6628)) +* **api:** api update ([1ffcc3b](https://github.com/moderation-api/sdk-typescript/commit/1ffcc3bc1df790e111b95697dd3a520a0d8d0f97)) +* **api:** api update ([cc909b9](https://github.com/moderation-api/sdk-typescript/commit/cc909b999d8790d84b69693d773334f5361e75b5)) + ## 4.1.1 (2026-05-19) Full Changelog: [v4.1.0...v4.1.1](https://github.com/moderation-api/sdk-typescript/compare/v4.1.0...v4.1.1) diff --git a/README.md b/README.md index e4f4693..44fe119 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ const moderationApi = new ModerationAPI({ }); ``` +const response = await client.content.submit({ content: { text: 'text', type: 'text' } }); + ### Content Moderation Use `content.submit` to moderate text, images, video, audio, or complex objects: @@ -198,7 +200,7 @@ import ModerationAPI from '@moderation-api/sdk'; const client = new ModerationAPI(); -const params: ModerationAPI.ContentSubmitParams = { content: { text: 'x', type: 'text' } }; +const params: ModerationAPI.ContentSubmitParams = { content: { text: 'text', type: 'text' } }; const response: ModerationAPI.ContentSubmitResponse = await client.content.submit(params); ``` @@ -213,7 +215,7 @@ a subclass of `APIError` will be thrown: ```ts const response = await client.content - .submit({ content: { text: 'x', type: 'text' } }) + .submit({ content: { text: 'text', type: 'text' } }) .catch(async (err) => { if (err instanceof ModerationAPI.APIError) { console.log(err.status); // 400 @@ -254,7 +256,7 @@ const client = new ModerationAPI({ }); // Or, configure per-request: -await client.content.submit({ content: { text: 'x', type: 'text' } }, { +await client.content.submit({ content: { text: 'text', type: 'text' } }, { maxRetries: 5, }); ``` @@ -271,7 +273,7 @@ const client = new ModerationAPI({ }); // Override per-request: -await client.content.submit({ content: { text: 'x', type: 'text' } }, { +await client.content.submit({ content: { text: 'text', type: 'text' } }, { timeout: 5 * 1000, }); ``` @@ -294,12 +296,14 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new ModerationAPI(); -const response = await client.content.submit({ content: { text: 'x', type: 'text' } }).asResponse(); +const response = await client.content + .submit({ content: { text: 'text', type: 'text' } }) + .asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object const { data: response, response: raw } = await client.content - .submit({ content: { text: 'x', type: 'text' } }) + .submit({ content: { text: 'text', type: 'text' } }) .withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(response.recommendation); diff --git a/package.json b/package.json index abbae9b..d01b7bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moderation-api/sdk", - "version": "4.1.1", + "version": "4.2.0", "description": "The official TypeScript library for the Moderation API API", "author": "Moderation API ", "types": "dist/index.d.ts", diff --git a/src/resources/content.ts b/src/resources/content.ts index 7c668ff..c39cdf7 100644 --- a/src/resources/content.ts +++ b/src/resources/content.ts @@ -289,6 +289,12 @@ export namespace ContentSubmitResponse { type: 'classifier'; + /** + * Optional structured data produced by the policy. For face detection: { count, + * faces: [{ confidence, gender, age }] }. + */ + data?: { [key: string]: unknown }; + /** * The keys of the flagged fields if submitting an object. */ @@ -502,6 +508,8 @@ export interface ContentSubmitParams { | ContentSubmitParams.Violence | ContentSubmitParams.SelfHarm | ContentSubmitParams.Spam + | ContentSubmitParams.LowQualityContent + | ContentSubmitParams.FaceDetection | ContentSubmitParams.SelfPromotion | ContentSubmitParams.Political | ContentSubmitParams.Religion @@ -794,6 +802,40 @@ export namespace ContentSubmitParams { threshold?: number; } + export interface LowQualityContent { + id: 'low_quality'; + + flag: boolean; + + /** + * Flag content with fewer than this many words as low-effort. Defaults to 3. Set + * to disable by omitting. + */ + minWords?: number; + + threshold?: number; + } + + export interface FaceDetection { + id: 'face_detection'; + + flag: boolean; + + /** + * Flag images that contain "at least" or "fewer than" the configured number of + * faces. Defaults to at_least. + */ + comparator?: 'at_least' | 'fewer_than'; + + /** + * Number of faces the comparator applies to. Defaults to 1, so the default rule + * flags any image containing a face. + */ + count?: number; + + threshold?: number; + } + export interface SelfPromotion { id: 'self_promotion'; diff --git a/src/version.ts b/src/version.ts index 00c1c8e..f9ec1c7 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.1.1'; // x-release-please-version +export const VERSION = '4.2.0'; // x-release-please-version diff --git a/tests/api-resources/content.test.ts b/tests/api-resources/content.test.ts index 684d6d6..b44b3e7 100644 --- a/tests/api-resources/content.test.ts +++ b/tests/api-resources/content.test.ts @@ -10,7 +10,7 @@ const client = new ModerationAPI({ describe('resource content', () => { // Mock server tests are disabled test.skip('submit: only required params', async () => { - const responsePromise = client.content.submit({ content: { text: 'x', type: 'text' } }); + const responsePromise = client.content.submit({ content: { text: 'text', type: 'text' } }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,7 +23,7 @@ describe('resource content', () => { // Mock server tests are disabled test.skip('submit: required and optional params', async () => { const response = await client.content.submit({ - content: { text: 'x', type: 'text' }, + content: { text: 'text', type: 'text' }, authorId: 'authorId', channel: 'channel', contentId: 'contentId',