Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.3.0"
".": "3.4.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-07681c3b51c92b9d92d71f11e9245c37a37ac1ea6df730cd730e85968064d814.yml
openapi_spec_hash: 48bffabe129598fc41a232cf5469bd4b
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-c4b4a6dd58ac7acb74655c95e375be9c52d9b4b23a6b4c40ac6fceeb3e91f8ed.yml
openapi_spec_hash: 436eb030ad0ba2f3c53382a40ec9f4c9
config_hash: 6a52f6ae7d55cf3b4e91538cc7752aeb
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 3.4.0 (2026-01-10)

Full Changelog: [v3.3.0...v3.4.0](https://github.com/moderation-api/sdk-typescript/compare/v3.3.0...v3.4.0)

### Features

* **api:** api update ([f718a30](https://github.com/moderation-api/sdk-typescript/commit/f718a30f25777e7b60eb43fdf8624e35c197d840))


### Chores

* break long lines in snippets into multiline ([92f3b55](https://github.com/moderation-api/sdk-typescript/commit/92f3b55a251e534868c57f21389d764e06fc0d14))

## 3.3.0 (2026-01-02)

Full Changelog: [v3.2.0...v3.3.0](https://github.com/moderation-api/sdk-typescript/compare/v3.2.0...v3.3.0)
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,17 @@ a subclass of `APIError` will be thrown:

<!-- prettier-ignore -->
```ts
const response = await client.content.submit({ content: { text: 'x', type: 'text' } }).catch(async (err) => {
if (err instanceof ModerationAPI.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
const response = await client.content
.submit({ content: { text: 'x', type: 'text' } })
.catch(async (err) => {
if (err instanceof ModerationAPI.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
```

Error codes are as follows:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moderation-api/sdk",
"version": "3.3.0",
"version": "3.4.0",
"description": "The official TypeScript library for the Moderation API API",
"author": "Moderation API <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/resources/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ export interface ContentSubmitParams {
| ContentSubmitParams.URLMasking
| ContentSubmitParams.Guideline
>;

/**
* Unix timestamp (in milliseconds) of when the content was created. Use if content
* is not submitted in real-time.
*/
timestamp?: number;
}

export namespace ContentSubmitParams {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '3.3.0'; // x-release-please-version
export const VERSION = '3.4.0'; // x-release-please-version
9 changes: 8 additions & 1 deletion tests/api-resources/actions/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ describe('resource actions', () => {
queueBehaviour: 'REMOVE',
type: 'AUTHOR_BLOCK',
valueRequired: true,
webhooks: [{ name: 'name', url: 'https://example.com', id: 'id', description: 'description' }],
webhooks: [
{
name: 'name',
url: 'https://example.com',
id: 'id',
description: 'description',
},
],
});
});

Expand Down
9 changes: 8 additions & 1 deletion tests/api-resources/content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ describe('resource content', () => {
doNotStore: true,
metadata: { foo: 'bar' },
metaType: 'profile',
policies: [{ id: 'toxicity', flag: true, threshold: 0 }],
policies: [
{
id: 'toxicity',
flag: true,
threshold: 0,
},
],
timestamp: 0,
});
});
});
48 changes: 40 additions & 8 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ describe('instantiate client', () => {
error: jest.fn(),
};

const client = new ModerationAPI({ logger: logger, logLevel: 'debug', secretKey: 'My Secret Key' });
const client = new ModerationAPI({
logger: logger,
logLevel: 'debug',
secretKey: 'My Secret Key',
});

await forceAPIResponseForClient(client);
expect(debugMock).toHaveBeenCalled();
Expand All @@ -107,7 +111,11 @@ describe('instantiate client', () => {
error: jest.fn(),
};

const client = new ModerationAPI({ logger: logger, logLevel: 'info', secretKey: 'My Secret Key' });
const client = new ModerationAPI({
logger: logger,
logLevel: 'info',
secretKey: 'My Secret Key',
});

await forceAPIResponseForClient(client);
expect(debugMock).not.toHaveBeenCalled();
Expand Down Expand Up @@ -157,7 +165,11 @@ describe('instantiate client', () => {
};

process.env['MODERATION_API_LOG'] = 'debug';
const client = new ModerationAPI({ logger: logger, logLevel: 'off', secretKey: 'My Secret Key' });
const client = new ModerationAPI({
logger: logger,
logLevel: 'off',
secretKey: 'My Secret Key',
});

await forceAPIResponseForClient(client);
expect(debugMock).not.toHaveBeenCalled();
Expand All @@ -173,7 +185,11 @@ describe('instantiate client', () => {
};

process.env['MODERATION_API_LOG'] = 'not a log level';
const client = new ModerationAPI({ logger: logger, logLevel: 'debug', secretKey: 'My Secret Key' });
const client = new ModerationAPI({
logger: logger,
logLevel: 'debug',
secretKey: 'My Secret Key',
});
expect(client.logLevel).toBe('debug');
expect(warnMock).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -552,7 +568,11 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new ModerationAPI({ secretKey: 'My Secret Key', timeout: 10, fetch: testFetch });
const client = new ModerationAPI({
secretKey: 'My Secret Key',
timeout: 10,
fetch: testFetch,
});

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
expect(count).toEqual(2);
Expand Down Expand Up @@ -582,7 +602,11 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new ModerationAPI({ secretKey: 'My Secret Key', fetch: testFetch, maxRetries: 4 });
const client = new ModerationAPI({
secretKey: 'My Secret Key',
fetch: testFetch,
maxRetries: 4,
});

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });

Expand All @@ -606,7 +630,11 @@ describe('retries', () => {
capturedRequest = init;
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};
const client = new ModerationAPI({ secretKey: 'My Secret Key', fetch: testFetch, maxRetries: 4 });
const client = new ModerationAPI({
secretKey: 'My Secret Key',
fetch: testFetch,
maxRetries: 4,
});

expect(
await client.request({
Expand Down Expand Up @@ -668,7 +696,11 @@ describe('retries', () => {
capturedRequest = init;
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};
const client = new ModerationAPI({ secretKey: 'My Secret Key', fetch: testFetch, maxRetries: 4 });
const client = new ModerationAPI({
secretKey: 'My Secret Key',
fetch: testFetch,
maxRetries: 4,
});

expect(
await client.request({
Expand Down